All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sleepycat.je.rep.ReplicationGroup Maven / Gradle / Ivy

The newest version!
/*-
 * Copyright (C) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
 *
 * This file was distributed by Oracle as part of a version of Oracle Berkeley
 * DB Java Edition made available at:
 *
 * http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html
 *
 * Please see the LICENSE file included in the top-level directory of the
 * appropriate version of Oracle Berkeley DB Java Edition for a copy of the
 * license and additional information.
 */

package com.sleepycat.je.rep;

import java.util.HashSet;
import java.util.Set;

import com.sleepycat.je.rep.impl.RepGroupImpl;

/**
 * An administrative view of the collection of nodes that form the replication
 * group. Can be obtained from a {@link ReplicatedEnvironment} or a {@link
 * com.sleepycat.je.rep.util.ReplicationGroupAdmin}.
 */
public class ReplicationGroup {

    /* All methods delegate to the group implementation. */
    final RepGroupImpl repGroupImpl;

    /**
     * @hidden
     * For internal use only
     * Used to wrap the actual group object implementation.
     */
    public ReplicationGroup(RepGroupImpl repGroupImpl) {
        this.repGroupImpl = repGroupImpl;
    }

    /**
     * Returns the name associated with the group.
     *
     * @return the name of the replication group.
     */
    public String getName() {
        return repGroupImpl.getName();
    }

    /**
     * Returns the set of all nodes in the group. The return value includes
     * ELECTABLE, MONITOR, and SECONDARY nodes.
     *
     * 

Note that SECONDARY nodes will only be included in the result when * this method is called for a replicated environment that is the master. * * @return the set of all nodes * @see NodeType */ /* * TODO: EXTERNAL is hidden for now. The doc need updated to include * EXTERNAL when it becomes public. */ public Set getNodes() { final Set result = new HashSet(); repGroupImpl.includeMembers(null, result); return result; } /** * Returns the subset of nodes in the group with replicated environments * that participate in elections and can become masters, ignoring node * priority. The return value includes ELECTABLE nodes, and excludes * MONITOR and SECONDARY nodes. * * @return the set of electable nodes * @see NodeType */ /* * TODO: EXTERNAL is hidden for now. The doc need updated to include * EXTERNAL when it becomes public. */ public Set getElectableNodes() { final Set result = new HashSet(); repGroupImpl.includeElectableMembers(result); return result; } /** * Returns the subset of nodes in the group with replicated environments * that do not participate in elections and cannot become masters. The * return value includes SECONDARY nodes, and excludes ELECTABLE and * MONITOR nodes. * *

Note that SECONDARY nodes will only be returned when this method is * called for a replicated environment that is the master. * * @return the set of secondary nodes * @see NodeType * @since 6.0 */ /* * TODO: EXTERNAL is hidden for now. The doc need updated to include * EXTERNAL when it becomes public. */ public Set getSecondaryNodes() { final Set result = new HashSet(); repGroupImpl.includeSecondaryMembers(result); return result; } /** * Returns the subset of nodes in the group that monitor group membership * but do not maintain replicated environments. The return value includes * MONITOR nodes, but excludes ELECTABLE and SECONDARY nodes. * * @return the set of monitor nodes * @see NodeType */ /* * TODO: EXTERNAL is hidden for now. The doc need updated to include * EXTERNAL when it becomes public. */ public Set getMonitorNodes() { final Set result = new HashSet(); repGroupImpl.includeMonitorMembers(result); return result; } /** * Returns the subset of nodes in the group that store replication data. * The return value includes all ELECTABLE and SECONDARY nodes, but * excludes MONITOR nodes. * *

Note that SECONDARY nodes will only be included in the result when * this method is called for a replicated environment that is the master. * * @return the set of data nodes * @see NodeType * @since 6.0 */ /* * TODO: EXTERNAL is hidden for now. The doc need updated to include * EXTERNAL when it becomes public. */ public Set getDataNodes() { final Set result = new HashSet(); repGroupImpl.includeDataMembers(result); return result; } /** * Returns the subset of nodes in the group that participates in elections * but does not have a copy of the data and cannot become a master. * The return value includes ARBITER nodes. * * @return the set of arbiter nodes * @see NodeType */ public Set getArbiterNodes() { final Set result = new HashSet(); repGroupImpl.includeArbiterMembers(result); return result; } /** * Get administrative information about a node by its node name. * *

Note that SECONDARY nodes will only be returned when this method is * called for a replicated environment that is the master. * * @param nodeName the node name to be used in the lookup * * @return an administrative view of the node associated with nodeName, or * null if there isn't such a node currently in the group */ /* * TODO: EXTERNAL is hidden for now. The doc need updated to include * EXTERNAL when it becomes public. */ public ReplicationNode getMember(String nodeName) { return repGroupImpl.getMember(nodeName); } /** * @hidden * Internal use only. * * Returns the underlying group implementation object. */ public RepGroupImpl getRepGroupImpl() { return repGroupImpl; } /** * Returns a formatted version of the information held in a * ReplicationGroup. */ @Override public String toString() { return repGroupImpl.toString(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy