本文整理汇总了Java中rice.p2p.commonapi.RouteMessage类的典型用法代码示例。如果您正苦于以下问题:Java RouteMessage类的具体用法?Java RouteMessage怎么用?Java RouteMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RouteMessage类属于rice.p2p.commonapi包,在下文中一共展示了RouteMessage类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
/**
* Called a message travels along your path.
* Don't worry about this method for now.
*/
@SuppressWarnings("deprecation")
public boolean forward(RouteMessage message) {
if (logHeavy)
System.out.println(this+"forwarding "+message.getMessage());
return true;
}
示例2: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
/**
* @return true if it should continue along the path. false will deliver it locally
*/
public boolean forward(RouteMessage message) {
try {
MyMsg msg = (MyMsg)message.getMessage(endpoint.getDeserializer());
msg.addHop(endpoint.getLocalNodeHandle());
} catch (IOException ioe) {
ioe.printStackTrace();
}
return true;
}
示例3: reroute
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
public void reroute(RouteMessage routeMessage, Id newDestinationId) {
if (LOG.isDebugEnabled())
LOG.debug(String.format("Rerouting message %s to id %s", routeMessage, newDestinationId.toStringFull()));
NodeHandle nextHop = routerWrapper.pick(routeMessage, newDestinationId);
if (LOG.isDebugEnabled())
LOG.debug(String.format("Setting next hop to %s", nextHop));
routeMessage.setDestinationId(newDestinationId);
routeMessage.setNextHopHandle(nextHop);
}
示例4: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
/**
* Called when this node is about to forward a message.
* <p>
* All messages are forwarded in this application.
*/
@Override
public boolean forward(RouteMessage message)
{
if (trace)
{
log("forward " + message);
}
return true;
}
示例5: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
public boolean forward(RouteMessage message) {
// TODO Auto-generated method stub
return true;
}
示例6: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
public boolean forward(RouteMessage message) {
return true;
}
示例7: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
@Override
public final boolean forward(RouteMessage routeMessage) {
Message innerMessage = null;
try {
innerMessage = routeMessage.getMessage(defaultDeserializer);
} catch (IOException e) {
LOG.warn("Error trying to extract message from RouteMessage. RouteMessage: " + routeMessage + " Deserializer: " + defaultDeserializer);
}
if (innerMessage == null || !(innerMessage instanceof ApplicationMessage))
return true;
ApplicationMessage appMessage = (ApplicationMessage) innerMessage;
String transactionUID = appMessage.getTransactionUID();
MDCHelper.putTransactionUID(transactionUID);
long startTime = ContinuationUtils.logStartOfContinuation(ContinuationUtils.APPLICATION_FORWARD, transactionUID);
try {
PiEntity payload = koalaPiEntityFactory.getPiEntity(appMessage.getJson());
KoalaPastryApplicationBase applicationToProcessMessage = appMessage.getDestinationApplicationName() == null ? this : localNodeApplicationsClassMap.get(appMessage.getDestinationApplicationName());
if (applicationToProcessMessage == null) {
LOG.warn(String.format(UNKNOWN_DESTINATION_APPLICATION_S, appMessage.getDestinationApplicationName()));
return true;
}
if (applicationToProcessMessage != this) {
LOG.debug(String.format("Forwarding message to specified destination application %s instead of %s", applicationToProcessMessage.getApplicationName(), this.getApplicationName()));
return applicationToProcessMessage.forward(routeMessage);
} else {
// Let's figure out if this message is about to terminate on our node
if (!(routeMessage instanceof rice.pastry.routing.RouteMessage)) {
throw new RuntimeException(String.format("Unexpected RouteMessage implementation: %s", routeMessage.getClass().getName()));
}
Id nextHopNodeId = ((rice.pastry.routing.RouteMessage) routeMessage).getNextHop().getNodeId();
boolean isForThisNode = getNodeId().equals(nextHopNodeId);
LOG.debug(String.format("Is message for id %s and dest node id %s for local node handle %s? %s", routeMessage.getDestinationId(), nextHopNodeId, getNodeId(), isForThisNode));
MessageForwardAction messageForwardAction = forwardPiMessage(isForThisNode, routeMessage.getDestinationId(), payload);
Id newDestinationId = messageForwardAction.getNewDestinationNodeId();
if (newDestinationId != null) {
LOG.debug(String.format("Changing destination id for message %s from %s to %s", appMessage.getUID(), routeMessage.getDestinationId(), newDestinationId));
RoutingMessageRedirector routingMessageRedirector = getRoutingMessageRedirector();
routingMessageRedirector.reroute(routeMessage, newDestinationId);
}
LOG.debug(String.format("Returning %s", messageForwardAction.shouldForwardMessage()));
return messageForwardAction.shouldForwardMessage();
}
} catch (Throwable t) {
LOG.error("Error while forwarding", t);
throw new RuntimeException(t.getMessage(), t);
} finally {
MDCHelper.clearTransactionUID();
ContinuationUtils.logEndOfContinuation(ContinuationUtils.APPLICATION_FORWARD, transactionUID, startTime);
}
}
示例8: pick
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
public NodeHandle pick(RouteMessage routeMessage, Id newDestinationId) {
if (!(newDestinationId instanceof rice.pastry.Id))
throw new RuntimeException("Unexpected type: " + newDestinationId.getClass());
Iterator<rice.pastry.NodeHandle> iter = wrappedRouter.getBestRoutingCandidates((rice.pastry.Id) newDestinationId);
return super.routerStrategy.pickNextHop((rice.pastry.routing.RouteMessage) routeMessage, iter);
}
示例9: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
/**
* Called a message travels along your path.
* Don't worry about this method for now.
*/
public boolean forward(RouteMessage message) {
return true;
}
示例10: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
/**
* This method is invoked on applications when the underlying node
* is about to forward the given message with the provided target to
* the specified next hop. Applications can change the contents of
* the message, specify a different nextHop (through re-routing), or
* completely terminate the message.
*
* @param message The message being sent, containing an internal message
* along with a destination key and nodeHandle next hop.
*
* @return Whether or not to forward the message further
*/
public boolean forward(RouteMessage message) { return true; }
示例11: forward
import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
/**
* This method is invoked on applications when the underlying node is about to forward the given message with the
* provided target to the specified next hop. Applications can change the contents of the message, specify a
* different nextHop (through re-routing), or completely terminate the message.
*
* @param message
* The message being sent, containing an internal message along with a destination key and nodeHandle
* next hop.
*
* @return Whether or not to forward the message further
*/
public boolean forward(RouteMessage message) {
return true;
}