public final class NetGroup
extends java.lang.Object
NetGroup
- NetGroup class represent membership in an RTMFP group.
Use this class to do the following:
Modifier and Type | Class and Description |
---|---|
static interface |
NetGroup.IListener
IListener - NetGroup listener. |
Constructor and Description |
---|
NetGroup(NetConnection connection,
java.lang.String groupspec)
Constructs a NetGroup on the specified NetConnection object and joins it to the group specified by groupspec.
|
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(NetGroup.IListener listener)
Registers an event listener.
|
void |
addHaveObjects(int startIndex,
int endIndex)
Adds objects from startIndex through endIndex, to the set of objects
this node advertises to neighbors as objects for which it fulfills requests.
|
boolean |
addMemberHint(java.lang.String peerID)
Manually adds a record specifying that peerID is a member of the group.
|
boolean |
addNeighbor(java.lang.String peerID)
Manually adds a neighbor by immediately connecting directly to the specified peerID,
which must already be in this group.
|
void |
addWantObjects(int startIndex,
int endIndex)
Adds objects from startIndex through endIndex, to the set of objects to retrieve.
|
void |
close()
Disconnect from the group and close this NetGroup.
|
java.lang.String |
convertPeerIDToGroupAddress(java.lang.String peerID)
Converts a peerID to a group address suitable for use with the sendToNearest() method.
|
void |
denyRequestedObject(int requestID)
Denies a request received in a NetStatusEvent NetGroup.Replication.Request for an object
previously advertised with addHaveObjects().
|
int |
estimatedMemberCount()
Returns the estimated number of members of the group,
based on local neighbor density and assuming an even distribution of group addresses.
|
NetGroupInfo |
info()
Returns a
NetGroupInfo object whose properties provide Quality of Service statistics
about this NetGroup's RTMFP peer-to-peer data transport. |
java.lang.String |
localCoverageFrom()
Returns the start of the range of group addresses for which this node is the "nearest" and responsible.
|
java.lang.String |
localCoverageTo()
Returns the end of the range of group addresses for which this node is the "nearest" and responsible.
|
int |
neighborCount()
Returns the number of group members to which this node is directly connected.
|
java.lang.String |
post(java.lang.Object message)
Sends a message to all members of a group.
|
java.lang.String |
receiveMode()
Returns this node's routing receive mode as one of values in the
NetGroupReceiveMode enum class. |
void |
receiveMode(java.lang.String mode)
Sets this node's routing receive mode as one of values in the
NetGroupReceiveMode enum class. |
void |
removeEventListener(NetGroup.IListener listener)
Removes the listener.
|
void |
removeHaveObjects(int startIndex,
int endIndex)
Removes objects from startIndex through endIndex, from the set of objects
this node advertises to neighbors as objects for which it fulfills requests.
|
void |
removeWantObjects(int startIndex,
int endIndex)
Removes objects from startIndex through endIndex, from the set of objects to retrieve.
|
java.lang.String |
replicationStrategy()
Returns the object replication fetch strategy.
|
void |
replicationStrategy(java.lang.String strategy)
Sets the object replication fetch strategy.
|
java.lang.String |
sendToAllNeighbors(java.lang.Object message)
Sends a message to all neighbors.
|
java.lang.String |
sendToNearest(java.lang.Object message,
java.lang.String groupAddress)
Sends a message to the neighbor (or local node) nearest to the specified group address.
|
java.lang.String |
sendToNeighbor(java.lang.Object message,
java.lang.String groupAddress)
Sends a message to the neighbor specified by the sendMode parameter.
|
void |
writeRequestedObject(int requestID,
java.lang.Object object)
Satisfies the request as received by NetStatusEvent NetGroup.Replication.
|
public NetGroup(NetConnection connection, java.lang.String groupspec)
connection
- groupspec
- public int estimatedMemberCount()
public NetGroupInfo info()
NetGroupInfo
object whose properties provide Quality of Service statistics
about this NetGroup's RTMFP peer-to-peer data transport.public java.lang.String localCoverageFrom()
public java.lang.String localCoverageTo()
public int neighborCount()
public java.lang.String receiveMode()
NetGroupReceiveMode
enum class.public void receiveMode(java.lang.String mode)
NetGroupReceiveMode
enum class.mode
- public java.lang.String replicationStrategy()
NetGroupReplicationStrategy
class.public void replicationStrategy(java.lang.String strategy)
NetGroupReplicationStrategy
class.strategy
- public void addHaveObjects(int startIndex, int endIndex)
startIndex
- beginning of the range of object indices to add to the Have setendIndex
- end of the range of object indices to add to the Have set.public boolean addMemberHint(java.lang.String peerID)
peerID
- peerID to add to the set of potential neighborstrue
for success, false
for failure.public boolean addNeighbor(java.lang.String peerID)
peerID
- peerID to which to immediately connecttrue
for success, false
for failure.public void addWantObjects(int startIndex, int endIndex)
startIndex
- beginning of the range of object indices to add to the Want setendIndex
- end of the range of object indices to add to the Want setpublic void close()
public java.lang.String convertPeerIDToGroupAddress(java.lang.String peerID)
peerID
- peerID to convertpublic void denyRequestedObject(int requestID)
requestID
- request identifier as given in the NetGroup.Replication.Request eventpublic java.lang.String post(java.lang.Object message)
message
- message to send to all other members of the grouppublic void removeHaveObjects(int startIndex, int endIndex)
startIndex
- beginning of the range of object indices to remove from the Have setendIndex
- end of the range of object indices to remove from the Have setpublic void removeWantObjects(int startIndex, int endIndex)
startIndex
- beginning of the range of object indices to remove from the Want setendIndex
- end of the range of object indices to remove from the Want setpublic java.lang.String sendToAllNeighbors(java.lang.Object message)
NetGroupSendResult.SENT
if at least one neighbor was selected.
For more information about routing messages, see "Route messages directly to a peer" in Flash Media Server Developer’s Guide.
When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener with NetGroup.SendTo.Notify in the code property of the info object.
message
- message to sendNetGroupSendResult
indicating the success or failure of the sendpublic java.lang.String sendToNearest(java.lang.Object message, java.lang.String groupAddress)
NetGroupSendResult.SENT
if the message was successfully sent toward its destination.
For more information about routing messages, see "Route messages directly to a peer" in Flash Media Server Developer’s Guide.
When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener with NetGroup.SendTo.Notify in the code property of the info object.
message
- message to sendgroupAddress
- group address toward which to route the messageNetGroupSendResult
indicating the success or failure of the sendpublic java.lang.String sendToNeighbor(java.lang.Object message, java.lang.String groupAddress)
NetGroupSendResult.SENT
if the message was successfully sent to the requested destination.
For more information about routing messages, see "Route messages directly to a peer" in Flash Media Server Developer’s Guide.
When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener with NetGroup.SendTo.Notify in the code property of the info object.
message
- message to sendgroupAddress
- group address toward which to route the messageNetGroupSendResult
indicating the success or failure of the sendpublic void writeRequestedObject(int requestID, java.lang.Object object)
requestID
- request identifier as given in the NetGroup.Replication.Request eventobject
- object corresponding to the index given in the NetGroup.Replication.Request eventpublic void addEventListener(NetGroup.IListener listener)
listener
- listener to addpublic void removeEventListener(NetGroup.IListener listener)
listener
- listener to remove