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.driver.restart;
020
021import org.apache.reef.annotations.Unstable;
022import org.apache.reef.annotations.audience.DriverSide;
023import org.apache.reef.annotations.audience.Private;
024
025/**
026 * Represents the current driver restart progress.
027 */
028@Private
029@DriverSide
030@Unstable
031public enum DriverRestartState {
032  /**
033   *  Driver has not begun the restart progress yet.
034   */
035  NOT_RESTARTED,
036
037  /**
038   * Driver has been notified of the restart by the runtime, but has not yet
039   * received its set of evaluator IDs to recover yet.
040   */
041  BEGAN,
042
043  /**
044   * Driver has received its set of evaluator IDs to recover.
045   */
046  IN_PROGRESS,
047
048  /**
049   * Driver has recovered all the evaluator IDs that it can, and the restart process is completed.
050   */
051  COMPLETED;
052
053  /**
054   * @return  true if the restart is in process.
055   */
056  public boolean isRestarting() {
057    switch (this) {
058    case BEGAN:
059    case IN_PROGRESS:
060      return true;
061    default:
062      return false;
063    }
064  }
065
066  /**
067   * @return true if the driver began the restart process. Can be already done with the restart process.
068   */
069  public boolean hasRestarted() {
070    return this != NOT_RESTARTED;
071  }
072
073  /**
074   * the negation of {@link #hasRestarted()}.
075   */
076  public boolean hasNotRestarted() {
077    return !this.hasRestarted();
078  }
079}