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

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


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

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

                    if (me.getResponseMessage().getOp() ==
                        elections.getProtocol().REJECT) {
                        /*
                         * The acceptor has already received a higher numbered
                         * Prepare request. Abandon this round as an
                         * optimization.
                         */
                        Utils.discardFutures
                            (futures.subList(futures.indexOf(f),
                                             futures.size()));
                        phase1HigherProposal.increment();
                        throw new HigherNumberedProposal(me.target);
                    } else if (me.getResponseMessage().getOp() ==
                            elections.getProtocol().PROMISE) {
                        result.promisories.add(me.target);
                        result.promisoryMessages.add(me);
                        Promise accept = (Promise) me.getResponseMessage();
                        Proposal acceptProposal = accept.getHighestProposal();
                        if ((result.acceptProposal == null) ||
                            ((acceptProposal != null) &&
                             (acceptProposal.compareTo(result.acceptProposal) >
                              0))) {
                            result.acceptProposal = acceptProposal;
                            result.acceptedValue = accept.getAcceptedValue();
                        }
                    } else if (me.getResponseMessage().getOp() ==
                               elections.getProtocol().PROTOCOL_ERROR){
                        ProtocolError protocolError =
                            (ProtocolError) me.getResponseMessage();
                        /* Possible protocol version, group, or config skew. */
                        LoggerUtils.logMsg(logger, elections.getRepImpl(),
                                           formatter, Level.WARNING,
                                           "Election protocol error: " +
                                           protocolError.getMessage());
                        return;
                    } else {
                        throw EnvironmentFailureException.unexpectedState
                            ("Unknown response: " +
                             me.getResponseMessage().getOp());
                    }
                }
            }.execute(logger, elections.getRepImpl(), null);
        }

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: " +
View Full Code Here

        List<Future<MessageExchange>> futures =
            new LinkedList<Future<MessageExchange>>();

        for (InetSocketAddress socketAddress : targets) {
            MessageExchange me = requestMessage.getProtocol()
            .new MessageExchange(socketAddress, serviceName, requestMessage);
            try {
                futures.add(threadPool.submit(me, me));
            } catch (RejectedExecutionException ree) {
                if (threadPool.isTerminated()) {
View Full Code Here

            new NodeStateProtocol(group.getName(),
                                  NameIdPair.NOCHECK,
                                  null);
        for (ReplicationNode repNode : group.getElectableNodes()) {
            /* Send out a NodeState request message for this electable node. */
            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

            for (final Future<MessageExchange> f : futures) {
                new Utils.WithFutureExceptionHandler () {
                    @Override
                    protected void processFuture ()
                        throws ExecutionException, InterruptedException {
                        MessageExchange me = f.get();

                        if (me.getResponseMessage() == null) {
                            return;
                        }
                        if (me.getResponseMessage().getOp() ==
                            protocol.MASTER_QUERY_RESPONSE){
                            MasterQueryResponse accept =
                                (MasterQueryResponse) me.getResponseMessage();
                            MasterValue masterValue =
                                (MasterValue) accept.getValue();
                            if ((masterValue != null) &&
                                 masterValue.getNameId().
                                 equals(protocol.getNameIdPair())) {
View Full Code Here

                    protected void processFuture ()
                        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){
View Full Code Here

        /* Consume the futures. */
        int errors = 0;
        for (Future<MessageExchange> f : futures) {
            try {
                MessageExchange me = f.get();
                if (me.getResponseMessage() == null) {
                    /* Simply log it, the nodes may be down. */
                    LoggerUtils.logMsg(logger,
                                       repImpl,
                                       formatter,
                                       Level.FINE,
View Full Code Here

               MemberNotFoundException,
               UnknownMasterException {

        /* Do the communication. */
        final InetSocketAddress masterAddress = getMasterSocket();
        final MessageExchange me = groupProtocol.new MessageExchange
            (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.
             */
 
View Full Code Here

                                                     formatter);

        InetSocketAddress masterAddress =
            new InetSocketAddress(masterValue.getHostName(),
                                  masterValue.getPort());
        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 InetSocketAddress masterAddress= getMasterSocket();
        /* Check if the node is itself the master. */
        if (masterAddress.equals(node.getSocketAddress())) {
            throw new MasterStateException("Cannot remove an active master");
        }
        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

TOP

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

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.