Class AutoRepairUtils
java.lang.Object
org.apache.cassandra.repair.autorepair.AutoRepairUtils
This class serves as a utility class for AutoRepair. It contains various helper APIs
to store/retrieve repair status, decide whose turn is next, etc.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic enumprotected static classRepresents a size estimate by both bytes and partition count for a given keyspace and table for a token range. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddHostIdToDeleteHosts(AutoRepairConfig.RepairType repairType, UUID myID, UUID hostToBeDeleted) static voidaddPriorityHosts(AutoRepairConfig.RepairType repairType, Set<InetAddressAndPort> hosts) calcTotalBytesToBeRepaired(AutoRepairConfig.RepairType repairType, String keyspaceName, List<String> tableNames, List<Range<Token>> tokenRanges) Calculates the total bytes to be repaired for a given keyspace and list of tables.static voidclearDeleteHosts(AutoRepairConfig.RepairType repairType, UUID hostId) getAllMVs(AutoRepairConfig.RepairType repairType, Keyspace keyspace, TableMetadata tableMetadata) getAutoRepairHistory(AutoRepairConfig.RepairType repairType) getCurrentRepairStatus(AutoRepairConfig.RepairType repairType, List<AutoRepairUtils.AutoRepairHistory> autoRepairHistories, UUID myId) getHostIdsInCurrentRing(AutoRepairConfig.RepairType repairType) getHostIdsInCurrentRing(AutoRepairConfig.RepairType repairType, Set<InetAddressAndPort> allNodesInRing) static StringgetKeyspaceTableName(String keyspace, String table) static longgetLastRepairTimeForNode(AutoRepairConfig.RepairType repairType, UUID hostId) static intgetMaxNumberOfNodeRunAutoRepair(AutoRepairConfig.RepairType repairType, int groupSize) getMostEligibleHostToRepair(AutoRepairConfig.RepairType repairType, AutoRepairUtils.CurrentRepairStatus currentRepairStatus, UUID myId) Identifies the most eligible host to repair for nodes preceding or equal to this nodes' lastRepairFinishTime.getPriorityHostIds(AutoRepairConfig.RepairType repairType) static Set<InetAddressAndPort>getPriorityHosts(AutoRepairConfig.RepairType repairType) getTokenRanges(boolean primaryRangeOnly, String keyspaceName) Calculates the token ranges owned by this node for a given keyspace.static booleanChecks whether the cluster has multiple major versionsstatic booleanChecks whether any node in the cluster is running an unsupported version for auto-repair.static voidinsertNewRepairHistory(AutoRepairConfig.RepairType repairType, long startTime, long finishTime) static voidinsertNewRepairHistory(AutoRepairConfig.RepairType repairType, UUID hostId, long startTime, long finishTime) static booleankeyspaceMaxRepairTimeExceeded(AutoRepairConfig.RepairType repairType, long startTime, int numOfTablesToBeRepaired) static AutoRepairUtils.RepairTurnmyTurnToRunRepair(AutoRepairConfig.RepairType repairType, UUID myId) static voidsetForceRepair(AutoRepairConfig.RepairType repairType, Set<InetAddressAndPort> hosts) static voidsetForceRepair(AutoRepairConfig.RepairType repairType, UUID hostId) static voidsetForceRepairNewNode(AutoRepairConfig.RepairType repairType) static voidsetup()static booleanstatic Collection<Range<Token>>static booleantableMaxRepairTimeExceeded(AutoRepairConfig.RepairType repairType, long startTime)
-
Constructor Details
-
AutoRepairUtils
public AutoRepairUtils()
-
-
Method Details
-
setup
public static void setup() -
getAutoRepairHistory
public static List<AutoRepairUtils.AutoRepairHistory> getAutoRepairHistory(AutoRepairConfig.RepairType repairType) -
clearDeleteHosts
-
setForceRepairNewNode
-
setForceRepair
public static void setForceRepair(AutoRepairConfig.RepairType repairType, Set<InetAddressAndPort> hosts) -
setForceRepair
-
getLastRepairTimeForNode
-
getCurrentRepairStatus
public static AutoRepairUtils.CurrentRepairStatus getCurrentRepairStatus(AutoRepairConfig.RepairType repairType, List<AutoRepairUtils.AutoRepairHistory> autoRepairHistories, UUID myId) -
hasMultipleLiveMajorVersions
public static boolean hasMultipleLiveMajorVersions()Checks whether the cluster has multiple major versions- Returns:
- true if more than one major versions are detected false if only one major version is detected
-
hasNodesBelowMinimumVersion
public static boolean hasNodesBelowMinimumVersion()Checks whether any node in the cluster is running an unsupported version for auto-repair.- Returns:
- true if any live node has a version at or below 5.0.7 (unsupported) or has an unknown version, false if all nodes are running versions above 5.0.7 (supported)
-
getHostIdsInCurrentRing
protected static TreeSet<UUID> getHostIdsInCurrentRing(AutoRepairConfig.RepairType repairType, Set<InetAddressAndPort> allNodesInRing) -
getHostIdsInCurrentRing
-
getHostWithLongestUnrepairTime
public static AutoRepairUtils.AutoRepairHistory getHostWithLongestUnrepairTime(AutoRepairConfig.RepairType repairType) -
getMostEligibleHostToRepair
public static AutoRepairUtils.AutoRepairHistory getMostEligibleHostToRepair(AutoRepairConfig.RepairType repairType, AutoRepairUtils.CurrentRepairStatus currentRepairStatus, UUID myId) Identifies the most eligible host to repair for nodes preceding or equal to this nodes' lastRepairFinishTime. The criteria for this is to find the node with the oldest last repair finish time of which none of its replicas are currently under repair.- Returns:
- The most eligible host to repair or null if no candidates before and including this nodes' current repair status.
-
getMaxNumberOfNodeRunAutoRepair
public static int getMaxNumberOfNodeRunAutoRepair(AutoRepairConfig.RepairType repairType, int groupSize) -
myTurnToRunRepair
public static AutoRepairUtils.RepairTurn myTurnToRunRepair(AutoRepairConfig.RepairType repairType, UUID myId) -
insertNewRepairHistory
public static void insertNewRepairHistory(AutoRepairConfig.RepairType repairType, UUID hostId, long startTime, long finishTime) -
insertNewRepairHistory
public static void insertNewRepairHistory(AutoRepairConfig.RepairType repairType, long startTime, long finishTime) -
addHostIdToDeleteHosts
public static void addHostIdToDeleteHosts(AutoRepairConfig.RepairType repairType, UUID myID, UUID hostToBeDeleted) -
addPriorityHosts
public static void addPriorityHosts(AutoRepairConfig.RepairType repairType, Set<InetAddressAndPort> hosts) -
getPriorityHostIds
-
getPriorityHosts
-
shouldConsiderKeyspace
-
tableMaxRepairTimeExceeded
public static boolean tableMaxRepairTimeExceeded(AutoRepairConfig.RepairType repairType, long startTime) -
keyspaceMaxRepairTimeExceeded
public static boolean keyspaceMaxRepairTimeExceeded(AutoRepairConfig.RepairType repairType, long startTime, int numOfTablesToBeRepaired) -
getAllMVs
public static List<String> getAllMVs(AutoRepairConfig.RepairType repairType, Keyspace keyspace, TableMetadata tableMetadata) -
split
-
getTokenRanges
Calculates the token ranges owned by this node for a given keyspace.- Parameters:
primaryRangeOnly- whether to use only primary token ranges or include replicated oneskeyspaceName- the name of the keyspace- Returns:
- one or more token ranges owned by this node
-
calcTotalBytesToBeRepaired
public static Map<String,Map<Range<Token>, calcTotalBytesToBeRepairedAutoRepairUtils.SizeEstimate>> (AutoRepairConfig.RepairType repairType, String keyspaceName, List<String> tableNames, List<Range<Token>> tokenRanges) Calculates the total bytes to be repaired for a given keyspace and list of tables.- Parameters:
repairType- the repair type (e.g., FULL, INCREMENTAL)keyspaceName- the name of the keyspacetableNames- the list of tables- Returns:
- a key-value map where the key is
keyspaceName.tableNameand the value is the number of bytes to be repaired.
-
getKeyspaceTableName
-