Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 167
rosnode kill support (shut down the node)#291
base:kinetic
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,6 +20,7 @@ | ||
| import org.ros.address.AdvertiseAddress; | ||
| import org.ros.address.BindAddress; | ||
| import org.ros.internal.node.DefaultNode; | ||
| import org.ros.internal.node.client.MasterClient; | ||
| import org.ros.internal.node.parameter.ParameterManager; | ||
| import org.ros.internal.node.service.ServiceManager; | ||
| @@ -52,12 +53,15 @@ public class SlaveServer extends XmlRpcServer { | ||
| private final TopicParticipantManager topicParticipantManager; | ||
| private final ParameterManager parameterManager; | ||
| private final TcpRosServer tcpRosServer; | ||
| private final DefaultNode defaultNode; | ||
| private boolean shutdownStarted; | ||
| public SlaveServer(GraphName nodeName, BindAddress tcpRosBindAddress, | ||
| AdvertiseAddress tcpRosAdvertiseAddress, BindAddress xmlRpcBindAddress, | ||
| AdvertiseAddress xmlRpcAdvertiseAddress, MasterClient master, | ||
| TopicParticipantManager topicParticipantManager, ServiceManager serviceManager, | ||
| ParameterManager parameterManager, ScheduledExecutorService executorService) { | ||
| ParameterManager parameterManager, ScheduledExecutorService executorService, | ||
| DefaultNode defaultNode) { | ||
| super(xmlRpcBindAddress, xmlRpcAdvertiseAddress); | ||
| this.nodeName = nodeName; | ||
| this.masterClient = master; | ||
| @@ -66,6 +70,7 @@ public SlaveServer(GraphName nodeName, BindAddress tcpRosBindAddress, | ||
| this.tcpRosServer = | ||
| new TcpRosServer(tcpRosBindAddress, tcpRosAdvertiseAddress, topicParticipantManager, | ||
| serviceManager, executorService); | ||
| this.defaultNode = defaultNode; | ||
| } | ||
| public AdvertiseAddress getTcpRosAdvertiseAddress() { | ||
| @@ -81,13 +86,22 @@ public void start() { | ||
| super.start(org.ros.internal.node.xmlrpc.SlaveXmlRpcEndpointImpl.class, | ||
| new SlaveXmlRpcEndpointImpl(this)); | ||
| tcpRosServer.start(); | ||
| shutdownStarted = false; | ||
| } | ||
| // TODO(damonkohler): This should also shut down the Node. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment can be removed. | ||
| @Override | ||
| public void shutdown() { | ||
| // prevent recursive call of this method | ||
| if (shutdownStarted) { | ||
| return; | ||
| } | ||
| shutdownStarted = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About thread safety: // In the constructor:shutdownLock = newObject();
// Then:@Overridepublicvoidshutdown() {
synchronized(shutdownLock) {
// current code goes here
}
}And the same for | ||
| super.shutdown(); | ||
| tcpRosServer.shutdown(); | ||
| if (defaultNode != null) { | ||
| defaultNode.shutdown(); | ||
| } | ||
| } | ||
| public List<Object> getBusStats(String callerId) { | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest changing to
Nodeinstead of tying this to a particular implementation.As we only need the
shutdownmethod, we can use the base interface instead.