(argsList);
- //insert the service name
- extendedArgs.add(0, SERVICE_CLASSNAME);
- //now have the service launcher do its work
- ServiceLauncher.serviceMain(extendedArgs);
- }
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/ClusterNode.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/ClusterNode.java
deleted file mode 100644
index 8b0a563..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/ClusterNode.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api;
-
-import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.slider.api.proto.Messages;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-/**
- * Describe a specific node in the cluster
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL )
-public final class ClusterNode implements Cloneable {
- protected static final Logger
- LOG = LoggerFactory.getLogger(ClusterNode.class);
-
- @JsonIgnore
- public ContainerId containerId;
-
- /**
- * server name
- */
- public String name;
-
-
- /**
- * UUID of container used in Slider RPC to refer to instances
- */
- public String id;
-
- public String role;
-
- public int roleId;
-
- public long createTime;
- public long startTime;
- /**
- * flag set when it is released, to know if it has
- * already been targeted for termination
- */
- public boolean released;
- public String host;
- public String ip;
- public String hostname;
- public String hostUrl;
-
- /**
- * state from {@link ClusterDescription}
- */
- public int state;
-
- /**
- * Exit code: only valid if the state >= STOPPED
- */
- public int exitCode;
-
- /**
- * what was the command executed?
- */
- public String command;
-
- /**
- * Any diagnostics
- */
- public String diagnostics;
-
- /**
- * What is the tail output from the executed process (or [] if not started
- * or the log cannot be picked up
- */
- public String[] output;
-
- /**
- * Any environment details
- */
- public String[] environment;
-
- /**
- * server-side ctor takes the container ID and builds the name from it
- * @param containerId container ID; can be null
- */
- public ClusterNode(ContainerId containerId) {
- if (containerId != null) {
- this.containerId = containerId;
- this.name = containerId.toString();
- }
- }
-
- /**
- * ctor for deserialization
- */
- public ClusterNode() {
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append(name).append(": ");
- builder.append(state).append("\n");
- builder.append("state: ").append(state).append("\n");
- builder.append("role: ").append(role).append("\n");
- append(builder, "host", host);
- append(builder, "hostURL", hostUrl);
- append(builder, "command", command);
- if (output != null) {
- for (String line : output) {
- builder.append(line).append("\n");
- }
- }
- append(builder, "diagnostics", diagnostics);
- return builder.toString();
- }
-
- private void append(StringBuilder builder, String key, Object val) {
- if (val != null) {
- builder.append(key).append(": ").append(val.toString()).append("\n");
- }
- }
-
- /**
- * Convert to a JSON string
- * @return a JSON string description
- * @throws IOException Problems mapping/writing the object
- */
- public String toJsonString() throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- return mapper.writeValueAsString(this);
- }
-
-
- /**
- * Convert from JSON
- * @param json input
- * @return the parsed JSON
- * @throws IOException IO
- */
- public static ClusterNode fromJson(String json)
- throws IOException, JsonParseException, JsonMappingException {
- ObjectMapper mapper = new ObjectMapper();
- try {
- return mapper.readValue(json, ClusterNode.class);
- } catch (IOException e) {
- LOG.error("Exception while parsing json : {}\n{}", e , json, e);
- throw e;
- }
- }
-
- /**
- * Build from a protobuf response
- * @param message
- * @return the deserialized node
- */
- public static ClusterNode fromProtobuf(Messages.RoleInstanceState message) {
- ClusterNode node = new ClusterNode();
- node.name = message.getName();
- node.command = message.getCommand();
- node.diagnostics = message.getDiagnostics();
- String[] arr;
- int environmentCount = message.getEnvironmentCount();
- if (environmentCount > 0) {
- arr = new String[environmentCount];
- node.environment = message.getEnvironmentList().toArray(arr);
- }
- node.exitCode = message.getExitCode();
- int outputCount = message.getOutputCount();
- if (outputCount > 0) {
- arr = new String[outputCount];
- node.output = message.getOutputList().toArray(arr);
- }
- node.role = message.getRole();
- node.roleId = message.getRoleId();
- node.state = message.getState();
- node.host = message.getHost();
- node.hostUrl = message.getHostURL();
- node.createTime = message.getCreateTime();
- node.startTime = message.getStartTime();
- node.released = message.getReleased();
- return node;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- public ClusterNode doClone() {
- try {
- return (ClusterNode)clone();
- } catch (CloneNotSupportedException e) {
- //not going to happen. This is a final class
- return null;
- }
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/OptionKeys.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/OptionKeys.java
deleted file mode 100644
index 988627d..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/OptionKeys.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api;
-
-/**
- * Keys for entries in the options section
- * of a cluster description.
- */
-public interface OptionKeys extends InternalKeys {
-
- /**
- * Time in milliseconds to wait after forking any in-AM
- * process before attempting to start up the containers: {@value}
- *
- * A shorter value brings the cluster up faster, but means that if the
- * in AM process fails (due to a bad configuration), then time
- * is wasted starting containers on a cluster that isn't going to come
- * up
- */
- String APPLICATION_TYPE = "application.type";
-
- String APPLICATION_NAME = "application.name";
-
- /**
- * Prefix for site.xml options: {@value}
- */
- String SITE_XML_PREFIX = "site.";
- /**
- * Prefix for config file options: {@value}
- */
- String CONF_FILE_PREFIX = "conf.";
- /**
- * Prefix for package options: {@value}
- */
- String PKG_FILE_PREFIX = "pkg.";
- /**
- * Prefix for export options: {@value}
- */
- String EXPORT_PREFIX = "export.";
- /**
- * Type suffix for config file and package options: {@value}
- */
- String TYPE_SUFFIX = ".type";
- /**
- * Name suffix for config file and package options: {@value}
- */
- String NAME_SUFFIX = ".name";
- /**
- * Per component suffix for config file options: {@value}
- */
- String PER_COMPONENT = ".per.component";
- /**
- * Per group suffix for config file options: {@value}
- */
- String PER_GROUP = ".per.group";
-
- /**
- * Zookeeper quorum host list: {@value}
- */
- String ZOOKEEPER_QUORUM = "zookeeper.quorum";
- String ZOOKEEPER_HOSTS = "zookeeper.hosts";
- String ZOOKEEPER_PORT = "zookeeper.port";
-
- /**
- * Zookeeper path value (string): {@value}
- */
- String ZOOKEEPER_PATH = "zookeeper.path";
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/RoleKeys.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/RoleKeys.java
deleted file mode 100644
index ce413ff..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/RoleKeys.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api;
-
-/**
- * Standard options for roles
- */
-public interface RoleKeys {
-
-
- /**
- * The name of a role: {@value}
- */
- String ROLE_NAME = "role.name";
-
- /**
- * The group of a role: {@value}
- */
- String ROLE_GROUP = "role.group";
-
- /**
- * The prefix of a role: {@value}
- */
- String ROLE_PREFIX = "role.prefix";
-
- /**
- * Status report: number actually granted : {@value}
- */
- String ROLE_ACTUAL_INSTANCES = "role.actual.instances";
-
- /**
- * Status report: number currently requested: {@value}
- */
- String ROLE_REQUESTED_INSTANCES = "role.requested.instances";
-
- /**
- * Status report: number currently being released: {@value}
- */
- String ROLE_RELEASING_INSTANCES = "role.releasing.instances";
-
- /**
- * Status report: total number that have failed: {@value}
- */
- String ROLE_FAILED_INSTANCES = "role.failed.instances";
-
- /**
- * Status report: number that have failed recently: {@value}
- */
- String ROLE_FAILED_RECENTLY_INSTANCES = "role.failed.recently.instances";
-
- /**
- * Status report: number that have failed for node-related issues: {@value}
- */
- String ROLE_NODE_FAILED_INSTANCES = "role.failed.node.instances";
-
- /**
- * Status report: number that been pre-empted: {@value}
- */
- String ROLE_PREEMPTED_INSTANCES = "role.failed.preempted.instances";
-
- /**
- * Number of pending anti-affine instances: {@value}
- */
- String ROLE_PENDING_AA_INSTANCES = "role.pending.aa.instances";
-
- /**
- * Status report: number currently being released: {@value}
- */
- String ROLE_FAILED_STARTING_INSTANCES = "role.failed.starting.instances";
-
- /**
- * Extra arguments (non-JVM) to use when starting this role
- */
- String ROLE_ADDITIONAL_ARGS = "role.additional.args";
-
- /**
- * JVM heap size for Java applications in MB. Only relevant for Java applications.
- * This MUST be less than or equal to the {@link ResourceKeys#YARN_MEMORY} option
- * {@value}
- */
- String JVM_HEAP = "jvm.heapsize";
-
- /*
- * GC options for Java applications.
- */
- String GC_OPTS = "gc.opts";
-
- /**
- * JVM options other than heap size. Only relevant for Java applications.
- * {@value}
- */
- String JVM_OPTS = "jvm.opts";
-
-
- /**
- * All keys w/ env. are converted into env variables and passed down
- */
- String ENV_PREFIX = "env.";
-
- /**
- * Container service record attribute prefix.
- */
- String SERVICE_RECORD_ATTRIBUTE_PREFIX = "service.record.attribute";
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/SliderClusterProtocol.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/SliderClusterProtocol.java
deleted file mode 100644
index aaf2f88..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/SliderClusterProtocol.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License") throws IOException, YarnException; you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api;
-
-import org.apache.hadoop.ipc.VersionedProtocol;
-import org.apache.hadoop.security.KerberosInfo;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.api.proto.Messages;
-import org.apache.hadoop.yarn.service.conf.SliderXmlConfKeys;
-
-import java.io.IOException;
-
-/**
- * Cluster protocol. This can currently act as a versioned IPC
- * endpoint or be relayed via protobuf
- */
-@KerberosInfo(serverPrincipal = SliderXmlConfKeys.KEY_KERBEROS_PRINCIPAL)
-public interface SliderClusterProtocol extends VersionedProtocol {
- long versionID = 0x01;
-
- /**
- * Stop the cluster
- */
-
- Messages.StopClusterResponseProto stopCluster(Messages.StopClusterRequestProto request) throws
- IOException, YarnException;
- /**
- * Upgrade the application containers
- *
- * @param request upgrade containers request object
- * @return upgrade containers response object
- * @throws IOException
- * @throws YarnException
- */
- Messages.UpgradeContainersResponseProto upgradeContainers(
- Messages.UpgradeContainersRequestProto request) throws IOException,
- YarnException;
-
-
- Messages.FlexComponentsResponseProto flexComponents(
- Messages.FlexComponentsRequestProto request) throws IOException;
-
- /**
- * Get the current cluster status
- */
- Messages.GetJSONClusterStatusResponseProto getJSONClusterStatus(Messages.GetJSONClusterStatusRequestProto request)
- throws IOException, YarnException;
-
-
- /**
- * List all running nodes in a role
- */
- Messages.ListNodeUUIDsByRoleResponseProto listNodeUUIDsByRole(Messages.ListNodeUUIDsByRoleRequestProto request)
- throws IOException, YarnException;
-
-
- /**
- * Get the details on a node
- */
- Messages.GetNodeResponseProto getNode(Messages.GetNodeRequestProto request)
- throws IOException, YarnException;
-
- /**
- * Get the
- * details on a list of nodes.
- * Unknown nodes are not returned
- * Important: the order of the results are undefined
- */
- Messages.GetClusterNodesResponseProto getClusterNodes(Messages.GetClusterNodesRequestProto request)
- throws IOException, YarnException;
-
- /**
- * Echo back the submitted text (after logging it).
- * Useful for adding information to the log, and for testing round trip
- * operations of the protocol
- * @param request request
- * @return response
- * @throws IOException
- * @throws YarnException
- */
- Messages.EchoResponseProto echo(Messages.EchoRequestProto request) throws IOException, YarnException;
-
- /**
- * Kill an identified container
- * @param request request containing the container to kill
- * @return the response
- * @throws IOException
- * @throws YarnException
- */
- Messages.KillContainerResponseProto killContainer(Messages.KillContainerRequestProto request)
- throws IOException, YarnException;
-
- /**
- * AM to commit suicide. If the Hadoop halt entry point has not been disabled,
- * this will fail rather than return with a response.
- * @param request request
- * @return response (this is not the expected outcome)
- * @throws IOException
- * @throws YarnException
- */
- Messages.AMSuicideResponseProto amSuicide(Messages.AMSuicideRequestProto request)
- throws IOException;
-
- /**
- * Get the application liveness
- * @return current liveness information
- * @throws IOException
- */
- Messages.ApplicationLivenessInformationProto getLivenessInformation(
- Messages.GetApplicationLivenessRequestProto request
- ) throws IOException;
-
- Messages.GetLiveContainersResponseProto getLiveContainers(
- Messages.GetLiveContainersRequestProto request
- ) throws IOException;
-
- Messages.ContainerInformationProto getLiveContainer(
- Messages.GetLiveContainerRequestProto request
- ) throws IOException;
-
- Messages.GetLiveComponentsResponseProto getLiveComponents(
- Messages.GetLiveComponentsRequestProto request
- ) throws IOException;
-
- Messages.ComponentInformationProto getLiveComponent(
- Messages.GetLiveComponentRequestProto request
- ) throws IOException;
-
- Messages.GetLiveNodesResponseProto getLiveNodes(
- Messages.GetLiveNodesRequestProto request
- ) throws IOException;
-
- Messages.NodeInformationProto getLiveNode(
- Messages.GetLiveNodeRequestProto request
- ) throws IOException;
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/StateValues.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/StateValues.java
deleted file mode 100644
index ad66a97..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/StateValues.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api;
-
-/**
- * Enumeration of state values.
- */
-public class StateValues {
-
- private StateValues() {}
-
- /**
- * Specification is incomplete & cannot
- * be used: {@value}.
- */
- public static final int STATE_INCOMPLETE = 0;
-
- /**
- * Spec has been submitted: {@value}
- */
- public static final int STATE_SUBMITTED = 1;
- /**
- * Cluster created: {@value}
- */
- public static final int STATE_CREATED = 2;
- /**
- * Live: {@value}
- */
- public static final int STATE_LIVE = 3;
- /**
- * Not ready.
- */
- public static final int STATE_NOT_READY = 4;
- /**
- * Ready.
- */
- public static final int STATE_READY = 5;
- /**
- * Stopped.
- */
- public static final int STATE_STOPPED = 99;
- /**
- * Destroyed.
- */
- public static final int STATE_DESTROYED = 100;
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/StatusKeys.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/StatusKeys.java
deleted file mode 100644
index 8a2c4bb..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/StatusKeys.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api;
-import static org.apache.slider.api.ResourceKeys.COMPONENT_INSTANCES;
-/**
- * Contains status and statistics keys
- */
-public interface StatusKeys {
-
- String STATISTICS_CONTAINERS_ACTIVE_REQUESTS = "containers.active.requests";
- String STATISTICS_CONTAINERS_COMPLETED = "containers.completed";
- String STATISTICS_CONTAINERS_DESIRED = "containers.desired";
- String STATISTICS_CONTAINERS_FAILED = "containers.failed";
- String STATISTICS_CONTAINERS_FAILED_RECENTLY = "containers.failed.recently";
- String STATISTICS_CONTAINERS_FAILED_NODE = "containers.failed.node";
- String STATISTICS_CONTAINERS_PREEMPTED = "containers.failed.preempted";
- String STATISTICS_CONTAINERS_LIVE = "containers.live";
- String STATISTICS_CONTAINERS_REQUESTED = "containers.requested";
- String STATISTICS_CONTAINERS_ANTI_AFFINE_PENDING = "containers.anti-affine.pending";
- String STATISTICS_CONTAINERS_STARTED = "containers.start.started";
- String STATISTICS_CONTAINERS_START_FAILED =
- "containers.start.failed";
- String STATISTICS_CONTAINERS_SURPLUS =
- "containers.surplus";
- String STATISTICS_CONTAINERS_UNKNOWN_COMPLETED =
- "containers.unknown.completed";
- /**
- * No of containers provided on AM restart
- */
- String INFO_CONTAINERS_AM_RESTART = "containers.at.am-restart";
-
- String INFO_CREATE_TIME_MILLIS = "create.time.millis";
- String INFO_CREATE_TIME_HUMAN = "create.time";
- String INFO_LIVE_TIME_MILLIS = "live.time.millis";
- String INFO_LIVE_TIME_HUMAN = "live.time";
- String INFO_FLEX_TIME_MILLIS = "flex.time.millis";
- String INFO_FLEX_TIME_HUMAN = "flex.time";
-
- String INFO_MASTER_ADDRESS = "info.master.address";
-
- /**
- * System time in millis when the status report was generated
- */
- String INFO_STATUS_TIME_MILLIS = "status.time.millis";
-
- /**
- * System time in human form when the status report was generated
- */
- String INFO_STATUS_TIME_HUMAN = "status.time";
-
- String INFO_AM_APP_ID = "info.am.app.id";
- String INFO_AM_ATTEMPT_ID = "info.am.attempt.id";
- String INFO_AM_CONTAINER_ID = "info.am.container.id";
- String INFO_AM_HOSTNAME = "info.am.hostname";
- String INFO_AM_RPC_PORT = "info.am.rpc.port";
- String INFO_AM_WEB_PORT = "info.am.web.port";
- String INFO_AM_WEB_URL = "info.am.web.url";
- String INFO_AM_AGENT_STATUS_PORT = "info.am.agent.status.port";
- String INFO_AM_AGENT_OPS_PORT = "info.am.agent.ops.port";
- String INFO_AM_AGENT_OPS_URL = "info.am.agent.ops.url";
- String INFO_AM_AGENT_STATUS_URL = "info.am.agent.status.url";
-
- /**
- * info: #of instances of a component requested: {@value}
- *
- */
- String COMPONENT_INSTANCES_ACTUAL = COMPONENT_INSTANCES + ".actual";
-
- /**
- * info: #of instances of a component requested: {@value}
- *
- */
- String COMPONENT_INSTANCES_REQUESTING = COMPONENT_INSTANCES + ".requesting";
-
- /**
- * info: #of instances of a component being released: {@value}
- *
- */
- String COMPONENT_INSTANCES_RELEASING = COMPONENT_INSTANCES + ".releasing";
-
- /**
- * info: #of instances of a component failed: {@value}
- *
- */
- String COMPONENT_INSTANCES_FAILED = COMPONENT_INSTANCES + ".failed";
-
- /**
- * info: #of instances of a component started: {@value}
- *
- */
- String COMPONENT_INSTANCES_STARTED = COMPONENT_INSTANCES + ".started";
-
-
- /**
- * info: #of instances of a component completed: {@value}
- *
- */
- String COMPONENT_INSTANCES_COMPLETED = COMPONENT_INSTANCES + ".completed";
-
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java
deleted file mode 100644
index 687edd2..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-/**
- * Serialized information about liveness
- *
- * If true liveness probes are implemented, this
- * datatype can be extended to publish their details.
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class ApplicationLivenessInformation {
- /** flag set if the cluster is at size */
- public boolean allRequestsSatisfied;
-
- /** number of outstanding requests: those needed to satisfy */
- public int requestsOutstanding;
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("ApplicationLivenessInformation{");
- sb.append("allRequestsSatisfied=").append(allRequestsSatisfied);
- sb.append(", requestsOutstanding=").append(requestsOutstanding);
- sb.append('}');
- return sb.toString();
- }
-}
-
-
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ComponentInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ComponentInformation.java
deleted file mode 100644
index d2fdd62..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ComponentInformation.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.apache.slider.api.StatusKeys;
-import org.apache.slider.server.appmaster.state.RoleStatus;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Serializable version of component data.
- *
- * This is sent in REST calls as a JSON object —but is also marshalled into
- * a protobuf structure. Look at {@link RestTypeMarshalling}
- * for the specifics there.
- *
- * This means that if any fields are added here. they must be added to
- * src/main/proto/SliderClusterMessages.proto and
- * the protobuf structures rebuilt via a {@code mvn generate-sources -Pcompile-protobuf}
- *
- * See also {@link RoleStatus#serialize()}
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-
-public class ComponentInformation {
-
- public String name;
- public int priority;
- public int desired, actual, releasing;
- public int placementPolicy;
- public int requested;
- public int failed, started, startFailed, completed, totalRequested;
- public int nodeFailed, failedRecently, preempted;
- public int pendingAntiAffineRequestCount;
- public boolean isAARequestOutstanding;
-
- public String failureMessage;
- public List containers;
-
- /**
- * Build the statistics map from the current data
- * @return a map for use in statistics reports
- */
- public Map buildStatistics() {
- Map stats = new HashMap<>();
- stats.put(StatusKeys.STATISTICS_CONTAINERS_ACTIVE_REQUESTS, requested);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_ANTI_AFFINE_PENDING, pendingAntiAffineRequestCount);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_COMPLETED, completed);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_DESIRED, desired);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_FAILED, failed);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_FAILED_NODE, nodeFailed);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_FAILED_RECENTLY, failedRecently);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_LIVE, actual);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_PREEMPTED, preempted);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_REQUESTED, totalRequested);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_STARTED, started);
- stats.put(StatusKeys.STATISTICS_CONTAINERS_START_FAILED, startFailed);
- return stats;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("ComponentInformation{");
- sb.append(", name='").append(name).append('\'');
- sb.append(", actual=").append(actual);
- sb.append(", completed=").append(completed);
- sb.append(", desired=").append(desired);
- sb.append(", failed=").append(failed);
- sb.append(", failureMessage='").append(failureMessage).append('\'');
- sb.append(", placementPolicy=").append(placementPolicy);
- sb.append(", isAARequestOutstanding=").append(isAARequestOutstanding);
- sb.append(", pendingAntiAffineRequestCount=").append(pendingAntiAffineRequestCount);
- sb.append(", priority=").append(priority);
- sb.append(", releasing=").append(releasing);
- sb.append(", requested=").append(requested);
- sb.append(", started=").append(started);
- sb.append(", startFailed=").append(startFailed);
- sb.append(", totalRequested=").append(totalRequested);
- sb.append(", container count='")
- .append(containers == null ? 0 : containers.size())
- .append('\'');
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ContainerInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ContainerInformation.java
deleted file mode 100644
index 6991340..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ContainerInformation.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.apache.hadoop.registry.client.binding.JsonSerDeser;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-/**
- * Serializable version of component instance data
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class ContainerInformation {
-
- public String containerId;
- public String component;
- public String appVersion;
- public Boolean released;
- public int state;
- public Integer exitCode;
- public String diagnostics;
- public long createTime;
- public long startTime;
-
- public String host;
- public String hostURL;
- public String placement;
- /**
- * What is the tail output from the executed process (or [] if not started
- * or the log cannot be picked up
- */
- public String[] output;
-
- @Override
- public String toString() {
- JsonSerDeser serDeser =
- new JsonSerDeser<>(
- ContainerInformation.class);
- return serDeser.toString(this);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeEntryInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeEntryInformation.java
deleted file mode 100644
index 8424be2..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeEntryInformation.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-/**
- * Serialized node entry information. Must be kept in sync with the protobuf equivalent.
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class NodeEntryInformation {
-
- /** incrementing counter of instances that failed */
- public int failed;
-
- /** Counter of "failed recently" events. */
- public int failedRecently;
-
- /** timestamp of last use */
- public long lastUsed;
-
- /** Number of live nodes. */
- public int live;
-
- /** incrementing counter of instances that have been pre-empted. */
- public int preempted;
-
- /** Priority */
- public int priority;
-
- /** instance explicitly requested on this node */
- public int requested;
-
- /** number of containers being released off this node */
- public int releasing;
-
- /** incrementing counter of instances that failed to start */
- public int startFailed;
-
- /** number of starting instances */
- public int starting;
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder(
- "NodeEntryInformation{");
- sb.append("priority=").append(priority);
- sb.append(", live=").append(live);
- sb.append(", requested=").append(requested);
- sb.append(", releasing=").append(releasing);
- sb.append(", starting=").append(starting);
- sb.append(", failed=").append(failed);
- sb.append(", failedRecently=").append(failedRecently);
- sb.append(", startFailed=").append(startFailed);
- sb.append(", preempted=").append(preempted);
- sb.append(", lastUsed=").append(lastUsed);
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformation.java
deleted file mode 100644
index 4fe5b4c..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformation.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Serialized node information. Must be kept in sync with the protobuf equivalent.
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class NodeInformation {
-
- public String hostname;
- public String state;
- public String labels;
- public String rackName;
- public String httpAddress;
- public String healthReport;
- public long lastUpdated;
- public Map entries = new HashMap<>();
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder(
- "NodeInformation{");
- sb.append("hostname='").append(hostname).append('\'');
- sb.append(", state='").append(state).append('\'');
- sb.append(", labels='").append(labels).append('\'');
- sb.append(", rackName='").append(rackName).append('\'');
- sb.append(", httpAddress='").append(httpAddress).append('\'');
- sb.append(", healthReport='").append(healthReport).append('\'');
- sb.append(", lastUpdated=").append(lastUpdated);
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformationList.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformationList.java
deleted file mode 100644
index 741523e..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformationList.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.apache.slider.core.persist.JsonSerDeser;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class NodeInformationList extends ArrayList {
- public NodeInformationList() {
- }
-
- public NodeInformationList(Collection extends NodeInformation> c) {
- super(c);
- }
-
- public NodeInformationList(int initialCapacity) {
- super(initialCapacity);
- }
-
- public static JsonSerDeser createSerializer() {
- return new JsonSerDeser<>(NodeInformationList.class);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/PingInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/PingInformation.java
deleted file mode 100644
index 223edca..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/PingInformation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-/**
- * Serialized information to/from Ping operations
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class PingInformation {
- public long time;
- public String text;
- public String verb;
- public String body;
-
- @Override
- public String toString() {
-
- final StringBuilder sb =
- new StringBuilder("PingResource{");
- sb.append("time=").append(time);
- sb.append(", verb=").append(verb);
- sb.append(", text='").append(text).append('\'');
- sb.append(", body='").append(body).append('\'');
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RestTypeMarshalling.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RestTypeMarshalling.java
deleted file mode 100644
index bc3d526..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RestTypeMarshalling.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.apache.slider.api.proto.Messages;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Class to handle marshalling of REST
- * types to/from Protobuf records.
- */
-public class RestTypeMarshalling {
-
- public static Messages.ApplicationLivenessInformationProto
- marshall(ApplicationLivenessInformation info) {
-
- Messages.ApplicationLivenessInformationProto.Builder builder =
- Messages.ApplicationLivenessInformationProto.newBuilder();
- builder.setAllRequestsSatisfied(info.allRequestsSatisfied);
- builder.setRequestsOutstanding(info.requestsOutstanding);
- return builder.build();
- }
-
- public static ApplicationLivenessInformation
- unmarshall(Messages.ApplicationLivenessInformationProto wire) {
- ApplicationLivenessInformation info = new ApplicationLivenessInformation();
- info.allRequestsSatisfied = wire.getAllRequestsSatisfied();
- info.requestsOutstanding = wire.getRequestsOutstanding();
- return info;
- }
-
- public static ComponentInformation
- unmarshall(Messages.ComponentInformationProto wire) {
- ComponentInformation info = new ComponentInformation();
- info.name = wire.getName();
- info.priority = wire.getPriority();
- info.placementPolicy = wire.getPlacementPolicy();
-
- info.actual = wire.getActual();
- info.completed = wire.getCompleted();
- info.desired = wire.getDesired();
- info.failed = wire.getFailed();
- info.releasing = wire.getReleasing();
- info.requested = wire.getRequested();
- info.started = wire.getStarted();
- info.startFailed = wire.getStartFailed();
- info.totalRequested = wire.getTotalRequested();
- info.containers = new ArrayList<>(wire.getContainersList());
- if (wire.hasFailureMessage()) {
- info.failureMessage = wire.getFailureMessage();
- }
- if (wire.hasPendingAntiAffineRequestCount()) {
- info.pendingAntiAffineRequestCount = wire.getPendingAntiAffineRequestCount();
- }
- if (wire.hasIsAARequestOutstanding()) {
- info.isAARequestOutstanding = wire.getIsAARequestOutstanding();
- }
- return info;
- }
- public static Messages.ComponentInformationProto marshall(ComponentInformation info) {
-
- Messages.ComponentInformationProto.Builder builder =
- Messages.ComponentInformationProto.newBuilder();
- builder.setName(info.name);
- builder.setPriority(info.priority);
- builder.setPlacementPolicy(info.placementPolicy);
-
- builder.setActual(info.actual);
- builder.setCompleted(info.completed);
- builder.setDesired(info.desired);
- builder.setFailed(info.failed);
- builder.setReleasing(info.releasing);
- builder.setRequested(info.requested);
- builder.setStarted(info.started);
- builder.setStartFailed(info.startFailed);
- builder.setTotalRequested(info.totalRequested);
- builder.setNodeFailed(info.nodeFailed);
- builder.setPreempted(info.preempted);
- builder.setFailedRecently(info.failedRecently);
- if (info.failureMessage != null) {
- builder.setFailureMessage(info.failureMessage);
- }
- if (info.containers != null) {
- builder.addAllContainers(info.containers);
- }
- builder.setPendingAntiAffineRequestCount(info.pendingAntiAffineRequestCount);
- builder.setIsAARequestOutstanding(info.isAARequestOutstanding);
- return builder.build();
- }
-
- public static Messages.NodeInformationProto marshall(NodeInformation info) {
-
- Messages.NodeInformationProto.Builder builder =
- Messages.NodeInformationProto.newBuilder();
- builder.setHostname(info.hostname);
- builder.setLastUpdated(info.lastUpdated);
- builder.setState(info.state != null? info.state : "unknown");
- builder.setRackName(info.rackName != null ? info.rackName : "");
- builder.setHealthReport(info.healthReport != null ? info.healthReport : "");
- builder.setHttpAddress(info.httpAddress != null ? info.httpAddress : "");
- builder.setLabels(info.labels != null ? info.labels: "");
-
-
- if (info.entries != null) {
- for (Map.Entry elt : info.entries.entrySet()) {
- NodeEntryInformation entry = elt.getValue();
- Messages.NodeEntryInformationProto.Builder node =
- Messages.NodeEntryInformationProto.newBuilder();
- node.setPriority(entry.priority);
- node.setName(elt.getKey());
- node.setFailed(entry.failed);
- node.setFailedRecently(entry.failedRecently);
- node.setLive(entry.live);
- node.setLastUsed(entry.lastUsed);
- node.setPreempted(entry.preempted);
- node.setRequested(entry.requested);
- node.setReleasing(entry.releasing);
- node.setStartFailed(entry.startFailed);
- node.setStarting(entry.starting);
- builder.addEntries(node.build());
- }
- }
- return builder.build();
- }
-
- public static NodeInformation unmarshall(Messages.NodeInformationProto wire) {
- NodeInformation info = new NodeInformation();
- info.healthReport = wire.getHealthReport();
- info.hostname = wire.getHostname();
- info.httpAddress = wire.getHttpAddress();
- info.labels = wire.getLabels();
- info.lastUpdated = wire.getLastUpdated();
- info.rackName = wire.getRackName();
- info.state = wire.getState();
- List entriesList = wire.getEntriesList();
- if (entriesList != null) {
- info.entries = new HashMap<>(entriesList.size());
- for (Messages.NodeEntryInformationProto entry : entriesList) {
- NodeEntryInformation nei = new NodeEntryInformation();
- nei.failed = entry.getFailed();
- nei.failedRecently = entry.getFailedRecently();
- nei.lastUsed = entry.getLastUsed();
- nei.live = entry.getLive();
- nei.preempted = entry.getPreempted();
- nei.priority = entry.getPriority();
- nei.requested = entry.getRequested();
- nei.releasing = entry.getReleasing();
- nei.startFailed = entry.getStartFailed();
- nei.starting = entry.getStarting();
- info.entries.put(entry.getName(), nei);
- }
- }
- return info;
- }
-
- public static ContainerInformation unmarshall(Messages.ContainerInformationProto wire) {
- ContainerInformation info = new ContainerInformation();
- info.containerId = wire.getContainerId();
- info.component = wire.getComponent();
- info.appVersion = wire.getAppVersion();
- info.state = wire.getState();
- if (wire.hasReleased()) {
- info.released = wire.getReleased();
- }
- if (wire.hasExitCode()) {
- info.exitCode = wire.getExitCode();
- }
- if (wire.hasDiagnostics()) {
- info.diagnostics = wire.getDiagnostics();
- }
- if (wire.hasHost()) {
- info.host = wire.getHost();
- }
- if (wire.hasHostURL()) {
- info.host = wire.getHostURL();
- }
- info.createTime = wire.getCreateTime();
- info.startTime = wire.getStartTime();
- info.output = wire.getOutputList().toArray(
- new String[wire.getOutputCount()]
- );
- if (wire.hasPlacement()) {
- info.placement = wire.getPlacement();
- }
- return info;
- }
-
- public static List unmarshall(Messages.GetLiveContainersResponseProto wire) {
- List infoList = new ArrayList<>(wire.getContainersList().size());
- for (Messages.ContainerInformationProto container : wire.getContainersList()) {
- infoList.add(unmarshall(container));
- }
- return infoList;
- }
-
- public static Messages.ContainerInformationProto marshall(ContainerInformation info) {
-
- Messages.ContainerInformationProto.Builder builder =
- Messages.ContainerInformationProto.newBuilder();
- if (info.containerId != null) {
- builder.setContainerId(info.containerId);
- }
- if (info.component != null) {
- builder.setComponent(info.component);
- }
- if (info.appVersion != null) {
- builder.setAppVersion(info.appVersion);
- }
- builder.setCreateTime(info.createTime);
- if (info.diagnostics != null) {
- builder.setDiagnostics(info.diagnostics);
- }
- if (info.host != null) {
- builder.setHost(info.host);
- }
- if (info.hostURL != null) {
- builder.setHostURL(info.hostURL);
- }
- if (info.output != null) {
- builder.addAllOutput(Arrays.asList(info.output));
- }
- if (info.released != null) {
- builder.setReleased(info.released);
- }
- if (info.placement != null) {
- builder.setPlacement(info.placement);
- }
- builder.setStartTime(info.startTime);
- builder.setState(info.state);
- return builder.build();
- }
-
- public static String unmarshall(Messages.WrappedJsonProto wire) {
- return wire.getJson();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RoleStatistics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RoleStatistics.java
deleted file mode 100644
index 25f4d9d..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RoleStatistics.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-
-/**
- * Simple role statistics for state views; can be generated by RoleStatus
- * instances, and aggregated for summary information.
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class RoleStatistics {
- public long activeAA = 0L;
- public long actual = 0L;
- public long completed = 0L;
- public long desired = 0L;
- public long failed = 0L;
- public long failedRecently = 0L;
- public long limitsExceeded = 0L;
- public long nodeFailed = 0L;
- public long preempted = 0L;
- public long requested = 0L;
- public long started = 0L;
-
- /**
- * Add another statistics instance
- * @param that the other value
- * @return this entry
- */
- public RoleStatistics add(final RoleStatistics that) {
- activeAA += that.activeAA;
- actual += that.actual;
- completed += that.completed;
- desired += that.desired;
- failed += that.failed;
- failedRecently += that.failedRecently;
- limitsExceeded += that.limitsExceeded;
- nodeFailed += that.nodeFailed;
- preempted += that.preempted;
- requested += that.requested;
- started += that.started;
- return this;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/SliderInstanceDescription.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/SliderInstanceDescription.java
deleted file mode 100644
index 3b95f80..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/SliderInstanceDescription.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.api.types;
-
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.yarn.api.records.ApplicationReport;
-
-/**
- * Description of a slider instance
- */
-public class SliderInstanceDescription {
-
- public final String name;
- public final Path path;
- public final ApplicationReport applicationReport;
-
- public SliderInstanceDescription(String name,
- Path path,
- ApplicationReport applicationReport) {
- this.name = name;
- this.path = path;
- this.applicationReport = applicationReport;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("SliderInstanceDescription{");
- sb.append("name='").append(name).append('\'');
- sb.append(", path=").append(path);
- sb.append(", applicationReport: ")
- .append(applicationReport == null
- ? "null"
- : (" id " + applicationReport.getApplicationId()));
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientUtils.java
deleted file mode 100644
index b28257f..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientUtils.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.client;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.PathNotFoundException;
-import org.apache.hadoop.registry.client.api.RegistryOperations;
-import org.apache.hadoop.registry.client.binding.RegistryPathUtils;
-import org.apache.hadoop.registry.client.exceptions.NoRecordException;
-import org.apache.hadoop.registry.client.types.ServiceRecord;
-import org.apache.hadoop.yarn.service.conf.SliderKeys;
-import org.apache.slider.core.exceptions.BadCommandArgumentsException;
-import org.apache.slider.core.exceptions.NotFoundException;
-import org.apache.slider.core.exceptions.SliderException;
-import org.apache.slider.core.registry.docstore.ConfigFormat;
-import org.apache.slider.core.registry.docstore.PublishedConfigSet;
-import org.apache.slider.core.registry.docstore.PublishedConfiguration;
-import org.apache.slider.core.registry.docstore.PublishedConfigurationOutputter;
-import org.apache.slider.core.registry.retrieve.RegistryRetriever;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.apache.hadoop.registry.client.binding.RegistryUtils.currentUser;
-import static org.apache.hadoop.registry.client.binding.RegistryUtils.servicePath;
-
-public class ClientUtils {
- public static ServiceRecord lookupServiceRecord(RegistryOperations rops,
- String user, String name) throws IOException, SliderException {
- return lookupServiceRecord(rops, user, null, name);
- }
-
- public static ServiceRecord lookupServiceRecord(RegistryOperations rops,
- String user, String type, String name) throws IOException,
- SliderException {
- if (StringUtils.isEmpty(user)) {
- user = currentUser();
- } else {
- user = RegistryPathUtils.encodeForRegistry(user);
- }
- if (StringUtils.isEmpty(type)) {
- type = SliderKeys.APP_TYPE;
- }
-
- String path = servicePath(user, type, name);
- return resolve(rops, path);
- }
-
- public static ServiceRecord resolve(RegistryOperations rops, String path)
- throws IOException, SliderException {
- try {
- return rops.resolve(path);
- } catch (PathNotFoundException | NoRecordException e) {
- throw new NotFoundException(e.getPath().toString(), e);
- }
- }
-
- public static PublishedConfiguration getConfigFromRegistry(
- RegistryOperations rops, Configuration configuration,
- String configName, String appName, String user, boolean external)
- throws IOException, SliderException {
- ServiceRecord instance = lookupServiceRecord(rops, user, appName);
-
- RegistryRetriever retriever = new RegistryRetriever(configuration, instance);
- PublishedConfigSet configurations = retriever.getConfigurations(external);
-
- PublishedConfiguration published = retriever.retrieveConfiguration(
- configurations, configName, external);
- return published;
- }
-
- public static String saveOrReturnConfig(PublishedConfiguration published,
- String format, File destPath, String fileName)
- throws BadCommandArgumentsException, IOException {
- ConfigFormat configFormat = ConfigFormat.resolve(format);
- if (configFormat == null) {
- throw new BadCommandArgumentsException(
- "Unknown/Unsupported format %s ", format);
- }
- PublishedConfigurationOutputter outputter =
- PublishedConfigurationOutputter.createOutputter(configFormat,
- published);
- boolean print = destPath == null;
- if (!print) {
- if (destPath.isDirectory()) {
- // creating it under a directory
- destPath = new File(destPath, fileName);
- }
- outputter.save(destPath);
- return null;
- } else {
- return outputter.asString();
- }
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java
deleted file mode 100644
index 7712191..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ /dev/null
@@ -1,2783 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.slider.client;
-
-import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.LocatedFileStatus;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.PathNotFoundException;
-import org.apache.hadoop.fs.RemoteIterator;
-import org.apache.hadoop.fs.permission.FsAction;
-import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.hadoop.yarn.proto.ClientAMProtocol.GetStatusRequestProto;
-import org.apache.hadoop.hdfs.HdfsConfiguration;
-import org.apache.hadoop.net.NetUtils;
-import org.apache.hadoop.registry.client.api.RegistryConstants;
-import org.apache.hadoop.registry.client.api.RegistryOperations;
-import org.apache.hadoop.registry.client.binding.RegistryPathUtils;
-import org.apache.hadoop.registry.client.binding.RegistryUtils;
-import org.apache.hadoop.registry.client.exceptions.NoRecordException;
-import org.apache.hadoop.registry.client.types.Endpoint;
-import org.apache.hadoop.registry.client.types.RegistryPathStatus;
-import org.apache.hadoop.registry.client.types.ServiceRecord;
-import org.apache.hadoop.registry.client.types.yarn.YarnRegistryAttributes;
-import org.apache.hadoop.security.Credentials;
-import org.apache.hadoop.security.KerberosDiags;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.util.Shell;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
-import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
-import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationReport;
-import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.api.records.ApplicationTimeout;
-import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
-import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
-import org.apache.hadoop.yarn.api.records.LocalResource;
-import org.apache.hadoop.yarn.api.records.LocalResourceType;
-import org.apache.hadoop.yarn.api.records.Resource;
-import org.apache.hadoop.yarn.api.records.YarnApplicationState;
-import org.apache.hadoop.yarn.client.api.YarnClientApplication;
-import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException;
-import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.hadoop.yarn.ipc.YarnRPC;
-import org.apache.hadoop.yarn.util.ConverterUtils;
-import org.apache.hadoop.yarn.util.Records;
-import org.apache.hadoop.yarn.util.Times;
-import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
-import org.apache.slider.api.SliderClusterProtocol;
-import org.apache.slider.api.proto.Messages;
-import org.apache.slider.api.resource.Application;
-import org.apache.slider.api.resource.Component;
-import org.apache.slider.api.types.ContainerInformation;
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.slider.client.ipc.SliderClusterOperations;
-import org.apache.slider.common.Constants;
-import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
-import org.apache.hadoop.yarn.service.conf.SliderKeys;
-import org.apache.hadoop.yarn.service.conf.SliderXmlConfKeys;
-import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs;
-import org.apache.slider.common.params.AbstractClusterBuildingActionArgs;
-import org.apache.slider.common.params.ActionAMSuicideArgs;
-import org.apache.slider.common.params.ActionClientArgs;
-import org.apache.hadoop.yarn.service.client.params.ActionDependencyArgs;
-import org.apache.slider.common.params.ActionDiagnosticArgs;
-import org.apache.slider.common.params.ActionExistsArgs;
-import org.apache.hadoop.yarn.service.client.params.ActionFlexArgs;
-import org.apache.slider.common.params.ActionFreezeArgs;
-import org.apache.slider.common.params.ActionKDiagArgs;
-import org.apache.slider.common.params.ActionKeytabArgs;
-import org.apache.slider.common.params.ActionKillContainerArgs;
-import org.apache.slider.common.params.ActionListArgs;
-import org.apache.slider.common.params.ActionLookupArgs;
-import org.apache.slider.common.params.ActionNodesArgs;
-import org.apache.slider.common.params.ActionRegistryArgs;
-import org.apache.slider.common.params.ActionResolveArgs;
-import org.apache.slider.common.params.ActionResourceArgs;
-import org.apache.slider.common.params.ActionStatusArgs;
-import org.apache.slider.common.params.ActionThawArgs;
-import org.apache.slider.common.params.ActionTokensArgs;
-import org.apache.slider.common.params.ActionUpgradeArgs;
-import org.apache.hadoop.yarn.service.client.params.Arguments;
-import org.apache.hadoop.yarn.service.client.params.ClientArgs;
-import org.apache.hadoop.yarn.service.client.params.CommonArgs;
-import org.apache.slider.common.tools.ConfigHelper;
-import org.apache.slider.common.tools.Duration;
-import org.apache.slider.common.tools.SliderFileSystem;
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.common.tools.SliderVersionInfo;
-import org.apache.slider.core.exceptions.BadClusterStateException;
-import org.apache.slider.core.exceptions.BadCommandArgumentsException;
-import org.apache.slider.core.exceptions.BadConfigException;
-import org.apache.slider.core.exceptions.ErrorStrings;
-import org.apache.slider.core.exceptions.NoSuchNodeException;
-import org.apache.slider.core.exceptions.NotFoundException;
-import org.apache.slider.core.exceptions.SliderException;
-import org.apache.slider.core.exceptions.UnknownApplicationInstanceException;
-import org.apache.slider.core.exceptions.UsageException;
-import org.apache.slider.core.launch.ClasspathConstructor;
-import org.apache.slider.core.launch.CredentialUtils;
-import org.apache.slider.core.launch.JavaCommandLineBuilder;
-import org.apache.slider.core.launch.SerializedApplicationReport;
-import org.apache.slider.core.main.RunService;
-import org.apache.slider.core.persist.ApplicationReportSerDeser;
-import org.apache.slider.core.persist.JsonSerDeser;
-import org.apache.slider.core.registry.SliderRegistryUtils;
-import org.apache.slider.core.registry.YarnAppListClient;
-import org.apache.slider.core.registry.docstore.ConfigFormat;
-import org.apache.slider.core.registry.docstore.PublishedConfigSet;
-import org.apache.slider.core.registry.docstore.PublishedConfiguration;
-import org.apache.slider.core.registry.docstore.PublishedExports;
-import org.apache.slider.core.registry.docstore.PublishedExportsOutputter;
-import org.apache.slider.core.registry.docstore.PublishedExportsSet;
-import org.apache.slider.core.registry.retrieve.RegistryRetriever;
-import org.apache.slider.core.zk.BlockingZKWatcher;
-import org.apache.slider.core.zk.ZKIntegration;
-import org.apache.hadoop.yarn.service.provider.AbstractClientProvider;
-import org.apache.hadoop.yarn.service.provider.ProviderUtils;
-import org.apache.slider.server.appmaster.rpc.RpcBinder;
-import org.apache.hadoop.yarn.service.ClientAMProtocol;
-import org.apache.hadoop.yarn.service.client.ClientAMProxy;
-import org.apache.hadoop.yarn.service.ServiceMaster;
-import org.apache.slider.server.services.utility.AbstractSliderLaunchedService;
-import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.data.ACL;
-import org.codehaus.jackson.map.PropertyNamingStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.net.InetSocketAddress;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import static org.apache.hadoop.registry.client.binding.RegistryUtils.*;
-import static org.apache.hadoop.yarn.api.records.YarnApplicationState.*;
-import static org.apache.slider.common.Constants.HADOOP_JAAS_DEBUG;
-import static org.apache.hadoop.yarn.service.client.params.SliderActions.*;
-import static org.apache.slider.common.tools.SliderUtils.*;
-import org.apache.hadoop.yarn.proto.ClientAMProtocol.GetStatusResponseProto;
-
-/**
- * Client service for Slider
- */
-
-public class SliderClient extends AbstractSliderLaunchedService implements RunService,
- SliderExitCodes, SliderKeys, ErrorStrings, SliderClientAPI {
- private static final Logger log = LoggerFactory.getLogger(SliderClient.class);
- public static final String E_MUST_BE_A_VALID_JSON_FILE
- = "Invalid configuration. Must be a valid json file.";
- public static final String E_INVALID_INSTALL_LOCATION
- = "A valid install location must be provided for the client.";
- public static final String E_UNABLE_TO_READ_SUPPLIED_PACKAGE_FILE
- = "Unable to read supplied package file";
- public static final String E_INVALID_APPLICATION_PACKAGE_LOCATION
- = "A valid application package location required.";
- public static final String E_INVALID_INSTALL_PATH = "Install path is not a valid directory";
- public static final String E_INSTALL_PATH_DOES_NOT_EXIST = "Install path does not exist";
- public static final String E_INVALID_APPLICATION_TYPE_NAME
- = "A valid application type name is required (e.g. HBASE).";
- public static final String E_USE_REPLACEPKG_TO_OVERWRITE = "Use --replacepkg to overwrite.";
- public static final String E_PACKAGE_DOES_NOT_EXIST = "Package does not exist";
- public static final String E_NO_ZOOKEEPER_QUORUM = "No Zookeeper quorum defined";
- public static final String E_NO_RESOURCE_MANAGER = "No valid Resource Manager address provided";
- public static final String E_PACKAGE_EXISTS = "Package exists";
- private static PrintStream clientOutputStream = System.out;
- private static final JsonSerDeser jsonSerDeser =
- new JsonSerDeser(Application.class,
- PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
-
- // value should not be changed without updating string find in slider.py
- private static final String PASSWORD_PROMPT = "Enter password for";
-
- private ClientArgs serviceArgs;
- public ApplicationId applicationId;
-
- private String deployedClusterName;
- /**
- * Cluster operations against the deployed cluster -will be null
- * if no bonding has yet taken place
- */
- private SliderClusterOperations sliderClusterOperations;
-
- protected SliderFileSystem sliderFileSystem;
- private YarnRPC rpc;
- /**
- * Yarn client service
- */
- private SliderYarnClientImpl yarnClient;
- private YarnAppListClient yarnAppListClient;
- ResourceCalculator calculator;
- /**
- * The YARN registry service
- */
- @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
- private RegistryOperations registryOperations;
-
- private static EnumSet terminatedStates =
- EnumSet.of(FINISHED, FAILED, KILLED);
- private static EnumSet waitingStates =
- EnumSet.of(NEW, NEW_SAVING, SUBMITTED, RUNNING);
-
- /**
- * Constructor
- */
- public SliderClient() {
- super("Slider Client");
- new HdfsConfiguration();
- new YarnConfiguration();
- }
-
- /**
- * This is called Before serviceInit is called
- * @param config the initial configuration build up by the
- * service launcher.
- * @param args argument list list of arguments passed to the command line
- * after any launcher-specific commands have been stripped.
- * @return the post-binding configuration to pass to the init()
- * operation.
- * @throws Exception
- */
- @Override
- public Configuration bindArgs(Configuration config, String... args) throws Exception {
- config = super.bindArgs(config, args);
- serviceArgs = new ClientArgs(args);
- serviceArgs.parse();
- // yarn-ify
- YarnConfiguration yarnConfiguration = new YarnConfiguration(config);
- return patchConfiguration(yarnConfiguration);
- }
-
- @Override
- protected void serviceInit(Configuration conf) throws Exception {
- Configuration clientConf = loadSliderClientXML();
- ConfigHelper.mergeConfigurations(conf, clientConf, SLIDER_CLIENT_XML, true);
- serviceArgs.applyDefinitions(conf);
- serviceArgs.applyFileSystemBinding(conf);
- AbstractActionArgs coreAction = serviceArgs.getCoreAction();
- // init security with our conf
- if (!coreAction.disableSecureLogin() && isHadoopClusterSecure(conf)) {
- forceLogin();
- initProcessSecurity(conf);
- }
- if (coreAction.getHadoopServicesRequired()) {
- initHadoopBinding();
- }
- rpc = YarnRPC.create(conf);
- super.serviceInit(conf);
- }
-
- @Override
- protected void serviceStart() throws Exception {
- super.serviceStart();
- }
-
- @Override
- protected void serviceStop() throws Exception {
- super.serviceStop();
- }
-
- /**
- * Launched service execution. This runs {@link #exec()}
- * then catches some exceptions and converts them to exit codes
- * @return an exit code
- * @throws Throwable
- */
- @Override
- public int runService() throws Throwable {
- try {
- return exec();
- } catch (FileNotFoundException | PathNotFoundException nfe) {
- throw new NotFoundException(nfe, nfe.toString());
- }
- }
-
- /**
- * Execute the command line
- * @return an exit code
- * @throws Throwable on a failure
- */
- public int exec() throws Throwable {
-
- // choose the action
- String action = serviceArgs.getAction();
- if (isUnset(action)) {
- throw new SliderException(EXIT_USAGE, serviceArgs.usage());
- }
-
- int exitCode = EXIT_SUCCESS;
- String clusterName = serviceArgs.getClusterName();
- // actions
-
- switch (action) {
- case ACTION_AM_SUICIDE:
- exitCode = actionAmSuicide(clusterName,
- serviceArgs.getActionAMSuicideArgs());
- break;
-
- case ACTION_BUILD:
- exitCode = actionBuild(getApplicationFromArgs(clusterName,
- serviceArgs.getActionBuildArgs()));
- break;
-
- case ACTION_CLIENT:
- exitCode = actionClient(serviceArgs.getActionClientArgs());
- break;
-
- case ACTION_CREATE:
- actionCreate(getApplicationFromArgs(clusterName,
- serviceArgs.getActionCreateArgs()));
- break;
-
- case ACTION_DEPENDENCY:
- exitCode = actionDependency(serviceArgs.getActionDependencyArgs());
- break;
-
- case ACTION_DESTROY:
- actionDestroy(clusterName);
- break;
-
- case ACTION_DIAGNOSTICS:
- exitCode = actionDiagnostic(serviceArgs.getActionDiagnosticArgs());
- break;
-
- case ACTION_EXISTS:
- exitCode = actionExists(clusterName,
- serviceArgs.getActionExistsArgs());
- break;
-
- case ACTION_FLEX:
- actionFlex(clusterName, serviceArgs.getActionFlexArgs());
- break;
-
- case ACTION_STOP:
- actionStop(clusterName, serviceArgs.getActionFreezeArgs());
- break;
-
- case ACTION_HELP:
- log.info(serviceArgs.usage());
- break;
-
- case ACTION_KDIAG:
- exitCode = actionKDiag(serviceArgs.getActionKDiagArgs());
- break;
-
- case ACTION_KILL_CONTAINER:
- exitCode = actionKillContainer(clusterName,
- serviceArgs.getActionKillContainerArgs());
- break;
-
- case ACTION_KEYTAB:
- exitCode = actionKeytab(serviceArgs.getActionKeytabArgs());
- break;
-
- case ACTION_LIST:
- exitCode = actionList(clusterName, serviceArgs.getActionListArgs());
- break;
-
- case ACTION_LOOKUP:
- exitCode = actionLookup(serviceArgs.getActionLookupArgs());
- break;
-
- case ACTION_NODES:
- exitCode = actionNodes("", serviceArgs.getActionNodesArgs());
- break;
-
- case ACTION_REGISTRY:
- exitCode = actionRegistry(serviceArgs.getActionRegistryArgs());
- break;
-
- case ACTION_RESOLVE:
- exitCode = actionResolve(serviceArgs.getActionResolveArgs());
- break;
-
- case ACTION_RESOURCE:
- exitCode = actionResource(serviceArgs.getActionResourceArgs());
- break;
-
- case ACTION_STATUS:
- exitCode = actionStatus(clusterName, serviceArgs.getActionStatusArgs());
- break;
-
- case ACTION_START:
- exitCode = actionStart(clusterName, serviceArgs.getActionThawArgs());
- break;
-
- case ACTION_TOKENS:
- exitCode = actionTokens(serviceArgs.getActionTokenArgs());
- break;
-
- case ACTION_UPDATE:
- exitCode = actionUpdate(clusterName, serviceArgs.getActionUpdateArgs());
- break;
-
- case ACTION_UPGRADE:
- exitCode = actionUpgrade(clusterName, serviceArgs.getActionUpgradeArgs());
- break;
-
- case ACTION_VERSION:
- exitCode = actionVersion();
- break;
-
- default:
- throw new SliderException(EXIT_UNIMPLEMENTED,
- "Unimplemented: " + action);
- }
-
- return exitCode;
- }
-
- /**
- * Perform everything needed to init the hadoop binding.
- * This assumes that the service is already in inited or started state
- * @throws IOException
- * @throws SliderException
- */
- protected void initHadoopBinding() throws IOException, SliderException {
- // validate the client
- validateSliderClientEnvironment(null);
- //create the YARN client
- yarnClient = new SliderYarnClientImpl();
- yarnClient.init(getConfig());
- if (getServiceState() == STATE.STARTED) {
- yarnClient.start();
- }
- addService(yarnClient);
- yarnAppListClient =
- new YarnAppListClient(yarnClient, getUsername(), getConfig());
- // create the filesystem
- sliderFileSystem = new SliderFileSystem(getConfig());
- }
-
- /**
- * Delete the zookeeper node associated with the calling user and the cluster
- * TODO: YARN registry operations
- **/
- @VisibleForTesting
- public boolean deleteZookeeperNode(String clusterName) throws YarnException, IOException {
- String user = getUsername();
- String zkPath = ZKIntegration.mkClusterPath(user, clusterName);
- Exception e = null;
- try {
- ZKIntegration client = getZkClient(clusterName, user);
- if (client != null) {
- if (client.exists(zkPath)) {
- log.info("Deleting zookeeper path {}", zkPath);
- }
- client.deleteRecursive(zkPath);
- return true;
- }
- } catch (InterruptedException | BadConfigException | KeeperException ex) {
- e = ex;
- }
- if (e != null) {
- log.warn("Unable to recursively delete zk node {}", zkPath, e);
- }
-
- return false;
- }
-
- /**
- * Create the zookeeper node associated with the calling user and the cluster
- *
- * @param clusterName slider application name
- * @param nameOnly should the name only be created (i.e. don't create ZK node)
- * @return the path, using the policy implemented in
- * {@link ZKIntegration#mkClusterPath(String, String)}
- * @throws YarnException
- * @throws IOException
- */
- @VisibleForTesting
- public String createZookeeperNode(String clusterName, Boolean nameOnly) throws YarnException, IOException {
- try {
- return createZookeeperNodeInner(clusterName, nameOnly);
- } catch (KeeperException.NodeExistsException e) {
- return null;
- } catch (KeeperException e) {
- return null;
- } catch (InterruptedException e) {
- throw new InterruptedIOException(e.toString());
- }
- }
-
- /**
- * Create the zookeeper node associated with the calling user and the cluster
- * -throwing exceptions on any failure
- * @param clusterName cluster name
- * @param nameOnly create the path, not the node
- * @return the path, using the policy implemented in
- * {@link ZKIntegration#mkClusterPath(String, String)}
- * @throws YarnException
- * @throws IOException
- * @throws KeeperException
- * @throws InterruptedException
- */
- @VisibleForTesting
- public String createZookeeperNodeInner(String clusterName, Boolean nameOnly)
- throws YarnException, IOException, KeeperException, InterruptedException {
- String user = getUsername();
- String zkPath = ZKIntegration.mkClusterPath(user, clusterName);
- if (nameOnly) {
- return zkPath;
- }
- ZKIntegration client = getZkClient(clusterName, user);
- if (client != null) {
- // set up the permissions. This must be done differently on a secure cluster from an insecure
- // one
- List zkperms = new ArrayList<>();
- if (UserGroupInformation.isSecurityEnabled()) {
- zkperms.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.AUTH_IDS));
- zkperms.add(new ACL(ZooDefs.Perms.READ, ZooDefs.Ids.ANYONE_ID_UNSAFE));
- } else {
- zkperms.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE));
- }
- client.createPath(zkPath, "",
- zkperms,
- CreateMode.PERSISTENT);
- return zkPath;
- } else {
- return null;
- }
- }
-
- /**
- * Gets a zookeeper client, returns null if it cannot connect to zookeeper
- **/
- protected ZKIntegration getZkClient(String clusterName, String user) throws YarnException {
- String registryQuorum = lookupZKQuorum();
- ZKIntegration client = null;
- try {
- BlockingZKWatcher watcher = new BlockingZKWatcher();
- client = ZKIntegration.newInstance(registryQuorum, user, clusterName, true, false, watcher,
- ZKIntegration.SESSION_TIMEOUT);
- boolean fromCache = client.init();
- if (!fromCache) {
- watcher.waitForZKConnection(2 * 1000);
- }
- } catch (InterruptedException e) {
- client = null;
- log.warn("Interrupted - unable to connect to zookeeper quorum {}",
- registryQuorum, e);
- } catch (IOException e) {
- log.warn("Unable to connect to zookeeper quorum {}", registryQuorum, e);
- }
- return client;
- }
-
- /**
- * Keep this signature for backward compatibility with
- * force=true by default.
- */
- @Override
- public int actionDestroy(String appName)
- throws YarnException, IOException {
- validateClusterName(appName);
- verifyNoLiveApp(appName, "Destroy");
- Path appDir = sliderFileSystem.buildClusterDirPath(appName);
- FileSystem fs = sliderFileSystem.getFileSystem();
- if (fs.exists(appDir)) {
- if (fs.delete(appDir, true)) {
- log.info("Successfully deleted application dir for " + appName);
- } else {
- String message =
- "Failed to delete application + " + appName + " at: " + appDir;
- log.info(message);
- throw new YarnException(message);
- }
- }
- if (!deleteZookeeperNode(appName)) {
- String message =
- "Failed to cleanup cleanup application " + appName + " in zookeeper";
- log.warn(message);
- throw new YarnException(message);
- }
-
- //TODO clean registry?
- String registryPath = SliderRegistryUtils.registryPathForInstance(
- appName);
- try {
- getRegistryOperations().delete(registryPath, true);
- } catch (IOException e) {
- log.warn("Error deleting registry entry {}: {} ", registryPath, e, e);
- } catch (SliderException e) {
- log.warn("Error binding to registry {} ", e, e);
- }
-
- log.info("Destroyed cluster {}", appName);
- return EXIT_SUCCESS;
- }
-
-
- @Override
- public int actionAmSuicide(String clustername,
- ActionAMSuicideArgs args) throws YarnException, IOException {
- SliderClusterOperations clusterOperations =
- createClusterOperations(clustername);
- clusterOperations.amSuicide(args.message, args.exitcode, args.waittime);
- return EXIT_SUCCESS;
- }
-
- private Application getApplicationFromArgs(String clusterName,
- AbstractClusterBuildingActionArgs args) throws IOException {
- File file = args.getAppDef();
- Path filePath = new Path(file.getAbsolutePath());
- log.info("Loading app definition from: " + filePath);
- Application application =
- jsonSerDeser.load(FileSystem.getLocal(getConfig()), filePath);
- if(args.lifetime > 0) {
- application.setLifetime(args.lifetime);
- }
- application.setName(clusterName);
- return application;
- }
-
- public int actionBuild(Application application) throws YarnException,
- IOException {
- Path appDir = checkAppNotExistOnHdfs(application);
- ServiceApiUtil.validateAndResolveApplication(application,
- sliderFileSystem, getConfig());
- persistApp(appDir, application);
- deployedClusterName = application.getName();
- return EXIT_SUCCESS;
- }
-
- public ApplicationId actionCreate(Application application)
- throws IOException, YarnException {
- String appName = application.getName();
- validateClusterName(appName);
- ServiceApiUtil.validateAndResolveApplication(application,
- sliderFileSystem, getConfig());
- verifyNoLiveApp(appName, "Create");
- Path appDir = checkAppNotExistOnHdfs(application);
-
- ApplicationId appId = submitApp(application);
- application.setId(appId.toString());
- // write app definition on to hdfs
- persistApp(appDir, application);
- return appId;
- //TODO deal with registry
- }
-
- private ApplicationId submitApp(Application app)
- throws IOException, YarnException {
- String appName = app.getName();
- Configuration conf = getConfig();
- Path appRootDir = sliderFileSystem.buildClusterDirPath(app.getName());
- deployedClusterName = appName;
-
- YarnClientApplication yarnApp = yarnClient.createApplication();
- ApplicationSubmissionContext submissionContext =
- yarnApp.getApplicationSubmissionContext();
- ServiceApiUtil.validateCompResourceSize(
- yarnApp.getNewApplicationResponse().getMaximumResourceCapability(),
- app);
-
- applicationId = submissionContext.getApplicationId();
- submissionContext.setKeepContainersAcrossApplicationAttempts(true);
- if (app.getLifetime() > 0) {
- Map appTimeout = new HashMap<>();
- appTimeout.put(ApplicationTimeoutType.LIFETIME, app.getLifetime());
- submissionContext.setApplicationTimeouts(appTimeout);
- }
- submissionContext.setMaxAppAttempts(conf.getInt(KEY_AM_RESTART_LIMIT, 2));
-
- Map localResources = new HashMap<>();
-
- // copy local slideram-log4j.properties to hdfs and add to localResources
- boolean hasSliderAMLog4j =
- addAMLog4jResource(appName, conf, localResources);
- // copy jars to hdfs and add to localResources
- addJarResource(appName, localResources);
- // add keytab if in secure env
- addKeytabResourceIfSecure(sliderFileSystem, localResources, conf, appName);
- printLocalResources(localResources);
-
- //TODO SliderAMClientProvider#copyEnvVars
- //TODO localResource putEnv
-
- Map env = addAMEnv(conf);
-
- // create AM CLI
- String cmdStr =
- buildCommandLine(appName, conf, appRootDir, hasSliderAMLog4j);
-
- //TODO set log aggregation context
- //TODO set retry window
- submissionContext.setResource(Resource.newInstance(
- conf.getLong(KEY_AM_RESOURCE_MEM, DEFAULT_KEY_AM_RESOURCE_MEM), 1));
- submissionContext.setQueue(conf.get(KEY_YARN_QUEUE, app.getQueue()));
- submissionContext.setApplicationName(appName);
- submissionContext.setApplicationType(SliderKeys.APP_TYPE);
- Set appTags =
- AbstractClientProvider.createApplicationTags(appName, null, null);
- if (!appTags.isEmpty()) {
- submissionContext.setApplicationTags(appTags);
- }
- ContainerLaunchContext amLaunchContext =
- Records.newRecord(ContainerLaunchContext.class);
- amLaunchContext.setCommands(Collections.singletonList(cmdStr));
- amLaunchContext.setEnvironment(env);
- amLaunchContext.setLocalResources(localResources);
- addCredentialsIfSecure(conf, amLaunchContext);
- submissionContext.setAMContainerSpec(amLaunchContext);
- submitApplication(submissionContext);
- return submissionContext.getApplicationId();
- }
-
- @VisibleForTesting
- public ApplicationId submitApplication(ApplicationSubmissionContext context)
- throws IOException, YarnException {
- return yarnClient.submitApplication(context);
- }
-
- private void printLocalResources(Map map) {
- log.info("Added LocalResource for localization: ");
- StringBuilder builder = new StringBuilder();
- for (Map.Entry entry : map.entrySet()) {
- builder.append(entry.getKey()).append(" -> ")
- .append(entry.getValue().getResource().getFile())
- .append(System.lineSeparator());
- }
- log.info(builder.toString());
- }
-
- private void addCredentialsIfSecure(Configuration conf,
- ContainerLaunchContext amLaunchContext) throws IOException {
- if (UserGroupInformation.isSecurityEnabled()) {
- // pick up oozie credentials
- Credentials credentials =
- CredentialUtils.loadTokensFromEnvironment(System.getenv(), conf);
- if (credentials == null) {
- // nothing from oozie, so build up directly
- credentials = new Credentials(
- UserGroupInformation.getCurrentUser().getCredentials());
- CredentialUtils.addRMRenewableFSDelegationTokens(conf,
- sliderFileSystem.getFileSystem(), credentials);
- } else {
- log.info("Using externally supplied credentials to launch AM");
- }
- amLaunchContext.setTokens(CredentialUtils.marshallCredentials(credentials));
- }
- }
-
- private String buildCommandLine(String appName, Configuration conf,
- Path appRootDir, boolean hasSliderAMLog4j) throws BadConfigException {
- JavaCommandLineBuilder CLI = new JavaCommandLineBuilder();
- CLI.forceIPv4().headless();
- //TODO CLI.setJVMHeap
- //TODO CLI.addJVMOPTS
- if (hasSliderAMLog4j) {
- CLI.sysprop(SYSPROP_LOG4J_CONFIGURATION, LOG4J_SERVER_PROP_FILENAME);
- CLI.sysprop(SYSPROP_LOG_DIR, ApplicationConstants.LOG_DIR_EXPANSION_VAR);
- }
- CLI.add(ServiceMaster.class.getCanonicalName());
- CLI.add(ACTION_CREATE, appName);
- //TODO debugAM CLI.add(Arguments.ARG_DEBUG)
- CLI.add(Arguments.ARG_CLUSTER_URI, new Path(appRootDir, appName + ".json"));
- // InetSocketAddress rmSchedulerAddress = getRmSchedulerAddress(conf);
-// String rmAddr = NetUtils.getHostPortString(rmSchedulerAddress);
-// CLI.add(Arguments.ARG_RM_ADDR, rmAddr);
- // pass the registry binding
- CLI.addConfOptionToCLI(conf, RegistryConstants.KEY_REGISTRY_ZK_ROOT,
- RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT);
- CLI.addMandatoryConfOption(conf, RegistryConstants.KEY_REGISTRY_ZK_QUORUM);
- if(isHadoopClusterSecure(conf)) {
- //TODO Is this required ??
- // if the cluster is secure, make sure that
- // the relevant security settings go over
- CLI.addConfOption(conf, DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY);
- }
-// // copy over any/all YARN RM client values, in case the server-side XML conf file
-// // has the 0.0.0.0 address
-// CLI.addConfOptions(conf, YarnConfiguration.RM_ADDRESS,
-// YarnConfiguration.RM_CLUSTER_ID, YarnConfiguration.RM_HOSTNAME,
-// YarnConfiguration.RM_PRINCIPAL);
-
- // write out the path output
- CLI.addOutAndErrFiles(STDOUT_AM, STDERR_AM);
- String cmdStr = CLI.build();
- log.info("Completed setting up app master command: {}", cmdStr);
- return cmdStr;
- }
-
- private Map addAMEnv(Configuration conf)
- throws IOException {
- Map env = new HashMap<>();
- ClasspathConstructor classpath =
- buildClasspath(SliderKeys.SUBMITTED_CONF_DIR, "lib",
- sliderFileSystem, getUsingMiniMRCluster());
- env.put("CLASSPATH", classpath.buildClasspath());
- env.put("LANG", "en_US.UTF-8");
- env.put("LC_ALL", "en_US.UTF-8");
- env.put("LANGUAGE", "en_US.UTF-8");
- String jaas = System.getenv(HADOOP_JAAS_DEBUG);
- if (jaas != null) {
- env.put(HADOOP_JAAS_DEBUG, jaas);
- }
- if (!UserGroupInformation.isSecurityEnabled()) {
- String userName = UserGroupInformation.getCurrentUser().getUserName();
- log.info("Run as user " + userName);
- // HADOOP_USER_NAME env is used by UserGroupInformation when log in
- // This env makes AM run as this user
- env.put("HADOOP_USER_NAME", userName);
- }
- env.putAll(getAmLaunchEnv(conf));
- log.info("AM env: \n{}", stringifyMap(env));
- return env;
- }
-
- protected Path addJarResource(String appName,
- Map localResources)
- throws IOException, SliderException {
- Path libPath = sliderFileSystem.buildClusterDirPath(appName);
- ProviderUtils
- .addProviderJar(localResources, ServiceMaster.class, SLIDER_JAR,
- sliderFileSystem, libPath, "lib", false);
- Path dependencyLibTarGzip = sliderFileSystem.getDependencyTarGzip();
- if (sliderFileSystem.isFile(dependencyLibTarGzip)) {
- log.info("Loading lib tar from " + sliderFileSystem.getFileSystem()
- .getScheme() + ": " + dependencyLibTarGzip);
- SliderUtils.putAmTarGzipAndUpdate(localResources, sliderFileSystem);
- } else {
- String[] libs = SliderUtils.getLibDirs();
- log.info("Loading dependencies from local file system: " + Arrays
- .toString(libs));
- for (String libDirProp : libs) {
- ProviderUtils
- .addAllDependencyJars(localResources, sliderFileSystem, libPath,
- "lib", libDirProp);
- }
- }
- return libPath;
- }
-
- private boolean addAMLog4jResource(String appName, Configuration conf,
- Map localResources)
- throws IOException, BadClusterStateException {
- boolean hasSliderAMLog4j = false;
- String hadoopConfDir =
- System.getenv(ApplicationConstants.Environment.HADOOP_CONF_DIR.name());
- if (hadoopConfDir != null) {
- File localFile =
- new File(hadoopConfDir, SliderKeys.LOG4J_SERVER_PROP_FILENAME);
- if (localFile.exists()) {
- Path localFilePath = createLocalPath(localFile);
- Path appDirPath = sliderFileSystem.buildClusterDirPath(appName);
- Path remoteConfPath =
- new Path(appDirPath, SliderKeys.SUBMITTED_CONF_DIR);
- Path remoteFilePath =
- new Path(remoteConfPath, SliderKeys.LOG4J_SERVER_PROP_FILENAME);
- copy(conf, localFilePath, remoteFilePath);
- LocalResource localResource = sliderFileSystem
- .createAmResource(remoteConfPath, LocalResourceType.FILE);
- localResources.put(localFilePath.getName(), localResource);
- hasSliderAMLog4j = true;
- }
- }
- return hasSliderAMLog4j;
- }
-
- private Path checkAppNotExistOnHdfs(Application application)
- throws IOException, SliderException {
- Path appDir = sliderFileSystem.buildClusterDirPath(application.getName());
- sliderFileSystem.verifyDirectoryNonexistent(
- new Path(appDir, application.getName() + ".json"));
- return appDir;
- }
-
- private Path checkAppExistOnHdfs(String appName)
- throws IOException, SliderException {
- Path appDir = sliderFileSystem.buildClusterDirPath(appName);
- sliderFileSystem.verifyPathExists(
- new Path(appDir, appName + ".json"));
- return appDir;
- }
-
- private void persistApp(Path appDir, Application application)
- throws IOException, SliderException {
- FsPermission appDirPermission = new FsPermission("750");
- sliderFileSystem.createWithPermissions(appDir, appDirPermission);
- Path appJson = new Path(appDir, application.getName() + ".json");
- jsonSerDeser
- .save(sliderFileSystem.getFileSystem(), appJson, application, true);
- log.info(
- "Persisted application " + application.getName() + " at " + appJson);
- }
-
- private void addKeytabResourceIfSecure(SliderFileSystem fileSystem,
- Map localResource, Configuration conf,
- String appName) throws IOException, BadConfigException {
- if (!UserGroupInformation.isSecurityEnabled()) {
- return;
- }
- String keytabPreInstalledOnHost =
- conf.get(SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH);
- if (StringUtils.isEmpty(keytabPreInstalledOnHost)) {
- String amKeytabName =
- conf.get(SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME);
- String keytabDir = conf.get(SliderXmlConfKeys.KEY_HDFS_KEYTAB_DIR);
- Path keytabPath =
- fileSystem.buildKeytabPath(keytabDir, amKeytabName, appName);
- if (fileSystem.getFileSystem().exists(keytabPath)) {
- LocalResource keytabRes =
- fileSystem.createAmResource(keytabPath, LocalResourceType.FILE);
- localResource
- .put(SliderKeys.KEYTAB_DIR + "/" + amKeytabName, keytabRes);
- log.info("Adding AM keytab on hdfs: " + keytabPath);
- } else {
- log.warn("No keytab file was found at {}.", keytabPath);
- if (conf.getBoolean(KEY_AM_LOGIN_KEYTAB_REQUIRED, false)) {
- throw new BadConfigException("No keytab file was found at %s.",
- keytabPath);
- } else {
- log.warn("The AM will be "
- + "started without a kerberos authenticated identity. "
- + "The application is therefore not guaranteed to remain "
- + "operational beyond 24 hours.");
- }
- }
- }
- }
-
- @Override
- public int actionUpgrade(String clustername, ActionUpgradeArgs upgradeArgs)
- throws YarnException, IOException {
- //TODO
- return 0;
- }
-
- @Override
- public int actionKeytab(ActionKeytabArgs keytabInfo)
- throws YarnException, IOException {
- if (keytabInfo.install) {
- return actionInstallKeytab(keytabInfo);
- } else if (keytabInfo.delete) {
- return actionDeleteKeytab(keytabInfo);
- } else if (keytabInfo.list) {
- return actionListKeytab(keytabInfo);
- } else {
- throw new BadCommandArgumentsException(
- "Keytab option specified not found.\n"
- + CommonArgs.usage(serviceArgs, ACTION_KEYTAB));
- }
- }
-
- private int actionListKeytab(ActionKeytabArgs keytabInfo) throws IOException {
- String folder = keytabInfo.folder != null ? keytabInfo.folder : StringUtils.EMPTY;
- Path keytabPath = sliderFileSystem.buildKeytabInstallationDirPath(folder);
- RemoteIterator files =
- sliderFileSystem.getFileSystem().listFiles(keytabPath, true);
- log.info("Keytabs:");
- while (files.hasNext()) {
- log.info("\t" + files.next().getPath().toString());
- }
-
- return EXIT_SUCCESS;
- }
-
- private int actionDeleteKeytab(ActionKeytabArgs keytabInfo)
- throws BadCommandArgumentsException, IOException {
- if (StringUtils.isEmpty(keytabInfo.folder)) {
- throw new BadCommandArgumentsException(
- "A valid destination keytab sub-folder name is required (e.g. 'security').\n"
- + CommonArgs.usage(serviceArgs, ACTION_KEYTAB));
- }
-
- if (StringUtils.isEmpty(keytabInfo.keytab)) {
- throw new BadCommandArgumentsException("A keytab name is required.");
- }
-
- Path pkgPath = sliderFileSystem.buildKeytabInstallationDirPath(keytabInfo.folder);
-
- Path fileInFs = new Path(pkgPath, keytabInfo.keytab );
- log.info("Deleting keytab {}", fileInFs);
- FileSystem sfs = sliderFileSystem.getFileSystem();
- require(sfs.exists(fileInFs), "No keytab to delete found at %s",
- fileInFs.toUri());
- sfs.delete(fileInFs, false);
-
- return EXIT_SUCCESS;
- }
-
- private int actionInstallKeytab(ActionKeytabArgs keytabInfo)
- throws BadCommandArgumentsException, IOException {
- Path srcFile = null;
- require(isSet(keytabInfo.folder),
- "A valid destination keytab sub-folder name is required (e.g. 'security').\n"
- + CommonArgs.usage(serviceArgs, ACTION_KEYTAB));
-
- requireArgumentSet(Arguments.ARG_KEYTAB, keytabInfo.keytab);
- File keytabFile = new File(keytabInfo.keytab);
- require(keytabFile.isFile(),
- "Unable to access supplied keytab file at %s", keytabFile.getAbsolutePath());
- srcFile = new Path(keytabFile.toURI());
-
- Path pkgPath = sliderFileSystem.buildKeytabInstallationDirPath(keytabInfo.folder);
- FileSystem sfs = sliderFileSystem.getFileSystem();
- sfs.mkdirs(pkgPath);
- sfs.setPermission(pkgPath, new FsPermission(
- FsAction.ALL, FsAction.NONE, FsAction.NONE));
-
- Path fileInFs = new Path(pkgPath, srcFile.getName());
- log.info("Installing keytab {} at {} and overwrite is {}.",
- srcFile, fileInFs, keytabInfo.overwrite);
- require(!(sfs.exists(fileInFs) && !keytabInfo.overwrite),
- "Keytab exists at %s. Use --overwrite to overwrite.", fileInFs.toUri());
-
- sfs.copyFromLocalFile(false, keytabInfo.overwrite, srcFile, fileInFs);
- sfs.setPermission(fileInFs,
- new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE));
-
- return EXIT_SUCCESS;
- }
-
- @Override
- public int actionResource(ActionResourceArgs resourceInfo)
- throws YarnException, IOException {
- if (resourceInfo.help) {
- actionHelp(ACTION_RESOURCE);
- return EXIT_SUCCESS;
- } else if (resourceInfo.install) {
- return actionInstallResource(resourceInfo);
- } else if (resourceInfo.delete) {
- return actionDeleteResource(resourceInfo);
- } else if (resourceInfo.list) {
- return actionListResource(resourceInfo);
- } else {
- throw new BadCommandArgumentsException(
- "Resource option specified not found.\n"
- + CommonArgs.usage(serviceArgs, ACTION_RESOURCE));
- }
- }
-
- private int actionListResource(ActionResourceArgs resourceInfo) throws IOException {
- String folder = resourceInfo.folder != null ? resourceInfo.folder : StringUtils.EMPTY;
- Path path = sliderFileSystem.buildResourcePath(folder);
- RemoteIterator files =
- sliderFileSystem.getFileSystem().listFiles(path, true);
- log.info("Resources:");
- while (files.hasNext()) {
- log.info("\t" + files.next().getPath().toString());
- }
-
- return EXIT_SUCCESS;
- }
-
- private int actionDeleteResource(ActionResourceArgs resourceInfo)
- throws BadCommandArgumentsException, IOException {
- if (StringUtils.isEmpty(resourceInfo.resource)) {
- throw new BadCommandArgumentsException("A file name is required.");
- }
-
- Path fileInFs;
- if (resourceInfo.folder == null) {
- fileInFs = sliderFileSystem.buildResourcePath(resourceInfo.resource);
- } else {
- fileInFs = sliderFileSystem.buildResourcePath(resourceInfo.folder,
- resourceInfo.resource);
- }
-
- log.info("Deleting resource {}", fileInFs);
- FileSystem sfs = sliderFileSystem.getFileSystem();
- require(sfs.exists(fileInFs), "No resource to delete found at %s", fileInFs.toUri());
- sfs.delete(fileInFs, true);
-
- return EXIT_SUCCESS;
- }
-
- private int actionInstallResource(ActionResourceArgs resourceInfo)
- throws BadCommandArgumentsException, IOException {
- Path srcFile = null;
- String folder = resourceInfo.folder != null ? resourceInfo.folder : StringUtils.EMPTY;
-
- requireArgumentSet(Arguments.ARG_RESOURCE, resourceInfo.resource);
- File file = new File(resourceInfo.resource);
- require(file.isFile() || file.isDirectory(),
- "Unable to access supplied file at %s", file.getAbsolutePath());
-
- File[] files;
- if (file.isDirectory()) {
- files = file.listFiles();
- } else {
- files = new File[] { file };
- }
-
- Path pkgPath = sliderFileSystem.buildResourcePath(folder);
- FileSystem sfs = sliderFileSystem.getFileSystem();
-
- if (!sfs.exists(pkgPath)) {
- sfs.mkdirs(pkgPath);
- sfs.setPermission(pkgPath, new FsPermission(
- FsAction.ALL, FsAction.NONE, FsAction.NONE));
- } else {
- require(sfs.isDirectory(pkgPath), "Specified folder %s exists and is " +
- "not a directory", folder);
- }
-
- if (files != null) {
- for (File f : files) {
- srcFile = new Path(f.toURI());
-
- Path fileInFs = new Path(pkgPath, srcFile.getName());
- log.info("Installing file {} at {} and overwrite is {}.",
- srcFile, fileInFs, resourceInfo.overwrite);
- require(!(sfs.exists(fileInFs) && !resourceInfo.overwrite),
- "File exists at %s. Use --overwrite to overwrite.", fileInFs.toUri());
-
- sfs.copyFromLocalFile(false, resourceInfo.overwrite, srcFile, fileInFs);
- sfs.setPermission(fileInFs,
- new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE));
- }
- }
-
- return EXIT_SUCCESS;
- }
-
- @Override
- public int actionClient(ActionClientArgs clientInfo) throws
- YarnException,
- IOException {
- if (clientInfo.install) {
- // TODO implement client install
- throw new UnsupportedOperationException("Client install not yet " +
- "supported");
- } else {
- throw new BadCommandArgumentsException(
- "Only install, keystore, and truststore commands are supported for the client.\n"
- + CommonArgs.usage(serviceArgs, ACTION_CLIENT));
-
- }
- }
-
- @Override
- public int actionUpdate(String clustername,
- AbstractClusterBuildingActionArgs buildInfo) throws
- YarnException, IOException {
- if (buildInfo.lifetime > 0) {
- updateLifetime(clustername, buildInfo.lifetime);
- } else {
- //TODO upgrade
- }
- return EXIT_SUCCESS;
- }
-
- public String updateLifetime(String appName, long lifetime)
- throws YarnException, IOException {
- EnumSet appStates = EnumSet.range(NEW, RUNNING);
- ApplicationReport report = findInstance(appName, appStates);
- if (report == null) {
- throw new YarnException("Application not found for " + appName);
- }
- ApplicationId appId = report.getApplicationId();
- log.info("Updating lifetime of an application: appName = " + appName
- + ", appId = " + appId+ ", lifetime = " + lifetime);
- Map map = new HashMap<>();
- String newTimeout =
- Times.formatISO8601(System.currentTimeMillis() + lifetime * 1000);
- map.put(ApplicationTimeoutType.LIFETIME, newTimeout);
- UpdateApplicationTimeoutsRequest request =
- UpdateApplicationTimeoutsRequest.newInstance(appId, map);
- yarnClient.updateApplicationTimeouts(request);
- log.info("Successfully updated lifetime for an application: appName = "
- + appName + ", appId = " + appId
- + ". New expiry time in ISO8601 format is " + newTimeout);
- return newTimeout;
- }
-
- protected Map getAmLaunchEnv(Configuration config) {
- String sliderAmLaunchEnv = config.get(KEY_AM_LAUNCH_ENV);
- log.debug("{} = {}", KEY_AM_LAUNCH_ENV, sliderAmLaunchEnv);
- // Multiple env variables can be specified with a comma (,) separator
- String[] envs = StringUtils.isEmpty(sliderAmLaunchEnv) ? null
- : sliderAmLaunchEnv.split(",");
- if (ArrayUtils.isEmpty(envs)) {
- return Collections.emptyMap();
- }
- Map amLaunchEnv = new HashMap<>();
- for (String env : envs) {
- if (StringUtils.isNotEmpty(env)) {
- // Each env name/value is separated by equals sign (=)
- String[] tokens = env.split("=");
- if (tokens != null && tokens.length == 2) {
- String envKey = tokens[0];
- String envValue = tokens[1];
- for (Map.Entry placeholder : generatePlaceholderKeyValueMap(
- env).entrySet()) {
- if (StringUtils.isNotEmpty(placeholder.getValue())) {
- envValue = envValue.replaceAll(
- Pattern.quote(placeholder.getKey()), placeholder.getValue());
- }
- }
- if (Shell.WINDOWS) {
- envValue = "%" + envKey + "%;" + envValue;
- } else {
- envValue = "$" + envKey + ":" + envValue;
- }
- log.info("Setting AM launch env {}={}", envKey, envValue);
- amLaunchEnv.put(envKey, envValue);
- }
- }
- }
- return amLaunchEnv;
- }
-
- protected Map generatePlaceholderKeyValueMap(String env) {
- String PLACEHOLDER_PATTERN = "\\$\\{[^{]+\\}";
- Pattern placeholderPattern = Pattern.compile(PLACEHOLDER_PATTERN);
- Matcher placeholderMatcher = placeholderPattern.matcher(env);
- Map placeholderKeyValueMap = new HashMap<>();
- if (placeholderMatcher.find()) {
- String placeholderKey = placeholderMatcher.group();
- String systemKey = placeholderKey
- .substring(2, placeholderKey.length() - 1).toUpperCase(Locale.ENGLISH)
- .replaceAll("\\.", "_");
- String placeholderValue = getSystemEnv(systemKey);
- log.debug("Placeholder {}={}", placeholderKey, placeholderValue);
- placeholderKeyValueMap.put(placeholderKey, placeholderValue);
- }
- return placeholderKeyValueMap;
- }
-
- /**
- * verify that a live cluster isn't there
- * @param clustername cluster name
- * @param action
- * @throws SliderException with exit code EXIT_CLUSTER_LIVE
- * if a cluster of that name is either live or starting up.
- */
- public void verifyNoLiveApp(String clustername, String action) throws
- IOException,
- YarnException {
- List existing = findAllLiveInstances(clustername);
-
- if (!existing.isEmpty()) {
- throw new SliderException(EXIT_APPLICATION_IN_USE,
- action +" failed for "
- + clustername
- + ": "
- + E_CLUSTER_RUNNING + " :" +
- existing.get(0));
- }
- }
-
- public String getUsername() throws IOException {
- return RegistryUtils.currentUser();
- }
-
- /**
- * Get the name of any deployed cluster
- * @return the cluster name
- */
- public String getDeployedClusterName() {
- return deployedClusterName;
- }
-
- /**
- * ask if the client is using a mini MR cluster
- * @return true if they are
- */
- private boolean getUsingMiniMRCluster() {
- return getConfig().getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER,
- false);
- }
-
-
- /**
- * List Slider instances belonging to a specific user with a specific app
- * name and within a set of app states.
- * @param user user: "" means all users, null means "default"
- * @param appName name of the application set as a tag
- * @param appStates a set of states the applications should be in
- * @return a possibly empty list of Slider AMs
- */
- public List listSliderInstances(String user,
- String appName, EnumSet appStates)
- throws YarnException, IOException {
- return yarnAppListClient.listInstances(user, appName, appStates);
- }
-
- /**
- * A basic list action to list live instances
- * @param clustername cluster name
- * @return success if the listing was considered successful
- * @throws IOException
- * @throws YarnException
- */
- public int actionList(String clustername) throws IOException, YarnException {
- ActionListArgs args = new ActionListArgs();
- args.live = true;
- return actionList(clustername, args);
- }
-
- /**
- * Implement the list action.
- * @param clustername List out specific instance name
- * @param args Action list arguments
- * @return 0 if one or more entries were listed
- * @throws IOException
- * @throws YarnException
- * @throws UnknownApplicationInstanceException if a specific instance
- * was named but it was not found
- */
- @Override
- public int actionList(String clustername, ActionListArgs args)
- throws IOException, YarnException {
- Set appInstances = getApplicationList(clustername, args);
- if (!appInstances.isEmpty()) {
- return EXIT_SUCCESS;
- } else {
- return EXIT_FALSE;
- }
- }
-
- /**
- * Retrieve a list of application instances satisfying the query criteria.
- *
- * @param clustername
- * List out specific instance name (set null for all)
- * @param args
- * Action list arguments
- * @return the list of application names which satisfies the list criteria
- * @throws IOException
- * @throws YarnException
- * @throws UnknownApplicationInstanceException
- * if a specific instance was named but it was not found
- */
- public Set getApplicationList(String clustername,
- ActionListArgs args) throws IOException, YarnException {
- if (args.help) {
- actionHelp(ACTION_LIST);
- // the above call throws an exception so the return is not really required
- return Collections.emptySet();
- }
- boolean live = args.live;
- String state = args.state;
- boolean listContainers = args.containers;
- boolean verbose = args.verbose;
- String version = args.version;
- Set components = args.components;
-
- if (live && !state.isEmpty()) {
- throw new BadCommandArgumentsException(
- Arguments.ARG_LIVE + " and " + Arguments.ARG_STATE + " are exclusive");
- }
- if (listContainers && isUnset(clustername)) {
- throw new BadCommandArgumentsException(
- "Should specify an application instance with "
- + Arguments.ARG_CONTAINERS);
- }
- // specifying both --version and --components with --containers is okay
- if (StringUtils.isNotEmpty(version) && !listContainers) {
- throw new BadCommandArgumentsException(Arguments.ARG_VERSION
- + " can be specified only with " + Arguments.ARG_CONTAINERS);
- }
- if (!components.isEmpty() && !listContainers) {
- throw new BadCommandArgumentsException(Arguments.ARG_COMPONENTS
- + " can be specified only with " + Arguments.ARG_CONTAINERS);
- }
-
- // flag to indicate only services in a specific state are to be listed
- boolean listOnlyInState = live || !state.isEmpty();
-
- YarnApplicationState min, max;
- if (live) {
- min = NEW;
- max = RUNNING;
- } else if (!state.isEmpty()) {
- YarnApplicationState stateVal = extractYarnApplicationState(state);
- min = max = stateVal;
- } else {
- min = NEW;
- max = KILLED;
- }
- // get the complete list of persistent instances
- Map persistentInstances = sliderFileSystem.listPersistentInstances();
-
- if (persistentInstances.isEmpty() && isUnset(clustername)) {
- // an empty listing is a success if no cluster was named
- log.debug("No application instances found");
- return Collections.emptySet();
- }
-
- // and those the RM knows about
- EnumSet appStates = EnumSet.range(min, max);
- List instances = listSliderInstances(null, clustername,
- appStates);
- sortApplicationsByMostRecent(instances);
- Map reportMap =
- buildApplicationReportMap(instances, min, max);
- log.debug("Persisted {} deployed {} filtered[{}-{}] & de-duped to {}",
- persistentInstances.size(),
- instances.size(),
- min, max,
- reportMap.size() );
-
- List containers = null;
- if (isSet(clustername)) {
- // only one instance is expected
- // resolve the persistent value
- Path persistent = persistentInstances.get(clustername);
- if (persistent == null) {
- throw unknownClusterException(clustername);
- }
- // create a new map with only that instance in it.
- // this restricts the output of results to this instance
- persistentInstances = new HashMap<>();
- persistentInstances.put(clustername, persistent);
- if (listContainers) {
- containers = getContainers(clustername);
- }
- }
-
- // at this point there is either the entire list or a stripped down instance
- Set listedInstances = new HashSet();
- for (String name : persistentInstances.keySet()) {
- ApplicationReport report = reportMap.get(name);
- if (!listOnlyInState || report != null) {
- // list the details if all were requested, or the filtering contained
- // a report
- listedInstances.add(report);
- // containers will be non-null when only one instance is requested
- String details = instanceDetailsToString(name, report,
- containers, version, components, verbose);
- print(details);
- }
- }
-
- return listedInstances;
- }
-
- public List getContainers(String name)
- throws YarnException, IOException {
- SliderClusterOperations clusterOps = new SliderClusterOperations(
- bondToCluster(name));
- try {
- return clusterOps.getContainers();
- } catch (NoSuchNodeException e) {
- throw new BadClusterStateException(
- "Containers not found for application instance %s", name);
- }
- }
-
-
- /**
- * Extract the state of a Yarn application --state argument
- * @param state state argument
- * @return the application state
- * @throws BadCommandArgumentsException if the argument did not match
- * any known state
- */
- private YarnApplicationState extractYarnApplicationState(String state) throws
- BadCommandArgumentsException {
- YarnApplicationState stateVal;
- try {
- stateVal = YarnApplicationState.valueOf(state.toUpperCase(Locale.ENGLISH));
- } catch (IllegalArgumentException e) {
- throw new BadCommandArgumentsException("Unknown state: " + state);
-
- }
- return stateVal;
- }
-
- /**
- * Is an application active: accepted or running
- * @param report the application report
- * @return true if it is running or scheduled to run.
- */
- public boolean isApplicationActive(ApplicationReport report) {
- return report.getYarnApplicationState() == RUNNING
- || report.getYarnApplicationState() == YarnApplicationState.ACCEPTED;
- }
-
- /**
- * Implement the islive action: probe for a cluster of the given name existing
- * @return exit code
- */
-
- @Override
- @VisibleForTesting
- public int actionFlex(String appName, ActionFlexArgs args)
- throws YarnException, IOException {
- Map componentCounts = new HashMap<>(args.getComponentMap()
- .size());
- for (Entry entry : args.getComponentMap().entrySet()) {
- long numberOfContainers = Long.parseLong(entry.getValue());
- componentCounts.put(entry.getKey(), numberOfContainers);
- }
- // throw usage exception if no changes proposed
- if (componentCounts.size() == 0) {
- actionHelp(ACTION_FLEX);
- }
- flex(appName, componentCounts);
- return EXIT_SUCCESS;
- }
-
- @Override
- public int actionExists(String name, boolean checkLive) throws YarnException, IOException {
- ActionExistsArgs args = new ActionExistsArgs();
- args.live = checkLive;
- return actionExists(name, args);
- }
-
- public int actionExists(String name, ActionExistsArgs args) throws YarnException, IOException {
- validateClusterName(name);
- boolean checkLive = args.live;
- log.debug("actionExists({}, {}, {})", name, checkLive, args.state);
-
- //initial probe for a cluster in the filesystem
- Path clusterDirectory = sliderFileSystem.buildClusterDirPath(name);
- if (!sliderFileSystem.getFileSystem().exists(clusterDirectory)) {
- throw unknownClusterException(name);
- }
- String state = args.state;
- if (!checkLive && isUnset(state)) {
- log.info("Application {} exists", name);
- return EXIT_SUCCESS;
- }
-
- //test for liveness/state
- boolean inDesiredState = false;
- ApplicationReport instance;
- instance = findInstance(name);
- if (instance == null) {
- log.info("Application {} not running", name);
- return EXIT_FALSE;
- }
- if (checkLive) {
- // the app exists, check that it is not in any terminated state
- YarnApplicationState appstate = instance.getYarnApplicationState();
- log.debug(" current app state = {}", appstate);
- inDesiredState = appstate.ordinal() < FINISHED.ordinal();
- } else {
- // scan for instance in single --state state
- state = state.toUpperCase(Locale.ENGLISH);
- YarnApplicationState desiredState = extractYarnApplicationState(state);
- List userInstances = yarnClient
- .listDeployedInstances("", EnumSet.of(desiredState), name);
- ApplicationReport foundInstance =
- yarnClient.findAppInInstanceList(userInstances, name, desiredState);
- if (foundInstance != null) {
- // found in selected state: success
- inDesiredState = true;
- // mark this as the instance to report
- instance = foundInstance;
- }
- }
-
- OnDemandReportStringifier report =
- new OnDemandReportStringifier(instance);
- if (!inDesiredState) {
- //cluster in the list of apps but not running
- log.info("Application {} found but is in wrong state {}", name,
- instance.getYarnApplicationState());
- log.debug("State {}", report);
- return EXIT_FALSE;
- } else {
- log.debug("Application instance is in desired state");
- log.info("Application {} is {}\n{}", name,
- instance.getYarnApplicationState(), report);
- return EXIT_SUCCESS;
- }
- }
-
-
- @Override
- public int actionKillContainer(String name,
- ActionKillContainerArgs args) throws YarnException, IOException {
- String id = args.id;
- if (isUnset(id)) {
- throw new BadCommandArgumentsException("Missing container id");
- }
- log.info("killingContainer {}:{}", name, id);
- SliderClusterOperations clusterOps =
- new SliderClusterOperations(bondToCluster(name));
- try {
- clusterOps.killContainer(id);
- } catch (NoSuchNodeException e) {
- throw new BadClusterStateException("Container %s not found in cluster %s",
- id, name);
- }
- return EXIT_SUCCESS;
- }
-
- /**
- * Find an instance of an application belonging to the current user.
- * @param appname application name
- * @return the app report or null if none is found
- * @throws YarnException YARN issues
- * @throws IOException IO problems
- */
- public ApplicationReport findInstance(String appname)
- throws YarnException, IOException {
- return findInstance(appname, null);
- }
-
- /**
- * Find an instance of an application belonging to the current user and in
- * specific app states.
- * @param appname application name
- * @param appStates app states in which the application should be in
- * @return the app report or null if none is found
- * @throws YarnException YARN issues
- * @throws IOException IO problems
- */
- public ApplicationReport findInstance(String appname,
- EnumSet appStates)
- throws YarnException, IOException {
- return yarnAppListClient.findInstance(appname, appStates);
- }
-
- /**
- * find all live instances of a specific app -if there is >1 in the cluster,
- * this returns them all. State should be running or less
- * @param appname application name
- * @return the list of all matching application instances
- */
- private List findAllLiveInstances(String appname)
- throws YarnException, IOException {
-
- return yarnAppListClient.findAllLiveInstances(appname);
- }
-
- /**
- * Connect to a Slider AM
- * @param app application report providing the details on the application
- * @return an instance
- * @throws YarnException
- * @throws IOException
- */
- private SliderClusterProtocol connect(ApplicationReport app)
- throws YarnException, IOException {
-
- try {
- return RpcBinder.getProxy(getConfig(),
- yarnClient.getRmClient(),
- app,
- Constants.CONNECT_TIMEOUT,
- Constants.RPC_TIMEOUT);
- } catch (InterruptedException e) {
- throw new SliderException(SliderExitCodes.EXIT_TIMED_OUT,
- e,
- "Interrupted waiting for communications with the Slider AM");
- }
- }
-
- @Override
- @VisibleForTesting
- public int actionStatus(String clustername, ActionStatusArgs statusArgs)
- throws YarnException, IOException {
- if (statusArgs.lifetime) {
- queryAndPrintLifetime(clustername);
- return EXIT_SUCCESS;
- }
-
- Application application = getApplication(clustername);
- String outfile = statusArgs.getOutput();
- if (outfile == null) {
- log.info(application.toString());
- } else {
- jsonSerDeser.save(application, new File(statusArgs.getOutput()));
- }
- return EXIT_SUCCESS;
- }
-
- @Override
- public Application actionStatus(String clustername)
- throws YarnException, IOException {
- return getApplication(clustername);
- }
-
- private void queryAndPrintLifetime(String appName)
- throws YarnException, IOException {
- ApplicationReport appReport = findInstance(appName);
- if (appReport == null) {
- throw new YarnException("No application found for " + appName);
- }
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintWriter timeoutStr =
- new PrintWriter(new OutputStreamWriter(baos, Charset.forName("UTF-8")));
- try {
- ApplicationTimeout lifetime = appReport.getApplicationTimeouts()
- .get(ApplicationTimeoutType.LIFETIME);
- if (lifetime.getRemainingTime() == -1L) {
- timeoutStr.append(appName + " has no lifetime configured.");
- } else {
- timeoutStr.append("\t" + ApplicationTimeoutType.LIFETIME);
- timeoutStr.print(" expires at : " + lifetime.getExpiryTime());
- timeoutStr.println(
- ".\tRemaining Time : " + lifetime.getRemainingTime() + " seconds");
- }
- System.out.println(baos.toString("UTF-8"));
- } finally {
- timeoutStr.close();
- }
- }
-
- @Override
- public int actionVersion() {
- SliderVersionInfo.loadAndPrintVersionInfo(log);
- return EXIT_SUCCESS;
- }
-
- @Override
- public int actionStop(String appName, ActionFreezeArgs freezeArgs)
- throws YarnException, IOException {
- validateClusterName(appName);
- ApplicationReport app = findInstance(appName);
- if (app == null) {
- throw new ApplicationNotFoundException(
- "Application " + appName + " doesn't exist in RM.");
- }
-
- if (terminatedStates.contains(app.getYarnApplicationState())) {
- log.info("Application {} is already in a terminated state {}", appName,
- app.getYarnApplicationState());
- return EXIT_SUCCESS;
- }
-
- try {
- SliderClusterProtocol appMaster = connect(app);
- Messages.StopClusterRequestProto r =
- Messages.StopClusterRequestProto.newBuilder()
- .setMessage(freezeArgs.message).build();
- appMaster.stopCluster(r);
- log.info("Application " + appName + " is being gracefully stopped...");
- long startTime = System.currentTimeMillis();
- int pollCount = 0;
- while (true) {
- Thread.sleep(200);
- ApplicationReport report =
- yarnClient.getApplicationReport(app.getApplicationId());
- if (terminatedStates.contains(report.getYarnApplicationState())) {
- log.info("Application " + appName + " is stopped.");
- break;
- }
- // kill after 10 seconds.
- if ((System.currentTimeMillis() - startTime) > 10000) {
- log.info("Stop operation timeout stopping, forcefully kill the app "
- + appName);
- yarnClient
- .killApplication(app.getApplicationId(), freezeArgs.message);
- break;
- }
- if (++pollCount % 10 == 0) {
- log.info("Waiting for application " + appName + " to be stopped.");
- }
- }
- } catch (IOException | YarnException | InterruptedException e) {
- log.info("Failed to stop " + appName
- + " gracefully, forcefully kill the app.");
- yarnClient.killApplication(app.getApplicationId(), freezeArgs.message);
- }
- return EXIT_SUCCESS;
- }
-
- @Override
- public int actionStart(String appName, ActionThawArgs thaw)
- throws YarnException, IOException {
- validateClusterName(appName);
- Path appDir = checkAppExistOnHdfs(appName);
- Application application = ServiceApiUtil.loadApplication(sliderFileSystem,
- appName);
- ServiceApiUtil.validateAndResolveApplication(application,
- sliderFileSystem, getConfig());
- // see if it is actually running and bail out;
- verifyNoLiveApp(appName, "Thaw");
- ApplicationId appId = submitApp(application);
- application.setId(appId.toString());
- // write app definition on to hdfs
- persistApp(appDir, application);
- return 0;
- }
-
- public Map flex(String appName, Map
- componentCounts) throws YarnException, IOException {
- validateClusterName(appName);
- Application persistedApp = ServiceApiUtil.loadApplication(sliderFileSystem,
- appName);
- Map original = new HashMap<>(componentCounts.size());
- for (Component persistedComp : persistedApp.getComponents()) {
- String name = persistedComp.getName();
- if (componentCounts.containsKey(persistedComp.getName())) {
- original.put(name, persistedComp.getNumberOfContainers());
- persistedComp.setNumberOfContainers(componentCounts.get(name));
- }
- }
- if (original.size() < componentCounts.size()) {
- componentCounts.keySet().removeAll(original.keySet());
- throw new YarnException("Components " + componentCounts.keySet()
- + " do not exist in app definition.");
- }
- jsonSerDeser
- .save(sliderFileSystem.getFileSystem(), ServiceApiUtil.getAppJsonPath(
- sliderFileSystem, appName), persistedApp, true);
- log.info("Updated app definition file for components " + componentCounts
- .keySet());
-
- ApplicationReport instance = findInstance(appName);
- if (instance != null) {
- log.info("Flexing running app " + appName);
- SliderClusterProtocol appMaster = connect(instance);
- SliderClusterOperations clusterOps =
- new SliderClusterOperations(appMaster);
- clusterOps.flex(componentCounts);
- for (Entry componentCount : componentCounts.entrySet()) {
- log.info(
- "Application name = " + appName + ", Component name = " +
- componentCount.getKey() + ", number of containers updated " +
- "from " + original.get(componentCount.getKey()) + " to " +
- componentCount.getValue());
- }
- } else {
- String message = "Application " + appName + "does not exist in RM. ";
- throw new YarnException(message);
- }
- return original;
- }
-
- /**
- * Connect to a live cluster and get its current state
- *
- * @param appName the cluster name
- * @return its description
- */
- @VisibleForTesting
- public Application getApplication(String appName)
- throws YarnException, IOException {
- validateClusterName(appName);
- SliderClusterOperations clusterOperations =
- createClusterOperations(appName);
- return clusterOperations.getApplication();
- }
-
- private ClientAMProtocol connectToAM(String appName)
- throws IOException, YarnException {
- if (applicationId == null) {
- Application persistedApp = ServiceApiUtil.loadApplication(sliderFileSystem,
- appName);
- if (persistedApp == null) {
- throw new YarnException("Application " + appName
- + " doesn't exist on hdfs. Please check if the app exists in RM");
- }
- applicationId = ApplicationId.fromString(persistedApp.getId());
- }
- // Wait until app becomes running.
- long startTime = System.currentTimeMillis();
- int pollCount = 0;
- ApplicationReport appReport = null;
- while (true) {
- appReport = yarnClient.getApplicationReport(applicationId);
- YarnApplicationState state = appReport.getYarnApplicationState();
- if (state == RUNNING) {
- break;
- }
- if (terminatedStates.contains(state)) {
- throw new YarnException(
- "Failed to getStatus " + applicationId + ": " + appReport
- .getDiagnostics());
- }
- long elapsedMillis = System.currentTimeMillis() - startTime;
- // if over 5 min, quit
- if (elapsedMillis >= 300000) {
- throw new YarnException(
- "Timed out while waiting for application " + applicationId
- + " to be running");
- }
-
- if (++pollCount % 10 == 0) {
- log.info("Waiting for application {} to be running, current state is {}",
- applicationId, state);
- }
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ie) {
- String msg =
- "Interrupted while waiting for application " + applicationId
- + " to be running.";
- throw new YarnException(msg, ie);
- }
- }
-
- // Make the connection
- InetSocketAddress address = NetUtils
- .createSocketAddrForHost(appReport.getHost(), appReport.getRpcPort());
- return ClientAMProxy
- .createProxy(getConfig(), ClientAMProtocol.class,
- UserGroupInformation.getCurrentUser(), rpc, address);
- }
-
- public Application getStatus(String appName)
- throws IOException, YarnException {
- ClientAMProtocol proxy = connectToAM(appName);
- GetStatusResponseProto response =
- proxy.getStatus(GetStatusRequestProto.newBuilder().build());
- Application app = jsonSerDeser.fromJson(response.getStatus());
- return app;
- }
-
-
- /**
- * Bond to a running cluster
- * @param clustername cluster name
- * @return the AM RPC client
- * @throws SliderException if the cluster is unkown
- */
- private SliderClusterProtocol bondToCluster(String clustername) throws
- YarnException,
- IOException {
- if (clustername == null) {
- throw unknownClusterException("(undefined)");
- }
- ApplicationReport instance = findInstance(clustername,
- SliderUtils.getAllLiveAppStates());
- if (null == instance) {
- throw unknownClusterException(clustername);
- }
- return connect(instance);
- }
-
- /**
- * Create a cluster operations instance against a given cluster
- * @param clustername cluster name
- * @return a bonded cluster operations instance
- * @throws YarnException YARN issues
- * @throws IOException IO problems
- */
- private SliderClusterOperations createClusterOperations(String clustername) throws
- YarnException,
- IOException {
- SliderClusterProtocol sliderAM = bondToCluster(clustername);
- return new SliderClusterOperations(sliderAM);
- }
-
- /**
- * Generate an exception for an unknown cluster
- * @param clustername cluster name
- * @return an exception with text and a relevant exit code
- */
- public UnknownApplicationInstanceException unknownClusterException(String clustername) {
- return UnknownApplicationInstanceException.unknownInstance(clustername);
- }
-
- @Override
- public String toString() {
- return "Slider Client in state " + getServiceState()
- + " and Slider Application Instance " + deployedClusterName;
- }
-
- /**
- * Get all YARN applications
- * @return a possibly empty list
- * @throws YarnException
- * @throws IOException
- */
- @VisibleForTesting
- public List getApplications()
- throws YarnException, IOException {
- return yarnClient.getApplications();
- }
-
- @Override
- public int actionResolve(ActionResolveArgs args)
- throws YarnException, IOException {
- // as this is an API entry point, validate
- // the arguments
- args.validate();
- String path = SliderRegistryUtils.resolvePath(args.path);
- ServiceRecordMarshal serviceRecordMarshal = new ServiceRecordMarshal();
- try {
- if (args.list) {
- File destDir = args.destdir;
- if (destDir != null && !destDir.exists() && !destDir.mkdirs()) {
- throw new IOException("Failed to create directory: " + destDir);
- }
-
-
- Map recordMap;
- Map znodes;
- try {
- znodes = statChildren(registryOperations, path);
- recordMap = extractServiceRecords(registryOperations,
- path,
- znodes.values());
- } catch (PathNotFoundException e) {
- // treat the root directory as if if is always there
-
- if ("/".equals(path)) {
- znodes = new HashMap<>(0);
- recordMap = new HashMap<>(0);
- } else {
- throw e;
- }
- }
- // subtract all records from the znodes map to get pure directories
- log.info("Entries: {}", znodes.size());
-
- for (String name : znodes.keySet()) {
- println(" " + name);
- }
- println("");
-
- log.info("Service records: {}", recordMap.size());
- for (Entry recordEntry : recordMap.entrySet()) {
- String name = recordEntry.getKey();
- ServiceRecord instance = recordEntry.getValue();
- String json = serviceRecordMarshal.toJson(instance);
- if (destDir == null) {
- println(name);
- println(json);
- } else {
- String filename = RegistryPathUtils.lastPathEntry(name) + ".json";
- File jsonFile = new File(destDir, filename);
- write(jsonFile, serviceRecordMarshal.toBytes(instance));
- }
- }
- } else {
- // resolve single entry
- ServiceRecord instance = resolve(path);
- File outFile = args.out;
- if (args.destdir != null) {
- outFile = new File(args.destdir, RegistryPathUtils.lastPathEntry(path));
- }
- if (outFile != null) {
- write(outFile, serviceRecordMarshal.toBytes(instance));
- } else {
- println(serviceRecordMarshal.toJson(instance));
- }
- }
- } catch (PathNotFoundException | NoRecordException e) {
- // no record at this path
- throw new NotFoundException(e, path);
- }
- return EXIT_SUCCESS;
- }
-
- @Override
- public int actionRegistry(ActionRegistryArgs registryArgs) throws
- YarnException,
- IOException {
- // as this is also a test entry point, validate
- // the arguments
- registryArgs.validate();
- try {
- if (registryArgs.list) {
- actionRegistryList(registryArgs);
- } else if (registryArgs.listConf) {
- // list the configurations
- actionRegistryListConfigsYarn(registryArgs);
- } else if (registryArgs.listExports) {
- // list the exports
- actionRegistryListExports(registryArgs);
- } else if (isSet(registryArgs.getConf)) {
- // get a configuration
- PublishedConfiguration publishedConfiguration =
- actionRegistryGetConfig(registryArgs);
- outputConfig(publishedConfiguration, registryArgs);
- } else if (isSet(registryArgs.getExport)) {
- // get a export group
- PublishedExports publishedExports =
- actionRegistryGetExport(registryArgs);
- outputExport(publishedExports, registryArgs);
- } else {
- // it's an unknown command
- log.info(CommonArgs.usage(serviceArgs, ACTION_DIAGNOSTICS));
- return EXIT_USAGE;
- }
-// JDK7
- } catch (FileNotFoundException e) {
- log.info("{}", e.toString());
- log.debug("{}", e, e);
- return EXIT_NOT_FOUND;
- } catch (PathNotFoundException e) {
- log.info("{}", e.toString());
- log.debug("{}", e, e);
- return EXIT_NOT_FOUND;
- }
- return EXIT_SUCCESS;
- }
-
- /**
- * Registry operation
- *
- * @param registryArgs registry Arguments
- * @return the instances (for tests)
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- */
- @VisibleForTesting
- public Collection actionRegistryList(
- ActionRegistryArgs registryArgs)
- throws YarnException, IOException {
- String serviceType = registryArgs.serviceType;
- String name = registryArgs.name;
- RegistryOperations operations = getRegistryOperations();
- Collection serviceRecords;
- if (StringUtils.isEmpty(name)) {
- String path = serviceclassPath(currentUser(), serviceType);
-
- try {
- Map recordMap =
- listServiceRecords(operations, path);
- if (recordMap.isEmpty()) {
- throw new UnknownApplicationInstanceException(
- "No applications registered under " + path);
- }
- serviceRecords = recordMap.values();
- } catch (PathNotFoundException e) {
- throw new NotFoundException(path, e);
- }
- } else {
- ServiceRecord instance = lookupServiceRecord(registryArgs);
- serviceRecords = new ArrayList<>(1);
- serviceRecords.add(instance);
- }
-
- for (ServiceRecord serviceRecord : serviceRecords) {
- logInstance(serviceRecord, registryArgs.verbose);
- }
- return serviceRecords;
- }
-
- @Override
- public int actionDiagnostic(ActionDiagnosticArgs diagnosticArgs) {
- try {
- if (diagnosticArgs.client) {
- actionDiagnosticClient(diagnosticArgs);
- } else if (diagnosticArgs.application) {
- // TODO print configs of application - get from AM
- } else if (diagnosticArgs.yarn) {
- // This method prints yarn nodes info and yarn configs.
- // We can just use yarn node CLI instead which is much more richful
- // for yarn configs, this method reads local config which is only client
- // config not cluster configs.
-// actionDiagnosticYarn(diagnosticArgs);
- } else if (diagnosticArgs.credentials) {
- // actionDiagnosticCredentials internall only runs a bare 'klist' command...
- // IMHO, the user can just run klist on their own with extra options supported, don't
- // actually see the point of this method.
-// actionDiagnosticCredentials();
- } else if (diagnosticArgs.all) {
- actionDiagnosticAll(diagnosticArgs);
- } else if (diagnosticArgs.level) {
- // agent is removed
- } else {
- // it's an unknown option
- log.info(CommonArgs.usage(serviceArgs, ACTION_DIAGNOSTICS));
- return EXIT_USAGE;
- }
- } catch (Exception e) {
- log.error(e.toString());
- return EXIT_FALSE;
- }
- return EXIT_SUCCESS;
- }
-
- private void actionDiagnosticAll(ActionDiagnosticArgs diagnosticArgs)
- throws IOException, YarnException {
- // assign application name from param to each sub diagnostic function
- actionDiagnosticClient(diagnosticArgs);
- // actionDiagnosticSlider only prints the agent location on hdfs,
- // which is invalid now.
- // actionDiagnosticCredentials only runs 'klist' command, IMHO, the user
- // can just run klist on its own with extra options supported, don't
- // actually see the point of this method.
- }
-
- private void actionDiagnosticClient(ActionDiagnosticArgs diagnosticArgs)
- throws SliderException, IOException {
- try {
- String currentCommandPath = getCurrentCommandPath();
- SliderVersionInfo.loadAndPrintVersionInfo(log);
- String clientConfigPath = getClientConfigPath();
- String jdkInfo = getJDKInfo();
- println("The slider command path: %s", currentCommandPath);
- println("The slider-client.xml used by current running command path: %s",
- clientConfigPath);
- println(jdkInfo);
-
- // security info
- Configuration config = getConfig();
- if (isHadoopClusterSecure(config)) {
- println("Hadoop Cluster is secure");
- println("Login user is %s", UserGroupInformation.getLoginUser());
- println("Current user is %s", UserGroupInformation.getCurrentUser());
-
- } else {
- println("Hadoop Cluster is insecure");
- }
-
- // verbose?
- if (diagnosticArgs.verbose) {
- // do the environment
- Map env = getSystemEnv();
- Set envList = ConfigHelper.sortedConfigKeys(env.entrySet());
- StringBuilder builder = new StringBuilder("Environment variables:\n");
- for (String key : envList) {
- builder.append(key).append("=").append(env.get(key)).append("\n");
- }
- println(builder.toString());
-
- // Java properties
- builder = new StringBuilder("JVM Properties\n");
- Map props =
- sortedMap(toMap(System.getProperties()));
- for (Entry entry : props.entrySet()) {
- builder.append(entry.getKey()).append("=")
- .append(entry.getValue()).append("\n");
- }
-
- println(builder.toString());
-
- // then the config
- println("Slider client configuration:\n" + ConfigHelper.dumpConfigToString(config));
- }
-
- validateSliderClientEnvironment(log);
- } catch (SliderException | IOException e) {
- log.error(e.toString());
- throw e;
- }
-
- }
-
- /**
- * Kerberos Diagnostics
- * @param args CLI arguments
- * @return exit code
- * @throws SliderException
- * @throws IOException
- */
- @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
- private int actionKDiag(ActionKDiagArgs args)
- throws Exception {
- PrintStream out;
- boolean closeStream = false;
- if (args.out != null) {
- out = new PrintStream(args.out, "UTF-8");
- closeStream = true;
- } else {
- out = System.err;
- }
- try {
- KerberosDiags kdiags = new KerberosDiags(getConfig(),
- out,
- args.services,
- args.keytab,
- args.principal,
- args.keylen,
- args.secure);
- kdiags.execute();
- } catch (KerberosDiags.KerberosDiagsFailure e) {
- log.error(e.toString());
- log.debug(e.toString(), e);
- throw e;
- } catch (Exception e) {
- log.error("Kerberos Diagnostics", e);
- throw e;
- } finally {
- if (closeStream) {
- out.flush();
- out.close();
- }
- }
- return 0;
- }
-
- /**
- * Log a service record instance
- * @param instance record
- * @param verbose verbose logging of all external endpoints
- */
- private void logInstance(ServiceRecord instance,
- boolean verbose) {
- if (!verbose) {
- log.info("{}", instance.get(YarnRegistryAttributes.YARN_ID, ""));
- } else {
- log.info("{}: ", instance.get(YarnRegistryAttributes.YARN_ID, ""));
- logEndpoints(instance);
- }
- }
-
- /**
- * Log the external endpoints of a service record
- * @param instance service record instance
- */
- private void logEndpoints(ServiceRecord instance) {
- List endpoints = instance.external;
- for (Endpoint endpoint : endpoints) {
- log.info(endpoint.toString());
- }
- }
-
- /**
- * list configs available for an instance
- *
- * @param registryArgs registry Arguments
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- */
- public void actionRegistryListConfigsYarn(ActionRegistryArgs registryArgs)
- throws YarnException, IOException {
-
- ServiceRecord instance = lookupServiceRecord(registryArgs);
-
- RegistryRetriever retriever = new RegistryRetriever(getConfig(), instance);
- PublishedConfigSet configurations =
- retriever.getConfigurations(!registryArgs.internal);
- PrintStream out = null;
- try {
- if (registryArgs.out != null) {
- out = new PrintStream(registryArgs.out, "UTF-8");
- } else {
- out = System.out;
- }
- for (String configName : configurations.keys()) {
- if (!registryArgs.verbose) {
- out.println(configName);
- } else {
- PublishedConfiguration published = configurations.get(configName);
- out.printf("%s: %s%n", configName, published.description);
- }
- }
- } finally {
- if (registryArgs.out != null && out != null) {
- out.flush();
- out.close();
- }
- }
- }
-
- /**
- * list exports available for an instance
- *
- * @param registryArgs registry Arguments
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- */
- public void actionRegistryListExports(ActionRegistryArgs registryArgs)
- throws YarnException, IOException {
- ServiceRecord instance = lookupServiceRecord(registryArgs);
-
- RegistryRetriever retriever = new RegistryRetriever(getConfig(), instance);
- PublishedExportsSet exports =
- retriever.getExports(!registryArgs.internal);
- PrintStream out = null;
- boolean streaming = false;
- try {
- if (registryArgs.out != null) {
- out = new PrintStream(registryArgs.out, "UTF-8");
- streaming = true;
- log.debug("Saving output to {}", registryArgs.out);
- } else {
- out = System.out;
- }
- log.debug("Number of exports: {}", exports.keys().size());
- for (String exportName : exports.keys()) {
- if (streaming) {
- log.debug(exportName);
- }
- if (!registryArgs.verbose) {
- out.println(exportName);
- } else {
- PublishedExports published = exports.get(exportName);
- out.printf("%s: %s%n", exportName, published.description);
- }
- }
- } finally {
- if (streaming) {
- out.flush();
- out.close();
- }
- }
- }
-
- /**
- * list configs available for an instance
- *
- * @param registryArgs registry Arguments
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- * @throws FileNotFoundException if the config is not found
- */
- @VisibleForTesting
- public PublishedConfiguration actionRegistryGetConfig(ActionRegistryArgs registryArgs)
- throws YarnException, IOException {
- return ClientUtils.getConfigFromRegistry(getRegistryOperations(),
- getConfig(), registryArgs.getConf, registryArgs.name, registryArgs.user,
- !registryArgs.internal);
- }
-
- /**
- * get a specific export group
- *
- * @param registryArgs registry Arguments
- *
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- * @throws FileNotFoundException if the config is not found
- */
- @VisibleForTesting
- public PublishedExports actionRegistryGetExport(ActionRegistryArgs registryArgs)
- throws YarnException, IOException {
- ServiceRecord instance = lookupServiceRecord(registryArgs);
-
- RegistryRetriever retriever = new RegistryRetriever(getConfig(), instance);
- boolean external = !registryArgs.internal;
- PublishedExportsSet exports = retriever.getExports(external);
-
- PublishedExports published = retriever.retrieveExports(exports,
- registryArgs.getExport,
- external);
- return published;
- }
-
- /**
- * write out the config. If a destination is provided and that dir is a
- * directory, the entry is written to it with the name provided + extension,
- * else it is printed to standard out.
- * @param published published config
- * @param registryArgs registry Arguments
- * @throws BadCommandArgumentsException
- * @throws IOException
- */
- private void outputConfig(PublishedConfiguration published,
- ActionRegistryArgs registryArgs) throws
- BadCommandArgumentsException,
- IOException {
- // decide whether or not to print
- String entry = registryArgs.getConf;
- String format = registryArgs.format;
- String output = ClientUtils.saveOrReturnConfig(published,
- registryArgs.format, registryArgs.out, entry + "." + format);
- if (output != null) {
- print(output);
- }
- }
-
- /**
- * write out the config
- * @param published
- * @param registryArgs
- * @throws BadCommandArgumentsException
- * @throws IOException
- */
- private void outputExport(PublishedExports published,
- ActionRegistryArgs registryArgs) throws
- BadCommandArgumentsException,
- IOException {
- // decide whether or not to print
- String entry = registryArgs.getExport;
- String format = ConfigFormat.JSON.toString();
- ConfigFormat configFormat = ConfigFormat.resolve(format);
- if (configFormat == null || configFormat != ConfigFormat.JSON) {
- throw new BadCommandArgumentsException(
- "Unknown/Unsupported format %s . Only JSON is supported.", format);
- }
-
- PublishedExportsOutputter outputter =
- PublishedExportsOutputter.createOutputter(configFormat,
- published);
- boolean print = registryArgs.out == null;
- if (!print) {
- File destFile;
- destFile = registryArgs.out;
- if (destFile.isDirectory()) {
- // creating it under a directory
- destFile = new File(destFile, entry + "." + format);
- }
- log.info("Destination path: {}", destFile);
- outputter.save(destFile);
- } else {
- print(outputter.asString());
- }
- }
-
- /**
- * Look up an instance
- * @return instance data
- * @throws SliderException other failures
- * @throws IOException IO problems or wrapped exceptions
- */
- private ServiceRecord lookupServiceRecord(ActionRegistryArgs registryArgs) throws
- SliderException,
- IOException {
- return ClientUtils.lookupServiceRecord(getRegistryOperations(),
- registryArgs.user, registryArgs.serviceType, registryArgs.name);
- }
-
- /**
- *
- * Look up an instance
- * @param path path
- * @return instance data
- * @throws NotFoundException no path/no service record
- * at the end of the path
- * @throws SliderException other failures
- * @throws IOException IO problems or wrapped exceptions
- */
- public ServiceRecord resolve(String path)
- throws IOException, SliderException {
- return ClientUtils.resolve(getRegistryOperations(), path);
- }
-
- /**
- * List instances in the registry for the current user
- * @return a list of slider registry instances
- * @throws IOException Any IO problem ... including no path in the registry
- * to slider service classes for this user
- * @throws SliderException other failures
- */
-
- public Map listRegistryInstances()
- throws IOException, SliderException {
- Map recordMap = listServiceRecords(
- getRegistryOperations(),
- serviceclassPath(currentUser(), SliderKeys.APP_TYPE));
- return recordMap;
- }
-
- /**
- * List instances in the registry
- * @return the instance IDs
- * @throws IOException
- * @throws YarnException
- */
- public List listRegisteredSliderInstances() throws
- IOException,
- YarnException {
- try {
- Map recordMap = listServiceRecords(
- getRegistryOperations(),
- serviceclassPath(currentUser(), SliderKeys.APP_TYPE));
- return new ArrayList<>(recordMap.keySet());
- } catch (PathNotFoundException e) {
- log.debug("No registry path for slider instances for current user: {}", e, e);
- // no entries: return an empty list
- return new ArrayList<>(0);
- } catch (IOException | YarnException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e);
- }
- }
-
- /**
- * Start the registry if it is not there yet
- * @return the registry service
- * @throws SliderException
- * @throws IOException
- */
- private synchronized RegistryOperations maybeStartYarnRegistry()
- throws SliderException, IOException {
-
- if (registryOperations == null) {
- registryOperations = startRegistryOperationsService();
- }
- return registryOperations;
- }
-
- @Override
- public RegistryOperations getRegistryOperations()
- throws SliderException, IOException {
- return maybeStartYarnRegistry();
- }
-
- /**
- * Output to standard out/stderr (implementation specific detail)
- * @param src source
- */
- private static void print(CharSequence src) {
- clientOutputStream.print(src);
- }
-
- /**
- * Output to standard out/stderr with a newline after
- * @param message message
- */
- private static void println(String message) {
- clientOutputStream.println(message);
- }
- /**
- * Output to standard out/stderr with a newline after, formatted
- * @param message message
- * @param args arguments for string formatting
- */
- private static void println(String message, Object ... args) {
- clientOutputStream.println(String.format(message, args));
- }
-
- /**
- * Implement the lookup action.
- * @param args Action arguments
- * @return 0 if the entry was found
- * @throws IOException
- * @throws YarnException
- * @throws UnknownApplicationInstanceException if a specific instance
- * was named but it was not found
- */
- @VisibleForTesting
- public int actionLookup(ActionLookupArgs args)
- throws IOException, YarnException {
- try {
- ApplicationId id = ConverterUtils.toApplicationId(args.id);
- ApplicationReport report = yarnClient.getApplicationReport(id);
- SerializedApplicationReport sar = new SerializedApplicationReport(report);
- ApplicationReportSerDeser serDeser = new ApplicationReportSerDeser();
- if (args.outputFile != null) {
- serDeser.save(sar, args.outputFile);
- } else {
- println(serDeser.toJson(sar));
- }
- } catch (IllegalArgumentException e) {
- throw new BadCommandArgumentsException(e, "%s : %s", args, e);
- } catch (ApplicationAttemptNotFoundException | ApplicationNotFoundException notFound) {
- throw new NotFoundException(notFound, notFound.toString());
- }
- return EXIT_SUCCESS;
- }
-
- @Override
- public int actionDependency(ActionDependencyArgs args) throws IOException,
- YarnException {
- String currentUser = getUsername();
- log.info("Running command as user {}", currentUser);
-
- String version = getSliderVersion();
- Path dependencyLibTarGzip = sliderFileSystem.getDependencyTarGzip();
-
- // Check if dependency has already been uploaded, in which case log
- // appropriately and exit success (unless overwrite has been requested)
- if (sliderFileSystem.isFile(dependencyLibTarGzip) && !args.overwrite) {
- println(String.format(
- "Dependency libs are already uploaded to %s. Use %s "
- + "if you want to re-upload", dependencyLibTarGzip.toUri(),
- Arguments.ARG_OVERWRITE));
- return EXIT_SUCCESS;
- }
-
- String[] libDirs = SliderUtils.getLibDirs();
- if (libDirs.length > 0) {
- File tempLibTarGzipFile = File.createTempFile(
- SliderKeys.SLIDER_DEPENDENCY_TAR_GZ_FILE_NAME + "_",
- SliderKeys.SLIDER_DEPENDENCY_TAR_GZ_FILE_EXT);
- // copy all jars
- tarGzipFolder(libDirs, tempLibTarGzipFile, createJarFilter());
-
- log.info("Uploading dependency for AM (version {}) from {} to {}",
- version, tempLibTarGzipFile.toURI(), dependencyLibTarGzip.toUri());
- sliderFileSystem.copyLocalFileToHdfs(tempLibTarGzipFile,
- dependencyLibTarGzip, new FsPermission(
- SliderKeys.SLIDER_DEPENDENCY_DIR_PERMISSIONS));
- return EXIT_SUCCESS;
- } else {
- return EXIT_FALSE;
- }
- }
-
- private int actionHelp(String actionName) throws YarnException, IOException {
- throw new UsageException(CommonArgs.usage(serviceArgs, actionName));
- }
-
- /**
- * List the nodes in the cluster, possibly filtering by node state or label.
- *
- * @param args argument list
- * @return a possibly empty list of nodes in the cluster
- * @throws IOException IO problems
- * @throws YarnException YARN problems
- */
- @Override
- public NodeInformationList listYarnClusterNodes(ActionNodesArgs args)
- throws YarnException, IOException {
- return yarnClient.listNodes(args.label, args.healthy);
- }
-
- /**
- * List the nodes in the cluster, possibly filtering by node state or label.
- *
- * @param args argument list
- * @return a possibly empty list of nodes in the cluster
- * @throws IOException IO problems
- * @throws YarnException YARN problems
- */
- public NodeInformationList listInstanceNodes(String instance, ActionNodesArgs args)
- throws YarnException, IOException {
- // TODO
- log.info("listInstanceNodes {}", instance);
- SliderClusterOperations clusterOps =
- new SliderClusterOperations(bondToCluster(instance));
- return clusterOps.getLiveNodes();
- }
-
- /**
- * List the nodes in the cluster, possibly filtering by node state or label.
- * Prints them to stdout unless the args names a file instead.
- * @param args argument list
- * @throws IOException IO problems
- * @throws YarnException YARN problems
- */
- public int actionNodes(String instance, ActionNodesArgs args) throws YarnException, IOException {
-
- args.instance = instance;
- NodeInformationList nodes;
- if (SliderUtils.isUnset(instance)) {
- nodes = listYarnClusterNodes(args);
- } else {
- nodes = listInstanceNodes(instance, args);
- }
- log.debug("Node listing for {} has {} nodes", args, nodes.size());
- JsonSerDeser serDeser = NodeInformationList.createSerializer();
- if (args.outputFile != null) {
- serDeser.save(nodes, args.outputFile);
- } else {
- println(serDeser.toJson(nodes));
- }
- return 0;
- }
-
- /**
- * Save/list tokens. This is for testing oozie integration
- * @param args commands
- * @return status
- */
- private int actionTokens(ActionTokensArgs args)
- throws IOException, YarnException {
- return new TokensOperation().actionTokens(args,
- sliderFileSystem.getFileSystem(),
- getConfig(),
- yarnClient);
- }
-
- @VisibleForTesting
- public ApplicationReport monitorAppToRunning(Duration duration)
- throws YarnException, IOException {
- return yarnClient.monitorAppToState(applicationId, RUNNING, duration);
- }
-}
-
-
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClientAPI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClientAPI.java
deleted file mode 100644
index f1bf2ad..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClientAPI.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.client;
-
-import org.apache.hadoop.registry.client.api.RegistryOperations;
-import org.apache.hadoop.service.Service;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.api.resource.Application;
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.slider.common.params.AbstractClusterBuildingActionArgs;
-import org.apache.slider.common.params.ActionAMSuicideArgs;
-import org.apache.slider.common.params.ActionClientArgs;
-import org.apache.hadoop.yarn.service.client.params.ActionDependencyArgs;
-import org.apache.slider.common.params.ActionDiagnosticArgs;
-import org.apache.hadoop.yarn.service.client.params.ActionFlexArgs;
-import org.apache.slider.common.params.ActionFreezeArgs;
-import org.apache.slider.common.params.ActionKeytabArgs;
-import org.apache.slider.common.params.ActionNodesArgs;
-import org.apache.slider.common.params.ActionKillContainerArgs;
-import org.apache.slider.common.params.ActionListArgs;
-import org.apache.slider.common.params.ActionRegistryArgs;
-import org.apache.slider.common.params.ActionResolveArgs;
-import org.apache.slider.common.params.ActionResourceArgs;
-import org.apache.slider.common.params.ActionStatusArgs;
-import org.apache.slider.common.params.ActionThawArgs;
-import org.apache.slider.common.params.ActionUpgradeArgs;
-import org.apache.slider.core.exceptions.BadCommandArgumentsException;
-import org.apache.slider.core.exceptions.SliderException;
-
-import java.io.IOException;
-
-/**
- * Interface of those method calls in the slider API that are intended
- * for direct public invocation.
- *
- * Stability: evolving
- */
-public interface SliderClientAPI extends Service {
-
- int actionDestroy(String clustername) throws YarnException, IOException;
-
- /**
- * AM to commit an asynchronous suicide
- */
- int actionAmSuicide(String clustername,
- ActionAMSuicideArgs args) throws YarnException, IOException;
-
- /**
- * Manage keytabs leveraged by slider
- *
- * @param keytabInfo the arguments needed to manage the keytab
- * @throws YarnException Yarn problems
- * @throws IOException other problems
- * @throws BadCommandArgumentsException bad arguments.
- */
- int actionKeytab(ActionKeytabArgs keytabInfo)
- throws YarnException, IOException;
-
- /**
- * Manage file resources leveraged by slider
- *
- * @param resourceInfo the arguments needed to manage the resource
- * @throws YarnException Yarn problems
- * @throws IOException other problems
- * @throws BadCommandArgumentsException bad arguments.
- */
- int actionResource(ActionResourceArgs resourceInfo)
- throws YarnException, IOException;
-
- /**
- * Perform client operations such as install or configure
- *
- * @param clientInfo the arguments needed for client operations
- *
- * @throws SliderException bad arguments.
- * @throws IOException problems related to package and destination folders
- */
- int actionClient(ActionClientArgs clientInfo)
- throws IOException, YarnException;
-
- /**
- * Update the cluster specification
- *
- * @param clustername cluster name
- * @param buildInfo the arguments needed to update the cluster
- * @throws YarnException Yarn problems
- * @throws IOException other problems
- */
- int actionUpdate(String clustername,
- AbstractClusterBuildingActionArgs buildInfo)
- throws YarnException, IOException;
-
- /**
- * Upgrade the cluster with a newer version of the application
- *
- * @param clustername cluster name
- * @param buildInfo the arguments needed to upgrade the cluster
- * @throws YarnException Yarn problems
- * @throws IOException other problems
- */
- int actionUpgrade(String clustername,
- ActionUpgradeArgs buildInfo)
- throws YarnException, IOException;
-
- /**
- * Implement the list action: list all nodes
- * @return exit code of 0 if a list was created
- */
- int actionList(String clustername, ActionListArgs args) throws IOException, YarnException;
-
-
- int actionFlex(String name, ActionFlexArgs args) throws YarnException,
- IOException;
-
- /**
- * Test for a cluster existing probe for a cluster of the given name existing
- * in the filesystem. If the live param is set, it must be a live cluster
- * @return exit code
- */
- int actionExists(String name, boolean checkLive) throws YarnException, IOException;
-
- /**
- * Kill a specific container of the cluster
- * @param name cluster name
- * @param args arguments
- * @return exit code
- * @throws YarnException
- * @throws IOException
- */
- int actionKillContainer(String name, ActionKillContainerArgs args)
- throws YarnException, IOException;
-
- /**
- * Status operation
- *
- * @param clustername cluster name
- * @param statusArgs status arguments
- * @return 0 -for success, else an exception is thrown
- * @throws YarnException
- * @throws IOException
- */
- int actionStatus(String clustername, ActionStatusArgs statusArgs)
- throws YarnException, IOException;
-
- /**
- * Status operation which returns the status object as a string instead of
- * printing it to the console or file.
- *
- * @param clustername cluster name
- * @return cluster status details
- * @throws YarnException
- * @throws IOException
- */
- Application actionStatus(String clustername) throws YarnException, IOException;
-
- /**
- * Version Details
- * @return exit code
- */
- int actionVersion();
-
- /**
- * Stop the cluster
- *
- * @param clustername cluster name
- * @param freezeArgs arguments to the stop
- * @return EXIT_SUCCESS if the cluster was not running by the end of the operation
- */
- int actionStop(String clustername, ActionFreezeArgs freezeArgs)
- throws YarnException, IOException;
-
- /**
- * Restore a cluster
- */
- int actionStart(String clustername, ActionThawArgs thaw) throws YarnException, IOException;
-
- /**
- * Registry operation
- *
- * @param args registry Arguments
- * @return 0 for success, -1 for some issues that aren't errors, just failures
- * to retrieve information (e.g. no configurations for that entry)
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- */
- int actionResolve(ActionResolveArgs args)
- throws YarnException, IOException;
-
- /**
- * Registry operation
- *
- * @param registryArgs registry Arguments
- * @return 0 for success, -1 for some issues that aren't errors, just failures
- * to retrieve information (e.g. no configurations for that entry)
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- */
- int actionRegistry(ActionRegistryArgs registryArgs)
- throws YarnException, IOException;
-
- /**
- * diagnostic operation
- *
- * @param diagnosticArgs diagnostic Arguments
- * @return 0 for success, -1 for some issues that aren't errors, just
- * failures to retrieve information (e.g. no application name
- * specified)
- * @throws YarnException YARN problems
- * @throws IOException Network or other problems
- */
- int actionDiagnostic(ActionDiagnosticArgs diagnosticArgs);
-
- /**
- * Get the registry binding. As this may start the registry, it can take time
- * and fail
- * @return the registry
- */
- RegistryOperations getRegistryOperations()
- throws SliderException, IOException;
-
- /**
- * Upload all Slider AM and agent dependency libraries to HDFS, so that they
- * do not need to be uploaded with every create call. This operation is
- * Slider version specific. So it needs to be invoked for every single
- * version of slider/slider-client.
- *
- * @throws SliderException
- * @throws IOException
- */
- int actionDependency(ActionDependencyArgs dependencyArgs) throws IOException,
- YarnException;
-
- /**
- * List the nodes
- * @param args
- * @return
- * @throws YarnException
- * @throws IOException
- */
- NodeInformationList listYarnClusterNodes(ActionNodesArgs args)
- throws YarnException, IOException;
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java
deleted file mode 100644
index e1b578c..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.client;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
-import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationReport;
-import org.apache.hadoop.yarn.api.records.NodeReport;
-import org.apache.hadoop.yarn.api.records.NodeState;
-import org.apache.hadoop.yarn.api.records.YarnApplicationState;
-import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.api.types.NodeInformation;
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.hadoop.yarn.service.conf.SliderKeys;
-import org.apache.slider.common.tools.Duration;
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.exceptions.BadCommandArgumentsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-//TODO, Remove this class and YarnAppListClient
-// why do we need so many yarn client wrappers ?
-// - yarn client already provides most of functionality already
-
-/**
- * A class that extends visibility to some of the YarnClientImpl
- * members and data structures, and factors out pure-YARN operations
- * from the slider entry point service
- */
-public class SliderYarnClientImpl extends YarnClientImpl {
- protected static final Logger log = LoggerFactory.getLogger(SliderYarnClientImpl.class);
-
- /**
- * Get the RM Client RPC interface
- * @return an RPC interface valid after initialization and authentication
- */
- public ApplicationClientProtocol getRmClient() {
- return rmClient;
- }
-
- /**
- * List Slider deployedinstances belonging to a specific user in a
- * given set of states and filtered by an application name tag.
- *
- * Deployed means: known about in the YARN cluster; it will include all apps
- * in the specified set of states and tagged with the specified app name.
- *
- * @param user
- * user: "" means all users
- * @param appStates
- * filter by a set of YarnApplicationState
- * @param appname
- * an application name tag in the format defined by
- * {@link SliderUtils#createNameTag(String)}
- * @return a possibly empty list of Slider AMs
- * @throws YarnException
- * @throws IOException
- */
- public List listDeployedInstances(String user,
- EnumSet appStates, String appname)
- throws YarnException, IOException {
- Preconditions.checkArgument(user != null, "Null User");
- Set types = new HashSet<>(1);
- types.add(SliderKeys.APP_TYPE);
- Set tags = null;
- if (appname != null) {
- tags = Collections.singleton(SliderUtils.createNameTag(appname));
- }
- List allApps = getApplications(types, appStates, tags);
- List results = new ArrayList<>();
- for (ApplicationReport report : allApps) {
- if (StringUtils.isEmpty(user) || user.equals(report.getUser())) {
- results.add(report);
- }
- }
- return results;
- }
-
- /**
- * Helper method to determine if a cluster application is running -or
- * is earlier in the lifecycle
- * @param app application report
- * @return true if the application is considered live
- */
- public boolean isApplicationLive(ApplicationReport app) {
- Preconditions.checkArgument(app != null, "Null app report");
-
- return app.getYarnApplicationState().ordinal() <= YarnApplicationState.RUNNING.ordinal();
- }
-
- /**
- * find all live instances of a specific app -if there is >1 in the cluster,
- * this returns them all. State should be running or less
- * @param user user
- * @param appname application name
- * @return the list of all matching application instances
- */
- public List findAllLiveInstances(String user,
- String appname) throws YarnException, IOException {
- Preconditions.checkArgument(StringUtils.isNotEmpty(appname),
- "Null/empty application name");
- return listDeployedInstances(user, SliderUtils.getAllLiveAppStates(),
- appname);
- }
-
- /**
- * Find a cluster in the instance list; biased towards live instances
- * @param instances list of instances
- * @param appname application name
- * @return the first found instance, else a failed/finished instance, or null
- * if there are none of those
- */
- public ApplicationReport findClusterInInstanceList(List instances,
- String appname) {
- Preconditions.checkArgument(instances != null, "Null instances list");
- Preconditions.checkArgument(StringUtils.isNotEmpty(appname),
- "Null/empty application name");
- // sort by most recent
- SliderUtils.sortApplicationsByMostRecent(instances);
- ApplicationReport found = null;
- for (ApplicationReport app : instances) {
- if (app.getName().equals(appname)) {
- if (isApplicationLive(app)) {
- return app;
- }
- // set the found value if not set
- found = found != null ? found : app;
- }
- }
- return found;
- }
-
- /**
- * Find an app in the instance list in the desired state
- * @param instances instance list
- * @param appname application name
- * @param desiredState yarn state desired
- * @return the match or null for none
- */
- public ApplicationReport findAppInInstanceList(List instances,
- String appname,
- YarnApplicationState desiredState) {
- Preconditions.checkArgument(instances != null, "Null instances list");
- Preconditions.checkArgument(StringUtils.isNotEmpty(appname),
- "Null/empty application name");
- Preconditions.checkArgument(desiredState != null, "Null desiredState");
- log.debug("Searching {} records for instance name {} in state '{}'",
- instances.size(), appname, desiredState);
- for (ApplicationReport app : instances) {
- if (app.getName().equals(appname)) {
-
- YarnApplicationState appstate =
- app.getYarnApplicationState();
- log.debug("app ID {} is in state {}", app.getApplicationId(), appstate);
- if (appstate.equals(desiredState)) {
- log.debug("match");
- return app;
- }
- }
- }
- // nothing found in desired state
- log.debug("No match");
- return null;
- }
-
- /**
- * List the nodes in the cluster, possibly filtering by node state or label.
- *
- * @param label label to filter by -or "" for any
- * @param live flag to request running nodes only
- * @return a possibly empty list of nodes in the cluster
- * @throws IOException IO problems
- * @throws YarnException YARN problems
- */
- public NodeInformationList listNodes(String label, boolean live)
- throws IOException, YarnException {
- Preconditions.checkArgument(label != null, "null label");
- NodeState[] states;
- if (live) {
- states = new NodeState[1];
- states[0] = NodeState.RUNNING;
- } else {
- states = new NodeState[0];
- }
- List reports = getNodeReports(states);
- NodeInformationList results = new NodeInformationList(reports.size());
- for (NodeReport report : reports) {
- if (live && report.getNodeState() != NodeState.RUNNING) {
- continue;
- }
- if (!label.isEmpty() && !report.getNodeLabels().contains(label)) {
- continue;
- }
- // build node info from report
- NodeInformation info = new NodeInformation();
- info.hostname = report.getNodeId().getHost();
- info.healthReport = report.getHealthReport();
- info.httpAddress = report.getHttpAddress();
- info.labels = SliderUtils.extractNodeLabel(report);
- info.rackName = report.getRackName();
- info.state = report.getNodeState().toString();
- results.add(info);
- }
- return results;
- }
-
- /**
- * Monitor the submitted application for reaching the requested state.
- * Will also report if the app reaches a later state (failed, killed, etc)
- * Kill application if duration!= null & time expires.
- * @param appId Application Id of application to be monitored
- * @param duration how long to wait -must be more than 0
- * @param desiredState desired state.
- * @return the application report -null on a timeout
- * @throws YarnException
- * @throws IOException
- */
- public ApplicationReport monitorAppToState(
- ApplicationId appId, YarnApplicationState desiredState, Duration duration)
- throws YarnException, IOException {
-
- if (appId == null) {
- throw new BadCommandArgumentsException("null application ID");
- }
- if (duration.limit <= 0) {
- throw new BadCommandArgumentsException("Invalid monitoring duration");
- }
- log.debug("Waiting {} millis for app to reach state {} ",
- duration.limit,
- desiredState);
- duration.start();
- try {
- while (true) {
- // Get application report for the appId we are interested in
-
- ApplicationReport r = getApplicationReport(appId);
-
- log.debug("queried status is\n{}",
- new SliderUtils.OnDemandReportStringifier(r));
-
- YarnApplicationState state = r.getYarnApplicationState();
- if (state.ordinal() >= desiredState.ordinal()) {
- log.debug("App in desired state (or higher) :{}", state);
- return r;
- }
- if (duration.getLimitExceeded()) {
- log.debug(
- "Wait limit of {} millis to get to state {}, exceeded; app " +
- "status\n {}",
- duration.limit,
- desiredState,
- new SliderUtils.OnDemandReportStringifier(r));
- return null;
- }
-
- // sleep 1s.
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignored) {
- log.debug("Thread sleep in monitoring loop interrupted");
- }
- }
- } finally {
- duration.close();
- }
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/TokensOperation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/TokensOperation.java
deleted file mode 100644
index 84c65b3..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/TokensOperation.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.client;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.security.Credentials;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.common.params.ActionTokensArgs;
-import org.apache.slider.core.exceptions.BadClusterStateException;
-import org.apache.slider.core.exceptions.NotFoundException;
-import static org.apache.slider.core.launch.CredentialUtils.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-
-public class TokensOperation {
-
- private static final Logger log = LoggerFactory.getLogger(TokensOperation.class);
- public static final String E_INSECURE
- = "Cluster is not secure -tokens cannot be acquired";
- public static final String E_MISSING_SOURCE_FILE = "Missing source file: ";
- public static final String E_NO_KEYTAB = "No keytab: ";
-
- public int actionTokens(ActionTokensArgs args, FileSystem fs,
- Configuration conf,
- YarnClientImpl yarnClient)
- throws IOException, YarnException {
- Credentials credentials;
- String footnote = "";
- UserGroupInformation user = UserGroupInformation.getCurrentUser();
- boolean isSecure = UserGroupInformation.isSecurityEnabled();
- if (args.keytab != null) {
- File keytab = args.keytab;
- if (!keytab.isFile()) {
- throw new NotFoundException(E_NO_KEYTAB + keytab.getAbsolutePath());
- }
- String principal = args.principal;
- log.info("Logging in as {} from keytab {}", principal, keytab);
- user = UserGroupInformation.loginUserFromKeytabAndReturnUGI(
- principal, keytab.getCanonicalPath());
- }
- Credentials userCredentials = user.getCredentials();
- File output = args.output;
- if (output != null) {
- if (!isSecure) {
- throw new BadClusterStateException(E_INSECURE);
- }
- credentials = new Credentials(userCredentials);
- // filesystem
- addRMRenewableFSDelegationTokens(conf, fs, credentials);
- addRMDelegationToken(yarnClient, credentials);
- if (maybeAddTimelineToken(conf, credentials) != null) {
- log.debug("Added timeline token");
- }
- saveTokens(output, credentials);
- String filename = output.getCanonicalPath();
- footnote = String.format(
- "%d tokens saved to %s%n" + "To use these in the environment:%n"
- + "export %s=%s", credentials.numberOfTokens(), filename,
- UserGroupInformation.HADOOP_TOKEN_FILE_LOCATION, filename);
- } else if (args.source != null) {
- File source = args.source;
- log.info("Reading credentials from file {}", source);
- if (!source.isFile()) {
- throw new NotFoundException( E_MISSING_SOURCE_FILE + source.getAbsolutePath());
- }
- credentials = Credentials.readTokenStorageFile(args.source, conf);
- } else {
- StringBuffer origin = new StringBuffer();
- File file = locateEnvCredentials(System.getenv(), conf,
- origin);
- if (file != null) {
- log.info("Credential Source {}", origin);
- } else {
- log.info("Credential source: logged in user");
- }
- credentials = userCredentials;
- }
- // list the tokens
- log.info("\n{}", dumpTokens(credentials, "\n"));
- if (!footnote.isEmpty()) {
- log.info(footnote);
- }
- return 0;
- }
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
deleted file mode 100644
index e89a660..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.client.ipc;
-
-import com.google.common.annotations.VisibleForTesting;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.api.ClusterNode;
-import org.apache.slider.api.SliderClusterProtocol;
-import org.apache.slider.api.StateValues;
-import org.apache.slider.api.proto.Messages;
-import org.apache.slider.api.resource.Application;
-import org.apache.slider.api.types.ContainerInformation;
-import org.apache.slider.api.types.NodeInformation;
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.slider.api.types.PingInformation;
-import org.apache.slider.common.tools.Duration;
-import org.apache.slider.core.exceptions.NoSuchNodeException;
-import org.apache.slider.core.exceptions.SliderException;
-import org.apache.slider.core.exceptions.WaitTimeoutException;
-import org.apache.slider.core.persist.JsonSerDeser;
-import org.codehaus.jackson.JsonParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import static org.apache.slider.api.types.RestTypeMarshalling.unmarshall;
-
-/**
- * Cluster operations at a slightly higher level than the RPC code
- */
-public class SliderClusterOperations {
- protected static final Logger
- log = LoggerFactory.getLogger(SliderClusterOperations.class);
-
- private final SliderClusterProtocol appMaster;
- private static final JsonSerDeser jsonSerDeser =
- new JsonSerDeser(Application.class);
- private static final Messages.EmptyPayloadProto EMPTY;
- static {
- EMPTY = Messages.EmptyPayloadProto.newBuilder().build();
- }
-
- public SliderClusterOperations(SliderClusterProtocol appMaster) {
- this.appMaster = appMaster;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("SliderClusterOperations{");
- sb.append("IPC binding=").append(appMaster);
- sb.append('}');
- return sb.toString();
- }
-
- /**
- * Get a node from the AM
- * @param uuid uuid of node
- * @return deserialized node
- * @throws IOException IO problems
- * @throws NoSuchNodeException if the node isn't found
- */
- public ClusterNode getNode(String uuid)
- throws IOException, NoSuchNodeException, YarnException {
- Messages.GetNodeRequestProto req =
- Messages.GetNodeRequestProto.newBuilder().setUuid(uuid).build();
- Messages.GetNodeResponseProto node = appMaster.getNode(req);
- return ClusterNode.fromProtobuf(node.getClusterNode());
- }
-
- /**
- * Unmarshall a list of nodes from a protobud response
- * @param nodes node list
- * @return possibly empty list of cluster nodes
- * @throws IOException
- */
- public List convertNodeWireToClusterNodes(List nodes)
- throws IOException {
- List nodeList = new ArrayList<>(nodes.size());
- for (Messages.RoleInstanceState node : nodes) {
- nodeList.add(ClusterNode.fromProtobuf(node));
- }
- return nodeList;
- }
-
- /**
- * Echo text (debug action)
- * @param text text
- * @return the text, echoed back
- * @throws YarnException
- * @throws IOException
- */
- public String echo(String text) throws YarnException, IOException {
- Messages.EchoRequestProto.Builder builder =
- Messages.EchoRequestProto.newBuilder();
- builder.setText(text);
- Messages.EchoRequestProto req = builder.build();
- Messages.EchoResponseProto response = appMaster.echo(req);
- return response.getText();
- }
-
-
- /**
- * Connect to a live cluster and get its current state
- * @return its description
- */
- public Application getApplication() throws YarnException, IOException {
- Messages.GetJSONClusterStatusRequestProto req =
- Messages.GetJSONClusterStatusRequestProto.newBuilder().build();
- Messages.GetJSONClusterStatusResponseProto resp =
- appMaster.getJSONClusterStatus(req);
- String statusJson = resp.getClusterSpec();
- try {
- return jsonSerDeser.fromJson(statusJson);
- } catch (JsonParseException e) {
- log.error("Error when parsing app json file", e);
- throw e;
- }
- }
-
- /**
- * Kill a container
- * @param id container ID
- * @return a success flag
- * @throws YarnException
- * @throws IOException
- */
- public boolean killContainer(String id) throws
- YarnException,
- IOException {
- Messages.KillContainerRequestProto.Builder builder =
- Messages.KillContainerRequestProto.newBuilder();
- builder.setId(id);
- Messages.KillContainerRequestProto req = builder.build();
- Messages.KillContainerResponseProto response = appMaster.killContainer(req);
- return response.getSuccess();
- }
-
- /**
- * List all node UUIDs in a role
- * @param role role name or "" for all
- * @return an array of UUID strings
- * @throws IOException
- * @throws YarnException
- */
- public String[] listNodeUUIDsByRole(String role) throws IOException, YarnException {
- Collection uuidList = innerListNodeUUIDSByRole(role);
- String[] uuids = new String[uuidList.size()];
- return uuidList.toArray(uuids);
- }
-
- public List innerListNodeUUIDSByRole(String role) throws IOException, YarnException {
- Messages.ListNodeUUIDsByRoleRequestProto req =
- Messages.ListNodeUUIDsByRoleRequestProto
- .newBuilder()
- .setRole(role)
- .build();
- Messages.ListNodeUUIDsByRoleResponseProto resp = appMaster.listNodeUUIDsByRole(req);
- return resp.getUuidList();
- }
-
- /**
- * List all nodes in a role. This is a double round trip: once to list
- * the nodes in a role, another to get their details
- * @param role
- * @return an array of ContainerNode instances
- * @throws IOException
- * @throws YarnException
- */
- public List listClusterNodesInRole(String role)
- throws IOException, YarnException {
-
- Collection uuidList = innerListNodeUUIDSByRole(role);
- Messages.GetClusterNodesRequestProto req =
- Messages.GetClusterNodesRequestProto
- .newBuilder()
- .addAllUuid(uuidList)
- .build();
- Messages.GetClusterNodesResponseProto resp = appMaster.getClusterNodes(req);
- return convertNodeWireToClusterNodes(resp.getClusterNodeList());
- }
-
- /**
- * Get the details on a list of uuids
- * @param uuids instance IDs
- * @return a possibly empty list of node details
- * @throws IOException
- * @throws YarnException
- */
- @VisibleForTesting
- public List listClusterNodes(String[] uuids)
- throws IOException, YarnException {
-
- Messages.GetClusterNodesRequestProto req =
- Messages.GetClusterNodesRequestProto
- .newBuilder()
- .addAllUuid(Arrays.asList(uuids))
- .build();
- Messages.GetClusterNodesResponseProto resp = appMaster.getClusterNodes(req);
- return convertNodeWireToClusterNodes(resp.getClusterNodeList());
- }
-
- /**
- * Wait for an instance of a named role to be live (or past it in the lifecycle)
- * @param role role to look for
- * @param timeout time to wait
- * @return the state. If still in CREATED, the cluster didn't come up
- * in the time period. If LIVE, all is well. If >LIVE, it has shut for a reason
- * @throws IOException IO
- * @throws SliderException Slider
- * @throws WaitTimeoutException if the wait timed out
- */
- @VisibleForTesting
- public int waitForRoleInstanceLive(String role, long timeout)
- throws WaitTimeoutException, IOException, YarnException {
- Duration duration = new Duration(timeout);
- duration.start();
- boolean live = false;
- int state = StateValues.STATE_CREATED;
-
- log.info("Waiting {} millis for a live node in role {}", timeout, role);
- try {
- while (!live) {
- // see if there is a node in that role yet
- List uuids = innerListNodeUUIDSByRole(role);
- String[] containers = uuids.toArray(new String[uuids.size()]);
- int roleCount = containers.length;
- ClusterNode roleInstance = null;
- if (roleCount != 0) {
-
- // if there is, get the node
- roleInstance = getNode(containers[0]);
- if (roleInstance != null) {
- state = roleInstance.state;
- live = state >= StateValues.STATE_LIVE;
- }
- }
- if (!live) {
- if (duration.getLimitExceeded()) {
- throw new WaitTimeoutException(
- String.format("Timeout after %d millis" +
- " waiting for a live instance of type %s; " +
- "instances found %d %s",
- timeout, role, roleCount,
- (roleInstance != null
- ? (" instance -\n" + roleInstance.toString())
- : "")
- ));
- } else {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignored) {
- // ignored
- }
- }
- }
- }
- } finally {
- duration.close();
- }
- return state;
- }
-
- public void flex(Map componentCounts) throws IOException{
- Messages.FlexComponentsRequestProto.Builder builder =
- Messages.FlexComponentsRequestProto.newBuilder();
- for (Entry componentCount : componentCounts.entrySet()) {
- Messages.ComponentCountProto componentProto =
- Messages.ComponentCountProto.newBuilder()
- .setName(componentCount.getKey())
- .setNumberOfContainers(componentCount.getValue()).build();
- builder.addComponents(componentProto);
- }
- appMaster.flexComponents(builder.build());
- }
-
- /**
- * Commit (possibly delayed) AM suicide
- *
- * @param signal exit code
- * @param text text text to log
- * @param delay delay in millis
- * @throws YarnException
- * @throws IOException
- */
- public void amSuicide(String text, int signal, int delay)
- throws IOException {
- Messages.AMSuicideRequestProto.Builder builder =
- Messages.AMSuicideRequestProto.newBuilder();
- if (text != null) {
- builder.setText(text);
- }
- builder.setSignal(signal);
- builder.setDelay(delay);
- Messages.AMSuicideRequestProto req = builder.build();
- appMaster.amSuicide(req);
- }
-
- public List getContainers() throws IOException {
- Messages.GetLiveContainersResponseProto response = appMaster
- .getLiveContainers(Messages.GetLiveContainersRequestProto.newBuilder()
- .build());
- return unmarshall(response);
- }
-
- public NodeInformationList getLiveNodes() throws IOException {
- Messages.GetLiveNodesResponseProto response =
- appMaster.getLiveNodes(Messages.GetLiveNodesRequestProto.newBuilder().build());
-
- int records = response.getNodesCount();
- NodeInformationList nil = new NodeInformationList(records);
- for (int i = 0; i < records; i++) {
- nil.add(unmarshall(response.getNodes(i)));
- }
- return nil;
- }
-
- public NodeInformation getLiveNode(String hostname) throws IOException {
- Messages.GetLiveNodeRequestProto.Builder builder =
- Messages.GetLiveNodeRequestProto.newBuilder();
- builder.setName(hostname);
- return unmarshall(appMaster.getLiveNode(builder.build()));
- }
-
- public PingInformation ping(String text) throws IOException {
- return null;
- }
-
- public void stop(String text) throws IOException {
- amSuicide(text, 3, 0);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/Constants.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/Constants.java
deleted file mode 100644
index 0e3559a..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/Constants.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common;
-
-public class Constants {
- public static final int CONNECT_TIMEOUT = 10000;
- public static final int RPC_TIMEOUT = 15000;
-
- public static final String HADOOP_JAAS_DEBUG = "HADOOP_JAAS_DEBUG";
- public static final String KRB5_CCNAME = "KRB5CCNAME";
- public static final String JAVA_SECURITY_KRB5_CONF
- = "java.security.krb5.conf";
- public static final String JAVA_SECURITY_KRB5_REALM
- = "java.security.krb5.realm";
- public static final String SUN_SECURITY_KRB5_DEBUG
- = "sun.security.krb5.debug";
- public static final String SUN_SECURITY_SPNEGO_DEBUG
- = "sun.security.spnego.debug";
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/SliderXMLConfKeysForTesting.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/SliderXMLConfKeysForTesting.java
deleted file mode 100644
index 61c828e..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/SliderXMLConfKeysForTesting.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common;
-
-/**
- * Keys shared across tests
- */
-public interface SliderXMLConfKeysForTesting {
-
- String KEY_TEST_THAW_WAIT_TIME = "slider.test.thaw.wait.seconds";
-
- int DEFAULT_THAW_WAIT_TIME_SECONDS = 60;
-
-
- String KEY_TEST_FREEZE_WAIT_TIME = "slider.test.freeze.wait.seconds";
-
- int DEFAULT_TEST_FREEZE_WAIT_TIME_SECONDS = 60;
-
- String KEY_TEST_TIMEOUT = "slider.test.timeout.seconds";
-
- int DEFAULT_TEST_TIMEOUT_SECONDS = 30 * 60;
-
- String KEY_ACCUMULO_LAUNCH_TIME =
- "slider.test.accumulo.launch.wait.seconds";
- int DEFAULT_ACCUMULO_LAUNCH_TIME_SECONDS = 60 * 3;
-
- String KEY_ACCUMULO_GO_LIVE_TIME =
- "slider.test.accumulo.live.wait.seconds";
- int DEFAULT_ACCUMULO_LIVE_TIME_SECONDS = 90;
-
- String KEY_TEST_AGENT_ENABLED = "slider.test.agent.enabled";
- String KEY_AGENTTESTS_QUEUE_LABELED_DEFINED = "slider.test.agent.labeled.queue.enabled";
- String KEY_AGENTTESTS_LABELS_RED_BLUE_DEFINED = "slider.test.agent.labels.defined";
- String KEY_AGENTTESTS_AM_FAILURES_ENABLED = "slider.test.agent.am.failures.enabled";
-
- int DEFAULT_AGENT_LAUNCH_TIME_SECONDS = 60 * 3;
-
- String KEY_TEST_AGENT_HOME = "slider.test.agent.home";
- String KEY_TEST_AGENT_TAR = "slider.test.agent.tar";
-
- String KEY_TEST_TEARDOWN_KILLALL = "slider.test.teardown.killall";
- boolean DEFAULT_TEARDOWN_KILLALL = true;
-
-
- /**
- * Key for amount of RAM to request
- */
- String KEY_TEST_YARN_RAM_REQUEST = "slider.test.yarn.ram";
- String DEFAULT_YARN_RAM_REQUEST = "192";
-
- /**
- * security related keys
- */
- String TEST_SECURITY_DIR = "/tmp/work/security";
-
- /**
- * Local path to AM keytab: {@value}
- */
- String KEY_TEST_AM_KEYTAB = "slider.test.am.keytab.local";
-
- /**
- * Is the test cluster windows? Default is: same as the local system.
- * {@value}
- */
- String KEY_TEST_WINDOWS_CLUSTER = "slider.test.windows.cluster";
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionAMSuicideArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionAMSuicideArgs.java
deleted file mode 100644
index 04ec9e2..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionAMSuicideArgs.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Parameters;
-import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs;
-import org.apache.hadoop.yarn.service.client.params.SliderActions;
-
-@Parameters(commandNames = { SliderActions.ACTION_AM_SUICIDE},
- commandDescription = SliderActions.DESCRIBE_ACTION_AM_SUICIDE)
-public class ActionAMSuicideArgs extends AbstractActionArgs {
-
- @Override
- public String getActionName() {
- return SliderActions.ACTION_AM_SUICIDE;
- }
-
- @Parameter(names = {ARG_MESSAGE},
- description = "reason for the action")
- public String message = "";
-
- @Parameter(names = {ARG_EXITCODE},
- description = "exit code")
- public int exitcode = 1;
-
- @Parameter(names = {ARG_WAIT},
- description = "time for AM to wait before exiting")
- public int waittime = 1000;
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java
deleted file mode 100644
index cb36961..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Parameters;
-import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs;
-import org.apache.hadoop.yarn.service.client.params.SliderActions;
-
-@Parameters(
- commandNames = { SliderActions.ACTION_DIAGNOSTICS},
- commandDescription = SliderActions.DESCRIBE_ACTION_DIAGNOSTIC)
-public class ActionDiagnosticArgs extends AbstractActionArgs {
-
- @Override
- public String getActionName() {
- return SliderActions.ACTION_DIAGNOSTICS;
- }
-
- @Parameter(names = {ARG_NAME},
- description = "the name of the running application")
- public String name;
-
- @Parameter(names = {ARG_CLIENT},
- description = "print configuration of the slider client")
- public boolean client = false;
-
- @Parameter(names = {ARG_APPLICATION},
- description = "print configuration of the running application")
- public boolean application;
-
- @Parameter(names = {ARG_VERBOSE},
- description = "print out information in details")
- public boolean verbose = false;
-
- @Parameter(names = {ARG_YARN},
- description = "print configuration of the YARN cluster")
- public boolean yarn = false;
-
- @Parameter(names = {ARG_CREDENTIALS},
- description = "print credentials of the current user")
- public boolean credentials = false;
-
- @Parameter(names = {ARG_ALL},
- description = "print all of the information above")
- public boolean all;
-
- @Parameter(names = {ARG_LEVEL},
- description = "diagnose each slider configuration one by one")
- public boolean level;
-
- /**
- * Get the min #of params expected
- * @return the min number of params in the {@link #parameters} field
- */
- @Override
- public int getMinParams() {
- return 0;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionKillContainerArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionKillContainerArgs.java
deleted file mode 100644
index e1e94bd..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionKillContainerArgs.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Parameters;
-import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs;
-import org.apache.hadoop.yarn.service.client.params.SliderActions;
-
-@Parameters(commandNames = { SliderActions.ACTION_KILL_CONTAINER},
- commandDescription = SliderActions.DESCRIBE_ACTION_KILL_CONTAINER)
-
-public class ActionKillContainerArgs extends AbstractActionArgs {
- @Override
- public String getActionName() {
- return SliderActions.ACTION_KILL_CONTAINER;
- }
-
- @Parameter(names = {ARG_ID},
- description = "ID of the container")
- public String id;
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionLookupArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionLookupArgs.java
deleted file mode 100644
index 0888812..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionLookupArgs.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Parameters;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs;
-import org.apache.hadoop.yarn.service.client.params.SliderActions;
-import org.apache.slider.core.exceptions.BadCommandArgumentsException;
-import org.apache.slider.core.exceptions.UsageException;
-
-import java.io.File;
-
-@Parameters(commandNames = { SliderActions.ACTION_LOOKUP},
- commandDescription = SliderActions.DESCRIBE_ACTION_LOOKUP)
-
-public class ActionLookupArgs extends AbstractActionArgs {
- @Override
- public String getActionName() {
- return SliderActions.ACTION_LOOKUP;
- }
-
- public int getMinParams() {
- return 0;
- }
- public int getMaxParams() {
- return 0;
- }
-
- @Parameter(names = {ARG_ID},
- description = "ID of the application")
- public String id;
-
- @Parameter(names = {ARG_OUTPUT, ARG_OUTPUT_SHORT},
- description = "output file for any application report")
- public File outputFile;
-
- @Override
- public void validate() throws BadCommandArgumentsException, UsageException {
- super.validate();
- if (StringUtils.isEmpty(id)) {
- throw new BadCommandArgumentsException("Missing mandatory argument "
- + ARG_ID);
- }
- }
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder(SliderActions.ACTION_LOOKUP);
- if (id!=null) {
- sb.append(" ");
- sb.append(ARG_ID).append(" ").append(id);
- }
- if (outputFile != null) {
- sb.append(" ");
- sb.append(ARG_OUTPUT).append(" ").append(outputFile.getAbsolutePath());
- }
- return sb.toString();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionNodesArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionNodesArgs.java
deleted file mode 100644
index 5a0b019..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionNodesArgs.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Parameters;
-import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs;
-import org.apache.hadoop.yarn.service.client.params.SliderActions;
-
-import java.io.File;
-
-@Parameters(commandNames = { SliderActions.ACTION_NODES},
- commandDescription = SliderActions.DESCRIBE_ACTION_NODES)
-public class ActionNodesArgs extends AbstractActionArgs {
-
- /**
- * Instance for API use; on CLI the name is derived from {@link #getClusterName()}.
- */
- public String instance;
-
- @Override
- public String getActionName() {
- return SliderActions.ACTION_NODES;
- }
-
- @Parameter(names = {ARG_OUTPUT, ARG_OUTPUT_SHORT},
- description = "Output file for the information")
- public File outputFile;
-
- @Parameter(names = {ARG_LABEL})
- public String label = "";
-
- @Parameter(names = {ARG_HEALTHY} )
- public boolean healthy;
-
- @Override
- public int getMinParams() {
- return 0;
- }
-
- @Override
- public int getMaxParams() {
- return 1;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder(
- "ActionNodesArgs{");
- sb.append("instance='").append(instance).append('\'');
- sb.append(", outputFile=").append(outputFile);
- sb.append(", label='").append(label).append('\'');
- sb.append(", healthy=").append(healthy);
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionUpgradeArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionUpgradeArgs.java
deleted file mode 100644
index b909cdd..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionUpgradeArgs.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameters;
-import org.apache.hadoop.yarn.service.client.params.SliderActions;
-
-@Parameters(commandNames = { SliderActions.ACTION_UPGRADE },
- commandDescription = SliderActions.DESCRIBE_ACTION_UPGRADE)
-public class ActionUpgradeArgs extends AbstractClusterBuildingActionArgs {
-
- @Override
- public String getActionName() {
- return SliderActions.ACTION_UPGRADE;
- }
-
-// TODO upgrade container
-// @Parameter(names={ARG_CONTAINERS}, variableArity = true,
-// description = "stop specific containers")
-// public List containers = new ArrayList<>(0);
-//
-// @Parameter(names={ARG_COMPONENTS}, variableArity = true,
-// description = "stop all containers of specific components")
-// public List components = new ArrayList<>(0);
-//
-// @Parameter(names = {ARG_FORCE},
-// description = "force spec upgrade operation")
-// public boolean force;
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionVersionArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionVersionArgs.java
deleted file mode 100644
index b0f17d0..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/ActionVersionArgs.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameters;
-import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs;
-import org.apache.hadoop.yarn.service.client.params.SliderActions;
-
-/**
- * The version command
- */
-@Parameters(commandNames = { SliderActions.ACTION_VERSION},
- commandDescription = SliderActions.DESCRIBE_ACTION_VERSION)
-public class ActionVersionArgs extends AbstractActionArgs {
- @Override
- public String getActionName() {
- return SliderActions.ACTION_VERSION;
- }
-
- public int getMinParams() {
- return 0;
- }
-
- /**
- * This action does not need hadoop services
- * @return false
- */
- @Override
- public boolean getHadoopServicesRequired() {
- return false;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/AddonArgsDelegate.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/AddonArgsDelegate.java
deleted file mode 100644
index 3ef8e19..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/AddonArgsDelegate.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.Parameter;
-import org.apache.slider.core.exceptions.BadCommandArgumentsException;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class AddonArgsDelegate extends AbstractArgsDelegate {
-
- /**
- * This is a listing of addon packages
- */
- @Parameter(names = {ARG_ADDON},
- arity = 2,
- description = "--addon ",
- splitter = DontSplitArguments.class)
- public List addonTuples = new ArrayList<>(0);
-
-
- /**
- * Get the list of addons (may be empty, but never null)
- *
- * @return map of named addons
- *
- * @throws BadCommandArgumentsException parse problem
- */
- public Map getAddonMap() throws BadCommandArgumentsException {
- return convertTupleListToMap("addon", addonTuples);
- }
-
- public List getAddonTuples() {
- return addonTuples;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/URIArgumentConverter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/URIArgumentConverter.java
deleted file mode 100644
index b0d1ebf..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/URIArgumentConverter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.converters.BaseConverter;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-public class URIArgumentConverter extends BaseConverter {
-
- public URIArgumentConverter(String optionName) {
- super(optionName);
- }
-
- @Override
- public URI convert(String value) {
- try {
- return new URI(value);
- } catch (URISyntaxException e) {
- throw new RuntimeException("Cannot make a URI from " + value);
- }
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/URLArgumentConverter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/URLArgumentConverter.java
deleted file mode 100644
index 8894309..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/URLArgumentConverter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.slider.common.params;
-
-import com.beust.jcommander.converters.BaseConverter;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-public class URLArgumentConverter extends BaseConverter {
- public URLArgumentConverter(String optionName) {
- super(optionName);
- }
-
- @Override
- public URL convert(String value) {
- try {
- return new URL(value);
- } catch (MalformedURLException e) {
- throw new RuntimeException("Cannot make a URL from " + value);
- }
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/tools/ConfigHelper.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/tools/ConfigHelper.java
deleted file mode 100644
index 64fd8ae..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/tools/ConfigHelper.java
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.tools;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.IOUtils;
-import org.apache.hadoop.yarn.service.conf.SliderKeys;
-import org.apache.hadoop.yarn.service.conf.SliderXmlConfKeys;
-import org.apache.slider.core.exceptions.BadConfigException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Methods to aid in config, both in the Configuration class and
- * with other parts of setting up Slider-initated processes.
- *
- * Some of the methods take an argument of a map iterable for their sources; this allows
- * the same method
- */
-public class ConfigHelper {
- private static final Logger log = LoggerFactory.getLogger(ConfigHelper.class);
-
- /**
- * Dump the (sorted) configuration
- * @param conf config
- * @return the sorted keyset
- */
- public static Set dumpConf(Configuration conf) {
- Set keys = sortedConfigKeys(conf);
- for (String key : keys) {
- log.info("{}={}", key, conf.get(key));
- }
- return keys;
- }
-
- /**
- * Take a configuration and return a sorted set
- * @param conf config
- * @return the sorted keyset
-
- */
- public static Set sortedConfigKeys(Iterable> conf) {
- TreeSet sorted = new TreeSet();
- for (Map.Entry entry : conf) {
- sorted.add(entry.getKey());
- }
- return sorted;
- }
-
- /**
- * Set an entire map full of values
- *
- * @param config config to patch
- * @param map map of data
- * @param origin origin data
- */
- public static void addConfigMap(Configuration config,
- Map map,
- String origin) throws BadConfigException {
- addConfigMap(config, map.entrySet(), origin);
- }
-
- /**
- * Set an entire map full of values
- *
- * @param config config to patch
- * @param map map of data
- * @param origin origin data
- */
- public static void addConfigMap(Configuration config,
- Iterable> map,
- String origin) throws BadConfigException {
- for (Map.Entry mapEntry : map) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- if (value == null) {
- throw new BadConfigException("Null value for property " + key);
- }
- config.set(key, value, origin);
- }
- }
-
-
- /**
- * Save a config file in a destination directory on a given filesystem
- * @param systemConf system conf used for creating filesystems
- * @param confToSave config to save
- * @param confdir the directory path where the file is to go
- * @param filename the filename
- * @return the destination path where the file was saved
- * @throws IOException IO problems
- */
- public static Path saveConfig(Configuration systemConf,
- Configuration confToSave,
- Path confdir,
- String filename) throws IOException {
- FileSystem fs = FileSystem.get(confdir.toUri(), systemConf);
- Path destPath = new Path(confdir, filename);
- saveConfig(fs, destPath, confToSave);
- return destPath;
- }
-
- /**
- * Save a config
- * @param fs filesystem
- * @param destPath dest to save
- * @param confToSave config to save
- * @throws IOException IO problems
- */
- public static void saveConfig(FileSystem fs,
- Path destPath,
- Configuration confToSave) throws
- IOException {
- FSDataOutputStream fos = fs.create(destPath);
- try {
- confToSave.writeXml(fos);
- } finally {
- IOUtils.closeStream(fos);
- }
- }
-
- /**
- * Convert to an XML string
- * @param conf configuration
- * @return conf
- * @throws IOException
- */
- public static String toXml(Configuration conf) throws IOException {
- StringWriter writer = new StringWriter();
- conf.writeXml(writer);
- return writer.toString();
- }
-
- /**
- * This will load and parse a configuration to an XML document
- * @param fs filesystem
- * @param path path
- * @return an XML document
- * @throws IOException IO failure
- */
- public Document parseConfiguration(FileSystem fs,
- Path path) throws
- IOException {
-
-
- byte[] data = loadBytes(fs, path);
- //this is here to track down a parse issue
- //related to configurations
- String s = new String(data, 0, data.length, "UTF-8");
- log.debug("XML resource {} is \"{}\"", path, s);
-/* JDK7
- try (ByteArrayInputStream in = new ByteArrayInputStream(data)) {
- Document document = parseConfigXML(in);
- return document;
- } catch (ParserConfigurationException | SAXException e) {
- throw new IOException(e);
- }
-*/
- ByteArrayInputStream in= null;
- try {
- in = new ByteArrayInputStream(data);
- Document document = parseConfigXML(in);
- return document;
- } catch (ParserConfigurationException e) {
- throw new IOException(e);
- } catch (SAXException e) {
- throw new IOException(e);
- } finally {
- IOUtils.closeStream(in);
- }
- }
-
- public static byte[] loadBytes(FileSystem fs, Path path) throws IOException {
- int len = (int) fs.getLength(path);
- byte[] data = new byte[len];
- /* JDK7
- try(FSDataInputStream in = fs.open(path)) {
- in.readFully(0, data);
- }
-*/
- FSDataInputStream in = null;
- in = fs.open(path);
- try {
- in.readFully(0, data);
- } finally {
- IOUtils.closeStream(in);
- }
- return data;
- }
-
- /**
- * Load a configuration from ANY FS path. The normal Configuration
- * loader only works with file:// URIs
- * @param fs filesystem
- * @param path path
- * @return a loaded resource
- * @throws IOException
- */
- public static Configuration loadConfiguration(FileSystem fs,
- Path path) throws IOException {
- byte[] data = loadBytes(fs, path);
-
- ByteArrayInputStream in2;
-
- in2 = new ByteArrayInputStream(data);
- Configuration conf1 = new Configuration(false);
- conf1.addResource(in2);
- //now clone it while dropping all its sources
- Configuration conf2 = new Configuration(false);
- String src = path.toString();
- for (Map.Entry entry : conf1) {
- String key = entry.getKey();
- String value = entry.getValue();
- conf2.set(key, value, src);
- }
- return conf2;
- }
-
-
- /**
- * Generate a config file in a destination directory on the local filesystem
- * @param confdir the directory path where the file is to go
- * @param filename the filename
- * @return the destination path
- */
- public static File saveConfig(Configuration generatingConf,
- File confdir,
- String filename) throws IOException {
-
-
- File destPath = new File(confdir, filename);
- OutputStream fos = new FileOutputStream(destPath);
- try {
- generatingConf.writeXml(fos);
- } finally {
- IOUtils.closeStream(fos);
- }
- return destPath;
- }
-
- /**
- * Parse an XML Hadoop configuration into an XML document. x-include
- * is supported, but as the location isn't passed in, relative
- * URIs are out.
- * @param in instream
- * @return a document
- * @throws ParserConfigurationException parser feature problems
- * @throws IOException IO problems
- * @throws SAXException XML is invalid
- */
- public static Document parseConfigXML(InputStream in) throws
- ParserConfigurationException,
- IOException,
- SAXException {
- DocumentBuilderFactory docBuilderFactory
- = DocumentBuilderFactory.newInstance();
- //ignore all comments inside the xml file
- docBuilderFactory.setIgnoringComments(true);
-
- //allow includes in the xml file
- docBuilderFactory.setNamespaceAware(true);
- docBuilderFactory.setXIncludeAware(true);
- DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
- return builder.parse(in);
- }
-
- /**
- * Load a Hadoop configuration from a local file.
- * @param file file to load
- * @return a configuration which hasn't actually had the load triggered
- * yet.
- * @throws FileNotFoundException file is not there
- * @throws IOException any other IO problem
- */
- public static Configuration loadConfFromFile(File file) throws
- IOException {
- return loadConfFromFile(file, false);
- }
-
- /**
- *
- * Load a Hadoop configuration from a local file.
- * @param file file to load
- * @param loadDefaults flag to indicate if the defaults should be loaded yet
- * @return a configuration which hasn't actually had the load triggered
- * yet.
- * @throws FileNotFoundException file is not there
- * @throws IOException any other IO problem
- */
- public static Configuration loadConfFromFile(File file,
- boolean loadDefaults) throws IOException {
- if (!file.exists()) {
- throw new FileNotFoundException("File not found :"
- + file.getAbsoluteFile());
- }
- Configuration conf = new Configuration(loadDefaults);
- try {
- conf.addResource(file.toURI().toURL());
- } catch (MalformedURLException e) {
- // should never happen...
- throw new IOException(
- "File " + file.toURI() + " doesn't have a valid URL");
- }
- return conf;
- }
-
- /**
- * Add a configuration from a file to an existing configuration
- * @param conf existing configuration
- * @param file file to load
- * @param overwrite flag to indicate new values should overwrite the predecessor
- * @return the merged configuration
- * @throws IOException
- */
- public static Configuration addConfigurationFile(Configuration conf,
- File file, boolean overwrite)
- throws IOException {
- Configuration c2 = loadConfFromFile(file, false);
- mergeConfigurations(conf, c2, file.getAbsolutePath(), overwrite);
- return conf;
- }
-
- /**
- * Add the system env variables with the given prefix (by convention, env.)
- * @param conf existing configuration
- * @param prefix prefix
- */
- public static void addEnvironmentVariables(Configuration conf, String prefix) {
- Map env = System.getenv();
- for (Map.Entry entry : env.entrySet()) {
- conf.set(prefix + entry.getKey(),entry.getValue(), "env");
- }
- }
-
- /**
- * looks for the config under $confdir/$templateFilename; if not there
- * loads it from /conf/templateFile.
- * The property {@link SliderKeys#KEY_TEMPLATE_ORIGIN} is set to the
- * origin to help debug what's happening
- * @param systemConf system conf
- * @param confdir conf dir in FS
- * @param templateFilename filename in the confdir
- * @param fallbackResource resource to fall back on
- * @return loaded conf
- * @throws IOException IO problems
- */
- public static Configuration loadTemplateConfiguration(Configuration systemConf,
- Path confdir,
- String templateFilename,
- String fallbackResource) throws
- IOException {
- FileSystem fs = FileSystem.get(confdir.toUri(), systemConf);
-
- Path templatePath = new Path(confdir, templateFilename);
- return loadTemplateConfiguration(fs, templatePath, fallbackResource);
- }
-
- /**
- * looks for the config under $confdir/$templateFilename; if not there
- * loads it from /conf/templateFile.
- * The property {@link SliderKeys#KEY_TEMPLATE_ORIGIN} is set to the
- * origin to help debug what's happening.
- * @param fs Filesystem
- * @param templatePath HDFS path for template
- * @param fallbackResource resource to fall back on, or "" for no fallback
- * @return loaded conf
- * @throws IOException IO problems
- * @throws FileNotFoundException if the path doesn't have a file and there
- * was no fallback.
- */
- public static Configuration loadTemplateConfiguration(FileSystem fs,
- Path templatePath,
- String fallbackResource)
- throws IOException {
- Configuration conf;
- String origin;
- if (fs.exists(templatePath)) {
- log.debug("Loading template configuration {}", templatePath);
- conf = loadConfiguration(fs, templatePath);
- origin = templatePath.toString();
- } else {
- if (fallbackResource.isEmpty()) {
- throw new FileNotFoundException("No config file found at " + templatePath);
- }
- log.debug("Template {} not found" +
- " -reverting to classpath resource {}", templatePath, fallbackResource);
- conf = new Configuration(false);
- conf.addResource(fallbackResource);
- origin = "Resource " + fallbackResource;
- }
- //force a get
- conf.get(SliderXmlConfKeys.KEY_TEMPLATE_ORIGIN);
- //now set the origin
- conf.set(SliderXmlConfKeys.KEY_TEMPLATE_ORIGIN, origin);
- return conf;
- }
-
-
- /**
- * For testing: dump a configuration
- * @param conf configuration
- * @return listing in key=value style
- */
- public static String dumpConfigToString(Configuration conf) {
- Set sorted = sortedConfigKeys(conf);
-
- StringBuilder builder = new StringBuilder();
- for (String key : sorted) {
-
- builder.append(key)
- .append("=")
- .append(conf.get(key))
- .append("\n");
- }
- return builder.toString();
- }
-
- /**
- * Merge in one configuration above another
- * @param base base config
- * @param merge one to merge. This MUST be a non-default-load config to avoid
- * merge origin confusion
- * @param origin description of the origin for the put operation
- * @param overwrite flag to indicate new values should overwrite the predecessor
- * @return the base with the merged values
- */
- public static Configuration mergeConfigurations(Configuration base,
- Iterable> merge,
- String origin,
- boolean overwrite) {
- for (Map.Entry entry : merge) {
- String key = entry.getKey();
- if (overwrite || base.get(key) == null) {
- base.set(key, entry.getValue(), origin);
- }
- }
- return base;
- }
-
- /**
- * Register a resource as a default resource.
- * Do not attempt to use this unless you understand that the
- * order in which default resources are loaded affects the outcome,
- * and that subclasses of Configuration often register new default
- * resources
- * @param resource the resource name
- * @return the URL or null
- */
- public static URL registerDefaultResource(String resource) {
- URL resURL = getResourceUrl(resource);
- if (resURL != null) {
- Configuration.addDefaultResource(resource);
- }
- return resURL;
- }
-
- /**
- * Load a configuration from a resource on this classpath.
- * If the resource is not found, an empty configuration is returned
- * @param resource the resource name
- * @return the loaded configuration.
- */
- public static Configuration loadFromResource(String resource) {
- Configuration conf = new Configuration(false);
- URL resURL = getResourceUrl(resource);
- if (resURL != null) {
- log.debug("loaded resources from {}", resURL);
- conf.addResource(resource);
- } else{
- log.debug("failed to find {} on the classpath", resource);
- }
- return conf;
-
- }
-
- /**
- * Get the URL to a resource, null if not on the CP
- * @param resource resource to look for
- * @return the URL or null
- */
- public static URL getResourceUrl(String resource) {
- return ConfigHelper.class.getClassLoader()
- .getResource(resource);
- }
-
- /**
- * Load a resource that must be on the classpath
- * @param resource the resource name
- * @return the loaded configuration
- * @throws FileNotFoundException if the resource is missing
- */
- public static Configuration loadMandatoryResource(String resource)
- throws FileNotFoundException {
- Configuration conf = new Configuration(false);
- URL resURL = getResourceUrl(resource);
- if (resURL != null) {
- log.debug("loaded resources from {}", resURL);
- conf.addResource(resource);
- } else {
- throw new FileNotFoundException(resource);
- }
- return conf;
- }
-
- /**
- * Propagate a property from a source to a dest config, with a best-effort
- * attempt at propagating the origin.
- * If the
- * @param dest destination
- * @param src source
- * @param key key to try to copy
- * @return true if the key was found and propagated
- */
- public static boolean propagate(Configuration dest,
- Configuration src,
- String key) {
- String val = src.get(key);
- if (val != null) {
- String[] origin = src.getPropertySources(key);
- if (origin != null && origin.length > 0) {
- dest.set(key, val, origin[0]);
- } else {
- dest.set(key, val);
- return true;
- }
- }
- return false;
- }
-
-
- /**
- * Take a configuration, return a hash map
- * @param conf conf
- * @return hash map
- */
- public static Map buildMapFromConfiguration(Configuration conf) {
- Map map = new HashMap();
- return SliderUtils.mergeEntries(map, conf);
- }
-
- /**
- * This goes through the keyset of one configuration and retrieves each value
- * from a value source -a different or the same configuration. This triggers
- * the property resolution process of the value, resolving any variables against
- * in-config or inherited configurations
- * @param keysource source of keys
- * @param valuesource the source of values
- * @return a new configuration where foreach key in keysource, get(key)==valuesource.get(key)
- */
- public static Configuration resolveConfiguration(
- Iterable> keysource,
- Configuration valuesource) {
- Configuration result = new Configuration(false);
- for (Map.Entry entry : keysource) {
- String key = entry.getKey();
- String value = valuesource.get(key);
- Preconditions.checkState(value != null,
- "no reference for \"%s\" in values", key);
- result.set(key, value);
- }
- return result;
- }
-
- /**
- * Register anything we consider deprecated
- */
- public static void registerDeprecatedConfigItems() {
- }
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/tools/SliderVersionInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/tools/SliderVersionInfo.java
deleted file mode 100644
index 86025ee..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/tools/SliderVersionInfo.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.tools;
-
-import org.apache.hadoop.util.VersionInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Locale;
-import java.util.Properties;
-
-/**
- * Extract the version properties, which will look something like
- *
- * application.name=${pom.name}
- * application.version=${pom.version}
- * application.build=${buildNumber}
- * application.build.java.version=${java.version}
- * application.build.info=${pom.name}-${pom.version} Built against ${buildNumber} on ${java.version} by ${user.name}
- *
- *
- * the mvn process-resources target will expand the properties
- * and add the resources to target/classes, which will then look something like
- *
- * application.name=Slider Core
- * application.version=0.7.1-SNAPSHOT
- * application.build=1dd69
- * application.build.java.version=1.7.0_45
- * application.build.user=stevel
- * application.build.info=Slider Core-0.7.1-SNAPSHOT Built against 1dd69 on 1.7.0_45 by stevel
- *
- *
- * Note: the values will change and more properties added.
- */
-public class SliderVersionInfo {
- private static final Logger log = LoggerFactory.getLogger(SliderVersionInfo.class);
-
- /**
- * Name of the resource containing the filled-in-at-runtime props
- */
- public static final String VERSION_RESOURCE =
- "org/apache/slider/providers/dynamic/application.properties";
-
- public static final String APP_NAME = "application.name";
- public static final String APP_VERSION = "application.version";
- public static final String APP_BUILD = "application.build";
- public static final String APP_BUILD_JAVA_VERSION = "application.build.java.version";
- public static final String APP_BUILD_USER = "application.build.user";
- public static final String APP_BUILD_INFO = "application.build.info";
- public static final String HADOOP_BUILD_INFO = "hadoop.build.info";
- public static final String HADOOP_DEPLOYED_INFO = "hadoop.deployed.info";
-
-
- public static Properties loadVersionProperties() {
- Properties props = new Properties();
- URL resURL = SliderVersionInfo.class.getClassLoader()
- .getResource(VERSION_RESOURCE);
- assert resURL != null : "Null resource " + VERSION_RESOURCE;
-
- try {
- InputStream inStream = resURL.openStream();
- assert inStream != null : "Null input stream from " + VERSION_RESOURCE;
- props.load(inStream);
- } catch (IOException e) {
- log.warn("IOE loading " + VERSION_RESOURCE, e);
- }
- return props;
- }
-
- /**
- * Load the version info and print it
- * @param logger logger
- */
- public static void loadAndPrintVersionInfo(Logger logger) {
- Properties props = loadVersionProperties();
- logger.info(props.getProperty(APP_BUILD_INFO));
- logger.info("Compiled against Hadoop {}",
- props.getProperty(HADOOP_BUILD_INFO));
- logger.info(getHadoopVersionString());
- }
-
- public static String getHadoopVersionString() {
- return String.format(Locale.ENGLISH,
- "Hadoop runtime version %s with source checksum %s and build date %s",
- VersionInfo.getBranch(),
- VersionInfo.getSrcChecksum(),
- VersionInfo.getDate());
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/buildutils/BuildHelper.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/buildutils/BuildHelper.java
deleted file mode 100644
index 80f165f..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/buildutils/BuildHelper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.buildutils;
-
-import org.apache.hadoop.util.VersionInfo;
-import org.apache.slider.common.tools.SliderVersionInfo;
-
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * classes to help with the build
- */
-public class BuildHelper {
- /**
- * Add the cluster build information; this will include Hadoop details too
- * @param dest map to insert this too
- * @param prefix prefix for the build info
- */
- public static void addBuildMetadata(Map dest, String prefix) {
-
- Properties props = SliderVersionInfo.loadVersionProperties();
- dest.put(prefix + "." + SliderVersionInfo.APP_BUILD_INFO,
- props.getProperty(
- SliderVersionInfo.APP_BUILD_INFO));
- dest.put(prefix + "." + SliderVersionInfo.HADOOP_BUILD_INFO,
- props.getProperty(SliderVersionInfo.HADOOP_BUILD_INFO));
-
- dest.put(prefix + "." + SliderVersionInfo.HADOOP_DEPLOYED_INFO,
- VersionInfo.getBranch() + " @" + VersionInfo.getSrcChecksum());
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java
deleted file mode 100644
index 9714a0f..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.conf;
-
-import com.google.common.base.Preconditions;
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.exceptions.BadConfigException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Standard map operations.
- *
- * This delegates the standard map interface to the map passed in,
- * so it can be used to add more actions to the map.
- */
-public class MapOperations implements Map {
- private static final Logger log =
- LoggerFactory.getLogger(MapOperations.class);
- public static final String DAYS = ".days";
- public static final String HOURS = ".hours";
- public static final String MINUTES = ".minutes";
- public static final String SECONDS = ".seconds";
-
- /**
- * Global options
- */
- public final Map options;
-
- public final String name;
-
- public MapOperations() {
- options = new HashMap();
- name = "";
- }
-
- /**
- * Create an instance
- * @param name name
- * @param options source of options
- */
- public MapOperations(String name, Map options) {
- Preconditions.checkArgument(options != null, "null map");
- this.options = options;
- this.name = name;
- }
-
- /**
- * Create an instance from an iterative map entry
- * @param entry entry to work with
- */
- public MapOperations(Map.Entry> entry) {
- Preconditions.checkArgument(entry != null, "null entry");
- this.name = entry.getKey();
- this.options = entry.getValue();
- }
-
- /**
- * Get an option value
- *
- * @param key key
- * @param defVal default value
- * @return option in map or the default
- */
- public String getOption(String key, String defVal) {
- String val = options.get(key);
- return val != null ? val : defVal;
- }
-
- /**
- * Get a boolean option
- *
- * @param key option key
- * @param defVal default value
- * @return option true if the option equals "true", or the default value
- * if the option was not defined at all.
- */
- public Boolean getOptionBool(String key, boolean defVal) {
- String val = getOption(key, Boolean.toString(defVal));
- return Boolean.valueOf(val);
- }
-
- /**
- * Get a cluster option or value
- *
- * @param key option key
- * @return the value
- * @throws BadConfigException if the option is missing
- */
-
- public String getMandatoryOption(String key) throws BadConfigException {
- String val = options.get(key);
- if (val == null) {
- if (log.isDebugEnabled()) {
- log.debug("Missing key {} from config containing {}",
- key, this);
- }
- String text = "Missing option " + key;
- if (SliderUtils.isSet(name)) {
- text += " from set " + name;
- }
- throw new BadConfigException(text);
- }
- return val;
- }
-
- /**
- * Get an integer option; use {@link Integer#decode(String)} so as to take hex
- * oct and bin values too.
- *
- * @param option option name
- * @param defVal default value
- * @return parsed value
- * @throws NumberFormatException if the role could not be parsed.
- */
- public int getOptionInt(String option, int defVal) {
- String val = getOption(option, Integer.toString(defVal));
- return Integer.decode(val);
- }
-
- /**
- * Get a long option; use {@link Long#decode(String)} so as to take hex
- * oct and bin values too.
- *
- * @param option option name
- * @param defVal default value
- * @return parsed value
- * @throws NumberFormatException
- */
- public long getOptionLong(String option, long defVal) {
- String val = getOption(option, Long.toString(defVal));
- return Long.decode(val);
- }
-
- /**
- * Get a mandatory integer option; use {@link Integer#decode(String)} so as to take hex
- * oct and bin values too.
- *
- * @param option option name
- * @return parsed value
- * @throws NumberFormatException if the option could not be parsed.
- * @throws BadConfigException if the option could not be found
- */
- public int getMandatoryOptionInt(String option) throws BadConfigException {
- getMandatoryOption(option);
- return getOptionInt(option, 0);
- }
-
- /**
- * Verify that an option is set: that is defined AND non-empty
- * @param key
- * @throws BadConfigException
- */
- public void verifyOptionSet(String key) throws BadConfigException {
- if (SliderUtils.isUnset(getOption(key, null))) {
- throw new BadConfigException("Unset option %s", key);
- }
- }
-
- public void mergeWithoutOverwrite(Map that) {
- SliderUtils.mergeMapsIgnoreDuplicateKeys(options, that);
- }
-
- /**
- * Merge a map by prefixed keys
- * @param that the map to merge in
- * @param prefix prefix to match on
- * @param overwrite flag to enable overwrite
- */
- public void mergeMapPrefixedKeys(Map that,
- String prefix,
- boolean overwrite) {
- for (Map.Entry entry : that.entrySet()) {
- String key = entry.getKey();
- if (key.startsWith(prefix)) {
- if (overwrite || get(key) == null) {
- put(key, entry.getValue());
- }
- }
- }
- }
-
- /**
- * Set a property if it is not already set
- * @param key key
- * @param value value
- */
- public void putIfUnset(String key, String value) {
- if (get(key) == null) {
- put(key, value);
- }
- }
-
- public void set(String key, Object value) {
- assert value != null;
- put(key, value.toString());
- }
-
- public int size() {
- return options.size();
- }
-
- public boolean isEmpty() {
- return options.isEmpty();
- }
-
- public boolean containsValue(Object value) {
- return options.containsValue(value);
- }
-
- public boolean containsKey(Object key) {
- return options.containsKey(key);
- }
-
- public String get(Object key) {
- return options.get(key);
- }
-
- public String put(String key, String value) {
- return options.put(key, value);
- }
-
- public String remove(Object key) {
- return options.remove(key);
- }
-
- public void putAll(Map extends String, ? extends String> m) {
- options.putAll(m);
- }
-
- public void clear() {
- options.clear();
- }
-
- public Set keySet() {
- return options.keySet();
- }
-
- public Collection values() {
- return options.values();
- }
-
- public Set> entrySet() {
- return options.entrySet();
- }
-
- @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
- public boolean equals(Object o) {
- return options.equals(o);
- }
-
- @Override
- public int hashCode() {
- return options.hashCode();
- }
-
- public boolean isSet(String key) {
- return SliderUtils.isSet(get(key));
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append(name).append("=\n");
-
- for (Entry entry : options.entrySet()) {
- builder.append(" ")
- .append(entry.getKey())
- .append('=')
- .append(entry.getValue())
- .append('\n');
- }
- return builder.toString();
- }
-
- /**
- * Get the time range of a set of keys
- * @param basekey base key to which suffix gets applied
- * @param defDays
- * @param defHours
- * @param defMins
- * @param defSecs
- * @return the aggregate time range in seconds
- */
- public long getTimeRange(String basekey,
- int defDays,
- int defHours,
- int defMins,
- int defSecs) {
- Preconditions.checkArgument(basekey != null);
- int days = getOptionInt(basekey + DAYS, defDays);
- int hours = getOptionInt(basekey + HOURS, defHours);
-
- int minutes = getOptionInt(basekey + MINUTES, defMins);
- int seconds = getOptionInt(basekey + SECONDS, defSecs);
- // range check
- Preconditions.checkState(days >= 0 && hours >= 0 && minutes >= 0
- && seconds >= 0,
- "Time range for %s has negative time component %s:%s:%s:%s",
- basekey, days, hours, minutes, seconds);
-
- // calculate total time, schedule the reset if expected
- long totalMinutes = (long) days * 24 * 60 + (long) hours * 24 + minutes;
- return totalMinutes * 60 + seconds;
- }
-
- /**
- * Get all entries with a specific prefix
- * @param prefix prefix
- * @return a prefixed map, possibly empty
- */
- public Map prefixedWith(String prefix) {
-
- Map prefixed = new HashMap<>(size());
- for (Entry entry: entrySet()) {
- if (entry.getKey().startsWith(prefix)) {
- prefixed.put(entry.getKey(), entry.getValue());
- }
- }
- return prefixed;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/NoSuchNodeException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/NoSuchNodeException.java
deleted file mode 100644
index ad2f1a4..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/NoSuchNodeException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-import java.io.IOException;
-
-/**
- * Exception raised when a node cannot be found in the structure
- * that is being examined.
- */
-public class NoSuchNodeException extends IOException {
-
- public NoSuchNodeException(String uuid) {
- super(uuid);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/NotFoundException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/NotFoundException.java
deleted file mode 100644
index 40cb94d..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/NotFoundException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-
-/**
- * Whatever was being resolved: it was not found
- */
-public class NotFoundException extends SliderException {
- public NotFoundException(String message,
- Object... args) {
- super(EXIT_NOT_FOUND, message, args);
- }
-
- public NotFoundException(Throwable throwable,
- String message, Object... args) {
- super(EXIT_NOT_FOUND, throwable, message, args);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/ServiceNotReadyException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/ServiceNotReadyException.java
deleted file mode 100644
index 435bc1a..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/ServiceNotReadyException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-import java.io.IOException;
-
-/**
- * This is an exception raised when the service does not consider itself
- * live (yet)
- */
-public class ServiceNotReadyException extends IOException {
-
- public static final String E_NOT_READY =
- "Service not ready for access: please retry";
-
- public ServiceNotReadyException(String message) {
- super(message);
- }
-
- public ServiceNotReadyException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ServiceNotReadyException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/SliderInternalStateException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/SliderInternalStateException.java
deleted file mode 100644
index deddbbc..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/SliderInternalStateException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-public class SliderInternalStateException extends SliderException {
- public SliderInternalStateException(String s) {
- super(EXIT_INTERNAL_ERROR, s);
- }
-
- public SliderInternalStateException(String s, Throwable throwable) {
- super(EXIT_INTERNAL_ERROR, throwable, s);
- }
-
- public SliderInternalStateException(String message,
- Object... args) {
- super(EXIT_INTERNAL_ERROR, message, args);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/TriggerClusterTeardownException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/TriggerClusterTeardownException.java
deleted file mode 100644
index bb9f430..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/TriggerClusterTeardownException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
-
-/**
- * An Exception to be thrown for an explicit "shut down the cluster" operation
- * raised by the application state or other parts of the AM
- */
-public class TriggerClusterTeardownException extends SliderException {
-
- private final FinalApplicationStatus finalApplicationStatus;
-
- public TriggerClusterTeardownException(int code,
- FinalApplicationStatus finalApplicationStatus, String message,
- Object... args) {
- super(code, message, args);
- this.finalApplicationStatus = finalApplicationStatus;
- }
-
- public FinalApplicationStatus getFinalApplicationStatus() {
- return finalApplicationStatus;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/UnknownApplicationInstanceException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/UnknownApplicationInstanceException.java
deleted file mode 100644
index a1f8ae9..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/UnknownApplicationInstanceException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-public class UnknownApplicationInstanceException extends SliderException {
- public UnknownApplicationInstanceException(String s) {
- super(EXIT_UNKNOWN_INSTANCE, s);
- }
-
- public UnknownApplicationInstanceException(String s, Throwable throwable) {
- super(EXIT_UNKNOWN_INSTANCE, throwable, s);
- }
-
- public UnknownApplicationInstanceException(String message,
- Object... args) {
- super(EXIT_UNKNOWN_INSTANCE, message, args);
- }
-
- /**
- * Create an instance with the standard exception name
- * @param name name
- * @return an instance to throw
- */
- public static UnknownApplicationInstanceException unknownInstance(String name) {
- return new UnknownApplicationInstanceException(ErrorStrings.E_UNKNOWN_INSTANCE
- + ": " + name);
- }
- public static UnknownApplicationInstanceException unknownInstance(String name,
- Throwable throwable) {
- UnknownApplicationInstanceException exception =
- unknownInstance(name);
- exception.initCause(throwable);
- return exception;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/WaitTimeoutException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/WaitTimeoutException.java
deleted file mode 100644
index 5ad3fdc..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/exceptions/WaitTimeoutException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-import java.io.IOException;
-
-/**
- * Called when some spinning operation timed out
- */
-public class WaitTimeoutException extends IOException {
- public WaitTimeoutException(String message) {
- super(message);
- }
-
- public WaitTimeoutException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/ContainerLauncher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/ContainerLauncher.java
deleted file mode 100644
index 7e164e4..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/launch/ContainerLauncher.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.launch;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.net.NetUtils;
-import org.apache.hadoop.security.Credentials;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.token.Token;
-import org.apache.hadoop.yarn.api.records.Container;
-import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
-import org.apache.hadoop.yarn.util.ConverterUtils;
-import org.apache.slider.common.tools.CoreFileSystem;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetSocketAddress;
-
-/**
- * Code to ease launching of any container
- */
-public class ContainerLauncher extends AbstractLauncher {
- private static final Logger log =
- LoggerFactory.getLogger(ContainerLauncher.class);
-
- public ContainerLauncher(Configuration conf,
- CoreFileSystem coreFileSystem,
- Container container,
- Credentials credentials) {
- super(coreFileSystem, credentials);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/IrqHandler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/IrqHandler.java
deleted file mode 100644
index 42442d1..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/IrqHandler.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.main;
-
-import sun.misc.Signal;
-import sun.misc.SignalHandler;
-
-import java.io.IOException;
-
-/**
- * This class bundles up all the compiler warnings about abuse of sun.misc
- * interrupt handling code
- * into one place.
- */
-@SuppressWarnings("UseOfSunClasses")
-public final class IrqHandler implements SignalHandler {
-
- public static final String CONTROL_C = "INT";
- public static final String SIGTERM = "TERM";
-
- private final String name;
- private final Interrupted handler;
-
- /**
- * Create an IRQ handler bound to the specific interrupt
- * @param name signal name
- * @param handler handler
- * @throws IOException
- */
- public IrqHandler(String name, Interrupted handler) throws IOException {
- this.handler = handler;
- this.name = name;
- try {
- Signal.handle(new Signal(name), this);
- } catch (IllegalArgumentException e) {
- throw new IOException(
- "Could not set handler for signal \"" + name + "\"."
- + "This can happen if the JVM has the -Xrs set.",
- e);
- }
- }
-
- @Override
- public String toString() {
- return "IrqHandler for signal " + name ;
- }
-
- /**
- * Handler for the JVM API for signal handling
- * @param signal signal raised
- */
-// @Override
- public void handle(Signal signal) {
- InterruptData data = new InterruptData(signal.getName(), signal.getNumber());
- handler.interrupted(data);
- }
-
- /**
- * Interrupt data to pass on.
- */
- public static class InterruptData {
- public final String name;
- public final int number;
-
- public InterruptData(String name, int number) {
- this.name = name;
- this.number = number;
- }
-
- @Override
- public String toString() {
- return "signal " + name + '(' + number + ')';
- }
- }
-
- /**
- * Callback on interruption
- */
- public interface Interrupted {
-
- /**
- * Handle an interrupt
- * @param interruptData data
- */
- void interrupted(InterruptData interruptData);
- }
-}
\ No newline at end of file
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/RunService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/RunService.java
deleted file mode 100644
index c3a1d0e..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/RunService.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.main;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.service.Service;
-
-/**
- * An interface which services can implement to have their
- * execution managed by the ServiceLauncher.
- * The command line options will be passed down before the
- * {@link Service#init(Configuration)} operation is invoked via an
- * invocation of {@link RunService#bindArgs(Configuration, String...)}
- * After the service has been successfully started via {@link Service#start()}
- * the {@link RunService#runService()} method is called to execute the
- * service. When this method returns, the service launcher will exit, using
- * the return code from the method as its exit option.
- */
-public interface RunService extends Service {
-
- /**
- * Propagate the command line arguments.
- * This method is called before {@link Service#init(Configuration)};
- * the configuration that is returned from this operation
- * is the one that is passed on to the init operation.
- * This permits implemenations to change the configuration before
- * the init operation.n
- *
- *
- * @param config the initial configuration build up by the
- * service launcher.
- * @param args argument list list of arguments passed to the command line
- * after any launcher-specific commands have been stripped.
- * @return the configuration to init the service with. This MUST NOT be null.
- * Recommended: pass down the config parameter with any changes
- * @throws Exception any problem
- */
- Configuration bindArgs(Configuration config, String... args) throws Exception;
-
- /**
- * Run a service. This called after {@link Service#start()}
- * @return the exit code
- * @throws Throwable any exception to report
- */
- int runService() throws Throwable ;
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
deleted file mode 100644
index f192ec8..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.main;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.net.NetUtils;
-import org.apache.hadoop.service.Service;
-import org.apache.hadoop.util.ExitUtil;
-import org.apache.hadoop.util.ShutdownHookManager;
-import org.apache.hadoop.util.VersionInfo;
-import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * A class to launch any service by name.
- *
- * It's designed to be subclassed for custom entry points.
- *
- *
- * Workflow
- *
- * - An instance of the class is created
- * - If it implements RunService, it is given the binding args off the CLI
- * - Its service.init() and service.start() methods are called.
- * - If it implements RunService, runService() is called and its return
- * code used as the exit code.
- * - Otherwise: it waits for the service to stop, assuming in its start() method
- * it begins work
- * - If an exception returned an exit code, that becomes the exit code of the
- * command.
- *
- * Error and warning messages are logged to stderr. Why? If the classpath
- * is wrong & logger configurations not on it, then no error messages by
- * the started app will be seen and the caller is left trying to debug
- * using exit codes.
- *
- */
-@SuppressWarnings("UseOfSystemOutOrSystemErr")
-public class ServiceLauncher
- implements LauncherExitCodes, IrqHandler.Interrupted,
- Thread.UncaughtExceptionHandler {
- private static final Logger LOG = LoggerFactory.getLogger(
- ServiceLauncher.class);
-
- protected static final int PRIORITY = 30;
-
- public static final String NAME = "ServiceLauncher";
-
- /**
- * Name of the "--conf" argument.
- */
- public static final String ARG_CONF = "--conf";
-
- public static final String USAGE_MESSAGE =
- "Usage: " + NAME + " classname [" + ARG_CONF +
- "] | ";
- static final int SHUTDOWN_TIME_ON_INTERRUPT = 30 * 1000;
-
- private volatile S service;
- private int serviceExitCode;
- @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
- private final List interruptHandlers = new ArrayList<>(1);
- private Configuration configuration;
- private String serviceClassName;
- private static AtomicBoolean signalAlreadyReceived = new AtomicBoolean(false);
-
-
- /**
- * Create an instance of the launcher
- * @param serviceClassName classname of the service
- */
- public ServiceLauncher(String serviceClassName) {
- this.serviceClassName = serviceClassName;
- }
-
- /**
- * Get the service. Null until and unless
- * {@link #launchService(Configuration, String[], boolean)} has completed
- * @return the service
- */
- public S getService() {
- return service;
- }
-
- /**
- * Get the configuration constructed from the command line arguments
- * @return the configuration used to create the service
- */
- public Configuration getConfiguration() {
- return configuration;
- }
-
- /**
- * The exit code from a successful service execution
- * @return the exit code.
- */
- public int getServiceExitCode() {
- return serviceExitCode;
- }
-
- @Override
- public String toString() {
- return "ServiceLauncher for " + serviceClassName;
- }
-
- /**
- * Launch the service, by creating it, initing it, starting it and then
- * maybe running it. {@link RunService#bindArgs(Configuration, String...)} is invoked
- * on the service between creation and init.
- *
- * All exceptions that occur are propagated upwards.
- *
- * If the method returns a status code, it means that it got as far starting
- * the service, and if it implements {@link RunService}, that the
- * method {@link RunService#runService()} has completed.
- *
- * At this point, the service is returned by {@link #getService()}.
- *
- * @param conf configuration
- * @param processedArgs arguments after the configuration parameters
- * have been stripped out.
- * @param addProcessHooks should process failure handlers be added to
- * terminate this service on shutdown. Tests should set this to false.
- * @throws ClassNotFoundException classname not on the classpath
- * @throws IllegalAccessException not allowed at the class
- * @throws InstantiationException not allowed to instantiate it
- * @throws InterruptedException thread interrupted
- * @throws Throwable any other failure
- */
- public int launchService(Configuration conf,
- String[] processedArgs,
- boolean addProcessHooks)
- throws Throwable {
-
- instantiateService(conf);
-
- // add any process shutdown hooks
- if (addProcessHooks) {
- ServiceShutdownHook shutdownHook = new ServiceShutdownHook(service);
- ShutdownHookManager.get().addShutdownHook(shutdownHook, PRIORITY);
- }
- RunService runService = null;
-
- if (service instanceof RunService) {
- //if its a runService, pass in the conf and arguments before init)
- runService = (RunService) service;
- configuration = runService.bindArgs(configuration, processedArgs);
- Preconditions.checkNotNull(configuration,
- "null configuration returned by bindArgs()");
- }
-
- //some class constructors init; here this is picked up on.
- if (!service.isInState(Service.STATE.INITED)) {
- service.init(configuration);
- }
- service.start();
- int exitCode = EXIT_SUCCESS;
- if (runService != null) {
- //assume that runnable services are meant to run from here
- exitCode = runService.runService();
- LOG.debug("Service exited with exit code {}", exitCode);
-
- } else {
- //run the service until it stops or an interrupt happens on a different thread.
- LOG.debug("waiting for service threads to terminate");
- service.waitForServiceToStop(0);
- }
- //exit
- serviceExitCode = exitCode;
- return serviceExitCode;
- }
-
- /**
- * Instantiate the service defined in serviceClassName
- * . Sets the configuration field
- * to the configuration, and service to the service.
- *
- * @param conf configuration to use
- * @throws ClassNotFoundException classname not on the classpath
- * @throws IllegalAccessException not allowed at the class
- * @throws InstantiationException not allowed to instantiate it
- */
- @SuppressWarnings("unchecked")
- public Service instantiateService(Configuration conf)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException,
- ExitUtil.ExitException, NoSuchMethodException, InvocationTargetException {
- Preconditions.checkArgument(conf != null, "null conf");
- configuration = conf;
-
- //Instantiate the class -this requires the service to have a public
- // zero-argument constructor
- Class> serviceClass =
- this.getClass().getClassLoader().loadClass(serviceClassName);
- Object instance = serviceClass.getConstructor().newInstance();
- if (!(instance instanceof Service)) {
- //not a service
- throw new ExitUtil.ExitException(EXIT_COMMAND_ARGUMENT_ERROR,
- "Not a Service class: " + serviceClassName);
- }
-
- service = (S) instance;
- return service;
- }
-
- /**
- * Register this class as the handler for the control-C interrupt.
- * Can be overridden for testing.
- */
- protected void registerInterruptHandler() {
- try {
- interruptHandlers.add(new IrqHandler(IrqHandler.CONTROL_C, this));
- interruptHandlers.add(new IrqHandler(IrqHandler.SIGTERM, this));
- } catch (IOException e) {
- error("Signal handler setup failed : {}" + e, e);
- }
- }
-
- /**
- * The service has been interrupted -try to shut down the service.
- * Give the service time to do this before the exit operation is called
- * @param interruptData the interrupted data.
- */
- @Override
- public void interrupted(IrqHandler.InterruptData interruptData) {
- String message = "Service interrupted by " + interruptData.toString();
- warn(message);
- if (!signalAlreadyReceived.compareAndSet(false, true)) {
- warn("Repeated interrupt: escalating to a JVM halt");
- // signal already received. On a second request to a hard JVM
- // halt and so bypass any blocking shutdown hooks.
- ExitUtil.halt(EXIT_INTERRUPTED, message);
- }
- int shutdownTimeMillis = SHUTDOWN_TIME_ON_INTERRUPT;
- //start an async shutdown thread with a timeout
- ServiceForcedShutdown forcedShutdown =
- new ServiceForcedShutdown(shutdownTimeMillis);
- Thread thread = new Thread(forcedShutdown);
- thread.setDaemon(true);
- thread.start();
- //wait for that thread to finish
- try {
- thread.join(shutdownTimeMillis);
- } catch (InterruptedException ignored) {
- //ignored
- }
- if (!forcedShutdown.isServiceStopped()) {
- warn("Service did not shut down in time");
- }
- exit(EXIT_INTERRUPTED, message);
- }
-
- /**
- * Uncaught exception handler.
- * If an error is raised: shutdown
- * The state of the system is unknown at this point -attempting
- * a clean shutdown is dangerous. Instead: exit
- * @param thread thread that failed
- * @param exception exception
- */
- @Override
- public void uncaughtException(Thread thread, Throwable exception) {
- if (ShutdownHookManager.get().isShutdownInProgress()) {
- LOG.error("Thread {} threw an error during shutdown: {}.",
- thread.toString(),
- exception,
- exception);
- } else if (exception instanceof Error) {
- try {
- LOG.error("Thread {} threw an error: {}. Shutting down",
- thread.toString(),
- exception,
- exception);
- } catch (Throwable err) {
- // We don't want to not exit because of an issue with logging
- }
- if (exception instanceof OutOfMemoryError) {
- // After catching an OOM java says it is undefined behavior, so don't
- // even try to clean up or we can get stuck on shutdown.
- try {
- System.err.println("Halting due to Out Of Memory Error...");
- } catch (Throwable err) {
- // Again we don't want to exit because of logging issues.
- }
- ExitUtil.halt(EXIT_EXCEPTION_THROWN);
- } else {
- // error other than OutOfMemory
- exit(convertToExitException(exception));
- }
- } else {
- // simple exception in a thread. There's a policy decision here:
- // terminate the service vs. keep going after a thread has failed
- LOG.error("Thread {} threw an exception: {}",
- thread.toString(),
- exception,
- exception);
- }
- }
-
- /**
- * Print a warning: currently this goes to stderr
- * @param text
- */
- protected void warn(String text) {
- System.err.println(text);
- }
-
- /**
- * Report an error. The message is printed to stderr; the exception
- * is logged via the current logger.
- * @param message message for the user
- * @param thrown the exception thrown
- */
- protected void error(String message, Throwable thrown) {
- String text = "Exception: " + message;
- warn(text);
- LOG.error(text, thrown);
- }
-
- /**
- * Exit the code.
- * This is method can be overridden for testing, throwing an
- * exception instead. Any subclassed method MUST raise an
- * ExitUtil.ExitException instance.
- * The service launcher code assumes that after this method is invoked,
- * no other code in the same method is called.
- * @param exitCode code to exit
- */
- protected void exit(int exitCode, String message) {
- ExitUtil.terminate(exitCode, message);
- }
-
- /**
- * Exit off an exception. This can be subclassed for testing
- * @param ee exit exception
- */
- protected void exit(ExitUtil.ExitException ee) {
- ExitUtil.terminate(ee.status, ee);
- }
-
- /**
- * Get the service name via {@link Service#getName()}.
- * If the service is not instantiated, the classname is returned instead.
- * @return the service name
- */
- public String getServiceName() {
- Service s = service;
- String name = null;
- if (s != null) {
- try {
- name = s.getName();
- } catch (Exception ignored) {
- // ignored
- }
- }
- if (name != null) {
- return "service " + name;
- } else {
- return "service classname " + serviceClassName;
- }
- }
-
- /**
- * Parse the command line, building a configuration from it, then
- * launch the service and wait for it to finish. finally, exit
- * passing the status code to the #exit(int) method.
- * @param args arguments to the service. arg[0] is
- * assumed to be the service classname and is automatically
- */
- public void launchServiceAndExit(List args) {
-
- registerInterruptHandler();
- //Currently the config just the default
- Configuration conf = new Configuration();
- String[] processedArgs = extractConfigurationArgs(conf, args);
- ExitUtil.ExitException ee = launchServiceRobustly(conf, processedArgs);
- System.out.flush();
- System.err.flush();
- exit(ee);
- }
-
- /**
- * Extract the configuration arguments and apply them to the configuration,
- * building an array of processed arguments to hand down to the service.
- *
- * @param conf configuration to update
- * @param args main arguments. args[0] is assumed to be the service
- * classname and is skipped
- * @return the processed list.
- */
- public static String[] extractConfigurationArgs(Configuration conf,
- List args) {
-
- //convert args to a list
- int argCount = args.size();
- if (argCount <= 1 ) {
- return new String[0];
- }
- List argsList = new ArrayList(argCount);
- ListIterator arguments = args.listIterator();
- //skip that first entry
- arguments.next();
- while (arguments.hasNext()) {
- String arg = arguments.next();
- if (arg.equals(ARG_CONF)) {
- //the argument is a --conf file tuple: extract the path and load
- //it in as a configuration resource.
-
- //increment the loop iterator
- if (!arguments.hasNext()) {
- //overshot the end of the file
- exitWithMessage(EXIT_COMMAND_ARGUMENT_ERROR,
- ARG_CONF + ": missing configuration file after ");
- }
- File file = new File(arguments.next());
- if (!file.exists()) {
- exitWithMessage(EXIT_COMMAND_ARGUMENT_ERROR,
- ARG_CONF + ": configuration file not found: " + file);
- }
- try {
- conf.addResource(file.toURI().toURL());
- } catch (MalformedURLException e) {
- LOG.debug("File {} cannot be converted to URL", file, e);
- exitWithMessage(EXIT_COMMAND_ARGUMENT_ERROR,
- ARG_CONF + ": configuration file path invalid: " + file);
- }
- } else {
- argsList.add(arg);
- }
- }
- String[] processedArgs = new String[argsList.size()];
- argsList.toArray(processedArgs);
- return processedArgs;
- }
-
- /**
- * Launch a service catching all exceptions and downgrading them to exit codes
- * after logging.
- * @param conf configuration to use
- * @param processedArgs command line after the launcher-specific arguments have
- * been stripped out
- * @return an exit exception, which will have a status code of 0 if it worked
- */
- public ExitUtil.ExitException launchServiceRobustly(Configuration conf,
- String[] processedArgs) {
- ExitUtil.ExitException exitException;
- try {
- int exitCode = launchService(conf, processedArgs, true);
- if (service != null) {
- Throwable failure = service.getFailureCause();
- if (failure != null) {
- //the service exited with a failure.
- //check what state it is in
- Service.STATE failureState = service.getFailureState();
- if (failureState == Service.STATE.STOPPED) {
- //the failure occurred during shutdown, not important enough to bother
- //the user as it may just scare them
- LOG.debug("Failure during shutdown:{} ", failure, failure);
- } else {
- //throw it for the catch handlers to deal with
- throw failure;
- }
- }
- }
- exitException = new ExitUtil.ExitException(exitCode,
- "In " + serviceClassName);
- // either the service succeeded, or an error raised during shutdown,
- // which we don't worry that much about
- } catch (ExitUtil.ExitException ee) {
- exitException = ee;
- } catch (Throwable thrown) {
- exitException = convertToExitException(thrown);
- }
- return exitException;
- }
-
- /**
- * Convert the exception to one that can be handed off to ExitUtils;
- * if it is of the write type it is passed throw as is. If not, a
- * new exception with the exit code {@link #EXIT_EXCEPTION_THROWN}
- * is created, with the argument thrown as the inner cause
- * @param thrown the exception thrown
- * @return an exception to terminate the process with
- */
- protected ExitUtil.ExitException convertToExitException(Throwable thrown) {
- ExitUtil.ExitException exitException;
- int exitCode;
- String message = thrown.getMessage();
- if (message == null) {
- message = thrown.toString();
- }
- if (thrown instanceof ExitCodeProvider) {
- exitCode = ((ExitCodeProvider) thrown).getExitCode();
- if (LOG.isDebugEnabled()) {
- LOG.debug("While running {}: {}", getServiceName(), message, thrown);
- }
- LOG.error(message);
- } else {
- // not any of the service launcher exceptions -assume something worse
- error(message, thrown);
- exitCode = EXIT_EXCEPTION_THROWN;
- }
- exitException = new ExitUtil.ExitException(exitCode, message);
- exitException.initCause(thrown);
- return exitException;
- }
-
-
- /**
- * Build a log message for starting up and shutting down.
- * This was grabbed from the ToolRunner code.
- * @param classname the class of the server
- * @param args arguments
- */
- public static String startupShutdownMessage(String classname,
- List args) {
- final String hostname = NetUtils.getHostname();
-
- return toStartupShutdownString("STARTUP_MSG: ", new String[]{
- "Starting " + classname,
- " host = " + hostname,
- " args = " + args,
- " version = " + VersionInfo.getVersion(),
- " classpath = " + System.getProperty("java.class.path"),
- " build = " + VersionInfo.getUrl() + " -r "
- + VersionInfo.getRevision()
- + "; compiled by '" + VersionInfo.getUser()
- + "' on " + VersionInfo.getDate(),
- " java = " + System.getProperty("java.version")
- });
- }
-
- /**
- * Exit with a printed message
- * @param status status code
- * @param message message
- */
- private static void exitWithMessage(int status, String message) {
- System.err.println(message);
- ExitUtil.terminate(status);
- }
-
- private static String toStartupShutdownString(String prefix, String[] msg) {
- StringBuilder b = new StringBuilder(prefix);
- b.append("\n/************************************************************");
- for (String s : msg) {
- b.append("\n").append(prefix).append(s);
- }
- b.append("\n************************************************************/");
- return b.toString();
- }
-
- /**
- * forced shutdown runnable.
- */
- protected class ServiceForcedShutdown implements Runnable {
-
- private final int shutdownTimeMillis;
- private boolean serviceStopped;
-
- public ServiceForcedShutdown(int shutdownTimeoutMillis) {
- this.shutdownTimeMillis = shutdownTimeoutMillis;
- }
-
- @Override
- public void run() {
- if (service != null) {
- service.stop();
- serviceStopped = service.waitForServiceToStop(shutdownTimeMillis);
- } else {
- serviceStopped = true;
- }
- }
-
- private boolean isServiceStopped() {
- return serviceStopped;
- }
- }
-
- /**
- * The real main function, which takes the arguments as a list
- * arg 0 must be the service classname
- * @param argsList the list of arguments
- */
- public static void serviceMain(List argsList) {
- if (argsList.isEmpty()) {
- exitWithMessage(EXIT_USAGE, USAGE_MESSAGE);
- } else {
- String serviceClassName = argsList.get(0);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(startupShutdownMessage(serviceClassName, argsList));
- StringBuilder builder = new StringBuilder();
- for (String arg : argsList) {
- builder.append('"').append(arg).append("\" ");
- }
- LOG.debug(builder.toString());
- }
- Thread.setDefaultUncaughtExceptionHandler(
- new YarnUncaughtExceptionHandler());
-
- ServiceLauncher serviceLauncher = new ServiceLauncher<>(serviceClassName);
- serviceLauncher.launchServiceAndExit(argsList);
- }
- }
-
- /**
- * This is the main entry point for the service launcher.
- * @param args command line arguments.
- */
- public static void main(String[] args) {
- List argsList = Arrays.asList(args);
- serviceMain(argsList);
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java
deleted file mode 100644
index de55789..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.main;
-
-import org.apache.hadoop.service.Service;
-import org.apache.hadoop.util.ShutdownHookManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.ref.WeakReference;
-
-/**
- * JVM Shutdown hook for Service which will stop the
- * Service gracefully in case of JVM shutdown.
- * This hook uses a weak reference to the service, so
- * does not cause services to be retained after they have
- * been stopped and deferenced elsewhere.
- */
-public class ServiceShutdownHook implements Runnable {
- private static final Logger LOG = LoggerFactory.getLogger(
- ServiceShutdownHook.class);
-
- private final WeakReference serviceRef;
- private Runnable hook;
-
- public ServiceShutdownHook(Service service) {
- serviceRef = new WeakReference<>(service);
- }
-
- public void register(int priority) {
- unregister();
- hook = this;
- ShutdownHookManager.get().addShutdownHook(hook, priority);
- }
-
- public synchronized void unregister() {
- if (hook != null) {
- try {
- ShutdownHookManager.get().removeShutdownHook(hook);
- } catch (IllegalStateException e) {
- LOG.info("Failed to unregister shutdown hook: {}", e, e);
- }
- hook = null;
- }
- }
-
- @Override
- public void run() {
- Service service;
- synchronized (this) {
- service = serviceRef.get();
- serviceRef.clear();
- }
- if (service == null) {
- return;
- }
- try {
- // Stop the Service
- service.stop();
- } catch (Throwable t) {
- LOG.info("Error stopping {}", service.getName(), t);
- }
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/Filenames.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/Filenames.java
deleted file mode 100644
index 06ecc51..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/Filenames.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.persist;
-
-public interface Filenames {
-
- String RESOURCES = "resources.json";
- String APPCONF = "app_config.json";
- String INTERNAL = "internal.json";
- String WRITELOCK = "writelock";
- String READLOCK = "readlock";
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/LockHeldAction.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/LockHeldAction.java
deleted file mode 100644
index 6659687..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/LockHeldAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.persist;
-
-import org.apache.slider.core.exceptions.SliderException;
-
-import java.io.IOException;
-
-/**
- * Optional action to add while the lock is held; this is needed to execute
- * some other persistent operations within the scope at the same lock
- * without inserting too much code into the persister
- */
-public interface LockHeldAction {
-
- /**
- * Execute the action
- * @throws IOException on any failure
- */
- public void execute() throws IOException, SliderException;
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/PersistKeys.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/PersistKeys.java
deleted file mode 100644
index 1964459..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/persist/PersistKeys.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.persist;
-
-public class PersistKeys {
-
- public static final String SCHEMA =
- "http://example.org/specification/v2.0.0";
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java
deleted file mode 100644
index d311fee..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.registry;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.yarn.api.records.ApplicationReport;
-import org.apache.hadoop.yarn.api.records.YarnApplicationState;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.client.SliderYarnClientImpl;
-import org.apache.slider.api.types.SliderInstanceDescription;
-import org.apache.slider.common.tools.CoreFileSystem;
-import org.apache.slider.common.tools.SliderUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Client code for interacting with a list of service instances.
- * The initial logic just enumerates service instances in the YARN RM
- */
-public class YarnAppListClient {
-
- private final SliderYarnClientImpl yarnClient;
- private final String username;
- private final Configuration conf;
- private static final Logger log =
- LoggerFactory.getLogger(YarnAppListClient.class);
-
- public YarnAppListClient(SliderYarnClientImpl yarnClient,
- String username,
- Configuration conf) {
-
- Preconditions.checkArgument(yarnClient != null,
- "yarn client is null: is app inited?");
- Preconditions.checkArgument(username != null,
- "username is null");
- Preconditions.checkArgument(conf != null,
- "conf parameter is null");
- this.yarnClient = yarnClient;
- this.username = username;
- this.conf = conf;
- }
-
- /**
- * find all live instances of a specific app -if there is more than one
- * in the cluster, this returns them all. State should be running or earlier
- * in the lifecycle
- * @param appname application name
- * @return the list of all matching application instances
- */
- public List findAllLiveInstances(String appname)
- throws YarnException, IOException {
- return yarnClient.findAllLiveInstances(username, appname);
- }
-
-
- /**
- * Find an instance of a application belong to the current user.
- * @param appname application name
- * @return the app report or null if none is found
- * @throws YarnException YARN issues
- * @throws IOException IO problems
- */
- public ApplicationReport findInstance(String appname) throws
- YarnException,
- IOException {
- return findInstance(appname, null);
- }
-
- /**
- * Find an instance of a application belong to the current user in specific
- * app states.
- * @param appname application name
- * @param appStates list of states in which application should be in
- * @return the app report or null if none is found
- * @throws YarnException YARN issues
- * @throws IOException IO problems
- */
- public ApplicationReport findInstance(String appname,
- EnumSet appStates)
- throws YarnException, IOException {
- List instances = listInstances(null, appname, appStates);
- return yarnClient.findClusterInInstanceList(instances, appname);
- }
-
- /**
- * List instances belonging to the specific user
- * @return a possibly empty list of AMs
- */
- public List