private Cell getCoordinationValueCell() { return getCellForSequence(0); }
@VisibleForTesting Optional<T> getValue(long sequenceNumber) { Preconditions.checkState( sequenceNumber > 0, "Only positive sequence numbers are supported, but found %s", sequenceNumber); return readFromCoordinationTable(getCellForSequence(sequenceNumber)) .map(Value::getContents) .map(this::deserializeValue); }
@VisibleForTesting void putUnlessValueExists(long sequenceNumber, T value) { Preconditions.checkState( sequenceNumber > 0, "Only positive sequence numbers are supported, but found %s", sequenceNumber); try { kvs.putUnlessExists(AtlasDbConstants.COORDINATION_TABLE, ImmutableMap.of(getCellForSequence(sequenceNumber), serializeValue(value))); } catch (KeyAlreadyExistsException e) { throw new SafeIllegalStateException("The coordination store failed a putUnlessExists. This is unexpected" + " as it implies timestamps may have been reused, or a writer to the store behaved badly." + " The offending sequence number was {}. " + " Please contact support - DO NOT ATTEMPT TO FIX THIS YOURSELF.", e, SafeArg.of("sequenceNumber", sequenceNumber)); } }
private Cell getCoordinationValueCell() { return getCellForSequence(0); }
@VisibleForTesting Optional<T> getValue(long sequenceNumber) { Preconditions.checkState( sequenceNumber > 0, "Only positive sequence numbers are supported, but found %s", sequenceNumber); return readFromCoordinationTable(getCellForSequence(sequenceNumber)) .map(Value::getContents) .map(this::deserializeValue); }
@VisibleForTesting void putUnlessValueExists(long sequenceNumber, T value) { Preconditions.checkState( sequenceNumber > 0, "Only positive sequence numbers are supported, but found %s", sequenceNumber); try { kvs.putUnlessExists(AtlasDbConstants.COORDINATION_TABLE, ImmutableMap.of(getCellForSequence(sequenceNumber), serializeValue(value))); } catch (KeyAlreadyExistsException e) { throw new SafeIllegalStateException("The coordination store failed a putUnlessExists. This is unexpected" + " as it implies timestamps may have been reused, or a writer to the store behaved badly." + " The offending sequence number was {}. " + " Please contact support - DO NOT ATTEMPT TO FIX THIS YOURSELF.", e, SafeArg.of("sequenceNumber", sequenceNumber)); } }