當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。