Package com.sleepycat.je.rep.impl

Examples of com.sleepycat.je.rep.impl.RepNodeImpl


        if (repGroupAdmin.getHelperSockets().size() == 0) {
            throw new IllegalStateException
                ("No helper sockets were specified at Monitor initialization");
        }
        RepNodeImpl monitorNode =
            new RepNodeImpl(nameIdPair,
                            NodeType.MONITOR,
                            monitorConfig.getNodeHostname(),
                            monitorConfig.getNodePort());
        /* Ensure that the monitor is part of the group. */
        return repGroupAdmin.ensureMonitor(monitorNode);
View Full Code Here


            final RepGroupImpl group = RepGroupDB.getGroup(envHome);
            if (createEnv) {
                printUsage("Environment exists:" + envHome +
                           "but -createEnv was specified.");
            }
            final RepNodeImpl node = group.getNode(nodeName);
            if (node == null) {
                if (! createNode) {
                    printUsage("The node:" + nodeName +
                               " is not a member of the group:" + group +
                               ". Use -createNode to create a new one.");
                }
            } else {
                /* Node exists, check arguments if any. */
                if (groupName == null) {
                    groupName = group.getName();
                } else if (!groupName.equals(group.getName())) {
                    printUsage("-groupname:" + groupName +
                               ", does not match the name:" + group.getName() +
                               " in the environment.");
                }

                if (hostPort == null) {
                    hostPort = node.getHostPortPair();
                } else if (!hostPort.equals(node.getHostPortPair())) {
                    System.err.println("-hostPort:" + hostPort +
                                       ", does not match the hostPort:" +
                                       node.getHostPortPair() +
                                       " in the environment. " +
                                       "Continuing ...");
                }
            }
        } catch (EnvironmentNotFoundException enf) {
View Full Code Here

               ExitException {

        NodeGroupInfo nodeGroup =
            (Protocol.NodeGroupInfo)(protocol.read(namedChannel));
        final RepGroupImpl group = repNode.getGroup();
        RepNodeImpl node = group.getNode(nodeGroup.getNodeName());

        try {

            if (nodeGroup.getNodeId() != replicaNameIdPair.getId()) {
                throw new ExitException
                    ("The replica node ID sent during protocol negotiation: " +
                     replicaNameIdPair +
                     " differs from the one sent in the MembershipInfo " +
                     "request: " + nodeGroup.getNodeId());
            }

            if (node == null) {
                /* Not currently a member. */
                try {
                    repNode.getRepGroupDB().ensureMember(nodeGroup);
                    node =
                        repNode.getGroup().getMember(nodeGroup.getNodeName());
                    if (node == null) {
                        throw EnvironmentFailureException.unexpectedState
                            ("Node: " + nodeGroup.getNameIdPair() +
                             " not found");
                    }
                } catch (InsufficientReplicasException e) {
                    throw new ExitException(e);
                } catch (InsufficientAcksException e) {
                    throw new ExitException(e);
                } catch (NodeConflictException e) {
                    throw new ExitException(e);
                }
            } else if (node.isRemoved()) {
                throw new ExitException
                    ("Node: " + nodeGroup.getNameIdPair() +
                     " is no longer a member of the group." +
                     " It was explicitly removed.");
            }

            doGroupChecks(nodeGroup, group);
            doNodeChecks(nodeGroup, node);
        } catch (ExitException exception) {
            LoggerUtils.info
                (logger, repNode.getRepImpl(), exception.getMessage());
            protocol.write(protocol.new NodeGroupInfoReject
                           (exception.getMessage()), namedChannel);
            throw exception;
        }

        /* Id is now established for sure, update the pair. */
        replicaNameIdPair.update(node.getNameIdPair());
        namedChannel.setNameIdPair(replicaNameIdPair);
        LoggerUtils.fine(logger, repNode.getRepImpl(),
                         "Channel Mapping: " + replicaNameIdPair + " is at " +
                         namedChannel.getChannel());
        protocol.write(protocol.new NodeGroupInfoOK(group.getUUID(),
View Full Code Here

                                                     formatter);
        EnsureOK okResp = (EnsureOK) doMessageExchange
            (groupProtocol.new EnsureNode(monitor), EnsureOK.class);

        monitor.getNameIdPair().update(okResp.getNameIdPair());
        return new RepNodeImpl(new NameIdPair(masterValue.getNodeName()),
                               NodeType.ELECTABLE,
                               masterValue.getHostName(),
                               masterValue.getPort());
    }
View Full Code Here

    private void checkMember(String nodeName, String masterErrorMessage)
        throws MasterStateException,
               MemberNotFoundException {

        final ReplicationGroup group = getGroup();
        final RepNodeImpl node = (RepNodeImpl) group.getMember(nodeName);

        /* Check the membership. */
        if (node == null) {
            throw new MemberNotFoundException("Node: " + nodeName + " is " +
                                              " is not a member of the " +
                                              "group: " + groupName);
        }

        if (node.isRemoved() && node.isQuorumAck()) {
            throw new MemberNotFoundException("Node: " + nodeName +
                                              " is not currently a member " +
                                              "of the group: " + groupName +
                                              ", it has been removed.");
        }

        /* Check if the node itself is the master. */
        final InetSocketAddress masterAddress = getMasterSocket();
        if (masterAddress.equals(node.getSocketAddress())) {
            throw new MasterStateException(masterErrorMessage);
        }
    }
View Full Code Here

        throws DatabaseException {

        group = repGroupDB.getGroup(new NoConsistencyRequiredPolicy());
        elections.updateRepGroup(group);
        if (nameIdPair.hasNullId()) {
            RepNodeImpl n = group.getMember(nameIdPair.getName());
            if (n != null) {
                /* May not be sufficiently current in the rep stream. */
                nameIdPair.update(n.getNameIdPair());
            }
        }
        return group;
    }
View Full Code Here

        /*
         * First remove it from the cached group, effectively setting new
         * durability requirements, for the ensuing group db updates.
         */
        RepNodeImpl node = group.removeMember(nodeName);

        /*
         * Shutdown any feeder that may be active with the replica. Any
         * subsequent attempts by the replica to rejoin the group will result
         * in a failure.
View Full Code Here

            throw new ReplicaStateException
                ("Can't update the network address for a live node.");
        }

        /* Update the node information in the group database. */
        RepNodeImpl node = group.getNode(nodeName);
        node.setHostName(newHostName);
        node.setPort(newPort);
        repGroupDB.updateMember(node);
    }
View Full Code Here

        }
    }

    /* Broadcast a Result message to re-elect a new master. */
    private void broadcastMessage(String nodeName) {
        RepNodeImpl node = group.getNode(nodeName);
        MasterValue newMaster = new MasterValue
            (node.getSocketAddress().getAddress().getHostAddress(),
             node.getSocketAddress().getPort(),
             node.getNameIdPair());
        Proposal proposal =
            new TimebasedProposalGenerator().nextProposal();
        elections.getLearner();
        Learner.informLearners
            (group.getLearnerSockets(),
View Full Code Here

            throw EnvironmentFailureException.unexpectedState
                ("Not currently a master. " + actionName + " must be " +
                 "invoked on the node that's currently the master.");
        }

        RepNodeImpl node = group.getNode(nodeName);
        if (node == null) {
            throw new MemberNotFoundException("Node:" + nodeName +
                                              "is not a member of the group:" +
                                              group.getName());
        }

        if (node.isRemoved() && node.isQuorumAck()) {
            throw new MemberNotFoundException("Node:" + nodeName +
                                              "is not currently a member of " +
                                              "the group:" + group.getName() +
                                              " It had been removed.");
        }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.rep.impl.RepNodeImpl

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.