public class GoalUtils extends Object
Modifier and Type | Field and Description |
---|---|
static double |
DEAD_BROKER_UTILIZATION |
static Double |
MAXIMUM_CAPACITY_DEVIATION_PERCENTAGE |
static int |
MIN_NUM_VALID_WINDOWS_FOR_SELF_HEALING |
Modifier and Type | Method and Description |
---|---|
static double |
averageDiskUtilizationPercentage(Broker broker)
Get the latest average utilization percentage of all the alive disks on the broker.
|
static double |
diskUtilizationPercentage(Disk disk)
Get the latest utilization percentage of the disk, or
DEAD_DISK_UTILIZATION if the disk is dead. |
static void |
ensureNoOfflineReplicas(ClusterModel clusterModel,
String goalName)
Checks the replicas that are supposed to be moved away from the dead brokers or broken disks have been moved.
|
static void |
ensureReplicasMoveOffBrokersWithBadDisks(ClusterModel clusterModel,
String goalName)
Checks for the broker with broken disk, the partitions of the replicas used to be on its broken disk does not have
any replica on this broker.
|
static Set<Replica> |
filterReplicas(Broker broker,
boolean followersOnly,
boolean leadersOnly,
boolean immigrantsOnly)
Get a filtered set of replicas from the given broker based on given filtering requirements.
|
static Set<Replica> |
filterReplicas(Broker broker,
boolean followersOnly,
boolean leadersOnly,
boolean immigrantsOnly,
EntityFilter<Replica> replicaFilter)
Get a filtered set of replicas from the given broker based on given filtering requirements.
|
static Map<Replica,Broker> |
getPartitionMoves(ClusterModel clusterModel,
Set<Goal> optimizedGoals,
List<Replica> replicasToMove,
Iterable<List<Broker>> brokersIterable)
Move a partition to a set of brokers and return the valid moves if one can be found.
|
static boolean |
legitMove(Replica replica,
Broker destinationBroker,
ClusterModel clusterModel,
ActionType actionType)
Check whether the proposed inter-broker action is legit.
|
static int |
numPartitionCells(Partition partition) |
static boolean |
partitionHasReplicaOnIgnoredBroker(Partition partition) |
static double |
utilizationPercentage(Broker broker,
Resource resource)
Get the utilization percentage of the broker for the given resource, or
DEAD_BROKER_UTILIZATION if the
broker is dead. |
static Optional<Double> |
validateEvenBrokerResourceCapacities(Map<Integer,Double> capacityByBrokerId,
Resource resource)
Validates that the given map of broker capacities have the same capacity.
|
public static final int MIN_NUM_VALID_WINDOWS_FOR_SELF_HEALING
public static final Double MAXIMUM_CAPACITY_DEVIATION_PERCENTAGE
public static final double DEAD_BROKER_UTILIZATION
public static Optional<Double> validateEvenBrokerResourceCapacities(Map<Integer,Double> capacityByBrokerId, Resource resource)
MAXIMUM_CAPACITY_DEVIATION_PERCENTAGE
.public static boolean legitMove(Replica replica, Broker destinationBroker, ClusterModel clusterModel, ActionType actionType)
(1) It is a replica movement across brokers, the destination broker does not have a replica of the same partition and is allowed to have a replica from the partition
OR
(2) It is a leadership movement, the replica is a leader and the destination broker has a follower of the same partition.
replica
- Replica that is affected from the given action type.destinationBroker
- Destination broker.clusterModel
- Cluster model.actionType
- Action type.public static void ensureNoOfflineReplicas(ClusterModel clusterModel, String goalName) throws OptimizationFailureException
clusterModel
- the cluster model to check.goalName
- Goal name for which the sanity check is executed.OptimizationFailureException
- when there are still replicas on the dead brokers or on broken disks.public static void ensureReplicasMoveOffBrokersWithBadDisks(ClusterModel clusterModel, String goalName) throws OptimizationFailureException
clusterModel
- the cluster model to check.goalName
- Goal name for which the sanity check is executed.OptimizationFailureException
- when there are replicas hosted by broker with broken disk which belongs to the
same partition as the replica used to be hosted on broken diskspublic static Set<Replica> filterReplicas(Broker broker, boolean followersOnly, boolean leadersOnly, boolean immigrantsOnly)
broker
- Broker whose replicas will be filters.followersOnly
- True if replicas should be filtered to ensure that they contain only the followers.leadersOnly
- True if replicas should be filtered to ensure that they contain only the leaders.immigrantsOnly
- True if replicas should be filtered to ensure that they contain only the immigrants.public static Set<Replica> filterReplicas(Broker broker, boolean followersOnly, boolean leadersOnly, boolean immigrantsOnly, EntityFilter<Replica> replicaFilter)
filterReplicas(Broker, boolean, boolean, boolean)
with which an EntityFilter
object can be provided to further filter replicas.public static double utilizationPercentage(Broker broker, Resource resource)
DEAD_BROKER_UTILIZATION
if the
broker is dead. The utilization percentage for resources is calculated from broker capacity and
Load.expectedUtilizationFor(Resource)
.broker
- Broker for which the resource utilization percentage has been queried.resource
- Resource for the utilization percentage.public static double averageDiskUtilizationPercentage(Broker broker)
broker
- Broker for which the average disk utilization percentage has been queried.public static double diskUtilizationPercentage(Disk disk)
DEAD_DISK_UTILIZATION
if the disk is dead.disk
- Disk to query.public static Map<Replica,Broker> getPartitionMoves(ClusterModel clusterModel, Set<Goal> optimizedGoals, List<Replica> replicasToMove, Iterable<List<Broker>> brokersIterable)
brokersIterable
argument provides an iterator that returns all possible
combination of brokers to which replicas can be moved.public static int numPartitionCells(Partition partition)
public static boolean partitionHasReplicaOnIgnoredBroker(Partition partition)
partition
- partition to be queried