|
@@ -104,6 +104,7 @@ public abstract class RMStateStore extends AbstractService {
|
|
|
protected static final String VERSION_NODE = "RMVersionNode";
|
|
|
protected static final String EPOCH_NODE = "EpochNode";
|
|
|
protected long baseEpoch;
|
|
|
+ private long epochRange;
|
|
|
protected ResourceManager resourceManager;
|
|
|
private final ReadLock readLock;
|
|
|
private final WriteLock writeLock;
|
|
@@ -732,6 +733,8 @@ public abstract class RMStateStore extends AbstractService {
|
|
|
// read the base epoch value from conf
|
|
|
baseEpoch = conf.getLong(YarnConfiguration.RM_EPOCH,
|
|
|
YarnConfiguration.DEFAULT_RM_EPOCH);
|
|
|
+ epochRange = conf.getLong(YarnConfiguration.RM_EPOCH_RANGE,
|
|
|
+ YarnConfiguration.DEFAULT_RM_EPOCH_RANGE);
|
|
|
initInternal(conf);
|
|
|
}
|
|
|
|
|
@@ -818,7 +821,20 @@ public abstract class RMStateStore extends AbstractService {
|
|
|
* Get the current epoch of RM and increment the value.
|
|
|
*/
|
|
|
public abstract long getAndIncrementEpoch() throws Exception;
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Compute the next epoch value by incrementing by one.
|
|
|
+ * Wraps around if the epoch range is exceeded so that
|
|
|
+ * when federation is enabled epoch collisions can be avoided.
|
|
|
+ */
|
|
|
+ protected long nextEpoch(long epoch){
|
|
|
+ long epochVal = epoch - baseEpoch + 1;
|
|
|
+ if (epochRange > 0) {
|
|
|
+ epochVal %= epochRange;
|
|
|
+ }
|
|
|
+ return epochVal + baseEpoch;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Blocking API
|
|
|
* The derived class must recover state from the store and return a new
|