Examples of ResponseMessage


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

    }
 
 
  @Override
  public void flush() throws IOException {
        ioSession.write(new ResponseMessage(correlationId, toByteArray()));
  }   
View Full Code Here

Examples of com.cloudesire.tisana4j.ExceptionTranslator.ResponseMessage

        ContentType type = ContentType.getOrDefault(response.getEntity());
        String charset = type.getCharset() != null ? type.getCharset().name() : "UTF-8";

        String errorStream = IOUtils.toString(stream, charset);

        ResponseMessage responseMessage = new ResponseMessage();
        RestException translatedException = exceptionTranslator.translateException(responseCode, response
          .getStatusLine().getReasonPhrase(), errorStream, responseMessage);

        if (translatedException != null) throw translatedException;

        throw getDefaultException(responseCode, response.getStatusLine().getReasonPhrase(), responseMessage.getResponse() );

      } catch (IllegalStateException | IOException e)
      {
        throw new RestException(responseCode, e.getMessage());
      }
View Full Code Here

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

      public void onTransportFailure(ServerFailure failure) {
        fail(receiver, failure);
      }

      public void onTransportSuccess(String payload) {
        ResponseMessage response = AutoBeanCodex.decode(
            MessageFactoryHolder.FACTORY, ResponseMessage.class, payload).as();
        if (response.getGeneralFailure() != null) {
          ServerFailureMessage failure = response.getGeneralFailure();
          ServerFailure fail = new ServerFailure(failure.getMessage(),
              failure.getExceptionType(), failure.getStackTrace(),
              failure.isFatal());

          fail(receiver, fail);
          return;
        }

        // Process violations and then stop
        if (response.getViolations() != null) {
          Set<Violation> errors = new HashSet<Violation>();
          for (ViolationMessage message : response.getViolations()) {
            errors.add(new MyViolation(message));
          }

          reuse();
          for (AbstractRequest<?> request : new ArrayList<AbstractRequest<?>>(
              invocations)) {
            request.onViolation(errors);
          }
          if (receiver != null) {
            receiver.onViolation(errors);
          }
          return;
        }

        // Process operations
        processReturnOperations(response);

        // Send return values
        for (int i = 0, j = invocations.size(); i < j; i++) {
          if (response.getStatusCodes().get(i)) {
            invocations.get(i).onSuccess(response.getInvocationResults().get(i));
          } else {
            ServerFailureMessage failure = AutoBeanCodex.decode(
                MessageFactoryHolder.FACTORY, ServerFailureMessage.class,
                response.getInvocationResults().get(i)).as();
            invocations.get(i).onFail(
                new ServerFailure(failure.getMessage(),
                    failure.getExceptionType(), failure.getStackTrace(),
                    failure.isFatal()));
          }
View Full Code Here

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

        fail();
      }

      @Override
      public void onTransportSuccess(String payload) {
        ResponseMessage resp =
            AutoBeanCodex.decode(MessageFactoryHolder.FACTORY, ResponseMessage.class, payload).as();
        ServerFailureMessage failure = resp.getGeneralFailure();
        assertNotNull(failure);
        finishTestAndReset();
      }
    });
  }
View Full Code Here

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

                                           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());
                    continue;
View Full Code Here

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

                    @Override
                    protected void processFuture()
                        throws ExecutionException, InterruptedException {

                        MessageExchange me = f.get();
                        final ResponseMessage responseMessage =
                            me.getResponseMessage();
                        if (responseMessage == null) {
                            LoggerUtils.logMsg(logger, elections.getRepImpl(),
                                               formatter, Level.WARNING,
                                               "No response from: " +
                                               me.target + " reason: " +
                                               me.exception);
                            return;
                        }

                        final Protocol protocol = elections.getProtocol();
                        final MessageOp op = responseMessage.getOp();
                        if (op == protocol.REJECT) {
                            Utils.discardFutures
                                (futures.subList(futures.indexOf(f),
                                                 futures.size()));
                            phase2HigherProposal.increment();
View Full Code Here

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

            MessageExchange me = stateProtocol.new MessageExchange
                (repNode.getSocketAddress(),
                 NodeStateService.SERVICE_NAME,
                 stateProtocol.new NodeStateRequest(repNode.getName()));
            me.run();
            ResponseMessage resp = me.getResponseMessage();
            if (resp instanceof NodeStateResponse) {
                NodeStateResponse response = (NodeStateResponse) resp;
                notifyJoin(new JoinGroupEvent(response.getNodeName(),
                                              response.getMasterName(),
                                              response.getJoinTime()));
View Full Code Here

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

                channel.configureBlocking(true);
                RequestMessage request = protocol.getRequestMessage(channel);
                if (request == null) {
                    return;
                }
                ResponseMessage response = getResponse(request);
                if (expectResponse && response != null) {
                    PrintWriter out = new PrintWriter
                        (channel.socket().getOutputStream(), true);
                    out.println(response.wireFormat());
                } else {
                    assert (response == null);
                }
            } catch (IOException e) {
                logMessage("IO error on socket: " + e.getMessage());
View Full Code Here

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

                        throws ExecutionException, InterruptedException {
                        /**
                         *  Wait for futures to complete and check for errors.
                         */
                        MessageExchange me = f.get();
                        ResponseMessage response = me.getResponseMessage();
                        if (response == null) {
                            return;
                        }
                        if (response.getOp() ==
                            protocol.MASTER_QUERY_RESPONSE){
                            results.add((MasterQueryResponse)response);
                        } else {
                            LoggerUtils.logMsg(logger,
                                               repImpl,
                                               formatter,
                                               Level.WARNING,
                                               "Unexpected MasterQuery " +
                                               "response:" +
                                               response.wireFormat());
                        }
                    }
                }.execute(logger, repImpl, formatter);
            }
            MasterQueryResponse bestResponse = null;
View Full Code Here

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

            (masterAddress, GroupService.SERVICE_NAME, request);
        me.run();

        TestHookExecute.doHookIfSet(testHook);

        ResponseMessage resp = me.getResponseMessage();

        if (resp == null) {
            if (me.getException() != null) {
                throw new UnknownMasterException
                    ("Problem communicating with master.", me.getException());
            }
            /*
             * Returning null on success is part of the message protocol, the
             * caller expects it.
             */
            return null;
        }

        if (respClass == null && resp instanceof Fail) {
            throw getException(resp);
        }

        if (respClass != null &&
            !(resp.getClass().getName().equals(respClass.getName()))) {
            throw getException(resp);
        }

        return resp;
    }
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.