use of org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier in project controller by opendaylight.
the class AbstractClientHistory method createHistoryProxy.
/**
* Create a new history proxy for a given shard.
*
* @throws InversibleLockException if the shard is being reconnected
*/
@GuardedBy("lock")
private ProxyHistory createHistoryProxy(final Long shard) {
final AbstractClientConnection<ShardBackendInfo> connection = client.getConnection(shard);
final LocalHistoryIdentifier proxyId = new LocalHistoryIdentifier(identifier.getClientId(), identifier.getHistoryId(), shard);
LOG.debug("Created proxyId {} for history {} shard {}", proxyId, identifier, shard);
final ProxyHistory ret = createHistoryProxy(proxyId, connection);
// Request creation of the history, if it is not the single history
if (ret.getIdentifier().getHistoryId() != 0) {
connection.sendRequest(new CreateLocalHistoryRequest(ret.getIdentifier(), connection.localActor()), this::createHistoryCallback);
}
return ret;
}
use of org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier in project controller by opendaylight.
the class AbstractDataStoreClientBehavior method createLocalHistory.
//
//
// Methods below are invoked from application threads
//
//
@Override
public final ClientLocalHistory createLocalHistory() {
final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(getIdentifier(), nextHistoryId.getAndIncrement());
final long stamp = lock.readLock();
try {
if (aborted != null) {
Throwables.throwIfUnchecked(aborted);
throw new RuntimeException(aborted);
}
final ClientLocalHistory history = new ClientLocalHistory(this, historyId);
LOG.debug("{}: creating a new local history {}", persistenceId(), history);
Verify.verify(histories.put(historyId, history) == null);
return history;
} finally {
lock.unlockRead(stamp);
}
}
use of org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier in project controller by opendaylight.
the class LeaderFrontendState method handlePurgeHistory.
private LocalHistorySuccess handlePurgeHistory(final PurgeLocalHistoryRequest request, final RequestEnvelope envelope, final long now) throws RequestException {
final LocalHistoryIdentifier id = request.getTarget();
final LocalFrontendHistory existing = localHistories.remove(id);
if (existing == null) {
LOG.debug("{}: history {} has already been purged", persistenceId, id);
return new LocalHistorySuccess(id, request.getSequence());
}
LOG.debug("{}: purging history {}", persistenceId, id);
purgedHistories.add(id.getHistoryId());
existing.purge(request.getSequence(), envelope, now);
return null;
}
use of org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier in project controller by opendaylight.
the class ShardTransactionActorFactory method actorNameFor.
private String actorNameFor(final TransactionIdentifier txId) {
final LocalHistoryIdentifier historyId = txId.getHistoryId();
final ClientIdentifier clientId = historyId.getClientId();
final FrontendIdentifier frontendId = clientId.getFrontendId();
final StringBuilder sb = new StringBuilder("shard-");
sb.append(shardName).append('-').append(frontendId.getMemberName().getName()).append(':').append(frontendId.getClientType().getName()).append('@').append(clientId.getGeneration()).append(':');
if (historyId.getHistoryId() != 0) {
sb.append(historyId.getHistoryId()).append('-');
}
return sb.append(txId.getTransactionId()).append('_').append(ACTOR_NAME_COUNTER.incrementAndGet()).toString();
}
use of org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier in project controller by opendaylight.
the class ReconnectingClientConnectionTest method testSendRequestReceiveResponse.
@Override
@Test
public void testSendRequestReceiveResponse() throws Exception {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
final Request<?, ?> request = createRequest(replyToProbe.ref());
connection.sendRequest(request, callback);
backendProbe.expectNoMsg();
final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(CLIENT_ID, 0L);
final RequestSuccess<?, ?> message = new TransactionAbortSuccess(new TransactionIdentifier(historyId, 0L), 0L);
final ResponseEnvelope<?> envelope = new SuccessEnvelope(message, 0L, 0L, 0L);
connection.receiveResponse(envelope);
verify(callback, after(1000).never()).accept(any());
}
Aggregations