use of org.apache.flink.kubernetes.utils.Constants.CHECKPOINT_COUNTER_KEY in project flink by apache.
the class KubernetesCheckpointIDCounter method getAndIncrement.
@Override
public long getAndIncrement() throws Exception {
final AtomicLong current = new AtomicLong();
final boolean updated = kubeClient.checkAndUpdateConfigMap(configMapName, configMap -> {
if (isValidOperation(configMap)) {
final long currentValue = getCurrentCounter(configMap);
current.set(currentValue);
configMap.getData().put(CHECKPOINT_COUNTER_KEY, String.valueOf(currentValue + 1));
return Optional.of(configMap);
}
return Optional.empty();
}).get();
if (updated) {
return current.get();
} else {
throw new KubernetesException("Failed to update ConfigMap " + configMapName + " since current KubernetesCheckpointIDCounter does not have the leadership.");
}
}
Aggregations