/** * Get the counter for the given storage key. * * @param storageService the storage service * @param storageContext the storage context * @param storageKey the storage key * @return the counter for the given storage key * @throws IOException if a storage service error occurs * @throws NumberFormatException if the storage record value cannot be parsed as an integer */ @Nullable protected Long getStorageKeyCounter(@Nonnull final StorageService storageService, @Nonnull final String storageContext, @Nonnull final String storageKey) throws IOException { Constraint.isNotNull(storageService, "Storage service cannot be null"); Constraint.isNotNull(storageContext, "Storage context cannot be null"); Constraint.isNotNull(storageKey, "Storage key cannot be null"); final String counterStorageKey = getCounterStorageKey(storageKey); final StorageRecord storageRecord = storageService.read(storageContext, counterStorageKey); log.debug("Read storage record '{}' with context '{}' and key '{}'", storageRecord, storageContext, counterStorageKey); return (storageRecord == null) ? null : storageRecord.getVersion(); }
/** * Get the counter for the given storage key. * * @param storageService the storage service * @param storageContext the storage context * @param storageKey the storage key * @return the counter for the given storage key * @throws IOException if a storage service error occurs * @throws NumberFormatException if the storage record value cannot be parsed as an integer */ @Nullable protected Long getStorageKeyCounter(@Nonnull final StorageService storageService, @Nonnull final String storageContext, @Nonnull final String storageKey) throws IOException { Constraint.isNotNull(storageService, "Storage service cannot be null"); Constraint.isNotNull(storageContext, "Storage context cannot be null"); Constraint.isNotNull(storageKey, "Storage key cannot be null"); final String counterStorageKey = getCounterStorageKey(storageKey); final StorageRecord storageRecord = storageService.read(storageContext, counterStorageKey); log.debug("Read storage record '{}' with context '{}' and key '{}'", storageRecord, storageContext, counterStorageKey); return (storageRecord == null) ? null : storageRecord.getVersion(); }
/** {@inheritDoc} */ @Override public Pair<Long, StorageRecord> read(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Positive final long version) throws IOException { Constraint.isGreaterThan(0, version, "Version must be positive"); final StorageRecord record = read(context, key); if (record == null) { return new Pair<>(); } final Pair<Long, StorageRecord> result = new Pair<>(record.getVersion(), null); if (version != record.getVersion()) { // Only set the record if it's not the same as the version requested result.setSecond(record); } return result; }
if (version != null && record.getVersion() == version) { return new Pair(record.getVersion(), record);
final String writeBackValue = writeBackSessionList.toString(); if (writeBackValue.length() == 0) { storageService.deleteWithVersion(sessionList.getVersion(), serviceId, serviceKey); } else if (!writeBackValue.equals(sessionList.getValue())) { storageService.updateWithVersion(sessionList.getVersion(), serviceId, serviceKey, writeBackValue, sessionList.getExpiration());
g.writeObjectFieldStart("attributes"); g.writeStringField("value", record.getValue()); g.writeNumberField("version", record.getVersion()); if (record.getExpiration() != null) { g.writeFieldName("expiration");
record.getVersion(), getId(), key, record.getValue().substring(pos + 1), record.getExpiration());
if (storageService.updateWithVersion(sessionList.getVersion(), serviceId, serviceKey, updated, sessionList.getExpiration()) == null) { log.debug("Secondary index record disappeared, nothing to do"); storageService.deleteWithVersion(sessionList.getVersion(), serviceId, serviceKey);
if (storageService.updateWithVersion(sessionList.getVersion(), serviceId, serviceKey, updated, Math.max(sessionList.getExpiration(), spSession.getExpirationInstant() + sessionSlop)) == null) {