You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ji...@apache.org on 2016/12/13 22:52:59 UTC
[07/74] [abbrv] hadoop git commit: YARN-5461. Initial code ported
from slider-core module. (jianhe)
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentEnv.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentEnv.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentEnv.java
new file mode 100644
index 0000000..781ae00
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentEnv.java
@@ -0,0 +1,376 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import com.google.gson.annotations.SerializedName;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class AgentEnv {
+
+ /**
+ * Various directories, configurable in <code>ambari-agent.ini</code>
+ */
+ private Directory[] stackFoldersAndFiles = new Directory[0];
+
+ /**
+ * Directories that match name <code>/etc/alternatives/*conf</code>
+ */
+ private Alternative[] alternatives = new Alternative[0];
+
+ /**
+ * List of existing users
+ */
+ private ExistingUser[] existingUsers = new ExistingUser[0];
+
+ /**
+ * List of repos
+ */
+ private String[] existingRepos = new String[0];
+
+ /**
+ * List of packages
+ */
+ private PackageDetail[] installedPackages = new PackageDetail[0];
+
+ /**
+ * The host health report
+ */
+ private HostHealth hostHealth = new HostHealth();
+
+ private Integer umask;
+
+ private Boolean iptablesIsRunning;
+
+ public Integer getUmask() {
+ return umask;
+ }
+
+ public void setUmask(Integer umask) {
+ this.umask = umask;
+ }
+
+ public Directory[] getStackFoldersAndFiles() {
+ return stackFoldersAndFiles;
+ }
+
+ public void setStackFoldersAndFiles(Directory[] dirs) {
+ stackFoldersAndFiles = dirs;
+ }
+
+ public void setExistingUsers(ExistingUser[] users) {
+ existingUsers = users;
+ }
+
+ public ExistingUser[] getExistingUsers() {
+ return existingUsers;
+ }
+
+ public void setAlternatives(Alternative[] dirs) {
+ alternatives = dirs;
+ }
+
+ public Alternative[] getAlternatives() {
+ return alternatives;
+ }
+
+ public void setExistingRepos(String[] repos) {
+ existingRepos = repos;
+ }
+
+ public String[] getExistingRepos() {
+ return existingRepos;
+ }
+
+ public void setInstalledPackages(PackageDetail[] packages) {
+ installedPackages = packages;
+ }
+
+ public PackageDetail[] getInstalledPackages() {
+ return installedPackages;
+ }
+
+ public void setHostHealth(HostHealth healthReport) {
+ hostHealth = healthReport;
+ }
+
+ public HostHealth getHostHealth() {
+ return hostHealth;
+ }
+
+ public Boolean getIptablesIsRunning() {
+ return iptablesIsRunning;
+ }
+
+ public void setIptablesIsRunning(Boolean iptablesIsRunning) {
+ this.iptablesIsRunning = iptablesIsRunning;
+ }
+
+ public static class HostHealth {
+ /**
+ * Java processes running on the system. Default empty array.
+ */
+ @SerializedName("activeJavaProcs")
+ private JavaProc[] activeJavaProcs = new JavaProc[0];
+
+ /**
+ * The current time when agent send the host check report
+ */
+ @SerializedName("agentTimeStampAtReporting")
+ private long agentTimeStampAtReporting = 0;
+
+ /**
+ * The current time when host check report was received
+ */
+ @SerializedName("serverTimeStampAtReporting")
+ private long serverTimeStampAtReporting = 0;
+
+ /**
+ * Live services running on the agent
+ */
+ @SerializedName("liveServices")
+ private LiveService[] liveServices = new LiveService[0];
+
+ public void setAgentTimeStampAtReporting(long currentTime) {
+ agentTimeStampAtReporting = currentTime;
+ }
+
+ public long getAgentTimeStampAtReporting() {
+ return agentTimeStampAtReporting;
+ }
+
+ public void setServerTimeStampAtReporting(long currentTime) {
+ serverTimeStampAtReporting = currentTime;
+ }
+
+ public long getServerTimeStampAtReporting() {
+ return serverTimeStampAtReporting;
+ }
+
+ public void setActiveJavaProcs(JavaProc[] procs) {
+ activeJavaProcs = procs;
+ }
+
+ public JavaProc[] getActiveJavaProcs() {
+ return activeJavaProcs;
+ }
+
+ public void setLiveServices(LiveService[] services) {
+ liveServices = services;
+ }
+
+ public LiveService[] getLiveServices() {
+ return liveServices;
+ }
+ }
+
+ public static class PackageDetail {
+ @SerializedName("name")
+ private String pkgName;
+ @SerializedName("version")
+ private String pkgVersion;
+ @SerializedName("repoName")
+ private String pkgRepoName;
+
+ public void setName(String name) {
+ pkgName = name;
+ }
+
+ public String getName() {
+ return pkgName;
+ }
+
+ public void setVersion(String version) {
+ pkgVersion = version;
+ }
+
+ public String getVersion() {
+ return pkgVersion;
+ }
+
+ public void setRepoName(String repoName) {
+ pkgRepoName = repoName;
+ }
+
+ public String getRepoName() {
+ return pkgRepoName;
+ }
+ }
+
+ /**
+ * Represents information about a directory of interest.
+ */
+ public static class Directory {
+ @SerializedName("name")
+ private String dirName;
+ @SerializedName("type")
+ private String dirType;
+
+ public void setName(String name) {
+ dirName = name;
+ }
+
+ public String getName() {
+ return dirName;
+ }
+
+ public void setType(String type) {
+ dirType = type;
+ }
+
+ public String getType() {
+ return dirType;
+ }
+ }
+
+ /**
+ * Represents information about running java processes.
+ */
+ public static class JavaProc {
+ @SerializedName("user")
+ private String user;
+ @SerializedName("pid")
+ private int pid = 0;
+ @SerializedName("hadoop")
+ private boolean is_hadoop = false;
+ @SerializedName("command")
+ private String command;
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setPid(int pid) {
+ this.pid = pid;
+ }
+
+ public int getPid() {
+ return pid;
+ }
+
+ public void setHadoop(boolean hadoop) {
+ is_hadoop = hadoop;
+ }
+
+ public boolean isHadoop() {
+ return is_hadoop;
+ }
+
+ public void setCommand(String cmd) {
+ command = cmd;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+ }
+
+ public static class Alternative {
+ @SerializedName("name")
+ private String altName;
+ @SerializedName("target")
+ private String altTarget;
+
+ public void setName(String name) {
+ altName = name;
+ }
+
+ public String getName() {
+ return altName;
+ }
+
+ public void setTarget(String target) {
+ altTarget = target;
+ }
+
+ public String getTarget() {
+ return altTarget;
+ }
+ }
+
+ public static class LiveService {
+ @SerializedName("name")
+ private String svcName;
+ @SerializedName("status")
+ private String svcStatus;
+ @SerializedName("desc")
+ private String svcDesc;
+
+ public void setName(String name) {
+ svcName = name;
+ }
+
+ public String getName() {
+ return svcName;
+ }
+
+ public void setStatus(String status) {
+ svcStatus = status;
+ }
+
+ public String getStatus() {
+ return svcStatus;
+ }
+
+ public void setDesc(String desc) {
+ svcDesc = desc;
+ }
+
+ public String getDesc() {
+ return svcDesc;
+ }
+ }
+
+ public static class ExistingUser {
+ @SerializedName("name")
+ private String name;
+ @SerializedName("homeDir")
+ private String homeDir;
+ @SerializedName("status")
+ private String status;
+
+ public void setUserName(String userName) {
+ name = userName;
+ }
+
+ public String getUserName() {
+ return name;
+ }
+
+ public void setUserHomeDir(String userHomeDir) {
+ homeDir = userHomeDir;
+ }
+
+ public String getUserHomeDir() {
+ return homeDir;
+ }
+
+ public void setUserStatus(String userStatus) {
+ status = userStatus;
+ }
+
+ public String getUserStatus() {
+ return status;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentResource.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentResource.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentResource.java
new file mode 100644
index 0000000..f1e105a
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentResource.java
@@ -0,0 +1,118 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.apache.slider.server.appmaster.web.WebAppApi;
+import org.apache.slider.server.services.security.SignCertResponse;
+import org.apache.slider.server.services.security.SignMessage;
+import org.apache.slider.server.appmaster.web.rest.AbstractSliderResource;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class AgentResource extends AbstractSliderResource {
+
+ private String agent_name;
+
+ public AgentResource(WebAppApi slider) {
+ super(slider);
+ }
+
+ private void init(HttpServletResponse res) {
+ res.setContentType(null);
+ }
+
+ @GET
+ @Path("/agent/register")
+ public Response endpointAgentRegister() {
+ Response response = Response.status(200).entity("/agent/register").build();
+ return response;
+ }
+
+ @GET
+ @Path("/agent")
+ public Response endpointAgent() {
+ Response response = Response.status(200).entity("/agent").build();
+ return response;
+ }
+ @GET
+ @Path("/")
+ public Response endpointRoot() {
+ Response response = Response.status(200).entity("/").build();
+ return response;
+ }
+
+ @POST
+ @Path("/{agent_name: [a-zA-Z][a-zA-Z_0-9]*}/register")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ public RegistrationResponse register(Register registration,
+ @Context HttpServletResponse res,
+ @PathParam("agent_name") String agent_name) {
+ init(res);
+ this.agent_name = agent_name;
+ AgentRestOperations ops = slider.getAgentRestOperations();
+ return ops.handleRegistration(registration);
+
+ }
+
+ @POST
+ @Path("/{agent_name: [a-zA-Z][a-zA-Z_0-9]*}/heartbeat")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.APPLICATION_JSON})
+ public HeartBeatResponse heartbeat(HeartBeat message,
+ @Context HttpServletResponse res,
+ @PathParam("agent_name") String agent_name) {
+ init(res);
+ AgentRestOperations ops = slider.getAgentRestOperations();
+ return ops.handleHeartBeat(message);
+ }
+
+ @GET
+ @Path("/cert/ca")
+ @Produces({MediaType.TEXT_PLAIN})
+ public String downloadSrvrCrt() {
+ return slider.getCertificateManager().getServerCert();
+ }
+
+ @Path("/certs/{hostName}")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public SignCertResponse signAgentCrt(@PathParam("hostName") String hostname,
+ SignMessage message, @Context HttpServletRequest req) {
+ return slider.getCertificateManager().signAgentCrt(hostname,
+ message.getCsr(),
+ message.getPassphrase());
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentRestOperations.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentRestOperations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentRestOperations.java
new file mode 100644
index 0000000..2891be8
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentRestOperations.java
@@ -0,0 +1,28 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+/**
+ *
+ */
+public interface AgentRestOperations {
+
+ RegistrationResponse handleRegistration(Register registration);
+
+ HeartBeatResponse handleHeartBeat(HeartBeat heartBeat);
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
new file mode 100644
index 0000000..3a3b0c0
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
@@ -0,0 +1,258 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import com.google.common.base.Preconditions;
+import com.sun.jersey.api.core.ResourceConfig;
+import com.sun.jersey.spi.container.WebApplication;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+import com.sun.jersey.spi.container.servlet.WebConfig;
+import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider;
+import org.apache.slider.core.conf.MapOperations;
+import org.apache.slider.providers.agent.AgentKeys;
+import org.apache.slider.server.appmaster.web.WebAppApi;
+import org.apache.slider.server.services.security.SecurityUtils;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.security.SslSelectChannelConnector;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.thread.QueuedThreadPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.ext.Provider;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.util.Set;
+
+/**
+ *
+ */
+public class AgentWebApp implements Closeable {
+ protected static final Logger LOG = LoggerFactory.getLogger(AgentWebApp.class);
+ private int port;
+ private int securedPort;
+ private static Server agentServer;
+ public static final String BASE_PATH = "slideragent";
+
+ public static class Builder {
+ final String name;
+ final String wsName;
+ final WebAppApi application;
+ int port;
+ int securedPort;
+ MapOperations configsMap;
+
+ public Builder(String name, String wsName, WebAppApi application) {
+ this.name = name;
+ this.wsName = wsName;
+ this.application = application;
+ }
+
+ public Builder withComponentConfig(MapOperations appMasterConfig) {
+ this.configsMap = appMasterConfig;
+ return this;
+ }
+
+ public Builder withPort (int port) {
+ this.port = port;
+ return this;
+ }
+
+ public Builder withSecuredPort (int securedPort) {
+ this.securedPort = securedPort;
+ return this;
+ }
+
+ public AgentWebApp start() throws IOException {
+ if (configsMap == null) {
+ throw new IllegalStateException("No SSL Configuration Available");
+ }
+
+ agentServer = new Server();
+ agentServer.setThreadPool(
+ new QueuedThreadPool(
+ configsMap.getOptionInt("agent.threadpool.size.max", 25)));
+ agentServer.setStopAtShutdown(true);
+ agentServer.setGracefulShutdown(1000);
+
+ SslSelectChannelConnector ssl1WayConnector = createSSLConnector(false, port);
+ SslSelectChannelConnector ssl2WayConnector =
+ createSSLConnector(Boolean.valueOf(
+ configsMap.getOption(AgentKeys.KEY_AGENT_TWO_WAY_SSL_ENABLED,
+ "false")), securedPort);
+ agentServer.setConnectors(new Connector[]{ssl1WayConnector,
+ ssl2WayConnector});
+
+ ServletHolder agent = new ServletHolder(new AgentServletContainer());
+ Context agentRoot = new Context(agentServer, "/", Context.SESSIONS);
+
+ agent.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
+ "com.sun.jersey.api.core.PackagesResourceConfig");
+ agent.setInitParameter("com.sun.jersey.config.property.packages",
+ "org.apache.slider.server.appmaster.web.rest.agent");
+ agent.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature",
+ "true");
+// agent.setInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
+// agent.setInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
+// agent.setInitParameter("com.sun.jersey.config.feature.Trace", "true");
+ agentRoot.addServlet(agent, "/*");
+
+ try {
+ openListeners();
+ agentServer.start();
+ } catch (IOException e) {
+ LOG.error("Unable to start agent server", e);
+ throw e;
+ } catch (Exception e) {
+ LOG.error("Unable to start agent server", e);
+ throw new IOException("Unable to start agent server: " + e, e);
+ }
+
+ AgentWebApp webApp = new AgentWebApp();
+ webApp.setPort(getConnectorPort(agentServer, 0));
+ webApp.setSecuredPort(getConnectorPort(agentServer, 1));
+ return webApp;
+
+ }
+
+ private void openListeners() throws Exception {
+ // from HttpServer2.openListeners()
+ for (Connector listener : agentServer.getConnectors()) {
+ if (listener.getLocalPort() != -1) {
+ // This listener is either started externally or has been bound
+ continue;
+ }
+ int port = listener.getPort();
+ while (true) {
+ // jetty has a bug where you can't reopen a listener that previously
+ // failed to open w/o issuing a close first, even if the port is changed
+ try {
+ listener.close();
+ listener.open();
+ LOG.info("Jetty bound to port " + listener.getLocalPort());
+ break;
+ } catch (BindException ex) {
+ if (port == 0) {
+ BindException be = new BindException("Port in use: "
+ + listener.getHost() + ":" + listener.getPort());
+ be.initCause(ex);
+ throw be;
+ }
+ }
+ // try the next port number
+ listener.setPort(++port);
+ Thread.sleep(100);
+ }
+ }
+ }
+
+ private SslSelectChannelConnector createSSLConnector(boolean needClientAuth, int port) {
+ SslSelectChannelConnector sslConnector = new
+ SslSelectChannelConnector();
+
+ String keystore = SecurityUtils.getSecurityDir() +
+ File.separator + "keystore.p12";
+ String srvrCrtPass = SecurityUtils.getKeystorePass();
+ sslConnector.setKeystore(keystore);
+ sslConnector.setTruststore(keystore);
+ sslConnector.setPassword(srvrCrtPass);
+ sslConnector.setKeyPassword(srvrCrtPass);
+ sslConnector.setTrustPassword(srvrCrtPass);
+ sslConnector.setKeystoreType("PKCS12");
+ sslConnector.setTruststoreType("PKCS12");
+ sslConnector.setNeedClientAuth(needClientAuth);
+
+ sslConnector.setPort(port);
+ sslConnector.setAcceptors(2);
+ return sslConnector;
+ }
+
+ @Provider
+ public class WebAppApiProvider extends
+ SingletonTypeInjectableProvider<javax.ws.rs.core.Context, WebAppApi> {
+
+ public WebAppApiProvider () {
+ super(WebAppApi.class, application);
+ }
+ }
+
+ public class AgentServletContainer extends ServletContainer {
+ public AgentServletContainer() {
+ super();
+ }
+
+ @Override
+ protected void configure(WebConfig wc,
+ ResourceConfig rc,
+ WebApplication wa) {
+ super.configure(wc, rc, wa);
+ Set<Object> singletons = rc.getSingletons();
+ singletons.add(new WebAppApiProvider());
+ }
+ }
+
+ private int getConnectorPort(Server webServer, int index) {
+ Preconditions.checkArgument(index >= 0);
+ if (index > webServer.getConnectors().length)
+ throw new IllegalStateException("Illegal connect index requested");
+
+ Connector c = webServer.getConnectors()[index];
+ if (c.getLocalPort() == -1) {
+ // The connector is not bounded
+ throw new IllegalStateException("The connector is not bound to a port");
+ }
+
+ return c.getLocalPort();
+ }
+ }
+
+ public static Builder $for(String name, WebAppApi app, String wsPrefix) {
+ return new Builder(name, wsPrefix, app);
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public void setSecuredPort(int securedPort) {
+ this.securedPort = securedPort;
+ }
+
+ public int getSecuredPort() {
+ return securedPort;
+ }
+
+ public void close() throws IOException{
+ //need to stop server and reset injector
+ try {
+ agentServer.stop();
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IOException(e.toString(), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebServices.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebServices.java
new file mode 100644
index 0000000..684ce6f
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebServices.java
@@ -0,0 +1,40 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.apache.slider.server.appmaster.web.WebAppApi;
+import org.apache.slider.server.appmaster.web.rest.RestPaths;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+
+/** The available agent REST services exposed by a slider AM. */
+@Path(RestPaths.SLIDER_AGENT_CONTEXT_ROOT)
+public class AgentWebServices {
+ /** AM/WebApp info object */
+ @Context
+ private WebAppApi slider;
+
+ public AgentWebServices() {
+ }
+
+ @Path(RestPaths.SLIDER_SUBPATH_AGENTS)
+ public AgentResource getAgentResource () {
+ return new AgentResource(slider);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/CommandReport.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/CommandReport.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/CommandReport.java
new file mode 100644
index 0000000..a37e490
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/CommandReport.java
@@ -0,0 +1,207 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.Map;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class CommandReport {
+
+ int exitCode;
+ private String role;
+ private String actionId;
+ private String stdout;
+ private String stderr;
+ private String structuredOut;
+ private String status;
+ private String clusterName;
+ private String serviceName;
+ private long taskId;
+ private String roleCommand;
+ private Map<String, String> folders;
+ private Map<String, String> allocatedPorts;
+ private Map<String, Map<String, String>> configurationTags;
+
+ @JsonProperty("taskId")
+ public long getTaskId() {
+ return taskId;
+ }
+
+ @JsonProperty("taskId")
+ public void setTaskId(long taskId) {
+ this.taskId = taskId;
+ }
+
+ @JsonProperty("clusterName")
+ public String getClusterName() {
+ return this.clusterName;
+ }
+
+ @JsonProperty("clusterName")
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ @JsonProperty("actionId")
+ public String getActionId() {
+ return this.actionId;
+ }
+
+ @JsonProperty("actionId")
+ public void setActionId(String actionId) {
+ this.actionId = actionId;
+ }
+
+ @JsonProperty("stderr")
+ public String getStdErr() {
+ return this.stderr;
+ }
+
+ @JsonProperty("stderr")
+ public void setStdErr(String stderr) {
+ this.stderr = stderr;
+ }
+
+ @JsonProperty("exitcode")
+ public int getExitCode() {
+ return this.exitCode;
+ }
+
+ @JsonProperty("exitcode")
+ public void setExitCode(int exitCode) {
+ this.exitCode = exitCode;
+ }
+
+ @JsonProperty("stdout")
+ public String getStdOut() {
+ return this.stdout;
+ }
+
+ @JsonProperty("stdout")
+ public void setStdOut(String stdout) {
+ this.stdout = stdout;
+ }
+
+ @JsonProperty("structuredOut")
+ public String getStructuredOut() {
+ return this.structuredOut;
+ }
+
+ @JsonProperty("structuredOut")
+ public void setStructuredOut(String structuredOut) {
+ this.structuredOut = structuredOut;
+ }
+
+ @JsonProperty("roleCommand")
+ public String getRoleCommand() {
+ return this.roleCommand;
+ }
+
+ @JsonProperty("roleCommand")
+ public void setRoleCommand(String roleCommand) {
+ this.roleCommand = roleCommand;
+ }
+
+ @JsonProperty("role")
+ public String getRole() {
+ return role;
+ }
+
+ @JsonProperty("role")
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ @JsonProperty("status")
+ public String getStatus() {
+ return status;
+ }
+
+ @JsonProperty("status")
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ @JsonProperty("serviceName")
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ @JsonProperty("serviceName")
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ /** @return the config tags that match this command, or <code>null</code> if none are present */
+ @JsonProperty("configurationTags")
+ public Map<String, Map<String, String>> getConfigurationTags() {
+ return configurationTags;
+ }
+
+ /** @param tags the config tags that match this command */
+ @JsonProperty("configurationTags")
+ public void setConfigurationTags(Map<String, Map<String, String>> tags) {
+ configurationTags = tags;
+ }
+
+ /** @return the allocated ports, or <code>null</code> if none are present */
+ @JsonProperty("allocatedPorts")
+ public Map<String, String> getAllocatedPorts() {
+ return allocatedPorts;
+ }
+
+ /** @param ports allocated ports */
+ @JsonProperty("allocatedPorts")
+ public void setAllocatedPorts(Map<String, String> ports) {
+ this.allocatedPorts = ports;
+ }
+
+ /** @return the folders, or <code>null</code> if none are present */
+ @JsonProperty("folders")
+ public Map<String, String> getFolders() {
+ return folders;
+ }
+
+ /** @param folders allocated ports */
+ @JsonProperty("folders")
+ public void setFolders(Map<String, String> folders) {
+ this.folders = folders;
+ }
+
+ @Override
+ public String toString() {
+ return "CommandReport{" +
+ "role='" + role + '\'' +
+ ", actionId='" + actionId + '\'' +
+ ", status='" + status + '\'' +
+ ", exitCode=" + exitCode +
+ ", clusterName='" + clusterName + '\'' +
+ ", serviceName='" + serviceName + '\'' +
+ ", taskId=" + taskId +
+ ", roleCommand=" + roleCommand +
+ ", configurationTags=" + configurationTags +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ComponentStatus.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ComponentStatus.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ComponentStatus.java
new file mode 100644
index 0000000..acdc234
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ComponentStatus.java
@@ -0,0 +1,129 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.Map;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class ComponentStatus {
+ String componentName;
+ String msg;
+ String status;
+ String serviceName;
+ String clusterName;
+ String roleCommand;
+ String ip;
+ String hostname;
+ @JsonProperty("configurations")
+ private Map<String, Map<String, String>> configurations;
+
+ public String getRoleCommand() {
+ return roleCommand;
+ }
+
+ public void setRoleCommand(String roleCommand) {
+ this.roleCommand = roleCommand;
+ }
+
+ public String getComponentName() {
+ return this.componentName;
+ }
+
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ public String getMessage() {
+ return this.msg;
+ }
+
+ public void setMessage(String msg) {
+ this.msg = msg;
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ /** @return the config tags that match this command, or <code>null</code> if none are present */
+ public Map<String, Map<String, String>> getConfigs() {
+ return configurations;
+ }
+
+ /** @param configs the config tags that match this status */
+ public void setConfigs(Map<String, Map<String, String>> configs) {
+ this.configurations = configs;
+ }
+
+ @Override
+ public String toString() {
+ return "ComponentStatus{" +
+ "componentName='" + componentName + '\'' +
+ ", msg='" + msg + '\'' +
+ ", status='" + status + '\'' +
+ ", serviceName='" + serviceName + '\'' +
+ ", clusterName='" + clusterName + '\'' +
+ ", roleCommand='" + roleCommand + '\'' +
+ ", ip='" + ip + '\'' +
+ ", hostname='" + hostname + '\'' +
+ '}';
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/DiskInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/DiskInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/DiskInfo.java
new file mode 100644
index 0000000..27c4d54
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/DiskInfo.java
@@ -0,0 +1,128 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class DiskInfo {
+ String available;
+ String mountpoint;
+ String device;
+ String used;
+ String percent;
+ String size;
+ String type;
+
+ /**
+ * DiskInfo object that tracks information about a disk.
+ * @param mountpoint
+ * @param available
+ * @param used
+ * @param percent
+ * @param size
+ */
+ public DiskInfo(String device, String mountpoint, String available,
+ String used, String percent, String size, String type) {
+ this.device = device;
+ this.mountpoint = mountpoint;
+ this.available = available;
+ this.used = used;
+ this.percent = percent;
+ this.size = size;
+ this.type = type;
+ }
+
+ /**
+ * Needed for Serialization
+ */
+ public DiskInfo() {}
+
+ @JsonProperty("available")
+ public void setAvailable(String available) {
+ this.available = available;
+ }
+
+ @JsonProperty("available")
+ public String getAvailable() {
+ return this.available;
+ }
+
+ @JsonProperty("mountpoint")
+ public String getMountPoint() {
+ return this.mountpoint;
+ }
+
+ @JsonProperty("mountpoint")
+ public void setMountPoint(String mountpoint) {
+ this.mountpoint = mountpoint;
+ }
+
+ @JsonProperty("type")
+ public String getType() {
+ return this.type;
+ }
+
+ @JsonProperty("type")
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @JsonProperty("used")
+ public String getUsed() {
+ return this.used;
+ }
+
+ @JsonProperty("used")
+ public void setUsed(String used) {
+ this.used = used;
+ }
+
+ @JsonProperty("percent")
+ public String getPercent() {
+ return this.percent;
+ }
+
+ @JsonProperty("percent")
+ public void setPercent(String percent) {
+ this.percent = percent;
+ }
+
+ @JsonProperty("size")
+ public String getSize() {
+ return this.size;
+ }
+
+ @JsonProperty("size")
+ public void setSize(String size) {
+ this.size = size;
+ }
+
+ @Override
+ public String toString() {
+ return "available=" + this.available + ",mountpoint=" + this.mountpoint
+ + ",used=" + this.used + ",percent=" + this.percent + ",size=" +
+ this.size + ",device=" + this.device +
+ ",type=" + this.type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
new file mode 100644
index 0000000..d3864b8
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
@@ -0,0 +1,310 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.apache.slider.providers.agent.application.metadata.Component;
+import org.apache.slider.providers.agent.application.metadata.DockerContainer;
+import org.apache.slider.providers.agent.application.metadata.DockerContainerInputFile;
+import org.apache.slider.providers.agent.application.metadata.DockerContainerMount;
+import org.apache.slider.providers.agent.application.metadata.DockerContainerPort;
+import org.apache.slider.providers.agent.application.metadata.Metainfo;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class ExecutionCommand {
+ protected static final Logger log =
+ LoggerFactory.getLogger(ExecutionCommand.class);
+ private AgentCommandType commandType = AgentCommandType.EXECUTION_COMMAND;
+ private String clusterName;
+ private long taskId;
+ private String commandId;
+ //TODO Remove hostname from being set in the command
+ private String hostname;
+ private String role;
+ private Map<String, String> hostLevelParams = new HashMap<String, String>();
+ private Map<String, String> roleParams = null;
+ private String roleCommand;
+ private Map<String, Map<String, String>> configurations;
+ private Map<String, Map<String, String>> componentConfigurations;
+ private Map<String, String> commandParams;
+ private String serviceName;
+ private String componentName;
+ private String componentType;
+ private List<DockerContainer> containers = new ArrayList<>();
+ private String pkg;
+ private boolean yarnDockerMode = false;
+
+ public ExecutionCommand(AgentCommandType commandType) {
+ this.commandType = commandType;
+ }
+
+ @JsonProperty("commandType")
+ public AgentCommandType getCommandType() {
+ return commandType;
+ }
+
+ @JsonProperty("commandType")
+ public void setCommandType(AgentCommandType commandType) {
+ this.commandType = commandType;
+ }
+
+ @JsonProperty("commandId")
+ public String getCommandId() {
+ return this.commandId;
+ }
+
+ @JsonProperty("commandId")
+ public void setCommandId(String commandId) {
+ this.commandId = commandId;
+ }
+
+ @JsonProperty("taskId")
+ public long getTaskId() {
+ return taskId;
+ }
+
+ @JsonProperty("taskId")
+ public void setTaskId(long taskId) {
+ this.taskId = taskId;
+ }
+
+ @JsonProperty("role")
+ public String getRole() {
+ return role;
+ }
+
+ @JsonProperty("role")
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ @JsonProperty("roleParams")
+ public Map<String, String> getRoleParams() {
+ return roleParams;
+ }
+
+ @JsonProperty("roleParams")
+ public void setRoleParams(Map<String, String> roleParams) {
+ this.roleParams = roleParams;
+ }
+
+ @JsonProperty("roleCommand")
+ public String getRoleCommand() {
+ return roleCommand;
+ }
+
+ @JsonProperty("roleCommand")
+ public void setRoleCommand(String cmd) {
+ this.roleCommand = cmd;
+ }
+
+ @JsonProperty("clusterName")
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ @JsonProperty("clusterName")
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ @JsonProperty("componentType")
+ public String getComponentType() {
+ return componentType;
+ }
+
+ @JsonProperty("componentType")
+ public void setComponentType(String componentType) {
+ this.componentType = componentType;
+ }
+
+ @JsonProperty("hostname")
+ public String getHostname() {
+ return hostname;
+ }
+
+ @JsonProperty("hostname")
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ @JsonProperty("hostLevelParams")
+ public Map<String, String> getHostLevelParams() {
+ return hostLevelParams;
+ }
+
+ @JsonProperty("hostLevelParams")
+ public void setHostLevelParams(Map<String, String> params) {
+ this.hostLevelParams = params;
+ }
+
+ @JsonProperty("configurations")
+ public Map<String, Map<String, String>> getConfigurations() {
+ return configurations;
+ }
+
+ @JsonProperty("configurations")
+ public void setConfigurations(Map<String, Map<String, String>> configurations) {
+ this.configurations = configurations;
+ }
+
+ @JsonProperty("commandParams")
+ public Map<String, String> getCommandParams() {
+ return commandParams;
+ }
+
+ @JsonProperty("commandParams")
+ public void setCommandParams(Map<String, String> commandParams) {
+ this.commandParams = commandParams;
+ }
+
+ @JsonProperty("serviceName")
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ @JsonProperty("serviceName")
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ @JsonProperty("componentName")
+ public String getComponentName() {
+ return componentName;
+ }
+
+ @JsonProperty("componentName")
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ @JsonProperty("package")
+ public String getPkg() {
+ return pkg;
+ }
+
+ @JsonProperty("package")
+ public void setPkg(String pkg) {
+ this.pkg = pkg;
+ }
+
+ @JsonProperty("componentConfig")
+ public Map<String, Map<String, String>> getComponentConfigurations() {
+ return componentConfigurations;
+ }
+
+ @JsonProperty("componentConfig")
+ public void setComponentConfigurations(
+ Map<String, Map<String, String>> componentConfigurations) {
+ this.componentConfigurations = componentConfigurations;
+ }
+
+ @JsonProperty("containers")
+ public List<DockerContainer> getContainers() {
+ return containers;
+ }
+
+ @JsonProperty("yarnDockerMode")
+ public boolean isYarnDockerMode() {
+ return yarnDockerMode ;
+ }
+
+ @JsonProperty("yarnDockerMode")
+ public void setYarnDockerMode(boolean yarnDockerMode) {
+ this.yarnDockerMode = yarnDockerMode;
+ }
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ExecutionCommand [commandType=").append(commandType)
+ .append(", clusterName=").append(clusterName).append(", taskId=")
+ .append(taskId).append(", commandId=").append(commandId)
+ .append(", hostname=").append(hostname).append(", role=").append(role)
+ .append(", hostLevelParams=").append(hostLevelParams)
+ .append(", roleParams=").append(roleParams).append(", roleCommand=")
+ .append(roleCommand).append(", configurations=").append(configurations)
+ .append(", commandParams=").append(commandParams)
+ .append(", serviceName=").append(serviceName)
+ .append(", componentName=").append(componentName)
+ .append(", componentType=").append(componentType)
+ .append(", yarnDockerMode=").append(yarnDockerMode).append(", pkg=")
+ .append(pkg).append("]");
+ return builder.toString();
+ }
+
+ public void addContainerDetails(String componentGroup, Metainfo metaInfo) {
+ Component component = metaInfo.getApplicationComponent(componentGroup);
+ this.setComponentType(component.getType());
+ log.info("Adding container details for {}", componentGroup, " from ",
+ metaInfo.toString());
+ for (DockerContainer metaContainer : component.getDockerContainers()) {
+ DockerContainer container = new DockerContainer();
+ container.setImage(metaContainer.getImage());
+ container.setNetwork(metaContainer.getNetwork());
+ container.setUseNetworkScript(metaContainer.getUseNetworkScript());
+ container.setName(metaContainer.getName());
+ container.setOptions(metaContainer.getOptions());
+ container.setAdditionalParam(metaContainer.getAdditionalParam());
+ container.setCommandPath(metaContainer.getAdditionalParam());
+ container.setStatusCommand(metaContainer.getStatusCommand());
+ container.setStartCommand(metaContainer.getStartCommand());
+ if (metaContainer.getMounts().size() > 0) {
+ for (DockerContainerMount metaContMount : metaContainer.getMounts()) {
+ DockerContainerMount contMnt = new DockerContainerMount();
+ contMnt.setContainerMount(metaContMount.getContainerMount());
+ contMnt.setHostMount(metaContMount.getHostMount());
+ container.getMounts().add(contMnt);
+ }
+ }
+ if (metaContainer.getPorts().size() > 0) {
+ for (DockerContainerPort metaCntPort : metaContainer.getPorts()) {
+ DockerContainerPort cntPort = new DockerContainerPort();
+ cntPort.setContainerPort(metaCntPort.getContainerPort());
+ cntPort.setHostPort(metaCntPort.getHostPort());
+ container.getPorts().add(cntPort);
+ }
+ }
+ if (metaContainer.getInputFiles().size() > 0) {
+ for (DockerContainerInputFile metaInpFile : metaContainer
+ .getInputFiles()) {
+ DockerContainerInputFile inpFile = new DockerContainerInputFile();
+ inpFile.setContainerMount(metaInpFile.getContainerMount());
+ inpFile.setFileLocalPath(metaInpFile.getFileLocalPath());
+ container.getInputFiles().add(inpFile);
+ }
+ }
+ if (metaContainer.getConfigFiles() != null) {
+ container.setConfigFiles(metaContainer.getConfigFiles());
+ }
+ log.info("Docker container meta info ready: " + container.toString());
+ this.getContainers().add(container);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeat.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeat.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeat.java
new file mode 100644
index 0000000..d17c465
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeat.java
@@ -0,0 +1,149 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ *
+ * Data model for agent heartbeat for server (ambari or app master).
+ *
+ */
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class HeartBeat {
+ private long responseId = -1;
+ private long timestamp;
+ private String hostname;
+ List<CommandReport> reports = new ArrayList<CommandReport>();
+ List<ComponentStatus> componentStatus = new ArrayList<ComponentStatus>();
+ private List<DiskInfo> mounts = new ArrayList<DiskInfo>();
+ HostStatus nodeStatus;
+ private AgentEnv agentEnv = null;
+ private String fqdn;
+ private String pkg;
+
+ public long getResponseId() {
+ return responseId;
+ }
+
+ public void setResponseId(long responseId) {
+ this.responseId=responseId;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public String getFqdn() {
+ return fqdn;
+ }
+
+ public void setFqdn(String fqdn) {
+ this.fqdn = fqdn;
+ }
+
+ @JsonProperty("reports")
+ public List<CommandReport> getReports() {
+ return this.reports;
+ }
+
+ @JsonProperty("reports")
+ public void setReports(List<CommandReport> reports) {
+ this.reports = reports;
+ }
+
+ public HostStatus getNodeStatus() {
+ return nodeStatus;
+ }
+
+ public void setNodeStatus(HostStatus nodeStatus) {
+ this.nodeStatus = nodeStatus;
+ }
+
+ public AgentEnv getAgentEnv() {
+ return agentEnv;
+ }
+
+ public void setAgentEnv(AgentEnv env) {
+ agentEnv = env;
+ }
+
+ @JsonProperty("componentStatus")
+ public List<ComponentStatus> getComponentStatus() {
+ return componentStatus;
+ }
+
+ @JsonProperty("componentStatus")
+ public void setComponentStatus(List<ComponentStatus> componentStatus) {
+ this.componentStatus = componentStatus;
+ }
+
+ @JsonProperty("mounts")
+ public List<DiskInfo> getMounts() {
+ return this.mounts;
+ }
+
+ @JsonProperty("mounts")
+ public void setMounts(List<DiskInfo> mounts) {
+ this.mounts = mounts;
+ }
+
+ @JsonProperty("package")
+ public String getPackage() {
+ return pkg;
+ }
+
+ @JsonProperty("package")
+ public void setPackage(String pkg) {
+ this.pkg = pkg;
+ }
+
+ @Override
+ public String toString() {
+ return "HeartBeat{" +
+ "responseId=" + responseId +
+ ", timestamp=" + timestamp +
+ ", hostname='" + hostname + '\'' +
+ ", reports=" + reports +
+ ", componentStatus=" + componentStatus +
+ ", package=" + pkg +
+ ", nodeStatus=" + nodeStatus +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeatResponse.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeatResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeatResponse.java
new file mode 100644
index 0000000..b500d67
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HeartBeatResponse.java
@@ -0,0 +1,147 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * Controller to Agent response data model.
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class HeartBeatResponse {
+
+ private long responseId;
+
+ List<ExecutionCommand> executionCommands = new ArrayList<ExecutionCommand>();
+ List<StatusCommand> statusCommands = new ArrayList<StatusCommand>();
+
+ RegistrationCommand registrationCommand;
+
+ boolean yarnDockerMode = false;
+ boolean restartAgent = false;
+ boolean restartEnabled = true;
+ boolean hasMappedComponents = false;
+ boolean terminateAgent = false;
+
+ @JsonProperty("responseId")
+ public long getResponseId() {
+ return responseId;
+ }
+
+ @JsonProperty("responseId")
+ public void setResponseId(long responseId) {
+ this.responseId=responseId;
+ }
+
+ @JsonProperty("executionCommands")
+ public List<ExecutionCommand> getExecutionCommands() {
+ return executionCommands;
+ }
+
+ @JsonProperty("executionCommands")
+ public void setExecutionCommands(List<ExecutionCommand> executionCommands) {
+ this.executionCommands = executionCommands;
+ }
+
+ @JsonProperty("statusCommands")
+ public List<StatusCommand> getStatusCommands() {
+ return statusCommands;
+ }
+
+ @JsonProperty("statusCommands")
+ public void setStatusCommands(List<StatusCommand> statusCommands) {
+ this.statusCommands = statusCommands;
+ }
+
+ @JsonProperty("registrationCommand")
+ public RegistrationCommand getRegistrationCommand() {
+ return registrationCommand;
+ }
+
+ @JsonProperty("registrationCommand")
+ public void setRegistrationCommand(RegistrationCommand registrationCommand) {
+ this.registrationCommand = registrationCommand;
+ }
+
+ @JsonProperty("restartAgent")
+ public boolean isRestartAgent() {
+ return restartAgent;
+ }
+
+ @JsonProperty("restartAgent")
+ public void setRestartAgent(boolean restartAgent) {
+ this.restartAgent = restartAgent;
+ }
+
+ @JsonProperty("restartEnabled")
+ public boolean getRstartEnabled() {
+ return restartEnabled;
+ }
+
+ @JsonProperty("restartEnabled")
+ public void setRestartEnabled(boolean restartEnabled) {
+ this.restartEnabled = restartEnabled;
+ }
+
+ @JsonProperty("hasMappedComponents")
+ public boolean hasMappedComponents() {
+ return hasMappedComponents;
+ }
+
+ @JsonProperty("hasMappedComponents")
+ public void setHasMappedComponents(boolean hasMappedComponents) {
+ this.hasMappedComponents = hasMappedComponents;
+ }
+
+ @JsonProperty("terminateAgent")
+ public boolean isTerminateAgent() {
+ return terminateAgent;
+ }
+
+ @JsonProperty("terminateAgent")
+ public void setTerminateAgent(boolean terminateAgent) {
+ this.terminateAgent = terminateAgent;
+ }
+
+ public void addExecutionCommand(ExecutionCommand execCmd) {
+ executionCommands.add(execCmd);
+ }
+
+ public void addStatusCommand(StatusCommand statCmd) {
+ statusCommands.add(statCmd);
+ }
+
+ @Override
+ public String toString() {
+ return "HeartBeatResponse{" +
+ "responseId=" + responseId +
+ ", executionCommands=" + executionCommands +
+ ", statusCommands=" + statusCommands +
+ ", registrationCommand=" + registrationCommand +
+ ", restartAgent=" + restartAgent +
+ ", terminateAgent=" + terminateAgent +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostInfo.java
new file mode 100644
index 0000000..bef7b07
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostInfo.java
@@ -0,0 +1,398 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class HostInfo {
+ private String architecture;
+ private String domain;
+ private String fqdn;
+ private String hardwareisa;
+ private String hardwaremodel;
+ private String hostname;
+ private String id;
+ private String interfaces;
+ private String ipaddress;
+ private String kernel;
+ private String kernelmajversion;
+ private String kernelrelease;
+ private String kernelversion;
+ private String macaddress;
+ private long memoryfree;
+ private long memorysize;
+ private List<DiskInfo> mounts = new ArrayList<DiskInfo>();
+ private long memorytotal;
+ private String netmask;
+ private String operatingsystem;
+ private String operatingsystemrelease;
+ private String osfamily;
+ private int physicalprocessorcount;
+ private int processorcount;
+ private boolean selinux;
+ private String swapfree;
+ private String swapsize;
+ private String timezone;
+ private String uptime;
+ private long uptime_days;
+ private long uptime_hours;
+
+
+ @JsonProperty("architecture")
+ public String getArchitecture() {
+ return this.architecture;
+ }
+
+ @JsonProperty("architecture")
+ public void setArchitecture(String architecture) {
+ this.architecture = architecture;
+ }
+
+ @JsonProperty("domain")
+ public String getDomain() {
+ return this.domain;
+ }
+
+ @JsonProperty("domain")
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ @JsonProperty("fqdn")
+ public String getFQDN() {
+ return this.fqdn;
+ }
+
+ @JsonProperty("fqdn")
+ public void setFQDN(String fqdn) {
+ this.fqdn = fqdn;
+ }
+
+ @JsonProperty("hardwareisa")
+ public String getHardwareIsa() {
+ return hardwareisa;
+ }
+
+ @JsonProperty("hardwareisa")
+ public void setHardwareIsa(String hardwareisa) {
+ this.hardwareisa = hardwareisa;
+ }
+
+ @JsonProperty("hardwaremodel")
+ public String getHardwareModel() {
+ return this.hardwaremodel;
+ }
+
+ @JsonProperty("hardwaremodel")
+ public void setHardwareModel(String hardwaremodel) {
+ this.hardwaremodel = hardwaremodel;
+ }
+
+ @JsonProperty("hostname")
+ public String getHostName() {
+ return this.hostname;
+ }
+
+ @JsonProperty("hostname")
+ public void setHostName(String hostname) {
+ this.hostname = hostname;
+ }
+
+ @JsonProperty("id")
+ public String getAgentUserId() {
+ return id;
+ }
+
+ @JsonProperty("id")
+ public void setAgentUserId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("interfaces")
+ public String getInterfaces() {
+ return this.interfaces;
+ }
+
+ @JsonProperty("interfaces")
+ public void setInterfaces(String interfaces) {
+ this.interfaces = interfaces;
+ }
+
+ @JsonProperty("ipaddress")
+ public String getIPAddress() {
+ return this.ipaddress;
+ }
+
+ @JsonProperty("ipaddress")
+ public void setIPAddress(String ipaddress) {
+ this.ipaddress = ipaddress;
+ }
+
+ @JsonProperty("kernel")
+ public String getKernel() {
+ return this.kernel;
+ }
+
+ @JsonProperty("kernel")
+ public void setKernel(String kernel) {
+ this.kernel = kernel;
+ }
+
+ @JsonProperty("kernelmajversion")
+ public String getKernelMajVersion() {
+ return this.kernelmajversion;
+ }
+
+ @JsonProperty("kernelmajversion")
+ public void setKernelMajVersion(String kernelmajversion) {
+ this.kernelmajversion = kernelmajversion;
+ }
+
+ @JsonProperty("kernelrelease")
+ public String getKernelRelease() {
+ return this.kernelrelease;
+ }
+
+ @JsonProperty("kernelrelease")
+ public void setKernelRelease(String kernelrelease) {
+ this.kernelrelease = kernelrelease;
+ }
+
+ @JsonProperty("kernelversion")
+ public String getKernelVersion() {
+ return this.kernelversion;
+ }
+
+ @JsonProperty("kernelversion")
+ public void setKernelVersion(String kernelversion) {
+ this.kernelversion = kernelversion;
+ }
+
+ @JsonProperty("macaddress")
+ public String getMacAddress() {
+ return this.macaddress;
+ }
+
+ @JsonProperty("macaddress")
+ public void setMacAddress(String macaddress) {
+ this.macaddress = macaddress;
+ }
+
+ @JsonProperty("memoryfree")
+ public long getFreeMemory() {
+ return this.memoryfree;
+ }
+
+ @JsonProperty("memoryfree")
+ public void setFreeMemory(long memoryfree) {
+ this.memoryfree = memoryfree;
+ }
+
+ @JsonProperty("memorysize")
+ public long getMemorySize() {
+ return this.memorysize;
+ }
+
+ @JsonProperty("memorysize")
+ public void setMemorySize(long memorysize) {
+ this.memorysize = memorysize;
+ }
+
+ @JsonProperty("mounts")
+ public List<DiskInfo> getMounts() {
+ return this.mounts;
+ }
+
+ @JsonProperty("mounts")
+ public void setMounts(List<DiskInfo> mounts) {
+ this.mounts = mounts;
+ }
+
+ @JsonProperty("memorytotal")
+ public long getMemoryTotal() {
+ return this.memorytotal;
+ }
+
+ @JsonProperty("memorytotal")
+ public void setMemoryTotal(long memorytotal) {
+ this.memorytotal = memorytotal;
+ }
+
+ @JsonProperty("netmask")
+ public String getNetMask() {
+ return this.netmask;
+ }
+
+ @JsonProperty("netmask")
+ public void setNetMask(String netmask) {
+ this.netmask = netmask;
+ }
+
+ @JsonProperty("operatingsystem")
+ public String getOS() {
+ return this.operatingsystem;
+ }
+
+ @JsonProperty("operatingsystem")
+ public void setOS(String operatingsystem) {
+ this.operatingsystem = operatingsystem;
+ }
+
+ @JsonProperty("operatingsystemrelease")
+ public String getOSRelease() {
+ return this.operatingsystemrelease;
+ }
+
+ @JsonProperty("operatingsystemrelease")
+ public void setOSRelease(String operatingsystemrelease) {
+ this.operatingsystemrelease = operatingsystemrelease;
+ }
+
+ @JsonProperty("osfamily")
+ public String getOSFamily() {
+ return this.osfamily;
+ }
+
+ @JsonProperty("osfamily")
+ public void setOSFamily(String osfamily) {
+ this.osfamily = osfamily;
+ }
+
+ @JsonProperty("physicalprocessorcount")
+ public int getPhysicalProcessorCount() {
+ return this.physicalprocessorcount;
+ }
+
+ @JsonProperty("physicalprocessorcount")
+ public void setPhysicalProcessorCount(int physicalprocessorcount) {
+ this.physicalprocessorcount = physicalprocessorcount;
+ }
+
+ @JsonProperty("processorcount")
+ public int getProcessorCount() {
+ return this.processorcount;
+ }
+
+ @JsonProperty("processorcount")
+ public void setProcessorCount(int processorcount) {
+ this.processorcount = processorcount;
+ }
+
+ @JsonProperty("selinux")
+ public boolean getSeLinux() {
+ return selinux;
+ }
+
+ @JsonProperty("selinux")
+ public void setSeLinux(boolean selinux) {
+ this.selinux = selinux;
+ }
+
+ @JsonProperty("swapfree")
+ public String getSwapFree() {
+ return this.swapfree;
+ }
+
+ @JsonProperty("swapfree")
+ public void setSwapFree(String swapfree) {
+ this.swapfree = swapfree;
+ }
+
+ @JsonProperty("swapsize")
+ public String getSwapSize() {
+ return swapsize;
+ }
+
+ @JsonProperty("swapsize")
+ public void setSwapSize(String swapsize) {
+ this.swapsize = swapsize;
+ }
+
+ @JsonProperty("timezone")
+ public String getTimeZone() {
+ return this.timezone;
+ }
+
+ @JsonProperty("timezone")
+ public void setTimeZone(String timezone) {
+ this.timezone = timezone;
+ }
+
+ @JsonProperty("uptime")
+ public String getUptime() {
+ return this.uptime;
+ }
+
+ @JsonProperty("uptime")
+ public void setUpTime(String uptime) {
+ this.uptime = uptime;
+ }
+
+ @JsonProperty("uptime_hours")
+ public long getUptimeHours() {
+ return this.uptime_hours;
+ }
+
+ @JsonProperty("uptime_hours")
+ public void setUpTimeHours(long uptime_hours) {
+ this.uptime_hours = uptime_hours;
+ }
+
+ @JsonProperty("uptime_days")
+ public long getUpTimeDays() {
+ return this.uptime_days;
+ }
+
+ @JsonProperty("uptime_days")
+ public void setUpTimeDays(long uptime_days) {
+ this.uptime_days = uptime_days;
+ }
+
+ private String getDiskString() {
+ if (mounts == null) {
+ return null;
+ }
+ StringBuilder ret = new StringBuilder();
+ for (DiskInfo diskInfo : mounts) {
+ ret.append("(").append(diskInfo.toString()).append(")");
+ }
+ return ret.toString();
+ }
+
+ public String toString() {
+ return "[" +
+ "hostname=" + this.hostname + "," +
+ "fqdn=" + this.fqdn + "," +
+ "domain=" + this.domain + "," +
+ "architecture=" + this.architecture + "," +
+ "processorcount=" + this.processorcount + "," +
+ "physicalprocessorcount=" + this.physicalprocessorcount + "," +
+ "osname=" + this.operatingsystem + "," +
+ "osversion=" + this.operatingsystemrelease + "," +
+ "osfamily=" + this.osfamily + "," +
+ "memory=" + this.memorytotal + "," +
+ "uptime_hours=" + this.uptime_hours + "," +
+ "mounts=" + getDiskString() + "]\n";
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostStatus.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostStatus.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostStatus.java
new file mode 100644
index 0000000..c584149
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/HostStatus.java
@@ -0,0 +1,63 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class HostStatus {
+ public HostStatus(Status status, String cause) {
+ super();
+ this.status = status;
+ this.cause = cause;
+ }
+ public HostStatus() {
+ super();
+ }
+
+ public enum Status {
+ HEALTHY,
+ UNHEALTHY
+ }
+ Status status;
+ String cause;
+ public Status getStatus() {
+ return status;
+ }
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+ public String getCause() {
+ return cause;
+ }
+ public void setCause(String cause) {
+ this.cause = cause;
+ }
+
+ @Override
+ public String toString() {
+ return "HostStatus{" +
+ "status=" + status +
+ ", cause='" + cause + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/Register.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/Register.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/Register.java
new file mode 100644
index 0000000..0150079
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/Register.java
@@ -0,0 +1,193 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.apache.slider.providers.agent.State;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.Map;
+
+/** Data model for agent to send heartbeat to ambari and/or app master. */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class Register {
+ private int responseId = -1;
+ private long timestamp;
+ private String label;
+ private int currentPingPort;
+ private HostInfo hardwareProfile;
+ private String publicHostname;
+ private String tags;
+ private AgentEnv agentEnv;
+ private String agentVersion;
+ private State actualState;
+ private State expectedState;
+ private Map<String, String> allocatedPorts;
+ private Map<String, String> logFolders;
+ private String pkg;
+ private String appVersion;
+
+ @JsonProperty("responseId")
+ public int getResponseId() {
+ return responseId;
+ }
+
+ @JsonProperty("responseId")
+ public void setResponseId(int responseId) {
+ this.responseId = responseId;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public HostInfo getHardwareProfile() {
+ return hardwareProfile;
+ }
+
+ public void setHardwareProfile(HostInfo hardwareProfile) {
+ this.hardwareProfile = hardwareProfile;
+ }
+
+ public String getPublicHostname() {
+ return publicHostname;
+ }
+
+ public void setPublicHostname(String name) {
+ this.publicHostname = name;
+ }
+
+ public AgentEnv getAgentEnv() {
+ return agentEnv;
+ }
+
+ public void setAgentEnv(AgentEnv env) {
+ this.agentEnv = env;
+ }
+
+ public String getAgentVersion() {
+ return agentVersion;
+ }
+
+ public void setAgentVersion(String agentVersion) {
+ this.agentVersion = agentVersion;
+ }
+
+ public int getCurrentPingPort() {
+ return currentPingPort;
+ }
+
+ public void setCurrentPingPort(int currentPingPort) {
+ this.currentPingPort = currentPingPort;
+ }
+
+ public State getActualState() {
+ return actualState;
+ }
+
+ public void setActualState(State actualState) {
+ this.actualState = actualState;
+ }
+
+ public State getExpectedState() {
+ return expectedState;
+ }
+
+ public void setExpectedState(State expectedState) {
+ this.expectedState = expectedState;
+ }
+
+ /** @return the allocated ports, or <code>null</code> if none are present */
+ @JsonProperty("allocatedPorts")
+ public Map<String, String> getAllocatedPorts() {
+ return allocatedPorts;
+ }
+
+ /** @param ports allocated ports */
+ @JsonProperty("allocatedPorts")
+ public void setAllocatedPorts(Map<String, String> ports) {
+ this.allocatedPorts = ports;
+ }
+
+ /** @return the log folders, or <code>null</code> if none are present */
+ @JsonProperty("logFolders")
+ public Map<String, String> getLogFolders() {
+ return logFolders;
+ }
+
+ /** @param logFolders assigned log folders */
+ @JsonProperty("logFolders")
+ public void setLogFolders(Map<String, String> logFolders) {
+ this.logFolders = logFolders;
+ }
+
+ public String getPkg() {
+ return pkg;
+ }
+
+ public void setPkg(String pkg) {
+ this.pkg = pkg;
+ }
+
+ @JsonProperty("appVersion")
+ public String getAppVersion() {
+ return appVersion;
+ }
+
+ @JsonProperty("appVersion")
+ public void setAppVersion(String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ @Override
+ public String toString() {
+ String ret = "responseId=" + responseId + "\n" +
+ "timestamp=" + timestamp + "\n" +
+ "label=" + label + "\n" +
+ "hostname=" + publicHostname + "\n" +
+ "expectedState=" + expectedState + "\n" +
+ "actualState=" + actualState + "\n" +
+ "appVersion=" + appVersion + "\n";
+
+ if (hardwareProfile != null) {
+ ret = ret + "hardwareprofile=" + this.hardwareProfile.toString();
+ }
+ return ret;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/31c4a419/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/RegistrationCommand.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/RegistrationCommand.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/RegistrationCommand.java
new file mode 100644
index 0000000..4b87dd2
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/RegistrationCommand.java
@@ -0,0 +1,43 @@
+/*
+ * 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.server.appmaster.web.rest.agent;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class RegistrationCommand {
+
+ private String command;
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ public RegistrationCommand(String command) {
+
+ this.command = command;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org