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 AtomicBoolean |
closed
Whether or not this shared object is closed
|
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 |
protected AtomicBoolean |
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 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.
|
attributesTRANSIENT_PREFIXHANDSHAKE_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(org.red5.io.object.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(org.red5.io.object.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 |
isClosed() |
boolean |
isPersistent()
Check if the shared object is persistent.
|
protected void |
notifyModified()
Send notification about modification of SO
|
protected boolean |
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(org.red5.io.object.Output output)
Write the object to the passed output stream.
|
boolean |
setAttribute(String name,
Object value)
Set an attribute on this object.
|
boolean |
setAttributes(IAttributeStore values)
Set multiple attributes on this object.
|
boolean |
setAttributes(Map<String,Object> values)
Set multiple attributes on this object.
|
void |
setDirty(boolean dirty)
Sets a modified or dirty property on this object to indicate whether or not a modification has been made.
|
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, sizeprotected static org.slf4j.Logger log
protected String name
protected String path
protected boolean persistent
protected IPersistenceStore storage
protected AtomicInteger version
protected AtomicInteger updateCounter
protected AtomicBoolean modified
protected long lastModified
protected SharedObjectMessage ownerMessage
protected transient volatile ConcurrentLinkedQueue<ISharedObjectEvent> syncEvents
protected transient volatile CopyOnWriteArraySet<IEventListener> listeners
protected IEventListener source
protected AtomicInteger acquireCount
protected transient StatisticsCounter listenerStats
protected AtomicInteger changeStats
protected AtomicInteger deleteStats
protected AtomicInteger sendStats
protected AtomicBoolean closed
public SharedObject()
public SharedObject(org.red5.io.object.Input input)
throws IOException
input - Input sourceIOException - I/O exceptionInputpublic 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 IPersistablegetName in interface ISharedObjectStatisticspublic void setName(String name)
setName in interface IPersistablename - New object namepublic String getPath()
getPath in interface IPersistablepublic void setPath(String path)
setPath in interface IPersistablepath - New persisted object pathpublic String getType()
getType in interface IPersistablepublic long getLastModified()
getLastModified in interface IPersistablepublic boolean isPersistent()
isPersistent in interface IPersistableisPersistent in interface ISharedObjectStatisticsTrueif the shared object is persistent, otherwise
False
public void setPersistent(boolean persistent)
setPersistent in interface IPersistablepersistent - trueif object is persistent,
falseotherwise
protected void sendUpdates()
protected void notifyModified()
protected void returnError(String message)
message - messageprotected void returnAttributeValue(String name)
name - namepublic Object getAttribute(String name, Object value)
getAttribute in interface IAttributeStoregetAttribute in class AttributeStorename - Attribute namevalue - Value to set if attribute doesn't existpublic boolean setAttribute(String name, Object value)
setAttribute in interface IAttributeStoresetAttribute in class AttributeStorename - the name of the attribute to changevalue - the new value of the attributepublic boolean setAttributes(Map<String,Object> values)
setAttributes in interface IAttributeStoresetAttributes in class AttributeStorevalues - the attributes to setpublic boolean setAttributes(IAttributeStore values)
setAttributes in interface IAttributeStoresetAttributes in class AttributeStorevalues - the attributes to setpublic boolean removeAttribute(String name)
removeAttribute in interface IAttributeStoreremoveAttribute in interface AttributeStoreMXBeanremoveAttribute in class AttributeStorename - Attributetrueif there's such an attribute and it was removed,
falseotherwise
protected void sendMessage(String handler, List<?> arguments)
handler - Event handlerarguments - Argumentspublic int getVersion()
getVersion in interface ISharedObjectStatisticspublic void removeAttributes()
removeAttributes in interface IAttributeStoreremoveAttributes in interface AttributeStoreMXBeanremoveAttributes in class AttributeStoreprotected boolean 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(org.red5.io.object.Output output)
throws IOException
serialize in interface IPersistableoutput - Output stream to write toIOException - Any I/O exceptionpublic void deserialize(org.red5.io.object.Input input)
throws IOException
deserialize in interface IPersistableinput - Input stream to load fromIOException - Any I/O exceptionpublic void setStore(IPersistenceStore store)
setStore in interface IPersistablestore - Store the object is saved inpublic IPersistenceStore getStore()
getStore in interface IPersistableprotected boolean clear()
trueon success,
falseotherwise
protected void close()
public void acquire()
acquiremust be paired with a call to
releaseso the SO isn't held forever. This is only valid for non-persistent SOs.
public boolean isAcquired()
trueif the SO is acquired, otherwise
false
public void release()
public boolean isClosed()
public long getCreationTime()
getCreationTime in interface IStatisticsBasepublic int getTotalListeners()
getTotalListeners in interface ISharedObjectStatisticspublic int getMaxListeners()
getMaxListeners in interface ISharedObjectStatisticspublic int getActiveListeners()
getActiveListeners in interface ISharedObjectStatisticspublic int getTotalChanges()
getTotalChanges in interface ISharedObjectStatisticspublic int getTotalDeletes()
getTotalDeletes in interface ISharedObjectStatisticspublic int getTotalSends()
getTotalSends in interface ISharedObjectStatisticspublic void setDirty(boolean dirty)
dirty - true if modified and false otherwiseCopyright © 2005–2017 Red5. All rights reserved.