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 2017/09/13 23:33:06 UTC
[19/82] [abbrv] hadoop git commit: YARN-7050. Post cleanup after
YARN-6903, removal of org.apache.slider package. Contributed by Jian He
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsBindingService.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/management/MetricsBindingService.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/management/MetricsBindingService.java
deleted file mode 100644
index 864a1cf..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/management/MetricsBindingService.java
+++ /dev/null
@@ -1,151 +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.management;
-
-import com.codahale.metrics.JmxReporter;
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.MetricSet;
-import com.codahale.metrics.ScheduledReporter;
-import com.codahale.metrics.Slf4jReporter;
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.service.CompositeService;
-import org.apache.slider.server.services.workflow.ClosingService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * YARN service which hooks up Codahale metrics to
- * JMX, and, if enabled Ganglia and/or an SLF4J log.
- */
-public class MetricsBindingService extends CompositeService
- implements MetricsKeys {
- protected static final Logger log =
- LoggerFactory.getLogger(MetricsBindingService.class);
- private final MetricRegistry metrics;
-
- private String reportingDetails = "not started";
-
-
- public MetricsBindingService(String name,
- MetricRegistry metrics) {
- super(name);
- Preconditions.checkArgument(metrics != null, "Null metrics");
- this.metrics = metrics;
- }
-
- /**
- * Instantiate...create a metric registry in the process
- * @param name service name
- */
- public MetricsBindingService(String name) {
- this(name, new MetricRegistry());
- }
-
- /**
- * Accessor for the metrics instance
- * @return the metrics
- */
- public MetricRegistry getMetrics() {
- return metrics;
- }
-
- @Override
- protected void serviceStart() throws Exception {
- super.serviceStart();
-
- StringBuilder summary = new StringBuilder();
- Configuration conf = getConfig();
-
- summary.append("Reporting to JMX");
- // always start the JMX binding
- JmxReporter jmxReporter;
- jmxReporter = JmxReporter.forRegistry(metrics).build();
- jmxReporter.start();
- addService(new ClosingService<>(jmxReporter));
-
-
- // Ganglia
- if (conf.getBoolean(METRICS_GANGLIA_ENABLED, false)) {
- log.warn("Ganglia integration is not implemented");
-/*
- // This is all disabled due to transitive dependencies on an LGPL library
- com.codahale.metrics.ganglia.GangliaReporter gangliaReporter;
- String host = conf.getTrimmed(METRICS_GANGLIA_HOST, "");
- int port = conf.getInt(METRICS_GANGLIA_PORT, DEFAULT_GANGLIA_PORT);
- int interval = conf.getInt(METRICS_GANGLIA_REPORT_INTERVAL, 60);
- int ttl = 1;
- info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode
- mcast = info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode.getModeForAddress(host);
- boolean ganglia31 = conf.getBoolean(METRICS_GANGLIA_VERSION_31, true);
-
- final info.ganglia.gmetric4j.gmetric.GMetric ganglia =
- new info.ganglia.gmetric4j.gmetric.GMetric(
- host,
- port,
- mcast,
- ttl,
- ganglia31);
- gangliaReporter = com.codahale.metrics.ganglia.GangliaReporter.forRegistry(metrics)
- .convertRatesTo(TimeUnit.SECONDS)
- .convertDurationsTo(
- TimeUnit.MILLISECONDS)
- .build(ganglia);
- gangliaReporter.start(interval, TimeUnit.SECONDS);
- addService(new ClosingService<ScheduledReporter>(gangliaReporter));
- summary.append(String.format(", Ganglia at %s:%d interval=%d",
- host, port, interval));
- */
- }
-
- // Logging
- if (conf.getBoolean(METRICS_LOGGING_ENABLED, false)) {
- ScheduledReporter reporter;
- String logName =
- conf.getTrimmed(METRICS_LOGGING_LOG, METRICS_DEFAULT_LOG);
- int interval = conf.getInt(METRICS_LOGGING_LOG_INTERVAL,
- METRICS_DEFAULT_LOG_INTERVAL);
- reporter = Slf4jReporter.forRegistry(metrics)
- .convertRatesTo(TimeUnit.SECONDS)
- .outputTo(LoggerFactory.getLogger(logName))
- .convertDurationsTo(TimeUnit.MILLISECONDS)
- .build();
- reporter.start(interval, TimeUnit.MINUTES);
- addService(new ClosingService<>(reporter));
- summary.append(String.format(", SLF4J to log %s interval=%d",
- logName, interval));
- }
- reportingDetails = summary.toString();
- log.info(reportingDetails);
- }
-
-
- @Override
- public String toString() {
- return super.toString() + " " + reportingDetails;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsConstants.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/management/MetricsConstants.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/management/MetricsConstants.java
deleted file mode 100644
index fa6bfc0..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/management/MetricsConstants.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.management;
-
-/**
- * Constants used in slider for metrics registration and lookup
- */
-public class MetricsConstants {
-
- /**
- * {@value}
- */
- public static final String CONTAINERS_OUTSTANDING_REQUESTS = "containers.outstanding-requests";
-
- /**
- * {@value}
- */
- public static final String CONTAINERS_STARTED = "containers.started";
-
- /**
- * {@value}
- */
- public static final String CONTAINERS_SURPLUS = "containers.surplus";
-
- /**
- * {@value}
- */
- public static final String CONTAINERS_COMPLETED = "containers.completed";
-
- /**
- * {@value}
- */
- public static final String CONTAINERS_FAILED = "containers.failed";
-
- /**
- * {@value}
- */
- public static final String CONTAINERS_START_FAILED = "containers.start-failed";
-
- public static final String PREFIX_SLIDER_ROLES = "slider.roles.";
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsKeys.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/management/MetricsKeys.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/management/MetricsKeys.java
deleted file mode 100644
index 13b3b6b..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/management/MetricsKeys.java
+++ /dev/null
@@ -1,92 +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.management;
-
-public interface MetricsKeys {
-
- /**
- * Prefix for metrics configuration options: {@value}
- */
- String METRICS_PREFIX = "slider.metrics.";
-
- /**
- * Boolean to enable Ganglia metrics reporting
- * {@value}
- */
- String METRICS_GANGLIA_ENABLED =
- METRICS_PREFIX + "ganglia.enabled";
- /**
- * {@value}
- */
- String METRICS_GANGLIA_HOST = METRICS_PREFIX + "ganglia.host";
- /**
- * {@value}
- */
- String METRICS_GANGLIA_PORT = METRICS_PREFIX + "ganglia.port";
- /**
- * {@value}
- */
- String METRICS_GANGLIA_VERSION_31 = METRICS_PREFIX + "ganglia.version-31";
- /**
- * {@value}
- */
- String METRICS_GANGLIA_REPORT_INTERVAL = METRICS_PREFIX + "ganglia.report.interval";
- /**
- * {@value}
- */
- int DEFAULT_GANGLIA_PORT = 8649;
-
-
- /**
- * Boolean to enable Logging metrics reporting
- * {@value}
- */
- String METRICS_LOGGING_ENABLED =
- METRICS_PREFIX + "logging.enabled";
-
- /**
- * String name of log to log to
- * {@value}
- */
- String METRICS_LOGGING_LOG =
- METRICS_PREFIX + "logging.log.name";
-
- /**
- * Default log name: {@value}
- */
- String METRICS_DEFAULT_LOG =
- "org.apache.slider.metrics.log";
-
-
- /**
- * Int log interval in seconds
- * {@value}
- */
- String METRICS_LOGGING_LOG_INTERVAL =
- METRICS_PREFIX + "logging.interval.minutes";
-
-
- /**
- * Default log interval: {@value}.
- * This is a big interval as in a long lived service, log overflows are easy
- * to create.
- */
- int METRICS_DEFAULT_LOG_INTERVAL = 60;
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/management/PrefixedMetricsSet.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/management/PrefixedMetricsSet.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/management/PrefixedMetricsSet.java
deleted file mode 100644
index e9ad46a..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/management/PrefixedMetricsSet.java
+++ /dev/null
@@ -1,53 +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.management;
-
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.MetricSet;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * From an existing metrics set, generate a new metrics set with the
- * prefix in front of every key.
- *
- * The prefix is added directly: if you want a '.' between prefix and metric
- * keys, include it in the prefix.
- */
-public class PrefixedMetricsSet implements MetricSet {
-
- private final String prefix;
- private final MetricSet source;
-
- public PrefixedMetricsSet(String prefix, MetricSet source) {
- this.prefix = prefix;
- this.source = source;
- }
-
- @Override
- public Map<String, Metric> getMetrics() {
- Map<String, Metric> sourceMetrics = source.getMetrics();
- Map<String, Metric> metrics = new HashMap<>(sourceMetrics.size());
- for (Map.Entry<String, Metric> entry : sourceMetrics.entrySet()) {
- metrics.put(prefix + "." + entry.getKey(), entry.getValue());
- }
- return metrics;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/management/Timestamp.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/management/Timestamp.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/management/Timestamp.java
deleted file mode 100644
index c30e749..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/management/Timestamp.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.server.appmaster.management;
-
-/**
- * A timestamp metric
- */
-public class Timestamp extends LongGauge {
-
- public Timestamp(long val) {
- super(val);
- }
-
- public Timestamp() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/management/YarnServiceHealthCheck.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/management/YarnServiceHealthCheck.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/management/YarnServiceHealthCheck.java
deleted file mode 100644
index 936563c..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/management/YarnServiceHealthCheck.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.management;
-
-import com.codahale.metrics.health.HealthCheck;
-import org.apache.hadoop.service.Service;
-
-public class YarnServiceHealthCheck extends HealthCheck {
-
- private final Service service;
-
- public YarnServiceHealthCheck(Service service) {
- this.service = service;
- }
-
- @Override
- protected Result check() throws Exception {
- return service.isInState(Service.STATE.STARTED)
- ? Result.healthy()
- : Result.unhealthy("Service is not running: %s", service);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosEntry.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/monkey/ChaosEntry.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/monkey/ChaosEntry.java
deleted file mode 100644
index a397e19..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/monkey/ChaosEntry.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.monkey;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.MetricRegistry;
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang.StringUtils;
-import org.apache.slider.api.InternalKeys;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Entry in the chaos list
- */
-public class ChaosEntry {
-
- protected static final Logger log =
- LoggerFactory.getLogger(ChaosEntry.class);
- public final String name;
- public final ChaosTarget target;
- public final long probability;
-
- private final Counter invocationCounter;
-
-
- /**
- * Constructor -includes validation of all arguments
- * @param name entry name
- * @param target target
- * @param probability probability of occurring
- */
- public ChaosEntry(String name, ChaosTarget target, long probability,
- MetricRegistry metrics) {
- Preconditions.checkArgument(!StringUtils.isEmpty(name), "missing name");
- Preconditions.checkArgument(target != null, "null target");
- Preconditions.checkArgument(probability > 0, "negative probability");
- Preconditions.checkArgument(probability <= InternalKeys.PROBABILITY_PERCENT_100,
- "probability over 100%: "+ probability);
- this.name = name;
- this.target = target;
- this.probability = probability;
- invocationCounter =
- metrics.counter(MetricRegistry.name(ChaosEntry.class, name));
- }
-
- /**
- * Trigger the chaos action
- */
- public void invokeChaos() {
- log.info("Invoking {}", name);
- invocationCounter.inc();
- target.chaosAction();
- }
-
- /**
- * Invoke Chaos if the trigger value is in range of the probability
- * @param value trigger value, 0-10K
- * @return true if the chaos method was invoked
- */
- public boolean maybeInvokeChaos(long value) {
- log.debug("Probability {} trigger={}", probability, value);
- if (value < probability) {
- invokeChaos();
- return true;
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosKillAM.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/monkey/ChaosKillAM.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/monkey/ChaosKillAM.java
deleted file mode 100644
index 3c1a914..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/monkey/ChaosKillAM.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.monkey;
-
-import org.apache.slider.server.appmaster.actions.ActionHalt;
-import org.apache.slider.server.appmaster.actions.QueueAccess;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Kill the AM
- */
-public class ChaosKillAM implements ChaosTarget {
-
- public static final int DELAY = 1000;
- private final QueueAccess queues;
- private final int exitCode;
-
- public ChaosKillAM(QueueAccess queues, int exitCode) {
- this.queues = queues;
- this.exitCode = exitCode;
- }
-
- /**
- * Trigger a delayed halt
- */
- @Override
- public void chaosAction() {
- queues.schedule(new ActionHalt(exitCode, "Chaos invoked halt", DELAY,
- TimeUnit.MILLISECONDS));
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosKillContainer.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/monkey/ChaosKillContainer.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/monkey/ChaosKillContainer.java
deleted file mode 100644
index 022312c..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/monkey/ChaosKillContainer.java
+++ /dev/null
@@ -1,84 +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.monkey;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.yarn.service.conf.SliderKeys;
-import org.apache.slider.server.appmaster.actions.ActionKillContainer;
-import org.apache.slider.server.appmaster.actions.QueueAccess;
-import org.apache.slider.server.appmaster.operations.RMOperationHandler;
-import org.apache.slider.server.appmaster.state.AppState;
-import org.apache.slider.server.appmaster.state.RoleInstance;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Kill a container
- */
-public class ChaosKillContainer implements ChaosTarget {
- protected static final Logger log =
- LoggerFactory.getLogger(ChaosKillContainer.class);
- public static final int DELAY = 100;
- private final AppState appState;
- private final QueueAccess queues;
- private final Random random = new Random();
- private final RMOperationHandler operationHandler;
-
- public ChaosKillContainer(AppState appState,
- QueueAccess queues,
- RMOperationHandler operationHandler) {
- Preconditions.checkNotNull(appState);
- Preconditions.checkNotNull(queues);
- this.appState = appState;
- this.queues = queues;
- this.operationHandler = operationHandler;
- }
-
- /**
- * Trigger a container kill
- */
- @Override
- public void chaosAction() {
- List<RoleInstance> liveContainers =
- appState.cloneLiveContainerInfoList();
- // purge any and all components which declare that they are an AM
- ListIterator<RoleInstance> containers =
- liveContainers.listIterator();
- while (containers.hasNext()) {
- RoleInstance instance = containers.next();
- if (SliderKeys.COMPONENT_AM.equals(instance.role)) {
- containers.remove();
- }
- }
- int size = liveContainers.size();
- if (size > 0) {
- int target = random.nextInt(size);
- RoleInstance roleInstance = liveContainers.get(target);
- log.info("Killing {}", roleInstance);
-
- queues.schedule(new ActionKillContainer(roleInstance.getContainerId(),
- DELAY, TimeUnit.MILLISECONDS, operationHandler));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosMonkeyService.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/monkey/ChaosMonkeyService.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/monkey/ChaosMonkeyService.java
deleted file mode 100644
index 8948f0d..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/monkey/ChaosMonkeyService.java
+++ /dev/null
@@ -1,138 +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.monkey;
-
-import com.codahale.metrics.MetricRegistry;
-import org.apache.hadoop.service.AbstractService;
-import org.apache.slider.api.InternalKeys;
-import org.apache.slider.server.appmaster.actions.QueueAccess;
-import org.apache.slider.server.appmaster.actions.RenewingAction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A chaos monkey service which will invoke ChaosTarget events
- */
-public class ChaosMonkeyService extends AbstractService {
- protected static final Logger log =
- LoggerFactory.getLogger(ChaosMonkeyService.class);
-
- private final MetricRegistry metrics;
- private final QueueAccess queues;
- private final Random random = new Random();
-
- private final List<ChaosEntry> chaosEntries =
- new ArrayList<ChaosEntry>();
-
- public ChaosMonkeyService(MetricRegistry metrics, QueueAccess queues) {
- super("ChaosMonkeyService");
- this.metrics = metrics;
- this.queues = queues;
- }
-
- /**
- * Add a target ... it is only added if <code>probability > 0</code>
- * @param name name
- * @param target chaos target
- * @param probability probability
- */
- public synchronized void addTarget(String name,
- ChaosTarget target, long probability) {
- if (probability > 0) {
- log.info("Adding {} with probability {}", name,
- ((double)probability) / InternalKeys.PROBABILITY_PERCENT_1);
- chaosEntries.add(new ChaosEntry(name, target, probability, metrics));
- } else {
- log.debug("Action {} not enabled", name);
- }
- }
-
- /**
- * Get the number of targets in the list
- * @return the count of added targets
- */
- public int getTargetCount() {
- return chaosEntries.size();
- }
-
- /**
- * Iterate through all the entries and invoke chaos on those wanted
- */
- public void play() {
- for (ChaosEntry chaosEntry : chaosEntries) {
- long p = randomPercentage();
- chaosEntry.maybeInvokeChaos(p);
- }
- }
-
- public int randomPercentage() {
- return random.nextInt(InternalKeys.PROBABILITY_PERCENT_100);
- }
-
- /**
- * Check for callers to see if chaos should be triggered; shares the
- * same random number source as the rest of the monkey entries
- * @param probability probability
- * @return true if the action should happen
- */
- public boolean chaosCheck(long probability) {
- return randomPercentage() < probability;
- }
-
- /**
- * Schedule the monkey
- *
- * @param delay initial delay
- * @param timeUnit time unit
- * @return true if it was scheduled (i.e. 1+ action) and interval > 0
- */
- public boolean schedule(long delay, long interval, TimeUnit timeUnit) {
- if (interval > 0 && !chaosEntries.isEmpty()) {
- queues.schedule(getChaosAction(delay, interval, timeUnit));
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the chaos action
- *
- * @param delay
- * @param timeUnit time unit
- * @return the action to schedule
- */
- public RenewingAction<MonkeyPlayAction> getChaosAction(long delay,
- long interval,
- TimeUnit timeUnit) {
- RenewingAction<MonkeyPlayAction> action = new RenewingAction<MonkeyPlayAction>(
- new MonkeyPlayAction(this, 0, TimeUnit.MILLISECONDS),
- delay,
- interval,
- timeUnit,
- 0
- );
- return action;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosTarget.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/monkey/ChaosTarget.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/monkey/ChaosTarget.java
deleted file mode 100644
index 1c3a9ac..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/monkey/ChaosTarget.java
+++ /dev/null
@@ -1,24 +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.monkey;
-
-public interface ChaosTarget {
-
- public void chaosAction();
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/MonkeyPlayAction.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/monkey/MonkeyPlayAction.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/monkey/MonkeyPlayAction.java
deleted file mode 100644
index 20e4466..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/monkey/MonkeyPlayAction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.monkey;
-
-import org.apache.slider.server.appmaster.SliderAppMaster;
-import org.apache.slider.server.appmaster.actions.AsyncAction;
-import org.apache.slider.server.appmaster.actions.QueueAccess;
-import org.apache.slider.server.appmaster.state.AppState;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Queueable action which calls {@link ChaosMonkeyService#play()} when
- * executed.
- */
-public class MonkeyPlayAction extends AsyncAction {
-
- private final ChaosMonkeyService monkey;
-
- public MonkeyPlayAction(ChaosMonkeyService monkey, long delay,
- TimeUnit timeUnit) {
- super("chaos monkey", delay, timeUnit);
- this.monkey = monkey;
- }
-
- @Override
- public void execute(SliderAppMaster appMaster,
- QueueAccess queueService,
- AppState appState) throws Exception {
- monkey.play();
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/AbstractRMOperation.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/operations/AbstractRMOperation.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/operations/AbstractRMOperation.java
deleted file mode 100644
index ed3f197..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/operations/AbstractRMOperation.java
+++ /dev/null
@@ -1,30 +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.operations;
-
-public abstract class AbstractRMOperation {
-
- /**
- * Execute the operation
- * @param asyncRMClient client
- * @param handler handler to perform the execution
- */
- public abstract void execute(RMOperationHandlerActions handler);
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/AsyncRMOperationHandler.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/operations/AsyncRMOperationHandler.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/operations/AsyncRMOperationHandler.java
deleted file mode 100644
index 7173354..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/operations/AsyncRMOperationHandler.java
+++ /dev/null
@@ -1,116 +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.operations;
-
-import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.hadoop.yarn.api.records.Priority;
-import org.apache.hadoop.yarn.api.records.Resource;
-import org.apache.hadoop.yarn.client.api.AMRMClient;
-import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Hands off RM operations to the Resource Manager.
- */
-public class AsyncRMOperationHandler extends RMOperationHandler {
- protected static final Logger log =
- LoggerFactory.getLogger(AsyncRMOperationHandler.class);
- private final AMRMClientAsync client;
- private final Resource maxResources;
-
- public AsyncRMOperationHandler(AMRMClientAsync client, Resource maxResources) {
- this.client = client;
- this.maxResources = maxResources;
- }
-
- @Override
- public int cancelContainerRequests(Priority priority1,
- Priority priority2,
- int count) {
- // need to revoke a previously issued container request
- // so enum the sets and pick some
- int remaining = cancelSinglePriorityRequests(priority1, count);
- if (priority2 != null) {
- remaining = cancelSinglePriorityRequests(priority2, remaining);
- }
-
- return remaining;
- }
-
- /**
- * Cancel just one of the priority levels
- * @param priority priority to cancel
- * @param count count to cancel
- * @return number of requests cancelled
- */
- @SuppressWarnings("unchecked")
- protected int cancelSinglePriorityRequests(Priority priority,
- int count) {
- List<Collection<AMRMClient.ContainerRequest>> requestSets =
- client.getMatchingRequests(priority, "", maxResources);
- if (count <= 0) {
- return 0;
- }
- int remaining = count;
- for (Collection<AMRMClient.ContainerRequest> requestSet : requestSets) {
- if (remaining == 0) {
- break;
- }
- for (AMRMClient.ContainerRequest request : requestSet) {
- if (remaining == 0) {
- break;
- }
- // a single release
- cancelSingleRequest(request);
- remaining --;
- }
- }
- return remaining;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void cancelSingleRequest(AMRMClient.ContainerRequest request) {
- // a single release
- client.removeContainerRequest(request);
- }
-
- @Override
- public void releaseAssignedContainer(ContainerId containerId) {
- log.debug("Releasing container {}", containerId);
-
- client.releaseAssignedContainer(containerId);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void addContainerRequest(AMRMClient.ContainerRequest req) {
- client.addContainerRequest(req);
- }
-
- @Override
- public void updateBlacklist(List<String> blacklistAdditions,
- List<String> blacklistRemovals) {
- client.updateBlacklist(blacklistAdditions, blacklistRemovals);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/CancelSingleRequest.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/operations/CancelSingleRequest.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/operations/CancelSingleRequest.java
deleted file mode 100644
index d7673d3..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/operations/CancelSingleRequest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.operations;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.yarn.client.api.AMRMClient;
-import org.apache.slider.server.appmaster.state.ContainerPriority;
-
-/**
- * Cancel a container request
- */
-public class CancelSingleRequest extends AbstractRMOperation {
-
- private final AMRMClient.ContainerRequest request;
-
- public CancelSingleRequest(AMRMClient.ContainerRequest request) {
- Preconditions.checkArgument(request != null, "Null container request");
- this.request = request;
- }
-
- @Override
- public void execute(RMOperationHandlerActions handler) {
- handler.cancelSingleRequest(request);
- }
-
- public AMRMClient.ContainerRequest getRequest() {
- return request;
- }
-
- @Override
- public String toString() {
- return "Cancel container request"
- + " for :" + ContainerPriority.toString(request.getPriority())
- + " request " + request;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/ContainerReleaseOperation.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/operations/ContainerReleaseOperation.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/operations/ContainerReleaseOperation.java
deleted file mode 100644
index 4271d50..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/operations/ContainerReleaseOperation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.operations;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.slider.server.appmaster.state.ContainerPriority;
-
-public class ContainerReleaseOperation extends AbstractRMOperation {
-
- private final ContainerId containerId;
-
- public ContainerReleaseOperation(ContainerId containerId) {
- Preconditions.checkArgument(containerId != null, "Null containerId");
- this.containerId = containerId;
- }
-
- public ContainerId getContainerId() {
- return containerId;
- }
-
- @Override
- public void execute(RMOperationHandlerActions handler) {
- handler.releaseAssignedContainer(containerId);
- }
-
- @Override
- public String toString() {
- return "release container " + containerId;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/ContainerRequestOperation.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/operations/ContainerRequestOperation.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/operations/ContainerRequestOperation.java
deleted file mode 100644
index e29ddd0..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/operations/ContainerRequestOperation.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.operations;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.yarn.api.records.Priority;
-import org.apache.hadoop.yarn.client.api.AMRMClient;
-import org.apache.slider.server.appmaster.state.ContainerPriority;
-
-/**
- * A container request operation
- */
-public class ContainerRequestOperation extends AbstractRMOperation {
-
- private final AMRMClient.ContainerRequest request;
-
- public ContainerRequestOperation(AMRMClient.ContainerRequest request) {
- Preconditions.checkArgument(request != null, "Null container request");
- this.request = request;
- }
-
- public AMRMClient.ContainerRequest getRequest() {
- return request;
- }
-
- public Priority getPriority() {
- return request.getPriority();
- }
-
- public boolean getRelaxLocality() {
- return request.getRelaxLocality();
- }
-
- @Override
- public void execute(RMOperationHandlerActions handler) {
- handler.addContainerRequest(request);
- }
-
- @Override
- public String toString() {
- return "request container for role "
- + ContainerPriority.toString(getPriority())
- + " request " + request
- + " relaxLocality=" + getRelaxLocality();
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/RMOperationHandler.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/operations/RMOperationHandler.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/operations/RMOperationHandler.java
deleted file mode 100644
index d0d038a..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/operations/RMOperationHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.appmaster.operations;
-
-import java.util.List;
-
-public abstract class RMOperationHandler implements RMOperationHandlerActions {
-
- @Override
- public void execute(List<AbstractRMOperation> operations) {
- for (AbstractRMOperation operation : operations) {
- operation.execute(this);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/RMOperationHandlerActions.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/operations/RMOperationHandlerActions.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/operations/RMOperationHandlerActions.java
deleted file mode 100644
index bbaa933..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/operations/RMOperationHandlerActions.java
+++ /dev/null
@@ -1,68 +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.operations;
-
-import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.hadoop.yarn.api.records.Priority;
-import org.apache.hadoop.yarn.client.api.AMRMClient;
-
-import java.util.List;
-
-public interface RMOperationHandlerActions {
-
- /**
- * Release an assigned container.
- * @param containerId container
- */
- void releaseAssignedContainer(ContainerId containerId);
-
- /**
- * Issue a container request.
- * @param request
- */
- void addContainerRequest(AMRMClient.ContainerRequest request);
-
- /**
- * Cancel a specific request.
- * @param request request to cancel
- */
- void cancelSingleRequest(AMRMClient.ContainerRequest request);
-
- /**
- * Remove a container request.
- * @param priority1 priority to remove at
- * @param priority2 second priority to target
- * @param count number to remove
- */
- int cancelContainerRequests(Priority priority1, Priority priority2, int count);
-
- /**
- * Blacklist resources.
- * @param blacklistAdditions resources to add to the blacklist
- * @param blacklistRemovals resources to remove from the blacklist
- */
- void updateBlacklist(List<String> blacklistAdditions,
- List<String> blacklistRemovals);
-
- /**
- * Execute an entire list of operations.
- * @param operations ops
- */
- void execute(List<AbstractRMOperation> operations);
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/operations/UpdateBlacklistOperation.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/operations/UpdateBlacklistOperation.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/operations/UpdateBlacklistOperation.java
deleted file mode 100644
index 90e2e5d..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/operations/UpdateBlacklistOperation.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.server.appmaster.operations;
-
-import java.util.List;
-
-/**
- * Update blacklisted resources for the application.
- */
-public class UpdateBlacklistOperation extends AbstractRMOperation {
- private final List<String> blacklistAdditions;
- private final List<String> blacklistRemovals;
-
- public UpdateBlacklistOperation(List<String> blacklistAdditions,
- List<String> blacklistRemovals) {
- this.blacklistAdditions = blacklistAdditions;
- this.blacklistRemovals = blacklistRemovals;
- }
-
- @Override
- public void execute(RMOperationHandlerActions handler) {
- handler.updateBlacklist(blacklistAdditions, blacklistRemovals);
- }
-
- @Override
- public String toString() {
- return "blacklist additions: " + blacklistAdditions
- + ", blacklist removals: " + blacklistRemovals;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/RpcBinder.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/rpc/RpcBinder.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/rpc/RpcBinder.java
deleted file mode 100644
index 2df9472..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/rpc/RpcBinder.java
+++ /dev/null
@@ -1,307 +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.rpc;
-
-import com.google.common.base.Preconditions;
-import com.google.protobuf.BlockingService;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.retry.RetryPolicies;
-import org.apache.hadoop.io.retry.RetryPolicy;
-import org.apache.hadoop.ipc.ProtobufRpcEngine;
-import org.apache.hadoop.ipc.ProtocolProxy;
-import org.apache.hadoop.ipc.RPC;
-import org.apache.hadoop.ipc.RpcEngine;
-import org.apache.hadoop.ipc.Server;
-import org.apache.hadoop.net.NetUtils;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.token.SecretManager;
-import org.apache.hadoop.security.token.Token;
-import org.apache.hadoop.security.token.TokenIdentifier;
-import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
-import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
-import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationReport;
-import org.apache.hadoop.yarn.api.records.YarnApplicationState;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier;
-import org.apache.hadoop.yarn.util.ConverterUtils;
-import org.apache.slider.api.SliderClusterProtocol;
-import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
-import org.apache.slider.common.tools.Duration;
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.exceptions.BadClusterStateException;
-import org.apache.slider.core.exceptions.ErrorStrings;
-import org.apache.slider.core.exceptions.SliderException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.security.PrivilegedExceptionAction;
-
-public class RpcBinder {
- protected static final Logger log =
- LoggerFactory.getLogger(RpcBinder.class);
-
- /**
- * Create a protobuf server bonded to the specific socket address
- * @param addr address to listen to; 0.0.0.0 as hostname acceptable
- * @param conf config
- * @param secretManager token secret handler
- * @param numHandlers threads to service requests
- * @param blockingService service to handle
- * @param portRangeConfig range of ports
- * @return the IPC server itself
- * @throws IOException
- */
- public static Server createProtobufServer(InetSocketAddress addr,
- Configuration conf,
- SecretManager<? extends TokenIdentifier> secretManager,
- int numHandlers,
- BlockingService blockingService,
- String portRangeConfig) throws
- IOException {
- Class<SliderClusterProtocolPB> sliderClusterAPIClass = registerSliderAPI(
- conf);
- RPC.Server server = new RPC.Builder(conf).setProtocol(sliderClusterAPIClass)
- .setInstance(blockingService)
- .setBindAddress(addr.getAddress()
- .getCanonicalHostName())
- .setPort(addr.getPort())
- .setNumHandlers(numHandlers)
- .setVerbose(false)
- .setSecretManager(secretManager)
- .setPortRangeConfig(
- portRangeConfig)
- .build();
- log.debug(
- "Adding protocol " + sliderClusterAPIClass.getCanonicalName() + " to the server");
- server.addProtocol(RPC.RpcKind.RPC_PROTOCOL_BUFFER, sliderClusterAPIClass,
- blockingService);
- return server;
- }
-
- /**
- * Add the protobuf engine to the configuration. Harmless and inexpensive
- * if repeated.
- * @param conf configuration to patch
- * @return the protocol class
- */
- public static Class<SliderClusterProtocolPB> registerSliderAPI(
- Configuration conf) {
- Class<SliderClusterProtocolPB> sliderClusterAPIClass =
- SliderClusterProtocolPB.class;
- RPC.setProtocolEngine(conf, sliderClusterAPIClass, ProtobufRpcEngine.class);
-
- //quick sanity check here
- assert verifyBondedToProtobuf(conf, sliderClusterAPIClass);
-
- return sliderClusterAPIClass;
- }
-
- /**
- * Verify that the conf is set up for protobuf transport of Slider RPC
- * @param conf configuration
- * @param sliderClusterAPIClass class for the API
- * @return true if the RPC engine is protocol buffers
- */
- public static boolean verifyBondedToProtobuf(Configuration conf,
- Class<SliderClusterProtocolPB> sliderClusterAPIClass) {
- return conf.getClass("rpc.engine." + sliderClusterAPIClass.getName(),
- RpcEngine.class) .equals(ProtobufRpcEngine.class);
- }
-
-
- /**
- * Connect to a server. May include setting up retry policies
- * @param addr
- * @param currentUser
- * @param conf
- * @param rpcTimeout
- * @return
- * @throws IOException
- */
- public static SliderClusterProtocol connectToServer(InetSocketAddress addr,
- UserGroupInformation currentUser,
- Configuration conf,
- int rpcTimeout) throws IOException {
- Class<SliderClusterProtocolPB> sliderClusterAPIClass =
- registerSliderAPI(conf);
-
- final RetryPolicy retryPolicy = RetryPolicies.TRY_ONCE_THEN_FAIL;
- log.debug("Connecting to Slider AM at {}", addr);
- ProtocolProxy<SliderClusterProtocolPB> protoProxy =
- RPC.getProtocolProxy(sliderClusterAPIClass,
- 1,
- addr,
- currentUser,
- conf,
- NetUtils.getDefaultSocketFactory(conf),
- rpcTimeout,
- retryPolicy);
- SliderClusterProtocolPB endpoint = protoProxy.getProxy();
- return new SliderClusterProtocolProxy(endpoint, addr);
- }
-
-
- /**
- * This loops for a limited period trying to get the Proxy -
- * by doing so it handles AM failover
- * @param conf configuration to patch and use
- * @param rmClient client of the resource manager
- * @param application application to work with
- * @param connectTimeout timeout for the whole proxy operation to timeout
- * (milliseconds). Use 0 to indicate "do not attempt to wait" -fail fast.
- * @param rpcTimeout timeout for RPCs to block during communications
- * @return the proxy
- * @throws IOException IO problems
- * @throws YarnException Slider-generated exceptions related to the binding
- * failing. This can include the application finishing or timeouts
- * @throws InterruptedException if a sleep operation waiting for
- * the cluster to respond is interrupted.
- */
- @SuppressWarnings("NestedAssignment")
- public static SliderClusterProtocol getProxy(final Configuration conf,
- final ApplicationClientProtocol rmClient,
- ApplicationReport application,
- final int connectTimeout,
- final int rpcTimeout)
- throws IOException, YarnException, InterruptedException {
- ApplicationId appId;
- appId = application.getApplicationId();
- Duration timeout = new Duration(connectTimeout);
- timeout.start();
- Exception exception = null;
- YarnApplicationState state = null;
- try {
- while (application != null &&
- (state = application.getYarnApplicationState()).equals(
- YarnApplicationState.RUNNING)) {
-
- try {
- return getProxy(conf, application, rpcTimeout);
- } catch (IOException e) {
- if (connectTimeout <= 0 || timeout.getLimitExceeded()) {
- throw e;
- }
- exception = e;
- } catch (YarnException e) {
- if (connectTimeout <= 0 || timeout.getLimitExceeded()) {
- throw e;
- }
- exception = e;
- }
- //at this point: app failed to work
- log.debug("Could not connect to {}. Waiting for getting the latest AM address...",
- appId);
- Thread.sleep(1000);
- //or get the app report
- application =
- rmClient.getApplicationReport(
- GetApplicationReportRequest.newInstance(appId)).getApplicationReport();
- }
- //get here if the app is no longer running. Raise a specific
- //exception but init it with the previous failure
- throw new BadClusterStateException(
- exception,
- ErrorStrings.E_FINISHED_APPLICATION, appId, state );
- } finally {
- timeout.close();
- }
- }
-
- /**
- * Get a proxy from the application report
- * @param conf config to use
- * @param application app report
- * @param rpcTimeout timeout in RPC operations
- * @return the proxy
- * @throws IOException
- * @throws SliderException
- * @throws InterruptedException
- */
- public static SliderClusterProtocol getProxy(final Configuration conf,
- final ApplicationReport application,
- final int rpcTimeout)
- throws IOException, SliderException, InterruptedException {
-
- String host = application.getHost();
- int port = application.getRpcPort();
- org.apache.hadoop.yarn.api.records.Token clientToAMToken =
- application.getClientToAMToken();
- return createProxy(conf, host, port, clientToAMToken, rpcTimeout);
- }
-
- /**
- *
- * @param conf config to use
- * @param host hosname
- * @param port port
- * @param clientToAMToken auth token: only used in a secure cluster.
- * converted via {@link ConverterUtils#convertFromYarn(org.apache.hadoop.yarn.api.records.Token, InetSocketAddress)}
- * @param rpcTimeout timeout in RPC operations
- * @return the proxy
- * @throws SliderException
- * @throws IOException
- * @throws InterruptedException
- */
- public static SliderClusterProtocol createProxy(final Configuration conf,
- String host,
- int port,
- org.apache.hadoop.yarn.api.records.Token clientToAMToken,
- final int rpcTimeout) throws
- SliderException,
- IOException,
- InterruptedException {
- String address = host + ":" + port;
- if (SliderUtils.isUnset(host) || 0 == port) {
- throw new SliderException(SliderExitCodes.EXIT_CONNECTIVITY_PROBLEM,
- "Slider instance "
- + " isn't providing a valid address for the" +
- " Slider RPC protocol: " + address);
- }
-
- UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();
- final UserGroupInformation newUgi = UserGroupInformation.createRemoteUser(
- currentUser.getUserName());
- final InetSocketAddress serviceAddr =
- NetUtils.createSocketAddrForHost(host, port);
- SliderClusterProtocol realProxy;
-
- log.debug("Connecting to {}", serviceAddr);
- if (UserGroupInformation.isSecurityEnabled()) {
- Preconditions.checkArgument(clientToAMToken != null,
- "Null clientToAMToken");
- Token<ClientToAMTokenIdentifier> token =
- ConverterUtils.convertFromYarn(clientToAMToken, serviceAddr);
- newUgi.addToken(token);
- realProxy =
- newUgi.doAs(new PrivilegedExceptionAction<SliderClusterProtocol>() {
- @Override
- public SliderClusterProtocol run() throws IOException {
- return connectToServer(serviceAddr, newUgi, conf, rpcTimeout);
- }
- });
- } else {
- realProxy = connectToServer(serviceAddr, newUgi, conf, rpcTimeout);
- }
- return realProxy;
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderAMPolicyProvider.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/rpc/SliderAMPolicyProvider.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/rpc/SliderAMPolicyProvider.java
deleted file mode 100644
index 37c0a70..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/rpc/SliderAMPolicyProvider.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.server.appmaster.rpc;
-
-import org.apache.hadoop.security.authorize.PolicyProvider;
-import org.apache.hadoop.security.authorize.Service;
-import org.apache.hadoop.yarn.service.conf.SliderXmlConfKeys;
-
-/**
- * {@link PolicyProvider} for Slider protocols.
- */
-
-public class SliderAMPolicyProvider extends PolicyProvider {
-
- private static final Service[] services =
- new Service[] {
- new Service(SliderXmlConfKeys.KEY_PROTOCOL_ACL, SliderClusterProtocolPB.class)
- };
-
- @SuppressWarnings("ReturnOfCollectionOrArrayField")
- @Override
- public Service[] getServices() {
- return services;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderClusterProtocolPB.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/rpc/SliderClusterProtocolPB.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/rpc/SliderClusterProtocolPB.java
deleted file mode 100644
index 7d237de..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/rpc/SliderClusterProtocolPB.java
+++ /dev/null
@@ -1,27 +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.rpc;
-
-import org.apache.slider.api.SliderClusterProtocol;
-import org.apache.slider.api.proto.SliderClusterAPI;
-
-public interface SliderClusterProtocolPB extends SliderClusterAPI.SliderClusterProtocolPB.BlockingInterface{
-
- long versionID = SliderClusterProtocol.versionID;
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderClusterProtocolPBImpl.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/rpc/SliderClusterProtocolPBImpl.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/rpc/SliderClusterProtocolPBImpl.java
deleted file mode 100644
index 526ab7c..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/rpc/SliderClusterProtocolPBImpl.java
+++ /dev/null
@@ -1,225 +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.rpc;
-
-import com.google.protobuf.RpcController;
-import com.google.protobuf.ServiceException;
-import org.apache.slider.api.SliderClusterProtocol;
-import org.apache.slider.api.proto.Messages;
-
-import java.io.IOException;
-
-/**
- * Server-side Relay from Protobuf to internal RPC.
- *
- */
-public class SliderClusterProtocolPBImpl implements SliderClusterProtocolPB {
-
- private SliderClusterProtocol real;
-
- public SliderClusterProtocolPBImpl(SliderClusterProtocol real) {
- this.real = real;
- }
-
- private ServiceException wrap(Exception e) {
- if (e instanceof ServiceException) {
- return (ServiceException) e;
- }
- return new ServiceException(e);
- }
-
- public long getProtocolVersion(String protocol, long clientVersion)
- throws IOException {
- return SliderClusterProtocol.versionID;
- }
-
- @Override
- public Messages.StopClusterResponseProto stopCluster(RpcController controller,
- Messages.StopClusterRequestProto request) throws ServiceException {
- try {
- return real.stopCluster(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.UpgradeContainersResponseProto upgradeContainers(RpcController controller,
- Messages.UpgradeContainersRequestProto request) throws ServiceException {
- try {
- return real.upgradeContainers(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.FlexComponentsResponseProto flexComponents(
- RpcController controller, Messages.FlexComponentsRequestProto request)
- throws ServiceException {
- try {
- return real.flexComponents(request);
- } catch (IOException e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.GetJSONClusterStatusResponseProto getJSONClusterStatus(
- RpcController controller,
- Messages.GetJSONClusterStatusRequestProto request) throws ServiceException {
- try {
- return real.getJSONClusterStatus(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.ListNodeUUIDsByRoleResponseProto listNodeUUIDsByRole(
- RpcController controller,
- Messages.ListNodeUUIDsByRoleRequestProto request) throws ServiceException {
- try {
- return real.listNodeUUIDsByRole(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.GetNodeResponseProto getNode(RpcController controller,
- Messages.GetNodeRequestProto request) throws ServiceException {
- try {
- return real.getNode(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.GetClusterNodesResponseProto getClusterNodes(RpcController controller,
- Messages.GetClusterNodesRequestProto request) throws ServiceException {
- try {
- return real.getClusterNodes(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.EchoResponseProto echo(RpcController controller,
- Messages.EchoRequestProto request) throws ServiceException {
- try {
- return real.echo(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.KillContainerResponseProto killContainer(RpcController controller,
- Messages.KillContainerRequestProto request) throws ServiceException {
- try {
- return real.killContainer(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.AMSuicideResponseProto amSuicide(RpcController controller,
- Messages.AMSuicideRequestProto request) throws ServiceException {
- try {
- return real.amSuicide(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.ApplicationLivenessInformationProto getLivenessInformation(
- RpcController controller,
- Messages.GetApplicationLivenessRequestProto request) throws ServiceException {
- try {
- return real.getLivenessInformation(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.GetLiveContainersResponseProto getLiveContainers(RpcController controller,
- Messages.GetLiveContainersRequestProto request) throws ServiceException {
- try {
- return real.getLiveContainers(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.ContainerInformationProto getLiveContainer(RpcController controller,
- Messages.GetLiveContainerRequestProto request) throws ServiceException {
- try {
- return real.getLiveContainer(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.GetLiveComponentsResponseProto getLiveComponents(RpcController controller,
- Messages.GetLiveComponentsRequestProto request) throws ServiceException {
- try {
- return real.getLiveComponents(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.ComponentInformationProto getLiveComponent(RpcController controller,
- Messages.GetLiveComponentRequestProto request) throws ServiceException {
- try {
- return real.getLiveComponent(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.GetLiveNodesResponseProto getLiveNodes(RpcController controller,
- Messages.GetLiveNodesRequestProto request) throws ServiceException {
- try {
- return real.getLiveNodes(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-
- @Override
- public Messages.NodeInformationProto getLiveNode(RpcController controller,
- Messages.GetLiveNodeRequestProto request) throws ServiceException {
- try {
- return real.getLiveNode(request);
- } catch (Exception e) {
- throw wrap(e);
- }
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org