Package voldemort.client.protocol

Examples of voldemort.client.protocol.RequestFormatType


        byte[] protoBytes = { inputBuffer.get(0), inputBuffer.get(1), inputBuffer.get(2) };

        try {
            String proto = ByteUtils.getString(protoBytes, "UTF-8");
            RequestFormatType requestFormatType = RequestFormatType.fromCode(proto);
            requestHandler = requestHandlerFactory.getRequestHandler(requestFormatType);

            if(logger.isInfoEnabled())
                logger.info("Protocol negotiated for " + socketChannel.socket() + ": "
                            + requestFormatType.getDisplayName());

            // The protocol negotiation is the first request, so respond by
            // sticking the bytes in the output buffer, signaling the Selector,
            // and returning false to denote no further processing is needed.
            outputStream.getBuffer().put(ByteUtils.getBytes("ok", "UTF-8"));
            prepForWrite(selectionKey);

            return false;
        } catch(IllegalArgumentException e) {
            // okay we got some nonsense. For backwards compatibility,
            // assume this is an old client who does not know how to negotiate
            RequestFormatType requestFormatType = RequestFormatType.VOLDEMORT_V0;
            requestHandler = requestHandlerFactory.getRequestHandler(requestFormatType);

            if(logger.isInfoEnabled())
                logger.info("No protocol proposal given for " + socketChannel.socket()
                            + ", assuming " + requestFormatType.getDisplayName());

            return true;
        }
    }
View Full Code Here


            DataInputStream inputStream = new DataInputStream(new BufferedInputStream(socket.getInputStream(),
                                                                                      64000));
            DataOutputStream outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(),
                                                                                          64000));

            RequestFormatType protocol = negotiateProtocol(inputStream, outputStream);
            RequestHandler handler = handlerFactory.getRequestHandler(protocol);
            logger.info("Client " + socket.getRemoteSocketAddress()
                        + " connected successfully with protocol " + protocol.getCode());

            while(!isInterrupted() && !socket.isClosed() && !isClosed) {
                StreamRequestHandler srh = handler.handleRequest(inputStream, outputStream);

                if(srh != null) {
View Full Code Here

    private RequestFormatType negotiateProtocol(InputStream input, OutputStream output)
            throws IOException {
        input.mark(3);
        byte[] protoBytes = new byte[3];
        ByteUtils.read(input, protoBytes);
        RequestFormatType requestFormat;
        try {
            String proto = ByteUtils.getString(protoBytes, "UTF-8");
            requestFormat = RequestFormatType.fromCode(proto);
            output.write(ByteUtils.getBytes("ok", "UTF-8"));
            output.flush();
View Full Code Here

      }
      {
         String formatTypeCode = conf.requestFormatType().get();
         if (formatTypeCode != null)
         {
            RequestFormatType formatType = RequestFormatType.fromCode(formatTypeCode);
            config.setRequestFormatType(formatType);
         }
      }
      {
         String routingTierString = conf.routingTier().get();
View Full Code Here

TOP

Related Classes of voldemort.client.protocol.RequestFormatType

Copyright © 2018 www.massapicom. 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.