public class MasterServer extends XmlRpcServer implements MasterRegistrationListener
MasterServer provides naming and registration services to the
rest of the Nodes in the ROS system. It tracks Publishers and
Subscribers to TopicSystemStates as well as
ServiceServers. The role of the MasterServer is to enable
individual ROS Nodes to locate one another. Once these Nodes
have located each other they communicate with each other peer-to-peer.| Modifier and Type | Field and Description |
|---|---|
static int |
SYSTEM_STATE_PUBLISHERS
Position in the
getSystemState() for publisher information. |
static int |
SYSTEM_STATE_SERVICES
Position in the
getSystemState() for service information. |
static int |
SYSTEM_STATE_SUBSCRIBERS
Position in the
getSystemState() for subscriber information. |
| Constructor and Description |
|---|
MasterServer(BindAddress bindAddress,
AdvertiseAddress advertiseAddress) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
contactSubscriberForPublisherUpdate(java.net.URI subscriberSlaveUri,
GraphName topicName,
java.util.List<java.net.URI> publisherUris)
Contact a subscriber and send it a publisher update.
|
java.util.List<java.lang.Object> |
getPublishedTopics(GraphName caller,
GraphName subgraph)
Get a list of all topics published for the give subgraph.
|
java.util.List<java.lang.Object> |
getSystemState()
Get the state of the ROS graph.
|
java.util.List<java.util.List<java.lang.String>> |
getTopicTypes(GraphName calledId)
Get a
List of all TopicSystemState message types. |
java.net.URI |
lookupNode(GraphName nodeName)
Returns a
NodeIdentifier for the Node with the given name. |
java.net.URI |
lookupService(GraphName serviceName)
Lookup the provider of a particular service.
|
void |
onNodeReplacement(NodeRegistrationInfo nodeInfo)
A node is being replaced.
|
java.util.List<java.net.URI> |
registerPublisher(GraphName nodeName,
java.net.URI nodeSlaveUri,
GraphName topicName,
java.lang.String topicMessageType)
Register the caller as a
Publisher of the specified topic. |
void |
registerService(GraphName nodeName,
java.net.URI nodeSlaveUri,
GraphName serviceName,
java.net.URI serviceUri)
Register a service with the master.
|
java.util.List<java.net.URI> |
registerSubscriber(GraphName nodeName,
java.net.URI nodeSlaveUri,
GraphName topicName,
java.lang.String topicMessageType)
Subscribe the caller to the specified topic.
|
void |
start()
Start the
MasterServer. |
boolean |
unregisterPublisher(GraphName nodeName,
GraphName topicName)
Unregister a
Publisher. |
boolean |
unregisterService(GraphName nodeName,
GraphName serviceName,
java.net.URI serviceUri)
Unregister a service from the master.
|
boolean |
unregisterSubscriber(GraphName nodeName,
GraphName topicName)
Unregister a
Subscriber. |
awaitStart, awaitStart, getAddress, getAdvertiseAddress, getPid, getUri, shutdown, startpublic static final int SYSTEM_STATE_PUBLISHERS
getSystemState() for publisher information.public static final int SYSTEM_STATE_SUBSCRIBERS
getSystemState() for subscriber information.public static final int SYSTEM_STATE_SERVICES
getSystemState() for service information.public MasterServer(BindAddress bindAddress, AdvertiseAddress advertiseAddress)
public void start()
MasterServer.public void registerService(GraphName nodeName, java.net.URI nodeSlaveUri, GraphName serviceName, java.net.URI serviceUri)
nodeName - the GraphName of the Node offering the servicenodeSlaveUri - the URI of the Node's SlaveServerserviceName - the GraphName of the serviceserviceUri - the URI of the servicepublic boolean unregisterService(GraphName nodeName, GraphName serviceName, java.net.URI serviceUri)
public java.util.List<java.net.URI> registerSubscriber(GraphName nodeName, java.net.URI nodeSlaveUri, GraphName topicName, java.lang.String topicMessageType)
nodeName - the GraphName of the Node offering the servicenodeSlaveUri - the URI of the Node's SlaveServertopicName - the GraphName of the subscribed TopicParticipanttopicMessageType - the message type of the topicList of XMLRPC API URIs for nodes currently
publishing the specified topicpublic boolean unregisterSubscriber(GraphName nodeName, GraphName topicName)
Subscriber.nodeName - the GraphName of the Node offering the servicetopicName - the GraphName of the subscribed TopicParticipanttrue if the Subscriber was registeredpublic java.util.List<java.net.URI> registerPublisher(GraphName nodeName, java.net.URI nodeSlaveUri, GraphName topicName, java.lang.String topicMessageType)
Publisher of the specified topic.nodeName - the GraphName of the Node offering the servicenodeSlaveUri - the URI of the Node's SlaveServertopicName - the GraphName of the subscribed TopicParticipanttopicMessageType - the message type of the topicList of the current Subscribers to the
Publisher's TopicSystemState in the form of XML-RPC
URIs for each Subscriber's SlaveServerprotected void contactSubscriberForPublisherUpdate(java.net.URI subscriberSlaveUri,
GraphName topicName,
java.util.List<java.net.URI> publisherUris)
subscriberSlaveUri - the slave URI of the subscriber to contacttopicName - the name of the topic whose publisher URIs are being updatedpublisherUris - the new list of publisher URIs to be sent to the subscriberpublic boolean unregisterPublisher(GraphName nodeName, GraphName topicName)
Publisher.nodeName - the GraphName of the Node offering the servicetopicName - the GraphName of the subscribed TopicParticipanttrue if the Publisher was unregisteredpublic java.net.URI lookupNode(GraphName nodeName)
NodeIdentifier for the Node with the given name.
This API is for looking information about Publishers and
Subscribers. Use lookupService(GraphName) instead to
lookup ROS-RPC URIs for ServiceServers.public java.util.List<java.util.List<java.lang.String>> getTopicTypes(GraphName calledId)
List of all TopicSystemState message types.calledId - the Node name of the callerpublic java.util.List<java.lang.Object> getSystemState()
This includes information about publishers, subscribers, and services.
public java.net.URI lookupService(GraphName serviceName)
serviceName - name of serviceURI of the SlaveServer with the provided name, or
null if there is no such service.public java.util.List<java.lang.Object> getPublishedTopics(GraphName caller, GraphName subgraph)
caller - name of the callersubgraph - subgraph containing the requested TopicSystemStates,
relative to callerList of Lists where the nested Lists
contain, in order, the TopicSystemState name and
TopicSystemState message typepublic void onNodeReplacement(NodeRegistrationInfo nodeInfo)
MasterRegistrationListenerThe information object is about to be trashed, so it should not be hung onto.
onNodeReplacement in interface MasterRegistrationListenernodeInfo - the node being replaced