SLIDER-302 providers switch to using queued action, methods and interfaces changed appropriately
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/8f777f31 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/8f777f31 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/8f777f31 Branch: refs/heads/develop Commit: 8f777f31ceb46e7b84a32524789b48664080bf41 Parents: e75f605 Author: Steve Loughran <ste...@apache.org> Authored: Fri Aug 8 17:53:21 2014 +0100 Committer: Steve Loughran <ste...@apache.org> Committed: Fri Aug 8 17:53:21 2014 +0100 ---------------------------------------------------------------------- .../providers/AbstractProviderService.java | 12 ++--- .../slider/providers/ProviderService.java | 16 ++----- .../providers/agent/AgentProviderService.java | 15 +++---- .../providers/agent/HeartbeatMonitor.java | 9 +--- .../server/appmaster/AMViewForProviders.java | 46 ------------------- .../appmaster/ContainerStartOperation.java | 40 ----------------- .../server/appmaster/SliderAppMaster.java | 39 +++++++++------- .../server/appmaster/actions/ActionHalt.java | 4 +- .../appmaster/actions/ActionStartContainer.java | 4 +- .../appmaster/actions/ActionStopQueue.java | 4 +- .../appmaster/actions/ActionStopSlider.java | 4 +- .../server/appmaster/actions/AsyncAction.java | 2 +- .../actions/ProviderReportedContainerLoss.java | 47 ++++++++++++++++++++ .../server/appmaster/actions/QueueExecutor.java | 14 +++--- .../server/appmaster/actions/TestActions.groovy | 2 +- .../model/mock/MockProviderService.groovy | 4 +- .../providers/agent/TestHeartbeatMonitor.java | 6 --- .../publisher/TestAgentProviderService.java | 6 +-- 18 files changed, 106 insertions(+), 168 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java b/slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java index b431a10..89b862e 100644 --- a/slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java +++ b/slider-core/src/main/java/org/apache/slider/providers/AbstractProviderService.java @@ -33,7 +33,7 @@ import org.apache.slider.core.exceptions.SliderException; import org.apache.slider.core.main.ExitCodeProvider; import org.apache.slider.core.registry.info.RegisteredEndpoint; import org.apache.slider.core.registry.info.ServiceInstanceData; -import org.apache.slider.server.appmaster.AMViewForProviders; +import org.apache.slider.server.appmaster.actions.QueueAccess; import org.apache.slider.server.appmaster.state.ContainerReleaseSelector; import org.apache.slider.server.appmaster.state.MostRecentContainerReleaseSelector; import org.apache.slider.server.appmaster.state.StateAccessForProviders; @@ -71,8 +71,8 @@ public abstract class AbstractProviderService protected AgentRestOperations restOps; protected RegistryViewForProviders registry; protected ServiceInstanceData registryInstanceData; - protected AMViewForProviders amView; protected URL amWebAPI; + protected QueueAccess queueAccess; public AbstractProviderService(String name) { super(name); @@ -87,8 +87,8 @@ public abstract class AbstractProviderService return amState; } - public AMViewForProviders getAppMaster() { - return amView; + public QueueAccess getQueueAccess() { + return queueAccess; } public void setAmState(StateAccessForProviders amState) { @@ -98,11 +98,11 @@ public abstract class AbstractProviderService @Override public void bind(StateAccessForProviders stateAccessor, RegistryViewForProviders reg, - AMViewForProviders amView, + QueueAccess queueAccess, List<Container> liveContainers) { this.amState = stateAccessor; this.registry = reg; - this.amView = amView; + this.queueAccess = queueAccess; } @Override http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/providers/ProviderService.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/providers/ProviderService.java b/slider-core/src/main/java/org/apache/slider/providers/ProviderService.java index 1466350..e717158 100644 --- a/slider-core/src/main/java/org/apache/slider/providers/ProviderService.java +++ b/slider-core/src/main/java/org/apache/slider/providers/ProviderService.java @@ -32,7 +32,7 @@ import org.apache.slider.core.exceptions.SliderException; import org.apache.slider.core.launch.ContainerLauncher; import org.apache.slider.core.main.ExitCodeProvider; import org.apache.slider.core.registry.info.ServiceInstanceData; -import org.apache.slider.server.appmaster.AMViewForProviders; +import org.apache.slider.server.appmaster.actions.QueueAccess; import org.apache.slider.server.appmaster.state.ContainerReleaseSelector; import org.apache.slider.server.appmaster.operations.RMOperationHandlerActions; import org.apache.slider.server.appmaster.state.StateAccessForProviders; @@ -146,17 +146,9 @@ public interface ProviderService extends ProviderCore, */ Map<String, String> buildMonitorDetails(ClusterDescription clusterSpec); - /** - * bind operation -invoked before the service is started - * @param stateAccessor interface offering read access to the state - * @param registry registry view - * @param amView AM access - * @param liveContainers list of live containers. If non-empty, the AM was - * restarted with one more running containers. - */ - void bind(StateAccessForProviders stateAccessor, - RegistryViewForProviders registry, - AMViewForProviders amView, + public void bind(StateAccessForProviders stateAccessor, + RegistryViewForProviders reg, + QueueAccess queueAccess, List<Container> liveContainers); /** http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java b/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java index 4d54509..419a454 100644 --- a/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java +++ b/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java @@ -58,7 +58,7 @@ import org.apache.slider.providers.agent.application.metadata.ExportGroup; import org.apache.slider.providers.agent.application.metadata.Metainfo; import org.apache.slider.providers.agent.application.metadata.OSPackage; import org.apache.slider.providers.agent.application.metadata.OSSpecific; -import org.apache.slider.server.appmaster.AMViewForProviders; +import org.apache.slider.server.appmaster.actions.ProviderReportedContainerLoss; import org.apache.slider.server.appmaster.state.StateAccessForProviders; import org.apache.slider.server.appmaster.web.rest.agent.AgentCommandType; import org.apache.slider.server.appmaster.web.rest.agent.AgentRestOperations; @@ -591,19 +591,16 @@ public class AgentProviderService extends AbstractProviderService implements /** * Lost heartbeat from the container - release it and ask for a replacement - * - * - * @param label + * (async operation) + * @param label * @param containerId * - * @return outcome of the operation */ - protected AMViewForProviders.ContainerLossReportOutcomes lostContainer( + protected void lostContainer( String label, - ContainerId containerId) throws - SliderException { + ContainerId containerId) { getComponentStatuses().remove(label); - return getAppMaster().providerLostContainer(containerId); + getQueueAccess().put(new ProviderReportedContainerLoss(containerId)); } /** http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/providers/agent/HeartbeatMonitor.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/providers/agent/HeartbeatMonitor.java b/slider-core/src/main/java/org/apache/slider/providers/agent/HeartbeatMonitor.java index cb22d2e..0a1beca 100644 --- a/slider-core/src/main/java/org/apache/slider/providers/agent/HeartbeatMonitor.java +++ b/slider-core/src/main/java/org/apache/slider/providers/agent/HeartbeatMonitor.java @@ -19,7 +19,6 @@ package org.apache.slider.providers.agent; import com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.slider.core.exceptions.SliderException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -114,13 +113,7 @@ public class HeartbeatMonitor implements Runnable { timeSinceLastHeartbeat); ContainerId containerId = componentInstanceState.getContainerId(); - try { - provider.lostContainer(containerLabel, containerId); - } catch (SliderException e) { - log.info( - "Error while requesting container release for {}. Message: {}", - containerId, e, e); - } + provider.lostContainer(containerLabel, containerId); } break; case HEARTBEAT_LOST: http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/AMViewForProviders.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/AMViewForProviders.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/AMViewForProviders.java deleted file mode 100644 index f426551..0000000 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/AMViewForProviders.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.slider.server.appmaster; - -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.slider.core.exceptions.SliderException; - -/** Operations available to a provider from AppMaster */ -public interface AMViewForProviders { - - /** - * Outcomes from container loss - */ - enum ContainerLossReportOutcomes { - /** - * The container doesn't exist...either it wasn't in use or it - * has been released - */ - CONTAINER_NOT_IN_USE, - - /** - * The container is known about and a review has been initated - */ - CONTAINER_LOST_REVIEW_INITIATED, - } - - /** Provider can ask AppMaster to release a specific container */ - ContainerLossReportOutcomes providerLostContainer(ContainerId containerId) throws SliderException; - -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/ContainerStartOperation.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/ContainerStartOperation.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/ContainerStartOperation.java deleted file mode 100644 index 50c99f3..0000000 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/ContainerStartOperation.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; - -import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; -import org.apache.slider.server.appmaster.state.RoleInstance; - -/** - * Callback for container start requests - */ -public interface ContainerStartOperation { - /** - * Add a node to the list of starting - * nodes then trigger the NM start operation with the given - * launch context - * @param container container - * @param ctx context - * @param instance node details - */ - void startContainer(Container container, - ContainerLaunchContext ctx, - RoleInstance instance) ; -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java index b82967f..52f7f8f 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java @@ -80,6 +80,7 @@ import org.apache.slider.core.exceptions.BadConfigException; import org.apache.slider.core.exceptions.SliderException; import org.apache.slider.core.exceptions.SliderInternalStateException; import org.apache.slider.core.exceptions.TriggerClusterTeardownException; +import org.apache.slider.core.main.ExitCodeProvider; import org.apache.slider.core.main.LauncherExitCodes; import org.apache.slider.core.main.RunService; import org.apache.slider.core.main.ServiceLauncher; @@ -168,9 +169,7 @@ public class SliderAppMaster extends AbstractSliderLaunchedService SliderClusterProtocol, ServiceStateChangeListener, RoleKeys, - ProviderCompleted, - ContainerStartOperation, - AMViewForProviders { + ProviderCompleted { protected static final Logger log = LoggerFactory.getLogger(SliderAppMaster.class); @@ -763,9 +762,9 @@ public class SliderAppMaster extends AbstractSliderLaunchedService //Give the provider restricted access to the state, registry - providerService.bind(stateForProviders, registry, this, + providerService.bind(stateForProviders, registry, actionQueues, liveContainers); - sliderAMProvider.bind(stateForProviders, registry, this, + sliderAMProvider.bind(stateForProviders, registry, actionQueues, liveContainers); // now do the registration @@ -1219,7 +1218,8 @@ public class SliderAppMaster extends AbstractSliderLaunchedService public void onError(Throwable e) { //callback says it's time to finish LOG_YARN.error("AMRMClientAsync.onError() received " + e, e); - signalAMComplete(EXIT_EXCEPTION_THROWN, "AMRMClientAsync.onError() received " + e); + signalAMComplete(EXIT_EXCEPTION_THROWN, + "AMRMClientAsync.onError() received " + e); } /* =================================================================== */ @@ -1484,18 +1484,13 @@ public class SliderAppMaster extends AbstractSliderLaunchedService } } - - /* =================================================================== */ - /* ProviderAMOperations */ - /* =================================================================== */ - /** * report container loss. If this isn't already known about, react * * @param containerId id of the container which has failed * @throws SliderException */ - public synchronized ContainerLossReportOutcomes providerLostContainer( + public synchronized void providerLostContainer( ContainerId containerId) throws SliderException { log.info("containerLostContactWithProvider: container {} lost", @@ -1506,10 +1501,8 @@ public class SliderAppMaster extends AbstractSliderLaunchedService // ask for more containers if needed log.info("Container released; triggering review"); reviewRequestAndReleaseNodes(); - return ContainerLossReportOutcomes.CONTAINER_LOST_REVIEW_INITIATED; } else { log.info("Container not in active set - ignoring"); - return ContainerLossReportOutcomes.CONTAINER_NOT_IN_USE; } } @@ -1570,7 +1563,6 @@ public class SliderAppMaster extends AbstractSliderLaunchedService * @param ctx context * @param instance node details */ - @Override // ContainerStartOperation public void startContainer(Container container, ContainerLaunchContext ctx, RoleInstance instance) { @@ -1676,6 +1668,22 @@ public class SliderAppMaster extends AbstractSliderLaunchedService actionQueues.delayedActions.add(action); } + + /** + * Handle any exception in a thread. If the exception provides an exit + * code, that is the one that will be used + * @param thread thread throwing the exception + * @param exception exception + */ + public void onExceptionInThread(Thread thread, Exception exception) { + log.error("Exception in {}: {}", thread.getName(), exception, exception); + int exitCode = EXIT_EXCEPTION_THROWN; + if (exception instanceof ExitCodeProvider) { + exitCode = ((ExitCodeProvider) exception).getExitCode(); + } + signalAMComplete(exitCode, exception.toString()); + } + /** * This is the main entry point for the service launcher. * @param args command line arguments. @@ -1691,4 +1699,5 @@ public class SliderAppMaster extends AbstractSliderLaunchedService //now have the service launcher do its work ServiceLauncher.serviceMain(extendedArgs); } + } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionHalt.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionHalt.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionHalt.java index a16d207..1468cd8 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionHalt.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionHalt.java @@ -21,8 +21,6 @@ package org.apache.slider.server.appmaster.actions; import org.apache.hadoop.util.ExitUtil; import org.apache.slider.server.appmaster.SliderAppMaster; -import java.io.IOException; - public class ActionHalt extends AsyncAction { private final int status; @@ -37,7 +35,7 @@ public class ActionHalt extends AsyncAction { } @Override - public void execute(SliderAppMaster appMaster) throws IOException { + public void execute(SliderAppMaster appMaster) throws Exception { ExitUtil.halt(status, text); } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStartContainer.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStartContainer.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStartContainer.java index 2d643ed..6179f35 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStartContainer.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStartContainer.java @@ -23,8 +23,6 @@ import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.slider.server.appmaster.SliderAppMaster; import org.apache.slider.server.appmaster.state.RoleInstance; -import java.io.IOException; - public class ActionStartContainer extends AsyncAction { private final Container container; @@ -43,7 +41,7 @@ public class ActionStartContainer extends AsyncAction { } @Override - public void execute(SliderAppMaster appMaster) throws IOException { + public void execute(SliderAppMaster appMaster) throws Exception { appMaster.startContainer(container, ctx, instance); } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopQueue.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopQueue.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopQueue.java index b64fd73..a11bccb 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopQueue.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopQueue.java @@ -20,8 +20,6 @@ package org.apache.slider.server.appmaster.actions; import org.apache.slider.server.appmaster.SliderAppMaster; -import java.io.IOException; - /** * Action to tell a queue executor to stop -after handing this on/executing it */ @@ -32,7 +30,7 @@ public class ActionStopQueue extends AsyncAction { } @Override - public void execute(SliderAppMaster appMaster) throws IOException { + public void execute(SliderAppMaster appMaster) throws Exception { // no-op } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopSlider.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopSlider.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopSlider.java index cffa3f2..0e6dc25 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopSlider.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ActionStopSlider.java @@ -21,8 +21,6 @@ package org.apache.slider.server.appmaster.actions; import org.apache.slider.core.main.LauncherExitCodes; import org.apache.slider.server.appmaster.SliderAppMaster; -import java.io.IOException; - public class ActionStopSlider extends AsyncAction { public ActionStopSlider(String message, int delay) { @@ -30,7 +28,7 @@ public class ActionStopSlider extends AsyncAction { } @Override - public void execute(SliderAppMaster appMaster) throws IOException { + public void execute(SliderAppMaster appMaster) throws Exception { String message = name; SliderAppMaster.getLog().info("SliderAppMasterApi.stopCluster: {}", message); http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/AsyncAction.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/AsyncAction.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/AsyncAction.java index 09bb517..a755064 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/AsyncAction.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/AsyncAction.java @@ -112,7 +112,7 @@ public abstract class AsyncAction implements Delayed { * @param appMaster * @throws IOException */ - public abstract void execute(SliderAppMaster appMaster) throws IOException; + public abstract void execute(SliderAppMaster appMaster) throws Exception; public enum ActionAttributes { SHRINKS_CLUSTER, http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ProviderReportedContainerLoss.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ProviderReportedContainerLoss.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ProviderReportedContainerLoss.java new file mode 100644 index 0000000..63b40d5 --- /dev/null +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/ProviderReportedContainerLoss.java @@ -0,0 +1,47 @@ +/* + * 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.actions; + +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.slider.server.appmaster.SliderAppMaster; + +/** + * Report container loss to the AM + * {@link SliderAppMaster#providerLostContainer(ContainerId)} + */ +public class ProviderReportedContainerLoss extends AsyncAction { + + private final ContainerId containerId; + + public ProviderReportedContainerLoss(ContainerId containerId) { + super("lost container " + containerId); + this.containerId = containerId; + } + + public ProviderReportedContainerLoss( + ContainerId containerId, int delayMillis) { + super("lost container " + containerId, delayMillis); + this.containerId = containerId; + } + + @Override + public void execute(SliderAppMaster appMaster) throws Exception { + appMaster.providerLostContainer(containerId); + } +} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/QueueExecutor.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/QueueExecutor.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/QueueExecutor.java index 7eeaddf..072f324 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/QueueExecutor.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/actions/QueueExecutor.java @@ -24,8 +24,6 @@ import org.apache.slider.server.appmaster.SliderAppMaster; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; - /** * Executor for async actions - hands them off to the AM as * appropriate @@ -41,7 +39,7 @@ public class QueueExecutor implements Runnable { QueueService actionQueues) { Preconditions.checkNotNull(appMaster); Preconditions.checkNotNull(actionQueues); - + this.appMaster = appMaster; this.actionQueues = actionQueues; } @@ -52,7 +50,7 @@ public class QueueExecutor implements Runnable { this.appMaster = null; this.actionQueues = actionQueues; } - + /** * Run until the queue has been told to stop */ @@ -67,9 +65,11 @@ public class QueueExecutor implements Runnable { take.execute(appMaster); } while (!(take instanceof ActionStopQueue)); log.info("Queue Executor run() stopped"); - } catch (InterruptedException | IOException e) { - log.error("Exception processing {}: {}", take, e, e); - + } catch (Exception e) { + log.error("Exception processing {}: {}", take, e, e); + if (appMaster != null) { + appMaster.onExceptionInThread(Thread.currentThread(), e); + } } } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/test/groovy/org/apache/slider/server/appmaster/actions/TestActions.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/actions/TestActions.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/actions/TestActions.groovy index 7e6338b..5dffea0 100644 --- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/actions/TestActions.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/actions/TestActions.groovy @@ -159,7 +159,7 @@ class TestActions { } @Override - public void execute(SliderAppMaster appMaster) throws IOException { + public void execute(SliderAppMaster appMaster) throws Exception { log.info("Executing $name"); executed.set(true); executionTimeNanos.set(System.nanoTime()) http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockProviderService.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockProviderService.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockProviderService.groovy index c46b828..458cfac 100644 --- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockProviderService.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockProviderService.groovy @@ -35,7 +35,7 @@ import org.apache.slider.core.launch.ContainerLauncher import org.apache.slider.core.registry.info.ServiceInstanceData import org.apache.slider.providers.ProviderRole import org.apache.slider.providers.ProviderService -import org.apache.slider.server.appmaster.AMViewForProviders +import org.apache.slider.server.appmaster.actions.QueueAccess import org.apache.slider.server.appmaster.state.ContainerReleaseSelector import org.apache.slider.server.appmaster.state.MostRecentContainerReleaseSelector import org.apache.slider.server.appmaster.state.StateAccessForProviders @@ -202,7 +202,7 @@ class MockProviderService implements ProviderService { void bind( StateAccessForProviders stateAccessor, RegistryViewForProviders registry, - AMViewForProviders amView, + QueueAccess queueAccess, List<Container> liveContainers) { } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/test/java/org/apache/slider/providers/agent/TestHeartbeatMonitor.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/providers/agent/TestHeartbeatMonitor.java b/slider-core/src/test/java/org/apache/slider/providers/agent/TestHeartbeatMonitor.java index b16b145..1ace44e 100644 --- a/slider-core/src/test/java/org/apache/slider/providers/agent/TestHeartbeatMonitor.java +++ b/slider-core/src/test/java/org/apache/slider/providers/agent/TestHeartbeatMonitor.java @@ -17,7 +17,6 @@ package org.apache.slider.providers.agent; import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.slider.server.appmaster.AMViewForProviders; import org.apache.slider.server.appmaster.model.mock.MockContainerId; import org.junit.Assert; import org.junit.Test; @@ -98,11 +97,6 @@ public class TestHeartbeatMonitor { slaveState.setState(State.STARTED); slaveState.heartbeat(now); expect(provider.getComponentStatuses()).andReturn(statuses).anyTimes(); - expect(provider.lostContainer(slaveLabel, slaveContainer)).andReturn( - AMViewForProviders.ContainerLossReportOutcomes.CONTAINER_LOST_REVIEW_INITIATED).once(); - // expect the second iteration to report no container any more - expect(provider.lostContainer(slaveLabel, slaveContainer)).andReturn( - AMViewForProviders.ContainerLossReportOutcomes.CONTAINER_NOT_IN_USE).once(); replay(provider); http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/8f777f31/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java index 5579592..a97e351 100644 --- a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java +++ b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/publisher/TestAgentProviderService.java @@ -18,7 +18,7 @@ package org.apache.slider.server.appmaster.web.rest.publisher; import org.apache.hadoop.yarn.api.records.Container; import org.apache.slider.providers.agent.AgentProviderService; -import org.apache.slider.server.appmaster.AMViewForProviders; +import org.apache.slider.server.appmaster.actions.QueueAccess; import org.apache.slider.server.appmaster.state.StateAccessForProviders; import org.apache.slider.server.services.registry.RegistryViewForProviders; import org.slf4j.Logger; @@ -43,9 +43,9 @@ public class TestAgentProviderService extends AgentProviderService { @Override public void bind(StateAccessForProviders stateAccessor, RegistryViewForProviders reg, - AMViewForProviders amView, + QueueAccess queueAccess, List<Container> liveContainers) { - super.bind(stateAccessor, reg, amView, liveContainers); + super.bind(stateAccessor, reg, queueAccess, liveContainers); Map<String,String> dummyProps = new HashMap<>(); dummyProps.put("prop1", "val1"); dummyProps.put("prop2", "val2");