- protected DistributedDataStoreClientBehavior onCommand(final Object command) {
- if (command instanceof GetClientRequest) {
- ((GetClientRequest) command).getReplyTo().tell(new Status.Success(this), ActorRef.noSender());
- } else {
- LOG.warn("{}: ignoring unhandled command {}", persistenceId(), command);
- }
-
- return this;
- }
-
- //
- //
- // Methods below are invoked from application threads
- //
- //
-
- private static <K, V extends LocalAbortable> V returnIfOperational(final Map<K , V> map, final K key, final V value,
- final Throwable aborted) {
- Verify.verify(map.put(key, value) == null);
-
- if (aborted != null) {
- try {
- value.localAbort(aborted);
- } catch (Exception e) {
- LOG.debug("Close of {} failed", value, e);
- }
- map.remove(key, value);
- throw Throwables.propagate(aborted);
- }
-
- return value;
- }
-
- @Override
- public ClientLocalHistory createLocalHistory() {
- final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(getIdentifier(),
- nextHistoryId.getAndIncrement());
- final ClientLocalHistory history = new ClientLocalHistory(this, historyId);
- LOG.debug("{}: creating a new local history {}", persistenceId(), history);
-
- return returnIfOperational(histories, historyId, history, aborted);
- }
-
- @Override
- public ClientTransaction createTransaction() {
- final TransactionIdentifier txId = new TransactionIdentifier(singleHistory.getIdentifier(),
- nextTransactionId.getAndIncrement());
- final ClientTransaction tx = new ClientTransaction(this, singleHistory, txId);
- LOG.debug("{}: creating a new transaction {}", persistenceId(), tx);
-
- return returnIfOperational(transactions, txId, tx, aborted);