Package com.sleepycat.je.rep.impl.TextProtocol

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


                    @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

            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

                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

                        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

            (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

        MessageExchange me = groupProtocol.new MessageExchange
            (masterAddress,
             GroupService.SERVICE_NAME,
             groupProtocol.new EnsureNode(monitor));
        me.run();
        ResponseMessage resp = me.getResponseMessage();
        if (resp instanceof EnsureOK) {
            EnsureOK okResp = (EnsureOK) resp;
            monitor.getNameIdPair().update(okResp.getNameIdPair());
            return new RepNodeImpl(new NameIdPair(masterValue.getNodeName()),
                                   NodeType.ELECTABLE,
View Full Code Here

        final MessageExchange me = groupProtocol.new MessageExchange
            (masterAddress,
             GroupService.SERVICE_NAME,
             groupProtocol.new RemoveMember(nodeName));
        me.run();
        ResponseMessage resp = me.getResponseMessage();
        if (resp instanceof OK) {
            return;
        }
        throw getException(resp);
    }
View Full Code Here

        MessageExchange me = groupProtocol.new MessageExchange
        (masterSocket,
         GroupService.SERVICE_NAME,
         groupProtocol.new GroupRequest());
        me.run();
        ResponseMessage resp = me.getResponseMessage();
        if (resp instanceof GroupResponse) {
            return new ReplicationGroup(((GroupResponse)resp).getGroup());
        }
        throw getException(resp);
    }
View Full Code Here

                    @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

TOP

Related Classes of com.sleepycat.je.rep.impl.TextProtocol.ResponseMessage

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.