http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/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 deleted file mode 100644 index 0150079..0000000 --- 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 +++ /dev/null @@ -1,193 +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.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/9fdab600/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 deleted file mode 100644 index 4b87dd2..0000000 --- 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 +++ /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.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; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/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/RegistrationResponse.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/RegistrationResponse.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/RegistrationResponse.java deleted file mode 100644 index 80b7a5e..0000000 --- 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/RegistrationResponse.java +++ /dev/null @@ -1,133 +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.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.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class RegistrationResponse { - - @JsonProperty("response") - private RegistrationStatus response; - - /** - * exitstatus is a code of error which was rised on server side. exitstatus - * = 0 (OK - Default) exitstatus = 1 (Registration failed because different - * version of agent and server) - */ - @JsonProperty("exitstatus") - private int exitstatus; - - /** log - message, which will be printed to agents log */ - @JsonProperty("log") - private String log; - - /** tags - tags associated with the container */ - @JsonProperty("tags") - private String tags; - - @JsonProperty("package") - private String pkg; - - //Response id to start with, usually zero. - @JsonProperty("responseId") - private long responseId; - - @JsonProperty("statusCommands") - private List<StatusCommand> statusCommands = null; - - public RegistrationResponse() { - } - - public RegistrationStatus getResponse() { - return response; - } - - public void setResponse(RegistrationStatus response) { - this.response = response; - } - - public int getExitstatus() { - return exitstatus; - } - - public void setExitstatus(int exitstatus) { - this.exitstatus = exitstatus; - } - - public RegistrationStatus getResponseStatus() { - return response; - } - - public void setResponseStatus(RegistrationStatus response) { - this.response = response; - } - - public List<StatusCommand> getStatusCommands() { - return statusCommands; - } - - public void setStatusCommands(List<StatusCommand> statusCommands) { - this.statusCommands = statusCommands; - } - - public long getResponseId() { - return responseId; - } - - public void setResponseId(long responseId) { - this.responseId = responseId; - } - - public String getTags() { - return tags; - } - - public void setTags(String tags) { - this.tags = tags; - } - - public String getLog() { - return log; - } - - public void setLog(String log) { - this.log = log; - } - - public String getPkg() { - return pkg; - } - - public void setPkg(String pkg) { - this.pkg = pkg; - } - - @Override - public String toString() { - return "RegistrationResponse{" + - "response=" + response + - ", responseId=" + responseId + - ", statusCommands=" + statusCommands + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/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/RegistrationStatus.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/RegistrationStatus.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/RegistrationStatus.java deleted file mode 100644 index 8374710..0000000 --- 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/RegistrationStatus.java +++ /dev/null @@ -1,22 +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.server.appmaster.web.rest.agent; - -public enum RegistrationStatus { - OK, - FAILED -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/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/StatusCommand.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/StatusCommand.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/StatusCommand.java deleted file mode 100644 index 5b205b5..0000000 --- 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/StatusCommand.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"); 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.HashMap; -import java.util.Map; - -/** - * Command to report the status of a list of services in roles. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class StatusCommand { - public static String STATUS_COMMAND = "STATUS"; - public static String GET_CONFIG_COMMAND = "GET_CONFIG"; - - AgentCommandType agentCommandType; - - private String clusterName; - private String serviceName; - private String componentName; - private Map<String, Map<String, String>> configurations; - private Map<String, String> commandParams = new HashMap<String, String>(); - private Map<String, String> hostLevelParams = new HashMap<String, String>(); - private String roleCommand; - private boolean yarnDockerMode; - - public StatusCommand() { - this.agentCommandType = AgentCommandType.STATUS_COMMAND; - } - - @JsonProperty("clusterName") - public String getClusterName() { - return clusterName; - } - - @JsonProperty("clusterName") - public void setClusterName(String clusterName) { - this.clusterName = clusterName; - } - - @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("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("hostLevelParams") - public Map<String, String> getHostLevelParams() { - return hostLevelParams; - } - - @JsonProperty("hostLevelParams") - public void setHostLevelParams(Map<String, String> params) { - this.hostLevelParams = params; - } - - @JsonProperty("commandParams") - public Map<String, String> getCommandParams() { - return commandParams; - } - - @JsonProperty("commandParams") - public void setCommandParams(Map<String, String> commandParams) { - this.commandParams = commandParams; - } - - @JsonProperty("commandType") - public AgentCommandType getCommandType() { - return agentCommandType; - } - - @JsonProperty("commandType") - public void setCommandType(AgentCommandType commandType) { - this.agentCommandType = commandType; - } - - @JsonProperty("roleCommand") - public String getRoleCommand() { - return roleCommand; - } - - @JsonProperty("roleCommand") - public void setRoleCommand(String roleCommand) { - this.roleCommand = roleCommand; - } - - @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("StatusCommand [agentCommandType=").append(agentCommandType) - .append(", clusterName=").append(clusterName).append(", serviceName=") - .append(serviceName).append(", componentName=").append(componentName) - .append(", configurations=").append(configurations) - .append(", commandParams=").append(commandParams) - .append(", hostLevelParams=").append(hostLevelParams) - .append(", roleCommand=").append(roleCommand).append("]"); - return builder.toString(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java deleted file mode 100644 index 0bea8fa..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java +++ /dev/null @@ -1,77 +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.providers.agent; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.slider.common.tools.SliderFileSystem; -import org.apache.slider.core.conf.AggregateConf; -import org.apache.slider.core.exceptions.BadConfigException; -import org.apache.slider.tools.TestUtility; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Set; - -/** - * - */ -public class TestAgentClientProvider { - protected static final Logger log = - LoggerFactory.getLogger(TestAgentClientProvider.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - @Test - public void testGetApplicationTags() throws Exception { - Configuration configuration = new Configuration(); - FileSystem fs = FileSystem.getLocal(configuration); - SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); - - AgentClientProvider provider = new AgentClientProvider(null); - String zipFileName = TestUtility.createAppPackage( - folder, - "testpkg", - "test.zip", - "target/test-classes/org/apache/slider/common/tools/test"); - Set<String> tags = provider.getApplicationTags(sliderFileSystem, zipFileName); - assert tags != null; - assert !tags.isEmpty(); - assert tags.contains("Name: STORM"); - assert tags.contains("Description: Apache Hadoop Stream processing framework"); - assert tags.contains("Version: 0.9.1.2.1"); - - } - - @Test - public void testValidateInstanceDefinition() throws Exception { - AgentClientProvider provider = new AgentClientProvider(null); - AggregateConf instanceDefinition = new AggregateConf(); - - try { - provider.validateInstanceDefinition(instanceDefinition, null); - Assert.assertFalse("Should fail with BadConfigException", true); - } catch (BadConfigException e) { - log.info(e.toString()); - Assert.assertTrue(e.getMessage().contains("Application definition must be provided")); - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java deleted file mode 100644 index ec62b54..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java +++ /dev/null @@ -1,76 +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.providers.agent; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - */ -public class TestAgentLaunchParameter { - protected static final Logger log = - LoggerFactory.getLogger(TestAgentLaunchParameter.class); - - @Test - public void testTestAgentLaunchParameter() throws Exception { - AgentLaunchParameter alp = new AgentLaunchParameter(""); - Assert.assertEquals("", alp.getNextLaunchParameter("abc")); - Assert.assertEquals("", alp.getNextLaunchParameter("HBASE_MASTER")); - - alp = new AgentLaunchParameter("a:1:2:3|b:5:6:NONE"); - Assert.assertEquals("1", alp.getNextLaunchParameter("a")); - Assert.assertEquals("2", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - - Assert.assertEquals("5", alp.getNextLaunchParameter("b")); - Assert.assertEquals("6", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("c")); - - alp = new AgentLaunchParameter("|a:1:3|b::5:NONE:"); - Assert.assertEquals("1", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("5", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - - alp = new AgentLaunchParameter("|:"); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("a")); - - alp = new AgentLaunchParameter("HBASE_MASTER:a,b:DO_NOT_REGISTER:"); - Assert.assertEquals("a,b", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("DO_NOT_REGISTER", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("DO_NOT_REGISTER", alp.getNextLaunchParameter("HBASE_MASTER")); - - alp = new AgentLaunchParameter("HBASE_MASTER:a,b:DO_NOT_REGISTER::c:::"); - Assert.assertEquals("a,b", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("DO_NOT_REGISTER", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("c", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("c", alp.getNextLaunchParameter("HBASE_MASTER")); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java deleted file mode 100644 index 5e1dc7f..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java +++ /dev/null @@ -1,94 +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.providers.agent; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.slider.common.tools.SliderFileSystem; -import org.apache.slider.providers.agent.application.metadata.Metainfo; -import org.apache.slider.tools.TestUtility; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestAgentUtils { - protected static final Logger log = - LoggerFactory.getLogger(TestAgentUtils.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - private static final String metainfo_str = "<metainfo>\n" - + " <schemaVersion>2.0</schemaVersion>\n" - + " <application>\n" - + " <name>MYTESTAPPLICATION</name>\n" - + " <comment>\n" - + " My Test Application\n" - + " </comment>\n" - + " <version>1.0</version>\n" - + " <type>YARN-APP</type>\n" - + " <components>\n" - + " <component>\n" - + " <name>REST</name>\n" - + " <category>MASTER</category>\n" - + " <commandScript>\n" - + " <script>scripts/rest.py</script>\n" - + " <scriptType>PYTHON</scriptType>\n" - + " <timeout>600</timeout>\n" - + " </commandScript>\n" - + " </component>\n" - + " </components>\n" - + " </application>\n" - + "</metainfo>"; - - @Test - public void testGetApplicationMetainfo() throws Exception { - String zipFileName = TestUtility.createAppPackage( - folder, - "testpkg", - "test.zip", - "target/test-classes/org/apache/slider/common/tools/test"); - Configuration configuration = new Configuration(); - FileSystem fs = FileSystem.getLocal(configuration); - log.info("fs working dir is {}", fs.getWorkingDirectory().toString()); - SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); - - // Without accompany metainfo file, read metainfo from the zip file - Metainfo metainfo = AgentUtils.getApplicationMetainfo( - sliderFileSystem, zipFileName, false); - Assert.assertNotNull(metainfo.getApplication()); - Assert.assertEquals("STORM", metainfo.getApplication().getName()); - - // With accompany metainfo file, read metainfo from the accompany file - String acompanyFileName = zipFileName + ".metainfo.xml"; - File f = new File(acompanyFileName); - try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { - writer.write(metainfo_str); - } - metainfo = AgentUtils.getApplicationMetainfo( - sliderFileSystem, zipFileName, false); - Assert.assertNotNull(metainfo.getApplication()); - Assert.assertEquals("MYTESTAPPLICATION", metainfo.getApplication().getName()); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java deleted file mode 100644 index dedf4f6..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java +++ /dev/null @@ -1,264 +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.providers.agent; - -import com.google.common.io.Files; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.slider.common.params.ActionCreateArgs; -import org.apache.slider.common.params.AddonArgsDelegate; -import org.apache.slider.common.tools.SliderFileSystem; -import org.apache.slider.core.conf.ConfTree; -import org.apache.slider.core.conf.ConfTreeOperations; -import org.apache.slider.core.exceptions.BadConfigException; -import org.apache.slider.core.persist.AppDefinitionPersister; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -/** - * - */ -public class TestAppDefinitionPersister { - protected static final Logger log = - LoggerFactory.getLogger(TestAppDefinitionPersister.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - /** - * @BeforeClass public static void initialize() { BasicConfigurator.resetConfiguration(); - * BasicConfigurator.configure(); }* - */ - - - @Test - public void testAppDefinitionPersister() throws Exception { - Configuration configuration = new Configuration(); - FileSystem fs = FileSystem.getLocal(configuration); - log.info("fs working dir is {}", fs.getWorkingDirectory().toString()); - SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); - - AppDefinitionPersister adp = new AppDefinitionPersister(sliderFileSystem); - String clustername = "c1"; - ActionCreateArgs buildInfo = new ActionCreateArgs(); - buildInfo.appMetaInfo = null; - buildInfo.appDef = null; - buildInfo.addonDelegate = new AddonArgsDelegate(); - - // nothing to do - adp.processSuppliedDefinitions(clustername, buildInfo, null); - adp.persistPackages(); - List<AppDefinitionPersister.AppDefinition> appDefinitions = adp.getAppDefinitions(); - Assert.assertTrue(appDefinitions.size() == 0); - - ConfTree ct = new ConfTree(); - ConfTreeOperations appConf = new ConfTreeOperations(ct); - final File tempDir = Files.createTempDir(); - final File metainfo = new File(tempDir, "metainfo.json"); - - // unreadable metainfo - buildInfo.appMetaInfo = metainfo; - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Path specified with " - + "--metainfo either cannot be read or is not a file")); - } - - try (PrintWriter writer = new PrintWriter(metainfo.getAbsolutePath(), "UTF-8")) { - writer.println("{"); - writer.println("}"); - } - buildInfo.appDef = metainfo; - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Both --metainfo and --appdef cannot be specified")); - } - - // both --metainfojson and --appdef cannot be specified - buildInfo.appMetaInfo = null; - buildInfo.appMetaInfoJson = "{}"; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Both --metainfojson and --appdef cannot be specified")); - } - - buildInfo.appDef = null; - - buildInfo.appMetaInfoJson = ""; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Empty string specified with --metainfojson")); - } - buildInfo.appMetaInfo = metainfo; - - // both --metainfo and --metainfojson cannot be specified - buildInfo.appMetaInfoJson = "{}"; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Both --metainfo and --metainfojson cannot be specified")); - } - buildInfo.appMetaInfoJson = null; - - appConf.getGlobalOptions().set(AgentKeys.APP_DEF, metainfo.getAbsolutePath()); - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "application.def cannot " - + "not be set if --metainfo is specified in the cmd line")); - } - - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - appDefinitions = adp.getAppDefinitions(); - Assert.assertTrue(appDefinitions.size() == 1); - Assert.assertTrue(appConf.getGlobalOptions().get(AgentKeys.APP_DEF).contains("appdef/appPkg.zip")); - log.info(appDefinitions.get(0).toString()); - Assert.assertTrue(appDefinitions.get(0).appDefPkgOrFolder.toString().endsWith("default")); - Assert.assertTrue(appDefinitions.get(0).targetFolderInFs.toString().contains("cluster/c1/appdef")); - Assert.assertEquals("appPkg.zip", appDefinitions.get(0).pkgName); - - buildInfo.appDef = tempDir; - buildInfo.appMetaInfo = null; - - appConf.getGlobalOptions().set(AgentKeys.APP_DEF, metainfo.getAbsolutePath()); - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains("application.def must not be set if --appdef is provided")); - } - - adp.getAppDefinitions().clear(); - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - appDefinitions = adp.getAppDefinitions(); - Assert.assertTrue(appDefinitions.size() == 1); - Assert.assertTrue(appConf.getGlobalOptions().get(AgentKeys.APP_DEF).contains("appdef/appPkg.zip")); - log.info(appDefinitions.get(0).toString()); - Assert.assertTrue(appDefinitions.get(0).appDefPkgOrFolder.toString().endsWith(tempDir.toString())); - Assert.assertTrue(appDefinitions.get(0).targetFolderInFs.toString().contains("cluster/c1/appdef")); - Assert.assertEquals("appPkg.zip", appDefinitions.get(0).pkgName); - - adp.getAppDefinitions().clear(); - buildInfo.appDef = null; - buildInfo.appMetaInfo = null; - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - - ArrayList<String> list = new ArrayList<String>() {{ - add("addon1"); - add(""); - add("addon2"); - add(metainfo.getAbsolutePath()); - }}; - - buildInfo.addonDelegate.addonTuples = list; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains("addon package can only be specified if main app package is specified")); - } - - buildInfo.appMetaInfo = metainfo; - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains("Invalid path for addon package addon1")); - } - - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - - list = new ArrayList<String>() {{ - add("addon1"); - add(tempDir.getAbsolutePath()); - add("addon2"); - add(metainfo.getAbsolutePath()); - }}; - - buildInfo.addonDelegate.addonTuples = list; - adp.getAppDefinitions().clear(); - - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - appDefinitions = adp.getAppDefinitions(); - - Assert.assertTrue(appDefinitions.size() == 3); - Assert.assertTrue(appConf.getGlobalOptions().get(AgentKeys.APP_DEF).contains("appdef/appPkg.zip")); - Assert.assertTrue(appConf.getGlobalOptions().get("application.addon.addon1").contains( - "addons/addon1/addon_addon1.zip")); - Assert.assertTrue(appConf.getGlobalOptions().get("application.addon.addon2").contains( - "addons/addon2/addon_addon2.zip")); - log.info(appConf.getGlobalOptions().get("application.addons")); - Assert.assertTrue(appConf.getGlobalOptions().get("application.addons").contains( - "application.addon.addon2,application.addon.addon1") - || appConf.getGlobalOptions().get("application.addons").contains( - "application.addon.addon1,application.addon.addon2")); - int seen = 0; - for (AppDefinitionPersister.AppDefinition adp_ad : appDefinitions) { - if (adp_ad.pkgName.equals("appPkg.zip")) { - log.info(adp_ad.toString()); - Assert.assertTrue(adp_ad.appDefPkgOrFolder.toString().endsWith("default")); - Assert.assertTrue(adp_ad.targetFolderInFs.toString().contains("cluster/c1/appdef")); - seen++; - } - if (adp_ad.pkgName.equals("addon_addon1.zip")) { - log.info(adp_ad.toString()); - Assert.assertTrue(adp_ad.appDefPkgOrFolder.toString().endsWith(tempDir.toString())); - Assert.assertTrue(adp_ad.targetFolderInFs.toString().contains("addons/addon1")); - seen++; - } - if (adp_ad.pkgName.equals("addon_addon2.zip")) { - log.info(adp_ad.toString()); - Assert.assertTrue(adp_ad.appDefPkgOrFolder.toString().endsWith("metainfo.json")); - Assert.assertTrue(adp_ad.targetFolderInFs.toString().contains("addons/addon2")); - seen++; - } - } - Assert.assertEquals(3, seen); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java deleted file mode 100644 index 7b38ee3..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java +++ /dev/null @@ -1,115 +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.providers.agent; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class TestComponentTagProvider { - protected static final Logger log = - LoggerFactory.getLogger(TestComponentTagProvider.class); - - @Test - public void testTagProvider() throws Exception { - ComponentTagProvider ctp = new ComponentTagProvider(); - Assert.assertEquals("", ctp.getTag(null, null)); - Assert.assertEquals("", ctp.getTag(null, "cid")); - Assert.assertEquals("", ctp.getTag("comp1", null)); - - Assert.assertEquals("1", ctp.getTag("comp1", "cid1")); - Assert.assertEquals("2", ctp.getTag("comp1", "cid2")); - Assert.assertEquals("3", ctp.getTag("comp1", "cid3")); - ctp.releaseTag("comp1", "cid2"); - Assert.assertEquals("2", ctp.getTag("comp1", "cid22")); - - ctp.releaseTag("comp1", "cid4"); - ctp.recordAssignedTag("comp1", "cid5", "5"); - Assert.assertEquals("4", ctp.getTag("comp1", "cid4")); - Assert.assertEquals("4", ctp.getTag("comp1", "cid4")); - Assert.assertEquals("6", ctp.getTag("comp1", "cid6")); - - ctp.recordAssignedTag("comp1", "cid55", "5"); - Assert.assertEquals("5", ctp.getTag("comp1", "cid55")); - - ctp.recordAssignedTag("comp2", "cidb3", "3"); - Assert.assertEquals("1", ctp.getTag("comp2", "cidb1")); - Assert.assertEquals("2", ctp.getTag("comp2", "cidb2")); - Assert.assertEquals("4", ctp.getTag("comp2", "cidb4")); - - ctp.recordAssignedTag("comp2", "cidb5", "six"); - ctp.recordAssignedTag("comp2", "cidb5", "-55"); - ctp.recordAssignedTag("comp2", "cidb5", "tags"); - ctp.recordAssignedTag("comp2", "cidb5", null); - ctp.recordAssignedTag("comp2", "cidb5", ""); - ctp.recordAssignedTag("comp2", "cidb5", "5"); - Assert.assertEquals("6", ctp.getTag("comp2", "cidb6")); - - ctp.recordAssignedTag("comp2", null, "5"); - ctp.recordAssignedTag(null, null, "5"); - ctp.releaseTag("comp1", null); - ctp.releaseTag(null, "cid4"); - ctp.releaseTag(null, null); - } - - @Test - public void testTagProviderWithThread() throws Exception { - ComponentTagProvider ctp = new ComponentTagProvider(); - Thread thread = new Thread(new Taggged(ctp)); - Thread thread2 = new Thread(new Taggged(ctp)); - Thread thread3 = new Thread(new Taggged(ctp)); - thread.start(); - thread2.start(); - thread3.start(); - ctp.getTag("comp1", "cid50"); - thread.join(); - thread2.join(); - thread3.join(); - Assert.assertEquals("101", ctp.getTag("comp1", "cid101")); - } - - public class Taggged implements Runnable { - private final ComponentTagProvider ctp; - - public Taggged(ComponentTagProvider ctp) { - this.ctp = ctp; - } - - public void run() { - for (int i = 0; i < 100; i++) { - String containerId = "cid" + (i + 1); - this.ctp.getTag("comp1", containerId); - } - for (int i = 0; i < 100; i++) { - String containerId = "cid" + (i + 1); - this.ctp.getTag("comp1", containerId); - } - for (int i = 0; i < 100; i += 2) { - String containerId = "cid" + (i + 1); - this.ctp.releaseTag("comp1", containerId); - } - for (int i = 0; i < 100; i += 2) { - String containerId = "cid" + (i + 1); - this.ctp.getTag("comp1", containerId); - } - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java deleted file mode 100644 index 6a2e5ab5..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java +++ /dev/null @@ -1,33 +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.providers.agent; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestState { - protected static final Logger log = LoggerFactory.getLogger(TestState.class); - - @Test - public void testState() throws Exception { - State state = State.STARTED; - Assert.assertEquals(Command.STOP, state.getSupportedCommand(false, true)); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestConfigParser.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestConfigParser.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestConfigParser.java deleted file mode 100644 index 3aa44a1..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestConfigParser.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.providers.agent.application.metadata; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * - */ -public class TestConfigParser { - protected static final Logger log = - LoggerFactory.getLogger(TestConfigParser.class); - private static final String config_1_str = "<configuration>\n" - + " <property>\n" - + " <name>security.client.protocol.acl</name>\n" - + " <value>*</value>\n" - + " <description>ACL for HRegionInterface protocol implementations (ie. \n" - + " clients talking to HRegionServers)\n" - + " The ACL is a comma-separated list of user and group names. The user and \n" - + " group list is separated by a blank. For e.g. \"alice,bob users,wheel\". \n" - + " A special value of \"*\" means all users are allowed.</description>\n" - + " </property>\n" - + "\n" - + " <property>\n" - + " <name>security.admin.protocol.acl</name>\n" - + " <value>*</value>\n" - + " <description>ACL for HMasterInterface protocol implementation (ie. \n" - + " clients talking to HMaster for admin operations).\n" - + " The ACL is a comma-separated list of user and group names. The user and \n" - + " group list is separated by a blank. For e.g. \"alice,bob users,wheel\". \n" - + " A special value of \"*\" means all users are allowed.</description>\n" - + " </property>\n" - + "\n" - + " <property>\n" - + " <name>security.masterregion.protocol.acl</name>\n" - + " <value>*</value>\n" - + " <description>ACL for HMasterRegionInterface protocol implementations\n" - + " (for HRegionServers communicating with HMaster)\n" - + " The ACL is a comma-separated list of user and group names. The user and \n" - + " group list is separated by a blank. For e.g. \"alice,bob users,wheel\". \n" - + " A special value of \"*\" means all users are allowed.</description>\n" - + " </property>\n" - + " <property>\n" - + " <name>emptyVal</name>\n" - + " <value></value>\n" - + " <description>non-empty-desc</description>\n" - + " </property>\n" - + " <property>\n" - + " <name>emptyDesc</name>\n" - + " <value></value>\n" - + " <description></description>\n" - + " </property>\n" - + " <property>\n" - + " <name>noDesc</name>\n" - + " <value></value>\n" - + " </property>\n" - + "</configuration>"; - - @Test - public void testParse() throws IOException { - - InputStream config_1 = new ByteArrayInputStream(config_1_str.getBytes()); - DefaultConfig config = new DefaultConfigParser().parse(config_1); - Assert.assertNotNull(config); - Assert.assertNotNull(config.getPropertyInfos()); - Assert.assertEquals(6, config.getPropertyInfos().size()); - for (PropertyInfo pInfo : config.getPropertyInfos()) { - if (pInfo.getName().equals("security.client.protocol.acl")) { - Assert.assertEquals("*", pInfo.getValue()); - Assert.assertTrue(pInfo.getDescription().startsWith("ACL for HRegionInterface ")); - } - if (pInfo.getName().equals("emptyVal")) { - Assert.assertEquals("", pInfo.getValue()); - Assert.assertEquals("non-empty-desc", pInfo.getDescription()); - } - if (pInfo.getName().equals("emptyDesc")) { - Assert.assertEquals("", pInfo.getValue()); - Assert.assertEquals("", pInfo.getDescription()); - } - if (pInfo.getName().equals("noDesc")) { - Assert.assertEquals("", pInfo.getValue()); - Assert.assertNull(pInfo.getDescription()); - } - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestMetainfoParser.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestMetainfoParser.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestMetainfoParser.java deleted file mode 100644 index ba1912a..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/TestMetainfoParser.java +++ /dev/null @@ -1,177 +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.providers.agent.application.metadata; - -import org.apache.slider.providers.agent.AgentProviderService; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mockito; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import static org.mockito.Mockito.doReturn; - -/** - * - */ -public class TestMetainfoParser { - protected static final Logger log = - LoggerFactory.getLogger(TestMetainfoParser.class); - public static final String METAINFO_XML = - "/org/apache/slider/providers/agent/application/metadata/metainfo.xml"; - - @Test - public void testParse() throws IOException { - - InputStream resStream = this.getClass().getResourceAsStream( - METAINFO_XML); - MetainfoParser parser = new MetainfoParser(); - Metainfo metainfo = parser.fromXmlStream(resStream); - Assert.assertNotNull(metainfo); - Assert.assertNotNull(metainfo.getApplication()); - Application application = metainfo.getApplication(); - assert "STORM".equals(application.getName()); - assert 6 == application.getComponents().size(); - OSPackage pkg = application.getOSSpecifics().get(0).getPackages().get(0); - assert "tarball".equals(pkg.getType()); - assert "files/apache-storm-0.9.1.2.1.1.0-237.tar.gz".equals(pkg.getName()); - boolean found = false; - for (Component comp : application.getComponents()) { - if (comp != null && comp.getName().equals("NIMBUS")) { - found = true; - Assert.assertEquals(0, comp.getComponentExports().size()); - } - if (comp != null && comp.getName().equals("SUPERVISOR")) { - Assert.assertEquals(1, comp.getComponentExports().size()); - } - if (comp != null && comp.getName().equals("ANOTHER_COMPONENT")) { - assert 2 == comp.getCommands().size(); - assert "start command".equals(comp.getCommands().get(0).getExec()); - assert "START".equals(comp.getCommands().get(0).getName()); - assert "stop command".equals(comp.getCommands().get(1).getExec()); - assert "STOP".equals(comp.getCommands().get(1).getName()); - } - } - assert found; - Assert.assertEquals(0, application.getConfigFiles().size()); - assert 1 == application.getPackages().size(); - Package p = application.getPackages().get(0); - assert "tarball".equals(p.getType()); - assert "test-tarball-name.tgz".equals(p.getName()); - } - - @Test - public void testJsonParse() throws IOException { - String metaInfo1_json = "{\n" - + "\"schemaVersion\":\"2.2\",\n" - + "\"application\":{\n" - + "\"name\": \"MEMCACHED\"," - + "\"exportGroups\": [" - + "{" - + "\"name\": \"Servers\"," - + "\"exports\": [" - + "{" - + "\"name\": \"host_port\"," - + "\"value\": \"${MEMCACHED_HOST}:${site.global.port}\"" - + "}" - + "]" - + "}" - + "]," - + "\"components\": [" - + "{" - + "\"name\": \"MEMCACHED\"," - + "\"compExports\": \"Servers-host_port\"," - + "\"commands\": [" - + "{" - + "\"exec\": \"java -classpath /usr/myapps/memcached/*:/usr/lib/hadoop/lib/* com.thimbleware.jmemcached.Main\"" - + "}" - + "]" - + "}," - + "{" - + "\"name\": \"MEMCACHED2\"," - + "\"commands\": [" - + "{" - + "\"exec\": \"scripts/config.py\"," - + "\"type\": \"PYTHON\"," - + "\"name\": \"CONFIGURE\"" - + "}" - + "]," - + "\"dockerContainers\": [" - + "{" - + "\"name\": \"redis\"," - + "\"image\": \"dockerhub/redis\"," - + "\"options\": \"-net=bridge\"," - + "\"mounts\": [" - + "{" - + "\"containerMount\": \"/tmp/conf\"," - + "\"hostMount\": \"{$conf:@//site/global/app_root}/conf\"" - + "}" - + "]" - + "}" - + "]" - + "}" - + "]" - + "}" - + "}"; - - MetainfoParser parser = new MetainfoParser(); - Metainfo mInfo = parser.fromJsonString(metaInfo1_json); - Assert.assertEquals("2.2", mInfo.getSchemaVersion()); - - Application app = mInfo.getApplication(); - Assert.assertNotNull(app); - - Assert.assertEquals("MEMCACHED", app.getName()); - List<ExportGroup> egs = app.getExportGroups(); - Assert.assertEquals(1, egs.size()); - ExportGroup eg = egs.get(0); - Assert.assertEquals("Servers", eg.getName()); - List<Export> exports = eg.getExports(); - Assert.assertEquals(1, exports.size()); - Export export = exports.get(0); - Assert.assertEquals("host_port", export.getName()); - Assert.assertEquals("${MEMCACHED_HOST}:${site.global.port}", export.getValue()); - - List<Component> components = app.getComponents(); - Assert.assertEquals(2, components.size()); - - Component c1 = mInfo.getApplicationComponent("MEMCACHED"); - Assert.assertNotNull(c1); - Assert.assertEquals("MEMCACHED", c1.getName()); - Assert.assertEquals("Servers-host_port", c1.getCompExports()); - Assert.assertEquals(1, c1.getCommands().size()); - ComponentCommand cmd = c1.getCommands().get(0); - Assert.assertEquals("START", cmd.getName()); - Assert.assertEquals("SHELL", cmd.getType()); - Assert.assertEquals("java -classpath /usr/myapps/memcached/*:/usr/lib/hadoop/lib/* com.thimbleware.jmemcached.Main", - cmd.getExec()); - - Component c2 = mInfo.getApplicationComponent("MEMCACHED2"); - Assert.assertNotNull(c2); - Assert.assertEquals("MEMCACHED2", c2.getName()); - Assert.assertEquals(1, c2.getCommands().size()); - cmd = c2.getCommands().get(0); - Assert.assertEquals("CONFIGURE", cmd.getName()); - Assert.assertEquals("PYTHON", cmd.getType()); - Assert.assertEquals("scripts/config.py", cmd.getExec()); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java deleted file mode 100644 index 7fceac7..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.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.server.appmaster.web.rest.publisher; - -import org.apache.hadoop.yarn.api.records.Container; -import org.apache.slider.common.tools.SliderFileSystem; -import org.apache.slider.providers.agent.AgentProviderService; -import org.apache.slider.server.appmaster.actions.QueueAccess; -import org.apache.slider.server.appmaster.state.StateAccessForProviders; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * - */ -public class TestAgentProviderService extends AgentProviderService { - protected static final Logger log = - LoggerFactory.getLogger(TestAgentProviderService.class); - - public TestAgentProviderService() { - super(); - log.info("TestAgentProviderService created"); - } - - @Override - public void bind(StateAccessForProviders stateAccessor, - QueueAccess queueAccess, - List<Container> liveContainers) { - super.bind(stateAccessor, queueAccess, liveContainers); - Map<String,String> dummyProps = new HashMap<String, String>(); - dummyProps.put("prop1", "val1"); - dummyProps.put("prop2", "val2"); - log.info("publishing dummy-site.xml with values {}", dummyProps); - publishApplicationInstanceData("dummy-site", "dummy configuration", - dummyProps.entrySet()); - // publishing global config for testing purposes - publishApplicationInstanceData("global", "global configuration", - stateAccessor.getAppConfSnapshot() - .getGlobalOptions().entrySet()); - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9fdab600/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestSliderProviderFactory.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestSliderProviderFactory.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestSliderProviderFactory.java deleted file mode 100644 index f49e15a..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestSliderProviderFactory.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.server.appmaster.web.rest.publisher; - -import org.apache.slider.providers.ProviderService; -import org.apache.slider.providers.agent.AgentProviderFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - */ -public class TestSliderProviderFactory extends AgentProviderFactory{ - protected static final Logger log = - LoggerFactory.getLogger(TestSliderProviderFactory.class); - - public TestSliderProviderFactory() { - log.info("Created TestSliderProviderFactory"); - } - - @Override - public ProviderService createServerProvider() { - log.info("Creating TestAgentProviderService"); - return new TestAgentProviderService(); - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org