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


Java Request.reply方法代码示例

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


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

示例1: 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

示例2: handleWireInboundMessage

import org.jetlang.channels.Request; //导入方法依赖的package包/类
@FiberOnly
private void handleWireInboundMessage(Channel channel, ReplicationWireMessage msg) {
  long messageId = msg.getMessageId();
  if (msg.getReceiverId() != nodeId) {
    LOG.debug("Got messageId {} for {} but I am {}, ignoring!", messageId, msg.getReceiverId(), nodeId);
    return;
  }

  if (msg.getInReply()) {
    Request<RpcRequest, RpcWireReply> request = outstandingRPCs.get(messageId);
    if (request == null) {
      LOG.debug("Got a reply message_id {} which we don't track", messageId);
      return;
    }

    outstandingRPCs.remove(messageId);
    outstandingRPCbySession.remove(request.getSession());
    request.reply(new RpcWireReply(msg));
  } else {
    handleWireRequestMessage(channel, msg);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:23,代码来源:ReplicatorService.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: receiveWrite

import org.jetlang.channels.Request; //导入方法依赖的package包/类
private void receiveWrite(Request<IncomingRpcRequest, OutgoingRpcReply> message) {
    BallotNumber k = message.getRequest().getBallotNumber();
    // If write > k or read > k THEN
    if (write.compareTo(k, info) > 0
            || read.compareTo(k, info) > 0) {
        // send nackWRITE, k
        LOG.debug("{} sending nackWRITE, rejected ballot {} because I already have (r;w) {} ; {}", getId(), k, read, write);
        message.reply(OutgoingRpcReply.getNackWriteMessage(message.getRequest(), k));
    } else {
        write = k;
        lease = message.getRequest().getLease();
        LOG.info("{} new lease value written [{}] with k {}", getId(), lease, write);

        // send ackWRITE, k
        message.reply(OutgoingRpcReply.getAckWriteMessage(message.getRequest(), k));
    }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:18,代码来源:FleaseLease.java

示例5: receiveRead

import org.jetlang.channels.Request; //导入方法依赖的package包/类
private void receiveRead(Request<IncomingRpcRequest, OutgoingRpcReply> message) {
    BallotNumber k = message.getRequest().getBallotNumber();
    // If write >= k or read >= k
    if (write.compareTo(k, info) >= 0
            || read.compareTo(k, info) >= 0) {
        // send (nackREAD, k) to p(j)
        LOG.debug("{} Sending nackREAD, rejecting ballot {} because I already have (r;w) {} ; {}", getId(), k, read, write);
        message.reply(OutgoingRpcReply.getNackReadMessage(message.getRequest(), k));
    } else {
        LOG.debug("{} onRead, setting 'read' to : {} (was: {})", getId(), k, read);
        read = k;
        // send (ackREAD,k,write(i),v(i)) to p(j)
        message.reply(OutgoingRpcReply.getAckReadMessage(message.getRequest(),
                k, write, lease));
    }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:17,代码来源:FleaseLease.java

示例6: 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

示例7: ping

import org.jetlang.channels.Request; //导入方法依赖的package包/类
/** Send a ping, unless we're done, in which case tell caller we are done. */
private void ping(final Request hammerRequest) throws Exception {
    final Callback<Integer> onReply = new Callback<Integer>() {
        @Override
        public void onMessage(final Integer response) {
            pongs++;
            if (response.intValue() != pongs) {
                throw new IllegalStateException("Expected " + pongs
                        + " but got " + response);
            }
            if (pongs < count) {
                try {
                    ping(hammerRequest);
                } catch (final Exception e) {
                    e.printStackTrace();
                    hammerRequest.reply(pongs);
                }
            } else {
                hammerRequest.reply(pongs);
            }
        }
    };
    ponger.ping(pongs, onReply);
}
 
开发者ID:skunkiferous,项目名称:PingPong,代码行数:25,代码来源:JetlangPinger.java

示例8: 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

示例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

示例11: appendReply

import org.jetlang.channels.Request; //导入方法依赖的package包/类
@FiberOnly
private void appendReply(Request<RpcWireRequest, RpcReply> request, boolean success) {
  AppendEntriesReply m = new AppendEntriesReply(currentTerm, success, 0);
  RpcReply reply = new RpcReply(m);
  request.reply(reply);
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:7,代码来源:ReplicatorInstance.java

示例12: handleServerRequests

import org.jetlang.channels.Request; //导入方法依赖的package包/类
private void handleServerRequests(Request<CommandRpcRequest<?>, CommandReply> msg) {
  System.out.println("Handle server requests: " + msg.getRequest());

  msg.reply(serverReply);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:6,代码来源:ControlServiceTest.java


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