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, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    
019    package org.apache.hadoop.conf;
020    
021    import com.google.common.base.Optional;
022    import org.apache.hadoop.classification.InterfaceAudience;
023    import org.apache.hadoop.classification.InterfaceStability;
024    import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange;
025    
026    import java.util.Map;
027    
028    @InterfaceAudience.Public
029    @InterfaceStability.Stable
030    public class ReconfigurationTaskStatus {
031      long startTime;
032      long endTime;
033      final Map<ReconfigurationUtil.PropertyChange, Optional<String>> status;
034    
035      public ReconfigurationTaskStatus(long startTime, long endTime,
036          Map<ReconfigurationUtil.PropertyChange, Optional<String>> status) {
037        this.startTime = startTime;
038        this.endTime = endTime;
039        this.status = status;
040      }
041    
042      /**
043       * Return true if
044       *   - A reconfiguration task has finished or
045       *   - an active reconfiguration task is running
046       */
047      public boolean hasTask() {
048        return startTime > 0;
049      }
050    
051      /**
052       * Return true if the latest reconfiguration task has finished and there is
053       * no another active task running.
054       */
055      public boolean stopped() {
056        return endTime > 0;
057      }
058    
059      public long getStartTime() {
060        return startTime;
061      }
062    
063      public long getEndTime() {
064        return endTime;
065      }
066    
067      public final Map<PropertyChange, Optional<String>> getStatus() {
068        return status;
069      }
070    }