当前位置: 首页>>代码示例>>Java>>正文


Java RouteMessage类代码示例

本文整理汇总了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;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:11,代码来源:RoutingTableTest.java

示例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;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:13,代码来源:MyApp.java

示例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);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:11,代码来源:RoutingMessageRedirector.java

示例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;
}
 
开发者ID:darioseidl,项目名称:pastry-push-sum,代码行数:16,代码来源:PastryPushSum.java

示例5: forward

import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
public boolean forward(RouteMessage message) {
  // TODO Auto-generated method stub
  return true;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:5,代码来源:BandwidthMeasuringTLTest.java

示例6: forward

import rice.p2p.commonapi.RouteMessage; //导入依赖的package包/类
public boolean forward(RouteMessage message) {
  return true;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:4,代码来源:MyScribeClient.java

示例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);
    }
}
 
开发者ID:barnyard,项目名称:pi,代码行数:60,代码来源:KoalaPastryApplicationBase.java

示例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);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:7,代码来源:RoutingMessageRedirector.java

示例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;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:8,代码来源:MyApp.java

示例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; }
 
开发者ID:barnyard,项目名称:pi,代码行数:14,代码来源:TestHarness.java

示例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;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:15,代码来源:ReplicationManagerImpl.java


注:本文中的rice.p2p.commonapi.RouteMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。