Examples of RequestMessage


Examples of com.betfair.cougar.netutil.nio.message.RequestMessage

    @Override
    public long sendRequest(byte[] message, ResponseHandler handler) throws IOException {
        if (!broken) {
            long correlationId = correlationIdGenerator.incrementAndGet();
            RequestMessage req = new RequestMessage(correlationId, message);
            callbacks.put(correlationId, new WaitingResponseHandler(getExpiryTime(), handler));

            session.write(req);
            return correlationId;
        }
View Full Code Here

Examples of com.google.gwt.requestfactory.shared.messages.RequestMessage

   *
   * @param payload the payload sent by the client
   * @return a payload to return to the client
   */
  public String process(String payload) {
    RequestMessage req = AutoBeanCodex.decode(FACTORY, RequestMessage.class,
        payload).as();
    AutoBean<ResponseMessage> responseBean = FACTORY.response();
    try {
      process(req, responseBean.as());
    } catch (ReportableException e) {
View Full Code Here

Examples of com.google.web.bindery.requestfactory.shared.messages.RequestMessage

            context.persistAndReturnSelf().using(foo).with("barField", "oneToManyField",
                "oneToManySetField", "simpleValue", "simpleValues").fire(
                new Receiver<SimpleFooProxy>() {
                  @Override
                  public void onSuccess(SimpleFooProxy response) {
                    RequestMessage requestMessage =
                        AutoBeanCodex.decode(MessageFactoryHolder.FACTORY, RequestMessage.class,
                            transport.lastRequestPayload).as();

                    int seenFoos = 0;
                    int seenValues = 0;
                    for (OperationMessage operationMessage : requestMessage.getOperations()) {
                      if (fooTypeToken.equals(operationMessage.getTypeToken())) {
                        seenFoos++;
                        @SuppressWarnings("unchecked")
                        SimpleProxyId<?> id = (SimpleProxyId<?>) foo.stableId();
                        assertEquals(id.getServerId(), operationMessage.getServerId());
                        assertEquals(2, operationMessage.getPropertyMap().size());
                        assertTrue(operationMessage.getPropertyMap().containsKey("simpleValue"));
                        assertTrue(operationMessage.getPropertyMap().containsKey("simpleValues"));
                      } else if (valueTypeToken.equals(operationMessage.getTypeToken())) {
                        seenValues++;
                        AutoBean<SimpleValueProxy> bean = AutoBeanUtils.getAutoBean(created);
                        SimpleProxyId<?> id = BaseProxyCategory.stableId(bean);
                        assertEquals(id.getClientId(), operationMessage.getClientId());
                        assertEquals(AutoBeanUtils.getAllProperties(bean).keySet(),
                            operationMessage.getPropertyMap().keySet());
                      }
                    }
                    assertTrue(seenFoos > 0);
                    assertTrue(seenValues > 0);

                    // Persist without any change
                    factory.simpleFooRequest().persistAndReturnSelf().using(response).fire(
                        new Receiver<SimpleFooProxy>() {

                          @Override
                          public void onSuccess(SimpleFooProxy response) {
                            RequestMessage requestMessage =
                                AutoBeanCodex.decode(MessageFactoryHolder.FACTORY,
                                    RequestMessage.class, transport.lastRequestPayload).as();

                            int seenFoos = 0;
                            for (OperationMessage operationMessage : requestMessage.getOperations()) {
                              if (fooTypeToken.equals(operationMessage.getTypeToken())) {
                                seenFoos++;
                                assertNull(operationMessage.getPropertyMap());
                              }
                            }
View Full Code Here

Examples of com.sleepycat.je.rep.impl.TextProtocol.RequestMessage

                        LoggerUtils.logMsg(logger, envImpl,
                                           formatter, Level.FINE,
                                           "Acceptor: EOF on request");
                        continue;
                    }
                    RequestMessage requestMessage = null;
                    try {
                        requestMessage = protocol.parseRequest(requestLine);
                    } catch (InvalidMessageException e) {
                        LoggerUtils.logMsg(logger, envImpl,
                                           formatter, Level.WARNING,
                                           "Message format error: " +
                                           e.getMessage());
                        out.println
                            (protocol.new ProtocolError(e).wireFormat());
                        continue;
                    }
                    ResponseMessage responseMessage = null;
                    if (requestMessage.getOp() == protocol.PROPOSE) {
                        responseMessage = process((Propose) requestMessage);
                    } else if (requestMessage.getOp() == protocol.ACCEPT) {
                        responseMessage = process((Accept) requestMessage);
                    } else if (requestMessage.getOp() == protocol.SHUTDOWN) {
                        break;
                    } else {
                        LoggerUtils.logMsg(logger, envImpl,
                                           formatter, Level.SEVERE,
                                           "Unrecognized request: " +
                                           requestLine);
                        continue;
                    }

                    /*
                     * The request message may be of an earlier version. If so,
                     * this node transparently read the older version. JE only
                     * throws out InvalidMesageException when the version of
                     * the request message is newer than the current protocol.
                     * To avoid sending a repsonse that the requester cannot
                     * understand, we send a response in the same version as
                     * that of the original request message.
                     */
                    responseMessage.setSendVersion
                        (requestMessage.getSendVersion());
                    out.println(responseMessage.wireFormat());
                } catch (IOException e) {
                    LoggerUtils.logMsg
                        (logger, envImpl, formatter, Level.WARNING,
                         "IO error on socket: " + e.getMessage());
View Full Code Here

Examples of com.sleepycat.je.rep.impl.TextProtocol.RequestMessage

        /* Read request and send out response. */
        public void run() {
            try {
                channel.configureBlocking(true);
                RequestMessage request = protocol.getRequestMessage(channel);
                if (request == null) {
                    return;
                }
                ResponseMessage response = getResponse(request);
                if (expectResponse && response != null) {
View Full Code Here

Examples of com.sleepycat.je.rep.impl.TextProtocol.RequestMessage

                        (new InputStreamReader(socket.getInputStream()));
                    final String requestLine = in.readLine();
                    if (requestLine == null) {
                        continue;
                    }
                    RequestMessage requestMessage;
                    try {
                        requestMessage = protocol.parseRequest(requestLine);
                    } catch (InvalidMessageException e) {
                        LoggerUtils.logMsg
                            (logger, envImpl, formatter, Level.WARNING,
                             "Message format exception: " + e.getMessage());
                        out = new PrintWriter(socket.getOutputStream(), true);
                        out.println(protocol.new
                                    ProtocolError(e).wireFormat());
                        continue;
                    }

                    LoggerUtils.logMsg(logger, envImpl, formatter,
                                       Level.FINEST,
                                       "learner request: " +
                                       requestMessage.getOp() +
                                       " sender: " +
                                       requestMessage.getSenderId());
                    if (requestMessage.getOp() == protocol.RESULT) {
                        Result result = (Result) requestMessage;
                        processResult(result.getProposal(),result.getValue());
                    } else if (requestMessage.getOp() ==
                               protocol.MASTER_QUERY) {
                        synchronized (this) {
                            if ((currentProposal != null) &&
                                    (currentValue != null)) {
                                out = new PrintWriter(socket.getOutputStream(),
                                                      true);
                                MasterQueryResponse responseMessage =
                                    protocol.new MasterQueryResponse
                                        (currentProposal, currentValue);

                                /*
                                 * The request message may be of an earlier
                                 * version. If so, this node transparently read
                                 * the older version. JE only throws out
                                 * InvalidMessageException when the version of
                                 * the request message is newer than the
                                 * current protocol. To avoid sending a
                                 * response that the requester cannot
                                 * understand, we send a response in the same
                                 * version as that of the original request
                                 * message.
                                 */
                                responseMessage.setSendVersion
                                    (requestMessage.getSendVersion());
                                out.println(responseMessage.wireFormat());
                            }
                        }
                    } else if (requestMessage.getOp() == protocol.SHUTDOWN) {
                        LoggerUtils.logMsg
                            (logger, envImpl, formatter, Level.FINE,
                             "Learner thread exiting");
                        break;
                    } else {
View Full Code Here

Examples of com.sleepycat.je.rep.impl.TextProtocol.RequestMessage

        final ExecutorService pool =
            Executors.newFixedThreadPool
               (threadPoolSize, new StoppableThreadFactory("JE Learner",
                                                           logger));
        try {
            RequestMessage masterQuery = protocol.new MasterQuery();
            List<Future<MessageExchange>> futures =
                Utils.broadcastMessage(learnerSockets,
                                       Learner.SERVICE_NAME,
                                       masterQuery,
                                       pool);
View Full Code Here

Examples of com.sleepycat.je.rep.impl.TextProtocol.RequestMessage

               MemberNotFoundException,
               MasterStateException,
               EnvironmentFailureException {

        final String masterErrorMessage = "Cannot remove an active master";
        final RequestMessage request =
            groupProtocol.new RemoveMember(nodeName);

        checkMember(nodeName, masterErrorMessage);
        doMessageExchange(request, OK.class);
    }
View Full Code Here

Examples of com.sleepycat.je.rep.impl.TextProtocol.RequestMessage

               ReplicaStateException,
               UnknownMasterException {

        final String masterErrorMessage =
            "Can't update address for the current master.";
        RequestMessage request =
            groupProtocol.new UpdateAddress(nodeName, newHostName, newPort);

        checkMember(nodeName, masterErrorMessage);
        doMessageExchange(request, OK.class);
    }
View Full Code Here

Examples of com.sleepycat.je.rep.impl.TextProtocol.RequestMessage

               MemberNotFoundException,
               UnknownMasterException {

        final String masterErrorMessage =
            "The node is currently the master, needn't to transfer";
        final RequestMessage transferMaster =
            groupProtocol.new TransferMaster(nodeName);

        checkMember(nodeName, masterErrorMessage);
        doMessageExchange(transferMaster, null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.