public YarnRegistryViewForProviders(RegistryOperations registryOperations, String user, String sliderServiceClass, String instanceName, ApplicationAttemptId applicationAttemptId) { Preconditions.checkArgument(registryOperations != null, "null registry operations"); Preconditions.checkArgument(user != null, "null user"); Preconditions.checkArgument(SliderUtils.isSet(sliderServiceClass), "unset service class"); Preconditions.checkArgument(SliderUtils.isSet(instanceName), "instanceName"); Preconditions.checkArgument(applicationAttemptId != null, "null applicationAttemptId"); this.registryOperations = registryOperations; this.user = user; this.sliderServiceClass = sliderServiceClass; this.instanceName = instanceName; this.applicationAttemptId = applicationAttemptId; }
/** * Release a tag associated with a container * * @param component * @param containerId */ public void releaseTag(String component, String containerId) { if (SliderUtils.isSet(component) && SliderUtils.isSet(containerId)) { ConcurrentHashMap<String, String> compTags = allTags.get(component); if (compTags != null) { synchronized (compTags) { for (String key : compTags.keySet()) { if (compTags.get(key).equals(containerId)) { compTags.put(key, FREE); } } } } } }
/** * Release a tag associated with a container * * @param component * @param containerId */ public void releaseTag(String component, String containerId) { if (SliderUtils.isSet(component) && SliderUtils.isSet(containerId)) { ConcurrentHashMap<String, String> compTags = allTags.get(component); if (compTags != null) { synchronized (compTags) { for (String key : compTags.keySet()) { if (compTags.get(key).equals(containerId)) { compTags.put(key, FREE); } } } } } }
/** * Set the size of the heap if a non-empty heap is passed in. * @param heap empty string or something like "128M" ,"1G" etc. The value is * trimmed. */ public void setJVMHeap(String heap) { if (SliderUtils.isSet(heap)) { add("-Xmx" + heap.trim()); } }
/** * Set the size of the heap if a non-empty heap is passed in. * @param heap empty string or something like "128M" ,"1G" etc. The value is * trimmed. */ public void setJVMHeap(String heap) { if (SliderUtils.isSet(heap)) { add("-Xmx" + heap.trim()); } }
public boolean isSet(String key) { return SliderUtils.isSet(get(key)); }
public boolean isSet(String key) { return SliderUtils.isSet(get(key)); }
/** * Build up the path string for package install location -no attempt to * create the directory is made * * @return the path for persistent app package */ public Path buildPackageDirPath(String packageName, String packageVersion) { Preconditions.checkNotNull(packageName); Path path = getBaseApplicationPath(); path = new Path(path, SliderKeys.PACKAGE_DIRECTORY + "/" + packageName); if (SliderUtils.isSet(packageVersion)) { path = new Path(path, packageVersion); } return path; }
/** * Build up the path string for package install location -no attempt to * create the directory is made * * @return the path for persistent app package */ public Path buildPackageDirPath(String packageName, String packageVersion) { Preconditions.checkNotNull(packageName); Path path = getBaseApplicationPath(); path = new Path(path, SliderKeys.PACKAGE_DIRECTORY + "/" + packageName); if (SliderUtils.isSet(packageVersion)) { path = new Path(path, packageVersion); } return path; }
private boolean isDockerContainer(String roleGroup) { String type = getApplicationComponent(roleGroup).getType(); if (SliderUtils.isSet(type)) { return type.toLowerCase().equals(SliderUtils.DOCKER) || type.toLowerCase().equals(SliderUtils.DOCKER_YARN); } return false; }
private boolean isDockerContainer(String roleGroup) { String type = getApplicationComponent(roleGroup).getType(); if (SliderUtils.isSet(type)) { return type.toLowerCase().equals(SliderUtils.DOCKER) || type.toLowerCase().equals(SliderUtils.DOCKER_YARN); } return false; }
private boolean isYarnDockerContainer(String roleGroup) { String type = getApplicationComponent(roleGroup).getType(); if (SliderUtils.isSet(type)) { return type.toLowerCase().equals(SliderUtils.DOCKER_YARN); } return false; }
private boolean isYarnDockerContainer(String roleGroup) { String type = getApplicationComponent(roleGroup).getType(); if (SliderUtils.isSet(type)) { return type.toLowerCase().equals(SliderUtils.DOCKER_YARN); } return false; }
/** * Query for the image path being set (non null/non empty) * @return true if there is a path in the image path option */ @JsonIgnore public boolean isImagePathSet() { return SliderUtils.isSet(getImagePath()); } }
/** * Query for the image path being set (non null/non empty) * @return true if there is a path in the image path option */ @JsonIgnore public boolean isImagePathSet() { return SliderUtils.isSet(getImagePath()); } }
/** * Inner Validation logic for container request * @param containerRequest request * @param priority raw priority of role * @param requestDetails details for error messages */ @VisibleForTesting public static void validateContainerRequest(AMRMClient.ContainerRequest containerRequest, int priority, String requestDetails) { String exp = containerRequest.getNodeLabelExpression(); boolean hasRacks = containerRequest.getRacks() != null && (!containerRequest.getRacks().isEmpty()); boolean hasNodes = containerRequest.getNodes() != null && (!containerRequest.getNodes().isEmpty()); boolean hasLabel = SliderUtils.isSet(exp); // Don't support specifying >= 2 node labels in a node label expression now if (hasLabel && (exp.contains("&&") || exp.contains("||"))) { throw new InvalidContainerRequestException( "Cannot specify more than two node labels" + " in a single node label expression: " + requestDetails); } // Don't allow specify node label against ANY request listing hosts or racks if (hasLabel && ( hasRacks || hasNodes)) { throw new InvalidContainerRequestException( "Cannot specify node label with rack or node: " + requestDetails); } }
@Override public void validate() throws BadCommandArgumentsException, UsageException { super.validate(); if (keytab != null && SliderUtils.isUnset(principal)) { throw new UsageException("Missing argument " + ARG_PRINCIPAL); } if (keytab == null && SliderUtils.isSet(principal)) { throw new UsageException("Missing argument " + ARG_KEYTAB); } } }
@Override public void validate() throws BadCommandArgumentsException, UsageException { super.validate(); if (keytab != null && SliderUtils.isUnset(principal)) { throw new UsageException("Missing argument " + ARG_PRINCIPAL); } if (keytab == null && SliderUtils.isSet(principal)) { throw new UsageException("Missing argument " + ARG_KEYTAB); } } }
/** * Add the ZK paths to the application options. * * @param zkBinding ZK binding */ public void addZKBinding(ZKPathBuilder zkBinding) throws BadConfigException { String quorum = zkBinding.getAppQuorum(); if (SliderUtils.isSet(quorum)) { MapOperations globalAppOptions = instanceDescription.getAppConfOperations().getGlobalOptions(); globalAppOptions.put(ZOOKEEPER_PATH, zkBinding.getAppPath()); globalAppOptions.put(ZOOKEEPER_QUORUM, quorum); globalAppOptions.put(ZOOKEEPER_HOSTS, ZookeeperUtils.convertToHostsOnlyList(quorum)); } }
/** * Add the ZK paths to the application options. * * @param zkBinding ZK binding */ public void addZKBinding(ZKPathBuilder zkBinding) throws BadConfigException { String quorum = zkBinding.getAppQuorum(); if (SliderUtils.isSet(quorum)) { MapOperations globalAppOptions = instanceDescription.getAppConfOperations().getGlobalOptions(); globalAppOptions.put(ZOOKEEPER_PATH, zkBinding.getAppPath()); globalAppOptions.put(ZOOKEEPER_QUORUM, quorum); globalAppOptions.put(ZOOKEEPER_HOSTS, ZookeeperUtils.convertToHostsOnlyList(quorum)); } }