use of org.apache.helix.model.InstanceConfig in project pinot by linkedin.
the class LargeClusterRoutingTableBuilderTest method createInstanceConfigs.
private List<InstanceConfig> createInstanceConfigs(int instanceCount) {
List<InstanceConfig> instanceConfigs = new ArrayList<>();
for (int i = 0; i < instanceCount; i++) {
InstanceConfig instanceConfig = new InstanceConfig(buildInstanceName(i));
instanceConfig.setInstanceEnabled(true);
instanceConfigs.add(instanceConfig);
}
return instanceConfigs;
}
use of org.apache.helix.model.InstanceConfig in project pinot by linkedin.
the class RoutingTableInstancePruner method isInactive.
/**
* Returns True iff:
* - The given instance is disabled in Helix.
* - The instance is being shutdown.
* False otherwise
*
* @param instanceName Name of instance to check.
* @return True if instance is disabled in helix, or is being shutdown, False otherwise.
*/
public boolean isInactive(String instanceName) {
if (!instanceConfigMap.containsKey(instanceName)) {
return true;
}
// If the instance is not enabled, return false.
InstanceConfig instanceConfig = instanceConfigMap.get(instanceName);
if (!instanceConfig.getInstanceEnabled()) {
LOGGER.info("Instance '{}' is disabled in the config map.", instanceName);
return true;
}
boolean status = false;
if (instanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS) != null) {
try {
if (instanceConfig.getRecord() == null) {
LOGGER.info("Config record not found for instance '{}'.", instanceName);
return true;
}
if (instanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS) != null) {
status = Boolean.valueOf(instanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS));
if (status == true) {
LOGGER.info("found an instance : '{}' in shutting down state", instanceName);
}
}
} catch (Exception e) {
LOGGER.error("unknown value found while parsing boolean isShuttingDownField ", e);
}
}
return status;
}
use of org.apache.helix.model.InstanceConfig in project ambry by linkedin.
the class HelixBootstrapUpgradeUtil method updatePartitionInfoIfChanged.
/**
* Goes through each existing partition and updates the {@link PartitionState} and capacity information for the
* replicas in each of the instances that hosts a replica for this partition, if it has changed and is different from
* the current information in the static cluster map.
* @param partition the partition whose {@link PartitionState} and/or capacity may have to be updated.
*/
private void updatePartitionInfoIfChanged(Partition partition) {
for (Map.Entry<String, HelixAdmin> entry : adminForDc.entrySet()) {
String dcName = entry.getKey();
HelixAdmin dcAdmin = entry.getValue();
String partitionName = Long.toString(partition.getId());
long replicaCapacityInStatic = partition.getReplicaCapacityInBytes();
boolean isSealed = partition.getPartitionState().equals(PartitionState.READ_ONLY);
List<ReplicaId> replicaList = getReplicasInDc(partition, dcName);
for (ReplicaId replicaId : replicaList) {
DataNodeId node = replicaId.getDataNodeId();
String instanceName = getInstanceName(node);
InstanceConfig instanceConfig = dcAdmin.getInstanceConfig(clusterName, instanceName);
boolean shouldSetInstanceConfig = false;
if (updateSealedStateIfRequired(partitionName, instanceConfig, isSealed)) {
System.out.println("Sealed state change of partition " + partitionName + " will be updated for instance " + instanceName);
shouldSetInstanceConfig = true;
}
if (updateReplicaCapacityIfRequired(partitionName, instanceConfig, replicaId.getMountPath(), replicaCapacityInStatic)) {
System.out.println("Replica capacity change of partition " + partitionName + " will be updated for instance" + instanceName);
shouldSetInstanceConfig = true;
}
if (shouldSetInstanceConfig) {
dcAdmin.setInstanceConfig(clusterName, instanceName, instanceConfig);
System.out.println("Successfully updated InstanceConfig for instance " + instanceName);
}
}
}
}
use of org.apache.helix.model.InstanceConfig in project ambry by linkedin.
the class HelixParticipant method setSealedReplicas.
/**
* Set the list of sealed replicas in the HelixAdmin
* @param sealedReplicas list of sealed replicas to be set in the HelixAdmin
* @return whether the operation succeeded or not
*/
private boolean setSealedReplicas(List<String> sealedReplicas) {
HelixAdmin helixAdmin = manager.getClusterManagmentTool();
InstanceConfig instanceConfig = helixAdmin.getInstanceConfig(clusterName, instanceName);
if (instanceConfig == null) {
throw new IllegalStateException("No instance config found for cluster: \"" + clusterName + "\", instance: \"" + instanceName + "\"");
}
instanceConfig.getRecord().setListField(ClusterMapUtils.SEALED_STR, sealedReplicas);
return helixAdmin.setInstanceConfig(clusterName, instanceName, instanceConfig);
}
use of org.apache.helix.model.InstanceConfig in project ambry by linkedin.
the class HelixParticipant method getSealedReplicas.
/**
* Get the list of sealed replicas from the HelixAdmin
* @return list of sealed replicas from HelixAdmin
*/
private List<String> getSealedReplicas() {
HelixAdmin helixAdmin = manager.getClusterManagmentTool();
InstanceConfig instanceConfig = helixAdmin.getInstanceConfig(clusterName, instanceName);
if (instanceConfig == null) {
throw new IllegalStateException("No instance config found for cluster: \"" + clusterName + "\", instance: \"" + instanceName + "\"");
}
return ClusterMapUtils.getSealedReplicas(instanceConfig);
}
Aggregations