This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.client;
020
021import org.apache.reef.annotations.Provided;
022import org.apache.reef.annotations.Unstable;
023import org.apache.reef.annotations.audience.ClientSide;
024import org.apache.reef.annotations.audience.Public;
025import org.apache.reef.driver.context.ActiveContext;
026import org.apache.reef.driver.evaluator.FailedEvaluator;
027import org.apache.reef.driver.parameters.*;
028import org.apache.reef.driver.restart.DriverRestarted;
029import org.apache.reef.driver.task.RunningTask;
030import org.apache.reef.driver.restart.DriverRestartCompleted;
031import org.apache.reef.tang.formats.ConfigurationModule;
032import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
033import org.apache.reef.tang.formats.OptionalImpl;
034import org.apache.reef.tang.formats.OptionalParameter;
035import org.apache.reef.wake.EventHandler;
036
037/**
038 * EventHandlers specific to Driver Restart. Please remember to bind a runtime-specific DriverRestartConfiguration,
039 * e.g. YarnDriverRestartConfiguration.
040 */
041@Public
042@ClientSide
043@Provided
044@Unstable
045public final class DriverRestartConfiguration extends ConfigurationModuleBuilder {
046  /**
047   * This event is fired in place of the ON_DRIVER_STARTED when the Driver is in fact restarted after failure.
048   */
049  public static final OptionalImpl<EventHandler<DriverRestarted>> ON_DRIVER_RESTARTED = new OptionalImpl<>();
050
051  /**
052   * Event handler for running tasks in previous evaluator, when driver restarted. Defaults to crash if not bound.
053   */
054  public static final OptionalImpl<EventHandler<RunningTask>> ON_DRIVER_RESTART_TASK_RUNNING = new OptionalImpl<>();
055
056  /**
057   * Event handler for active context when driver restart. Defaults to closing the context if not bound.
058   */
059  public static final OptionalImpl<EventHandler<ActiveContext>> ON_DRIVER_RESTART_CONTEXT_ACTIVE = new OptionalImpl<>();
060
061  /**
062   * Event handler for the event of driver restart completion, default to logging if not bound.
063   */
064  public static final OptionalImpl<EventHandler<DriverRestartCompleted>> ON_DRIVER_RESTART_COMPLETED =
065      new OptionalImpl<>();
066
067  /**
068   * Event handler for the event of driver restart completion, default to logging if not bound.
069   */
070  public static final OptionalImpl<EventHandler<FailedEvaluator>> ON_DRIVER_RESTART_EVALUATOR_FAILED =
071      new OptionalImpl<>();
072
073  /**
074   * The amount of time in seconds the driver waits for evaluators to report back on restart.
075   * Defaults to 3 minutes. If the value is set to Integer.MAX_VALUE, the driver will wait forever.
076   */
077  public static final OptionalParameter<Integer> DRIVER_RESTART_EVALUATOR_RECOVERY_SECONDS = new OptionalParameter<>();
078
079  /**
080   * Parameter to determine whether the driver should fail or continue if there are evaluator
081   * preservation log failures. Defaults to false.
082   */
083  public static final OptionalParameter<Boolean> FAIL_DRIVER_ON_EVALUATOR_LOG_ERROR =
084      new OptionalParameter<>();
085
086  public static final ConfigurationModule CONF = new DriverRestartConfiguration()
087      .bindNamedParameter(FailDriverOnEvaluatorLogErrors.class, FAIL_DRIVER_ON_EVALUATOR_LOG_ERROR)
088      .bindNamedParameter(DriverRestartEvaluatorRecoverySeconds.class, DRIVER_RESTART_EVALUATOR_RECOVERY_SECONDS)
089      .bindSetEntry(DriverRestartHandler.class, ON_DRIVER_RESTARTED)
090      .bindSetEntry(DriverRestartTaskRunningHandlers.class, ON_DRIVER_RESTART_TASK_RUNNING)
091      .bindSetEntry(DriverRestartContextActiveHandlers.class, ON_DRIVER_RESTART_CONTEXT_ACTIVE)
092      .bindSetEntry(DriverRestartCompletedHandlers.class, ON_DRIVER_RESTART_COMPLETED)
093      .bindSetEntry(DriverRestartFailedEvaluatorHandlers.class, ON_DRIVER_RESTART_EVALUATOR_FAILED)
094      .build();
095
096  private DriverRestartConfiguration(){
097  }
098}