/** * Get the health threshold percent for a specific role, falling back to * the global one if not. * @param roleGroup role group * @return the threshold percent for health */ public int getHealthThresholdPercentForRole(String roleGroup) { ConfTreeOperations resources = instanceDefinition.getResourceOperations(); return resources.getComponentOptInt(roleGroup, CONTAINER_HEALTH_THRESHOLD_PERCENT, healthThresholdPercent); }
/** * Get the node failure threshold for a specific role, falling back to * the global one if not * @param roleGroup role group * @return the threshold for failures */ private int getNodeFailureThresholdForRole(String roleGroup) { ConfTreeOperations resources = instanceDefinition.getResourceOperations(); return resources.getComponentOptInt(roleGroup, NODE_FAILURE_THRESHOLD, nodeFailureThreshold); }
/** * Get the node failure threshold for a specific role, falling back to * the global one if not * @param roleGroup role group * @return the threshold for failures */ private int getNodeFailureThresholdForRole(String roleGroup) { ConfTreeOperations resources = instanceDefinition.getResourceOperations(); return resources.getComponentOptInt(roleGroup, NODE_FAILURE_THRESHOLD, nodeFailureThreshold); }
/** * Get the failure threshold for a specific role, falling back to * the global one if not * @param roleStatus role * @return the threshold for failures */ private int getFailureThresholdForRole(RoleStatus roleStatus) { ConfTreeOperations resources = instanceDefinition.getResourceOperations(); return resources.getComponentOptInt(roleStatus.getGroup(), CONTAINER_FAILURE_THRESHOLD, failureThreshold); }
/** * Get the failure threshold for a specific role, falling back to * the global one if not * @param roleStatus role * @return the threshold for failures */ private int getFailureThresholdForRole(RoleStatus roleStatus) { ConfTreeOperations resources = instanceDefinition.getResourceOperations(); return resources.getComponentOptInt(roleStatus.getGroup(), CONTAINER_FAILURE_THRESHOLD, failureThreshold); }
public void validateNodeCount(AggregateConf instanceDescription, String name, int min, int max) throws BadCommandArgumentsException { MapOperations component = instanceDescription.getResourceOperations().getComponent(name); int count; if (component == null) { count = 0; } else { count = component.getOptionInt(ResourceKeys.COMPONENT_INSTANCES, 0); } validateNodeCount(name, count, min, max); }
public void validateNodeCount(AggregateConf instanceDescription, String name, int min, int max) throws BadCommandArgumentsException { MapOperations component = instanceDescription.getResourceOperations().getComponent(name); int count; if (component == null) { count = 0; } else { count = component.getOptionInt(ResourceKeys.COMPONENT_INSTANCES, 0); } validateNodeCount(name, count, min, max); }
/** * Validate the instance definition. * @param instanceDefinition instance definition */ @Override public void validateInstanceDefinition(AggregateConf instanceDefinition, SliderFileSystem fs) throws SliderException { super.validateInstanceDefinition(instanceDefinition, fs); ConfTreeOperations resources = instanceDefinition.getResourceOperations(); Set<String> unknownRoles = resources.getComponentNames(); unknownRoles.removeAll(knownRoleNames); if (!unknownRoles.isEmpty()) { throw new BadCommandArgumentsException("Unknown component: %s", unknownRoles.iterator().next()); } providerUtils.validateNodeCount(instanceDefinition, HBaseKeys.ROLE_WORKER, 0, -1); providerUtils.validateNodeCount(instanceDefinition, HBaseKeys.ROLE_MASTER, 0, -1); providerUtils.validateNodeCount(instanceDefinition, HBaseKeys.ROLE_REST_GATEWAY, 0, -1); providerUtils.validateNodeCount(instanceDefinition, HBaseKeys.ROLE_THRIFT_GATEWAY, 0, -1); providerUtils.validateNodeCount(instanceDefinition, HBaseKeys.ROLE_THRIFT2_GATEWAY, 0, -1); }
for (String component : instanceDefinition.getResourceOperations().getComponentNames()) { instanceDefinition.getAppConfOperations().getOrAddComponent(component); ConfTreeOperations resources = instanceDefinition.getResourceOperations();
@Override public void validateInstanceDefinition(AggregateConf instanceDefinition, SliderFileSystem fs) throws SliderException { super.validateInstanceDefinition(instanceDefinition, fs); ConfTreeOperations resources = instanceDefinition.getResourceOperations(); Set<String> unknownRoles = resources.getComponentNames(); unknownRoles.removeAll(knownRoleNames); if (!unknownRoles.isEmpty()) { throw new BadCommandArgumentsException("There is unknown role: %s", unknownRoles.iterator().next()); } providerUtils.validateNodeCount(instanceDefinition, AccumuloKeys.ROLE_TABLET, 1, -1); providerUtils.validateNodeCount(instanceDefinition, AccumuloKeys.ROLE_MASTER, 1, -1); providerUtils.validateNodeCount(instanceDefinition, AccumuloKeys.ROLE_GARBAGE_COLLECTOR, 0, -1); providerUtils.validateNodeCount(instanceDefinition, AccumuloKeys.ROLE_MONITOR, 0, -1); providerUtils.validateNodeCount(instanceDefinition, AccumuloKeys.ROLE_TRACER , 0, -1); MapOperations globalAppConfOptions = instanceDefinition.getAppConfOperations().getGlobalOptions(); globalAppConfOptions.verifyOptionSet(AccumuloKeys.OPTION_ZK_HOME); globalAppConfOptions.verifyOptionSet(AccumuloKeys.OPTION_HADOOP_HOME); }
/** * Start an asychronous launch operation * @param assignment container assignment * @param clusterSpec cluster spec to use for template * @param credentials credentials to use */ public void launchRole(ContainerAssignment assignment, AggregateConf clusterSpec, Credentials credentials) { RoleStatus role = assignment.role; String roleName = role.getName(); String roleGroup = role.getGroup(); // prelaunch safety check Preconditions.checkArgument(provider.isSupportedRole(roleName)); RoleLaunchService.RoleLauncher launcher = new RoleLaunchService.RoleLauncher(assignment, clusterSpec, clusterSpec.getResourceOperations().getOrAddComponent(roleGroup), clusterSpec.getAppConfOperations().getOrAddComponent(roleGroup), credentials); execute(launcher); }
/** * Start an asychronous launch operation * @param assignment container assignment * @param clusterSpec cluster spec to use for template * @param credentials credentials to use */ public void launchRole(ContainerAssignment assignment, AggregateConf clusterSpec, Credentials credentials) { RoleStatus role = assignment.role; String roleName = role.getName(); String roleGroup = role.getGroup(); // prelaunch safety check Preconditions.checkArgument(provider.isSupportedRole(roleName)); RoleLaunchService.RoleLauncher launcher = new RoleLaunchService.RoleLauncher(assignment, clusterSpec, clusterSpec.getResourceOperations().getOrAddComponent(roleGroup), clusterSpec.getAppConfOperations().getOrAddComponent(roleGroup), credentials); execute(launcher); }
instanceDefinition.getResourceOperations();
instanceDefinition.getResourceOperations();
instanceDefinition.getResourceOperations(); for (ProviderRole role : roles) { String name = role.name;
instanceDefinition.getResourceOperations(); for (ProviderRole role : roles) { String name = role.name;
ConfTreeOperations resTemplate = ConfTreeOperations.fromResource(resourceTemplate); instanceConf.getResourceOperations() .mergeWithoutOverwrite(resTemplate.confTree);
ConfTreeOperations resTemplate = ConfTreeOperations.fromResource(resourceTemplate); instanceConf.getResourceOperations() .mergeWithoutOverwrite(resTemplate.confTree);
private AggregateConf prepareConfForAgentStateTests() { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); AggregateConf instanceDefinition = new AggregateConf(); instanceDefinition.setInternal(tree); instanceDefinition.setAppConf(tree); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.APP_DEF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_CONF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_VERSION, "."); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_MASTER"); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_REGIONSERVER"); return instanceDefinition; }
private AggregateConf prepareConfForAgentStateTests() { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); AggregateConf instanceDefinition = new AggregateConf(); instanceDefinition.setInternal(tree); instanceDefinition.setAppConf(tree); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.APP_DEF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_CONF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_VERSION, "."); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_MASTER"); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_REGIONSERVER"); return instanceDefinition; }