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


Java Request.getRequest方法代码示例

本文整理汇总了Java中org.jetlang.channels.Request.getRequest方法的典型用法代码示例。如果您正苦于以下问题:Java Request.getRequest方法的具体用法?Java Request.getRequest怎么用?Java Request.getRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jetlang.channels.Request的用法示例。


在下文中一共展示了Request.getRequest方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onIncomingMessage

import org.jetlang.channels.Request; //导入方法依赖的package包/类
@FiberOnly
private void onIncomingMessage(Request<RpcWireRequest, RpcReply> message) {
  try {
    RpcWireRequest req = message.getRequest();
    if (req.isPreElectionPollMessage()) {
      doPreElectionPollMessage(message);

    } else if (req.isRequestVoteMessage()) {
      doRequestVote(message);

    } else if (req.isAppendMessage()) {
      doAppendMessage(message);

    } else {
      logger.warn("got a message of protobuf type I don't know: {}", req);
    }
  } catch (Exception e) {
    logger.error("Uncaught exception while processing message {}: {}", message, e);
    throw e;
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:22,代码来源:ReplicatorInstance.java

示例2: doPreElectionPollMessage

import org.jetlang.channels.Request; //导入方法依赖的package包/类
@FiberOnly
private void doPreElectionPollMessage(Request<RpcWireRequest, RpcReply> message) {
  final RpcWireRequest request = message.getRequest();
  final PreElectionPoll msg = request.getPreElectionPollMessage();
  final long msgLastLogTerm = msg.getLastLogTerm();
  final long msgLastLogIndex = msg.getLastLogIndex();

  final boolean wouldVote =
      msg.getTerm() >= currentTerm
          && atLeastAsUpToDateAsLocalLog(msgLastLogTerm, msgLastLogIndex)
          && !rejectPollFromOldConfiguration(request.from, msgLastLogTerm, msgLastLogIndex);

  logger.debug("sending pre-election reply to {} wouldVote = {}", message.getRequest().from, wouldVote);
  PreElectionReply m = new PreElectionReply(currentTerm, wouldVote);
  RpcReply reply = new RpcReply(m);
  message.reply(reply);
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:18,代码来源:ReplicatorInstance.java

示例3: handleNodeInfoRequest

import org.jetlang.channels.Request; //导入方法依赖的package包/类
@FiberOnly
private void handleNodeInfoRequest(Request<NodeInfoRequest, NodeInfoReply> message) {
  NodeInfoRequest req = message.getRequest();
  NodeInfo peer = peerNodeInfoMap.get(req.nodeId);
  if (peer == null) {
    message.reply(NodeInfoReply.NO_REPLY);
    return;
  }

  Integer servicePort = peer.modules.get(req.moduleType);
  if (servicePort == null) {
    message.reply(NodeInfoReply.NO_REPLY);
    return;
  }

  List<String> peerAddresses = peer.availability.getAddressesList();
  if (peerAddresses == null || peerAddresses.isEmpty()) {
    message.reply(NodeInfoReply.NO_REPLY);
    return;
  }

  // does this module run on that peer?
  message.reply(new NodeInfoReply(true, peerAddresses, servicePort));
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:25,代码来源:BeaconService.java

示例4: JetlangPonger

import org.jetlang.channels.Request; //导入方法依赖的package包/类
/** Creates a JetlangPonger. */
public JetlangPonger(final Fiber _fiber) {
    fiber = _fiber;
    channel = new MemoryRequestChannel();
    final Callback<Request> onReq = new Callback<Request>() {
        @Override
        public void onMessage(final Request message) {
            final Object request = message.getRequest();
            if (request instanceof PingRequest) {
                final PingRequest ping = (PingRequest) request;
                message.reply(ping.processRequest(JetlangPonger.this));
            } else {
                throw new IllegalStateException(
                        "Expected PingRequest but got "
                                + request.getClass());
            }
        }
    };
    fiber.start();
    channel.subscribe(fiber, onReq);
}
 
开发者ID:skunkiferous,项目名称:PingPong,代码行数:22,代码来源:JetlangPonger.java

示例5: messageForwarder

import org.jetlang.channels.Request; //导入方法依赖的package包/类
private void messageForwarder(final Request<RpcRequest, RpcWireReply> origMsg) {

    final RpcRequest request = origMsg.getRequest();
    final long destination = request.to;
    final ReplicatorInstance repl = replicators.get(destination);
    if (repl == null) {
      // boo
      LOG.info("Request to nonexistent peer {}", destination);
      // Do nothing and allow request to timeout.
      return;
    }

    LOG.debug("Request {}", request);
    if (shouldDropMessage(request)) {
      LOG.debug("Request dropped: {}", request);
      return;
    }

    final RpcWireRequest newRequest = new RpcWireRequest(request.from, request.quorumId, request.message);
    AsyncRequest.withOneReply(rpcFiber, repl.getIncomingChannel(), newRequest, msg -> {
      // Note that 'RpcReply' has an empty from/to/messageId.  We must know from our context (and so we do)
      RpcWireReply newReply = new RpcWireReply(request.from, request.to, request.quorumId, msg.message);
      LOG.debug("Reply {}", newReply);
      if (shouldDropMessage(newReply)) {
        LOG.debug("Reply dropped: {}", newReply);
        return;
      }
      replyChannel.publish(newReply);
      origMsg.reply(newReply);
    });
  }
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:32,代码来源:InRamSim.java

示例6: routeOutboundRequests

import org.jetlang.channels.Request; //导入方法依赖的package包/类
/**
 * Either route an outbound request to a callback, or queue it, depending on destination peer
 */
private void routeOutboundRequests(Request<RpcRequest, RpcWireReply> request) {
  long to = request.getRequest().to;
  if (peerBehavioralCallbacks.containsKey(to)) {
    peerBehavioralCallbacks.get(to).onMessage(request);
  } else {
    if (!requests.containsKey(to)) {
      requests.put(to, new LinkedBlockingQueue<>());
    }
    requests.get(to).add(request);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:15,代码来源:ReplicatorLeaderTest.java

示例7: sendAppendEntriesReply

import org.jetlang.channels.Request; //导入方法依赖的package包/类
/**
 * Reply true or false to a single AppendEntries request
 */
private void sendAppendEntriesReply(Request<RpcRequest, RpcWireReply> request,
                                    boolean trueIsSuccessFlag,
                                    long myNextIndex) {
  RpcRequest message = request.getRequest();
  long termFromMessage = message.getAppendMessage().getTerm();
  AppendEntriesReply replyMessage = new AppendEntriesReply(termFromMessage, trueIsSuccessFlag, myNextIndex);
  request.reply(new RpcWireReply(message.from, message.to, QUORUM_ID, replyMessage));
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:12,代码来源:ReplicatorLeaderTest.java

示例8: handleLoopBack

import org.jetlang.channels.Request; //导入方法依赖的package包/类
private void handleLoopBack(Request<RpcRequest, RpcWireReply> request) {
  final RpcWireRequest newRequest = new RpcWireRequest(MY_ID, QUORUM_ID, request.getRequest().message);

  AsyncRequest.withOneReply(rpcFiber, replicatorInstance.getIncomingChannel(), newRequest,
      reply -> {
        final RpcWireReply wireReply = new RpcWireReply(MY_ID, MY_ID, QUORUM_ID, reply.message);
        selfReplyChannel.publish(wireReply);
        request.reply(wireReply);
      });
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:11,代码来源:ReplicatorElectionTest.java

示例9: messageForwarder

import org.jetlang.channels.Request; //导入方法依赖的package包/类
private void messageForwarder(final Request<OutgoingRpcRequest, IncomingRpcReply> origMsg) {

        // ok, who sent this?!!!!!
        final OutgoingRpcRequest request = origMsg.getRequest();
//        msgSize.update(request.message.getSerializedSize());
        final long dest = request.to;
        // find it:
        final FleaseLease fl = fleaseRunners.get(dest);
        if (fl == null) {
            // boo
            LOG.error("Request to non exist: " + dest);
            origMsg.reply(null);
            return;
        }

        messages.mark();
        messageTxn.inc();

        //LOG.debug("Forwarding message from {} to {}, contents: {}", request.from, request.to, request.message);
        // Construct and send a IncomingRpcRequest from the OutgoingRpcRequest.
        // There is absolutely no way to know who this is from at this point from the infrastructure.
        final IncomingRpcRequest newRequest = new IncomingRpcRequest(1, request.from, request.message);
        AsyncRequest.withOneReply(rpcFiber, fl.getIncomingChannel(), newRequest, new Callback<OutgoingRpcReply>() {
            @Override
            public void onMessage(OutgoingRpcReply msg) {
                // Translate the OutgoingRpcReply -> IncomingRpcReply.
                //LOG.debug("Forwarding reply message from {} back to {}, contents: {}", dest, request.to, msg.message);
                messages.mark();
                messageTxn.dec();
//                msgSize.update(msg.message.getSerializedSize());
                IncomingRpcReply newReply = new IncomingRpcReply(msg.message, dest);
                origMsg.reply(newReply);
            }
        });
    }
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:36,代码来源:InRamSim.java

示例10: JetlangPinger

import org.jetlang.channels.Request; //导入方法依赖的package包/类
/** Creates a JetlangPinger. */
@SuppressWarnings({ "rawtypes", "unchecked" })
public JetlangPinger(final Fiber _fiber) {
    fiber = _fiber;
    channel = new MemoryRequestChannel();
    final Callback<Request> onReq = new Callback<Request>() {
        @Override
        public void onMessage(final Request message) {
            final Object request = message.getRequest();
            if (request instanceof HammerRequest) {
                final HammerRequest req = (HammerRequest) request;
                try {
                    req.processRequest(JetlangPinger.this);
                    ping(message);
                } catch (final Exception e) {
                    e.printStackTrace();
                    message.reply(-1);
                }
            } else {
                throw new IllegalStateException(
                        "Expected HammerRequest but got "
                                + request.getClass());
            }
        }
    };
    fiber.start();
    channel.subscribe(fiber, onReq);
}
 
开发者ID:skunkiferous,项目名称:PingPong,代码行数:29,代码来源:JetlangPinger.java


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