this.persistenceId = Preconditions.checkNotNull(persistenceId);
this.clientId = Preconditions.checkNotNull(clientId);
this.tree = Preconditions.checkNotNull(tree);
- standaloneHistory = new StandaloneFrontendHistory(persistenceId, clientId, tree);
+ standaloneHistory = new StandaloneFrontendHistory(persistenceId, tree.ticker(), clientId, tree);
}
@Override
}
@Nullable LocalHistorySuccess handleLocalHistoryRequest(final LocalHistoryRequest<?> request,
- final RequestEnvelope envelope) throws RequestException {
+ final RequestEnvelope envelope, final long now) throws RequestException {
checkRequestSequence(envelope);
try {
if (request instanceof CreateLocalHistoryRequest) {
return handleCreateHistory((CreateLocalHistoryRequest) request);
} else if (request instanceof DestroyLocalHistoryRequest) {
- return handleDestroyHistory((DestroyLocalHistoryRequest) request);
+ return handleDestroyHistory((DestroyLocalHistoryRequest) request, now);
} else if (request instanceof PurgeLocalHistoryRequest) {
- return handlePurgeHistory((PurgeLocalHistoryRequest)request);
+ return handlePurgeHistory((PurgeLocalHistoryRequest)request, now);
} else {
throw new UnsupportedRequestException(request);
}
lastSeenHistory = id.getHistoryId();
}
- localHistories.put(id, new LocalFrontendHistory(persistenceId, tree.ensureTransactionChain(id)));
+ localHistories.put(id, new LocalFrontendHistory(persistenceId, tree.ticker(), tree.ensureTransactionChain(id)));
LOG.debug("{}: created history {}", persistenceId, id);
return new LocalHistorySuccess(id, request.getSequence());
}
- private LocalHistorySuccess handleDestroyHistory(final DestroyLocalHistoryRequest request) throws RequestException {
+ private LocalHistorySuccess handleDestroyHistory(final DestroyLocalHistoryRequest request, final long now)
+ throws RequestException {
final LocalHistoryIdentifier id = request.getTarget();
final LocalFrontendHistory existing = localHistories.get(id);
if (existing == null) {
return new LocalHistorySuccess(id, request.getSequence());
}
- return existing.destroy(request.getSequence());
+ return existing.destroy(request.getSequence(), now);
}
- private LocalHistorySuccess handlePurgeHistory(final PurgeLocalHistoryRequest request) throws RequestException {
+ private LocalHistorySuccess handlePurgeHistory(final PurgeLocalHistoryRequest request, final long now)
+ throws RequestException {
final LocalHistoryIdentifier id = request.getTarget();
final LocalFrontendHistory existing = localHistories.remove(id);
if (existing != null) {
if (!existing.isDestroyed()) {
LOG.warn("{}: purging undestroyed history {}", persistenceId, id);
- existing.destroy(request.getSequence());
+ existing.destroy(request.getSequence(), now);
}
// FIXME: record a PURGE tombstone in the journal
}
@Nullable TransactionSuccess<?> handleTransactionRequest(final TransactionRequest<?> request,
- final RequestEnvelope envelope) throws RequestException {
+ final RequestEnvelope envelope, final long now) throws RequestException {
checkRequestSequence(envelope);
try {
history = standaloneHistory;
}
- return history.handleTransactionRequest(request, envelope);
+ return history.handleTransactionRequest(request, envelope, now);
} finally {
expectNextRequest();
}