Search in sources :

Example 1 with LocalHistoryIdentifier

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;
}
Also used : CreateLocalHistoryRequest(org.opendaylight.controller.cluster.access.commands.CreateLocalHistoryRequest) LocalHistoryIdentifier(org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier) GuardedBy(javax.annotation.concurrent.GuardedBy)

Example 2 with LocalHistoryIdentifier

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);
    }
}
Also used : LocalHistoryIdentifier(org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier)

Example 3 with LocalHistoryIdentifier

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;
}
Also used : LocalHistoryIdentifier(org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier) LocalHistorySuccess(org.opendaylight.controller.cluster.access.commands.LocalHistorySuccess)

Example 4 with LocalHistoryIdentifier

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();
}
Also used : ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) LocalHistoryIdentifier(org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier) FrontendIdentifier(org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier)

Example 5 with LocalHistoryIdentifier

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());
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) TransactionAbortSuccess(org.opendaylight.controller.cluster.access.commands.TransactionAbortSuccess) SuccessEnvelope(org.opendaylight.controller.cluster.access.concepts.SuccessEnvelope) TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier) LocalHistoryIdentifier(org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier) Test(org.junit.Test)

Aggregations

LocalHistoryIdentifier (org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier)16 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)5 Test (org.junit.Test)4 LocalHistorySuccess (org.opendaylight.controller.cluster.access.commands.LocalHistorySuccess)3 Response (org.opendaylight.controller.cluster.access.concepts.Response)3 DeadHistoryException (org.opendaylight.controller.cluster.access.commands.DeadHistoryException)2 TransactionAbortSuccess (org.opendaylight.controller.cluster.access.commands.TransactionAbortSuccess)2 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)2 FrontendIdentifier (org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier)2 SuccessEnvelope (org.opendaylight.controller.cluster.access.concepts.SuccessEnvelope)2 ActorRef (akka.actor.ActorRef)1 HashMap (java.util.HashMap)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 GuardedBy (javax.annotation.concurrent.GuardedBy)1 Before (org.junit.Before)1 CreateLocalHistoryRequest (org.opendaylight.controller.cluster.access.commands.CreateLocalHistoryRequest)1 LocalHistoryRequest (org.opendaylight.controller.cluster.access.commands.LocalHistoryRequest)1 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)1 TransactionRequest (org.opendaylight.controller.cluster.access.commands.TransactionRequest)1