public class RepGroupImpl extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RepGroupImpl.NodeConflictException |
| Modifier and Type | Field and Description |
|---|---|
static int |
FORMAT_VERSION_2
The latest format version that is compatible with JE 6.0.0 and earlier
versions.
|
static int |
FORMAT_VERSION_3
Format version introduced in JE 6.0.1 that records a node's most recent
JE version, and the minimum JE version required to join the group.
|
static JEVersion |
FORMAT_VERSION_3_JE_VERSION
The first JE version that supports FORMAT_VERSION_3.
|
static int |
INITIAL_FORMAT_VERSION
The initial format version for newly created RepGroupImpl instances.
|
static int |
MAX_FORMAT_VERSION
The latest supported format version.
|
static int |
MAX_NODES_WITH_TRANSIENT_ID
The maximum number of nodes with transient ID that can join the group at
the same time time.
|
static JEVersion |
MIN_FORMAT_VERSION_JE_VERSION
The first JE version that supports the oldest supported format version.
|
| Constructor and Description |
|---|
RepGroupImpl(String groupName,
boolean unknownUUID,
JEVersion currentJEVersion)
Constructor to create a group and specify if the group's UUID should be
unknown or generated randomly.
|
RepGroupImpl(String groupName,
JEVersion currentJEVersion)
Constructor to create a new empty repGroup, typically as part of
environment initialization.
|
RepGroupImpl(String groupName,
UUID uuid,
int formatVersion)
Constructor to create a group and specify the group's UUID and format
version.
|
RepGroupImpl(String groupName,
UUID uuid,
int formatVersion,
int changeVersion,
int nodeIdSequence,
JEVersion minJEVersion)
Constructor used to recreate an existing RepGroup, typically as part of
a deserialization operation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTransientIdNode(RepNodeImpl node)
Add a node with transient id.
|
void |
checkForConflicts(RepNodeImpl node)
Checks for whether a new or changed node definition is in conflict with
other members of the group.
|
int |
countAllMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p)
Counts the number of nodes that are currently members of the group.
|
static RepGroupImpl |
deserializeHex(String[] tokens,
int start)
De-serializes an array of tokens into a Rep group object and its nodes.
|
static RepNodeImpl |
deserializeNode(byte[] bytes,
int formatVersion)
Deserialize the mode from its byte representation.
|
boolean |
equals(Object obj) |
int |
getAckGroupSize()
Returns the number of all electable nodes that are currently members of
the group.
|
Set<InetSocketAddress> |
getAllAcceptorSockets()
Returns the socket addresses for all nodes that are currently members of
the group and act as acceptors for elections.
|
Set<RepNodeImpl> |
getAllElectableMembers()
Returns all electable nodes that are currently members of the group.
|
Set<Integer> |
getAllElectionMemberIds()
Returns the node IDs for all nodes that are currently members of the
group and that act as proposers, acceptors, or distinguished learners.
|
Set<InetSocketAddress> |
getAllHelperSockets()
Return the socket addresses for all nodes that are currently members of
the group and act as helpers to supply election results.
|
Set<RepNodeImpl> |
getAllLearnerMembers()
Returns all the nodes that are currently members of the group that act
as distinguished learners to receive election results.
|
Set<InetSocketAddress> |
getAllLearnerSockets()
Return the socket addresses for all nodes that are currently members of
the group and act as distinguished learners to receive election results.
|
Set<RepNodeImpl> |
getAllMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p)
Returns all nodes that are currently members of the group.
|
Set<InetSocketAddress> |
getAllMonitorSockets()
Returns the socket addresses for all monitor nodes that are currently
members of the group.
|
Set<RepNodeImpl> |
getArbiterMembers()
Returns the arbiter nodes that are currently members of the group.
|
int |
getChangeVersion()
Returns the version of the instance as represented by changes to the
members constituting the group.
|
Set<RepNodeImpl> |
getDataMembers()
Returns the nodes that are currently members of the group that store
replication data.
|
int |
getElectableGroupSize()
Returns the number of all electable nodes that are currently members of
the group.
|
Set<RepNodeImpl> |
getElectableMembers()
Returns electable nodes that are currently members of the group.
|
Set<RepNodeImpl> |
getExternalMembers()
Returns the external nodes that are currently members of the group.
|
static int |
getFirstNodeId()
Returns the node ID that is associated with the very first node in the
replication group.
|
int |
getFormatVersion()
Returns the version of the format (the schema) in use by this group
instance in the database.
|
static int |
getMaxFormatVersion(JEVersion jeVersion)
Returns the highest format version supported by the specified JE
version.
|
RepNodeImpl |
getMember(InetSocketAddress socket)
Gets the node that is currently a member of the group that has the given
socket address.
|
RepNodeImpl |
getMember(int nodeId)
Returns the node with the specified ID that is currently a member of the
group, throwing an exception if the node is found but is no longer a
member.
|
RepNodeImpl |
getMember(String name)
Returns the node with the specified name that is currently a member of
the group, throwing an exception if the node is found but is no longer a
member.
|
JEVersion |
getMinJEVersion()
Returns the minimum JE version that a node must be running in order to
join the group.
|
Set<RepNodeImpl> |
getMonitorMembers()
Returns the monitor nodes that are currently members of the group.
|
String |
getName()
Returns the name of the group.
|
int |
getNextNodeId()
Increments the node ID sequence and returns it.
|
RepNodeImpl |
getNode(int nodeId)
Returns the node with the specified ID, regardless of its membership
state.
|
RepNodeImpl |
getNode(String name)
Returns the node with the specified name, regardless of its membership
state.
|
int |
getNodeIdSequence()
Returns the current highest node ID currently in use by the group.
|
Set<RepNodeImpl> |
getRemovedNodes()
Returns nodes that are removed from the group.
|
Set<RepNodeImpl> |
getSecondaryMembers()
Returns the secondary nodes that are currently members of the group.
|
UUID |
getUUID()
returns the unique UUID associated with the replicated environment.
|
int |
hashCode() |
boolean |
hasUnknownUUID() |
static RepNodeImpl |
hexDeserializeNode(String hex,
int formatVersion)
Deserializes the object serialized by
serializeHex(int) |
void |
includeAllMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p,
Set<? super RepNodeImpl> set)
Adds all nodes that are currently members of the group to the specified
set.
|
void |
includeArbiterMembers(Set<? super RepNodeImpl> set)
Adds the arbiter nodes that are currently members of the group to the
specified set.
|
void |
includeDataMembers(Set<? super RepNodeImpl> set)
Adds the nodes that are currently members of the group that store
replication data to the specified set.
|
void |
includeElectableMembers(Set<? super RepNodeImpl> set)
Adds the electable nodes that are currently members of the group to the
specified set.
|
void |
includeExternalMembers(Set<? super RepNodeImpl> set)
Adds the external nodes.
|
void |
includeMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p,
Set<? super RepNodeImpl> set)
Adds nodes that are currently members of the group to the specified set.
|
void |
includeMonitorMembers(Set<? super RepNodeImpl> set)
Adds the monitor nodes that are currently members of the group to the
specified set.
|
void |
includeSecondaryMembers(Set<? super RepNodeImpl> set)
Adds the secondary nodes that are currently members of the group to the
specified set.
|
int |
incrementChangeVersion()
Increments the object change version.
|
static boolean |
isUnknownUUID(UUID uuid)
Predicate to help determine whether the UUID is the canonical unknown
UUID.
|
void |
makeConsistent()
Used to ensure that the ReplicationGroup value is consistent after it
has been fetched via a readUncommitted access to the rep group database.
|
RepNodeImpl |
removeMember(String nodeName,
boolean delete)
Removes a member transiently from the rep group by marking it as removed
and optionally deleting it from the by-name and by-ID maps.
|
void |
removeTransientNode(RepNodeImpl node)
Remove a node with transient id, which should have an assigned ID
|
static byte[] |
serializeBytes(RepNodeImpl node,
int formatVersion)
Serialize the node into its byte representation.
|
String |
serializeHex(int groupFormatVersion)
Returns a serialized character based form of the group suitable for use
in subclasses of SimpleProtocol.
|
static String |
serializeHex(RepNodeImpl node,
int formatVersion)
Returns the serialized form of the node as a sequence of hex characters
suitable for use by the text based protocols.
|
void |
setMinJEVersion(JEVersion newMinJEVersion)
Sets the minimum JE version that a node must be running in order to join
the replication group.
|
void |
setNodeIdSequence(int nodeIdSequence)
Set the node id sequence.
|
void |
setNodes(Map<Integer,RepNodeImpl> nodes)
Sets the nodes associated with the Rep group.
|
void |
setUUID(UUID uuid)
Sets the UUID.
|
String |
toString()
Return information to the user, format nicely for ease of reading.
|
public static final int MAX_FORMAT_VERSION
public static final int FORMAT_VERSION_3
public static final int FORMAT_VERSION_2
public static final int INITIAL_FORMAT_VERSION
public static final JEVersion FORMAT_VERSION_3_JE_VERSION
public static final JEVersion MIN_FORMAT_VERSION_JE_VERSION
public static final int MAX_NODES_WITH_TRANSIENT_ID
public RepGroupImpl(String groupName, JEVersion currentJEVersion)
groupName - the group namecurrentJEVersion - if non-null, override the current JE version,
for testingpublic RepGroupImpl(String groupName, boolean unknownUUID, JEVersion currentJEVersion)
public RepGroupImpl(String groupName, UUID uuid, int formatVersion)
public RepGroupImpl(String groupName, UUID uuid, int formatVersion, int changeVersion, int nodeIdSequence, JEVersion minJEVersion)
groupName - uuid - formatVersion - changeVersion - minJEVersion - public boolean hasUnknownUUID()
public static boolean isUnknownUUID(UUID uuid)
public void setUUID(UUID uuid)
public RepNodeImpl removeMember(String nodeName, boolean delete)
nodeName - identifies the node being removeddelete - whether to delete the node from the mapsEnvironmentFailureException - if the node is not part of the group
or is a node with a transient IDpublic void checkForConflicts(RepNodeImpl node) throws DatabaseException, RepGroupImpl.NodeConflictException
This check must be done when adding a new member to the group, or changing the network address of an existing member, and must be done with the rep group entry in the database locked for write to prevent race conditions.
node - the new node that is being checked for conflictsRepGroupImpl.NodeConflictException - if there is a conflictDatabaseExceptionpublic void setNodes(Map<Integer,RepNodeImpl> nodes)
public void addTransientIdNode(RepNodeImpl node)
node - the node with transient idIllegalStateException - if the store does not currently support
secondary nodesRepGroupImpl.NodeConflictException - if the node conflicts with an existing
persistent nodepublic void removeTransientNode(RepNodeImpl node)
node - the node with a transient IDpublic UUID getUUID()
public int getFormatVersion()
public static int getMaxFormatVersion(JEVersion jeVersion)
jeVersion - the JE versionpublic int getChangeVersion()
public int incrementChangeVersion()
public int getNodeIdSequence()
public void setNodeIdSequence(int nodeIdSequence)
public int getNextNodeId()
public static int getFirstNodeId()
public JEVersion getMinJEVersion()
public void setMinJEVersion(JEVersion newMinJEVersion) throws MinJEVersionUnsupportedException
RepGroupDB.fetchGroup(java.lang.String, com.sleepycat.je.dbi.DatabaseImpl, com.sleepycat.je.txn.Txn) method and should be
stored to the group database after making this change. Throws a MinJEVersionUnsupportedException if the requested version is not
supported. Updates the group format version as needed to match the JE
version. Has no effect if the current minimum value is already as high
or higher than the requested one.newMinJEVersion - the new minimum JE versionMinJEVersionUnsupportedException - if the requested version is not
supported by the group's electable nodespublic void makeConsistent()
public String serializeHex(int groupFormatVersion)
groupFormatVersion - the group format versionpublic static String serializeHex(RepNodeImpl node, int formatVersion)
node - the node to be serialized.formatVersion - the group format versionpublic static byte[] serializeBytes(RepNodeImpl node, int formatVersion)
node - the node to be serializedformatVersion - the group format versionpublic static RepNodeImpl hexDeserializeNode(String hex, int formatVersion)
serializeHex(int)hex - the string containing the serialized form of the nodeformatVersion - the group format versionpublic static RepNodeImpl deserializeNode(byte[] bytes, int formatVersion)
bytes - the byte representation of the node.formatVersion - the group format versionpublic static RepGroupImpl deserializeHex(String[] tokens, int start)
startrepresents the group object and each
subsequent token represents a node in the group.tokens - the array representing the group and its nodesstart - the position in the array at which to start the
de-serialization.public Set<Integer> getAllElectionMemberIds()
public Set<RepNodeImpl> getAllMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p)
public void includeAllMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p,
Set<? super RepNodeImpl> set)
public int countAllMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p)
public void includeMembers(com.sleepycat.je.rep.impl.RepGroupImpl.Predicate p,
Set<? super RepNodeImpl> set)
public RepNodeImpl getMember(InetSocketAddress socket)
public Set<RepNodeImpl> getRemovedNodes()
public Set<RepNodeImpl> getAllElectableMembers()
public Set<RepNodeImpl> getElectableMembers()
public void includeElectableMembers(Set<? super RepNodeImpl> set)
public Set<RepNodeImpl> getDataMembers()
public void includeDataMembers(Set<? super RepNodeImpl> set)
public Set<RepNodeImpl> getMonitorMembers()
public void includeMonitorMembers(Set<? super RepNodeImpl> set)
public Set<RepNodeImpl> getAllLearnerMembers()
public Set<RepNodeImpl> getSecondaryMembers()
public Set<RepNodeImpl> getExternalMembers()
public void includeSecondaryMembers(Set<? super RepNodeImpl> set)
public void includeExternalMembers(Set<? super RepNodeImpl> set)
public Set<RepNodeImpl> getArbiterMembers()
public void includeArbiterMembers(Set<? super RepNodeImpl> set)
public Set<InetSocketAddress> getAllLearnerSockets()
public Set<InetSocketAddress> getAllHelperSockets()
public Set<InetSocketAddress> getAllMonitorSockets()
public Set<InetSocketAddress> getAllAcceptorSockets()
public RepNodeImpl getMember(int nodeId)
nodeId - the node IDEnvironmentFailureException - if the node is no longer a memberpublic RepNodeImpl getMember(String name) throws MemberNotFoundException
name - the node nameMemberNotFoundException - if the node is no longer a memberpublic RepNodeImpl getNode(int nodeId)
public RepNodeImpl getNode(String name)
public int getElectableGroupSize()
public int getAckGroupSize()
public String getName()
Copyright © 2024. All rights reserved.