org.red5.server.so
public class SharedObject extends AttributeStore implements ISharedObjectStatistics, IPersistable, Constants
Modifier and Type | Field and Description |
---|---|
protected AtomicInteger |
acquireCount
Number of times the SO has been acquired
|
protected AtomicInteger |
changeStats
Counts number of "change" events.
|
protected AtomicInteger |
deleteStats
Counts number of "delete" events.
|
protected long |
lastModified
Last modified timestamp
|
protected CopyOnWriteArraySet<IEventListener> |
listeners
Listeners
|
protected StatisticsCounter |
listenerStats
Manages listener statistics.
|
protected static org.slf4j.Logger |
log
Logger
|
protected boolean |
modified
Has changes? flag
|
protected String |
name
Shared Object name (identifier)
|
protected SharedObjectMessage |
ownerMessage
Owner event
|
protected String |
path
SO path
|
protected boolean |
persistent
true if the SharedObject was stored by the persistence framework (NOT in database,
just plain serialization to the disk) and can be used later on reconnection
|
protected AtomicInteger |
sendStats
Counts number of "send message" events.
|
protected IEventListener |
source
Event listener, actually RTMP connection
|
protected IPersistenceStore |
storage
Object that is delegated with all storage work for persistent SOs
|
protected ConcurrentLinkedQueue<ISharedObjectEvent> |
syncEvents
Synchronization events
|
protected AtomicInteger |
updateCounter
Number of pending update operations
|
protected AtomicInteger |
version
Version.
|
attributes
TRANSIENT_PREFIX
HANDSHAKE_SIZE, HEADER_CONTINUE, HEADER_NEW, HEADER_SAME_SOURCE, HEADER_TIMER_CHANGE, MEDIUM_INT_MAX, SO_CLIENT_CLEAR_DATA, SO_CLIENT_DELETE_DATA, SO_CLIENT_INITIAL_DATA, SO_CLIENT_SEND_MESSAGE, SO_CLIENT_STATUS, SO_CLIENT_UPDATE_ATTRIBUTE, SO_CLIENT_UPDATE_DATA, SO_CONNECT, SO_DELETE_ATTRIBUTE, SO_DISCONNECT, SO_SEND_MESSAGE, SO_SET_ATTRIBUTE, SOURCE_TYPE_LIVE, SOURCE_TYPE_VOD, TYPE_ABORT, TYPE_AGGREGATE, TYPE_AUDIO_DATA, TYPE_BYTES_READ, TYPE_CHUNK_SIZE, TYPE_CLIENT_BANDWIDTH, TYPE_EDGE_ORIGIN, TYPE_FLEX_MESSAGE, TYPE_FLEX_SHARED_OBJECT, TYPE_FLEX_STREAM_SEND, TYPE_INVOKE, TYPE_NOTIFY, TYPE_PING, TYPE_SERVER_BANDWIDTH, TYPE_SHARED_OBJECT, TYPE_STREAM_METADATA, TYPE_VIDEO_DATA
Constructor and Description |
---|
SharedObject()
Constructs a new SharedObject.
|
SharedObject(Input input)
Constructs new SO from Input object
|
SharedObject(Map<String,Object> data,
String name,
String path,
boolean persistent)
Creates new SO from given data map, name, path and persistence option
|
SharedObject(Map<String,Object> data,
String name,
String path,
boolean persistent,
IPersistenceStore storage)
Creates new SO from given data map, name, path, storage object and persistence option
|
SharedObject(String name,
String path,
boolean persistent)
Creates new SO from given data map, name, path and persistence option
|
SharedObject(String name,
String path,
boolean persistent,
IPersistenceStore storage)
Creates new SO from given data map, name, path, storage object and persistence option
|
Modifier and Type | Method and Description |
---|---|
void |
acquire()
Prevent shared object from being released.
|
protected void |
beginUpdate()
Begin update of this Shared Object.
|
protected void |
beginUpdate(IEventListener listener)
Begin update of this Shared Object and setting listener
|
protected void |
checkRelease()
Check if shared object must be released.
|
protected boolean |
clear()
Deletes all the attributes and sends a clear event to all listeners.
|
protected void |
close()
Detaches a reference from this shared object, reset it's state, this will destroy the
reference immediately.
|
void |
deserialize(Input input)
Load the object from the passed input stream.
|
protected void |
endUpdate()
End update of this Shared Object.
|
int |
getActiveListeners()
Return current number of subscribed listeners.
|
Object |
getAttribute(String name,
Object value)
Return attribute by name and set if it doesn't exist yet.
|
long |
getCreationTime()
Return the timestamp the object was created.
|
Map<String,Object> |
getData()
Getter for data.
|
long |
getLastModified()
Returns the timestamp when the object was last modified.
|
Set<IEventListener> |
getListeners()
Get event listeners.
|
int |
getMaxListeners()
Return maximum number of concurrent subscribed listenes.
|
String |
getName()
Return the name of the shared object.
|
String |
getPath()
Returns the path of the persistent object.
|
IPersistenceStore |
getStore()
Returns the persistence store this object is stored in
|
int |
getTotalChanges()
Return number of attribute changes.
|
int |
getTotalDeletes()
Return number of attribute deletes.
|
int |
getTotalListeners()
Return total number of subscribed listeners.
|
int |
getTotalSends()
Return number of times a message was sent.
|
String |
getType()
Returns the type of the persistent object.
|
int |
getVersion()
Getter for version.
|
boolean |
isAcquired()
Check if shared object currently is acquired.
|
boolean |
isPersistent()
Check if the shared object is persistent.
|
protected void |
notifyModified()
Send notification about modification of SO
|
protected void |
register(IEventListener listener)
Register event listener
|
void |
release()
Release previously acquired shared object.
|
boolean |
removeAttribute(String name)
Removes attribute with given name
|
void |
removeAttributes()
Remove all attributes (clear Shared Object)
|
protected void |
returnAttributeValue(String name)
Return an attribute value to the owner.
|
protected void |
returnError(String message)
Return an error message to the client.
|
protected void |
sendMessage(String handler,
List<?> arguments)
Broadcast event to event handler
|
protected void |
sendUpdates()
Send update notification over data channel of RTMP connection
|
void |
serialize(Output output)
Write the object to the passed output stream.
|
boolean |
setAttribute(String name,
Object value)
Set value of attribute with given name
|
void |
setAttributes(IAttributeStore values)
Set attributes as attributes store.
|
void |
setAttributes(Map<String,Object> values)
Set attributes as map.
|
void |
setName(String name)
Set the name of the persistent object.
|
void |
setPath(String path)
Set the path of the persistent object.
|
void |
setPersistent(boolean persistent)
Set the persistent flag of the object.
|
void |
setStore(IPersistenceStore store)
Store a reference to the persistence store in the object.
|
protected void |
unregister(IEventListener listener)
Unregister event listener
|
filterNull, from, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute
protected static org.slf4j.Logger log
protected String name
protected String path
protected boolean persistent
protected IPersistenceStore storage
protected AtomicInteger version
protected AtomicInteger updateCounter
protected boolean modified
protected long lastModified
protected SharedObjectMessage ownerMessage
protected ConcurrentLinkedQueue<ISharedObjectEvent> syncEvents
protected CopyOnWriteArraySet<IEventListener> listeners
protected IEventListener source
protected AtomicInteger acquireCount
protected StatisticsCounter listenerStats
protected AtomicInteger changeStats
protected AtomicInteger deleteStats
protected AtomicInteger sendStats
public SharedObject()
public SharedObject(Input input) throws IOException
input
- Input sourceIOException
- I/O exceptionInput
public SharedObject(String name, String path, boolean persistent)
name
- SO namepath
- SO pathpersistent
- SO persistencepublic SharedObject(String name, String path, boolean persistent, IPersistenceStore storage)
name
- SO namepath
- SO pathpersistent
- SO persistencestorage
- Persistence storagepublic SharedObject(Map<String,Object> data, String name, String path, boolean persistent)
data
- Dataname
- SO namepath
- SO pathpersistent
- SO persistencepublic SharedObject(Map<String,Object> data, String name, String path, boolean persistent, IPersistenceStore storage)
data
- Dataname
- SO namepath
- SO pathpersistent
- SO persistencestorage
- Persistence storagepublic String getName()
getName
in interface IPersistable
getName
in interface ISharedObjectStatistics
public void setName(String name)
setName
in interface IPersistable
name
- New object namepublic String getPath()
getPath
in interface IPersistable
public void setPath(String path)
setPath
in interface IPersistable
path
- New persisted object pathpublic String getType()
getType
in interface IPersistable
public long getLastModified()
getLastModified
in interface IPersistable
public boolean isPersistent()
isPersistent
in interface IPersistable
isPersistent
in interface ISharedObjectStatistics
True
if the shared object is persistent, otherwise False
public void setPersistent(boolean persistent)
setPersistent
in interface IPersistable
persistent
- true
if object is persistent, false
otherwiseprotected void sendUpdates()
protected void notifyModified()
protected void returnError(String message)
message
- protected void returnAttributeValue(String name)
name
- public Object getAttribute(String name, Object value)
getAttribute
in interface IAttributeStore
getAttribute
in class AttributeStore
name
- Attribute namevalue
- Value to set if attribute doesn't existpublic boolean setAttribute(String name, Object value)
setAttribute
in interface IAttributeStore
setAttribute
in class AttributeStore
name
- Attribute namevalue
- Attribute valuetrue
if there's such attribute and value was set, false
otherwisepublic void setAttributes(Map<String,Object> values)
setAttributes
in interface IAttributeStore
setAttributes
in class AttributeStore
values
- Attributes.public void setAttributes(IAttributeStore values)
setAttributes
in interface IAttributeStore
setAttributes
in class AttributeStore
values
- Attributes.public boolean removeAttribute(String name)
removeAttribute
in interface IAttributeStore
removeAttribute
in interface AttributeStoreMXBean
removeAttribute
in class AttributeStore
name
- Attributetrue
if there's such an attribute and it was removed, false
otherwiseprotected void sendMessage(String handler, List<?> arguments)
handler
- Event handlerarguments
- Argumentspublic int getVersion()
getVersion
in interface ISharedObjectStatistics
public void removeAttributes()
removeAttributes
in interface IAttributeStore
removeAttributes
in interface AttributeStoreMXBean
removeAttributes
in class AttributeStore
protected void register(IEventListener listener)
listener
- Event listenerprotected void unregister(IEventListener listener)
listener
- Event listenerprotected void checkRelease()
public Set<IEventListener> getListeners()
protected void beginUpdate()
protected void beginUpdate(IEventListener listener)
listener
- Update with listenerprotected void endUpdate()
public void serialize(Output output) throws IOException
serialize
in interface IPersistable
output
- Output stream to write toIOException
- Any I/O exceptionpublic void deserialize(Input input) throws IOException
deserialize
in interface IPersistable
input
- Input stream to load fromIOException
- Any I/O exceptionpublic void setStore(IPersistenceStore store)
setStore
in interface IPersistable
store
- Store the object is saved inpublic IPersistenceStore getStore()
getStore
in interface IPersistable
protected boolean clear()
true
on success, false
otherwiseprotected void close()
public void acquire()
acquire
must be paired with a call to release
so the SO isn't held
forever. This is only valid for non-persistent SOs.public boolean isAcquired()
true
if the SO is acquired, otherwise false
public void release()
public long getCreationTime()
getCreationTime
in interface IStatisticsBase
public int getTotalListeners()
getTotalListeners
in interface ISharedObjectStatistics
public int getMaxListeners()
getMaxListeners
in interface ISharedObjectStatistics
public int getActiveListeners()
getActiveListeners
in interface ISharedObjectStatistics
public int getTotalChanges()
getTotalChanges
in interface ISharedObjectStatistics
public int getTotalDeletes()
getTotalDeletes
in interface ISharedObjectStatistics
public int getTotalSends()
getTotalSends
in interface ISharedObjectStatistics
Copyright © 2006-2012 The Red5 Project