-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52c5db3
commit 9c92ad5
Showing
8 changed files
with
95 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,3 @@ | ||
/* | ||
* Copyright (C) 2011 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package org.ros.internal.node.client; | ||
|
||
import org.ros.internal.node.response.IntegerResultFactory; | ||
|
@@ -34,10 +18,12 @@ | |
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
|
||
/** | ||
* @author [email protected] (Damon Kohler) | ||
* Create a client to the RpcEndpoint via SlaveRpcEndpointImpl | ||
* from the socket address passed in constructor. | ||
* @author jg | ||
*/ | ||
public class SlaveClient extends Client<SlaveRpcEndpoint> { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,16 @@ | ||
/* | ||
* Copyright (C) 2012 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package org.ros.internal.node.server.master; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import org.ros.internal.node.service.ServiceIdentifier; | ||
import org.ros.master.client.TopicSystemState; | ||
import org.ros.namespace.GraphName; | ||
|
@@ -37,10 +23,10 @@ | |
* <p> | ||
* This class is not thread-safe. | ||
* | ||
* @author [email protected] (Keith M. Hughes) | ||
* @author jg | ||
*/ | ||
public class MasterRegistrationManagerImpl { | ||
|
||
private static boolean DEBUG = true; | ||
private static final Log log = LogFactory.getLog(MasterRegistrationManagerImpl.class); | ||
|
||
/** | ||
|
@@ -65,6 +51,7 @@ public class MasterRegistrationManagerImpl { | |
*/ | ||
private final MasterRegistrationListener listener; | ||
|
||
|
||
public MasterRegistrationManagerImpl(MasterRegistrationListener listener) { | ||
this.listener = listener; | ||
nodes = new HashMap<GraphName, NodeRegistrationInfo>(); | ||
|
@@ -425,21 +412,27 @@ private NodeRegistrationInfo obtainNodeRegistrationInfo(GraphName nodeName, Inet | |
} | ||
log.info("Replacing node "+node.getNodeSlaveUri()+" with new requested "+nodeSlaveUri); | ||
// The node is switching slave URIs, so we need a new one. | ||
potentiallyDeleteNode(node); | ||
//potentiallyDeleteNode(node); | ||
nodes.remove(nodeName); | ||
cleanupNode(node); | ||
NodeRegistrationInfo newNode = new NodeRegistrationInfo(nodeName, nodeSlaveUri); | ||
nodes.put(nodeName, newNode); | ||
// Try to reach old node via SlaveClient to shut it down | ||
/* | ||
try { | ||
listener.onNodeReplacement(node); | ||
} catch (Exception e) { | ||
// No matter what, we want to keep going | ||
log.error("Error during onNodeReplacement call", e); | ||
} | ||
*/ | ||
return newNode; | ||
} else { | ||
// no existing node | ||
node = new NodeRegistrationInfo(nodeName, nodeSlaveUri); | ||
nodes.put(nodeName, node); | ||
return node; | ||
} | ||
|
||
// Either no existing node, or the old node needs to go away | ||
node = new NodeRegistrationInfo(nodeName, nodeSlaveUri); | ||
nodes.put(nodeName, node); | ||
|
||
return node; | ||
} | ||
|
||
/** | ||
|
@@ -463,6 +456,39 @@ private void cleanupNode(NodeRegistrationInfo node) { | |
} | ||
} | ||
|
||
/** | ||
* A node is being replaced. Change the NodeRegistrationInfo to the new address | ||
* | ||
* @param node | ||
* the node being replaced | ||
* @param newNode | ||
* the new node | ||
*/ | ||
private void replaceNode(NodeRegistrationInfo node, NodeRegistrationInfo newNode) { | ||
boolean found = false; | ||
for (TopicRegistrationInfo topic : node.getPublishers()) { | ||
found = topic.removePublisher(node); | ||
if( found ) { | ||
if( DEBUG ) | ||
log.info("Replacing publisher:"+node+" "+newNode+" "+topic); | ||
topic.addPublisher(newNode, topic.getMessageType()); | ||
} | ||
} | ||
|
||
for (TopicRegistrationInfo topic : node.getSubscribers()) { | ||
found = topic.removeSubscriber(node); | ||
if( found ) { | ||
if( DEBUG ) | ||
log.info("Replacing subscriber:"+node+" "+newNode+" "+topic); | ||
topic.addSubscriber(newNode, topic.getMessageType()); | ||
} | ||
} | ||
|
||
// TODO: service? | ||
for (ServiceRegistrationInfo service : node.getServices()) { | ||
services.remove(service.getServiceName()); | ||
} | ||
} | ||
/** | ||
* Remove a node from registration if it no longer has any registrations. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 1 addition & 19 deletions
20
src/main/java/org/ros/internal/node/server/master/NodeRegistrationInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,15 @@ | ||
/* | ||
* Copyright (C) 2012 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package org.ros.internal.node.server.master; | ||
|
||
import org.ros.namespace.GraphName; | ||
|
||
import java.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
import java.net.URI; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Information a master needs about a node. | ||
* | ||
* @author [email protected] (Keith M. Hughes) | ||
* @author jg | ||
*/ | ||
public class NodeRegistrationInfo { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters