Search in sources :

Example 1 with FrontendIdentifier

use of org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier in project controller by opendaylight.

the class FrontendShardDataTreeSnapshotMetadataTest method createFrontedClientMetadata.

private static FrontendClientMetadata createFrontedClientMetadata(final long num) {
    final String index = String.valueOf(num);
    final String indexName = "test_" + index;
    final FrontendIdentifier frontendIdentifier = FrontendIdentifier.create(MemberName.forName(indexName), FrontendType.forName(index));
    final ClientIdentifier clientIdentifier = ClientIdentifier.create(frontendIdentifier, num);
    final RangeSet<UnsignedLong> purgedHistories = TreeRangeSet.create();
    purgedHistories.add(Range.closed(UnsignedLong.ZERO, UnsignedLong.ONE));
    final Collection<FrontendHistoryMetadata> currentHistories = Collections.singleton(new FrontendHistoryMetadata(num, num, true, ImmutableMap.of(UnsignedLong.ZERO, Boolean.TRUE), purgedHistories));
    return new FrontendClientMetadata(clientIdentifier, purgedHistories, currentHistories);
}
Also used : ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) UnsignedLong(com.google.common.primitives.UnsignedLong) FrontendIdentifier(org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier)

Example 2 with FrontendIdentifier

use of org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier 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 3 with FrontendIdentifier

use of org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier in project controller by opendaylight.

the class AbstractClientActorTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final FrontendType frontendType = FrontendType.forName(getClass().getSimpleName());
    final FrontendIdentifier frontendId = FrontendIdentifier.create(MEMBER_NAME, frontendType);
    final ClientIdentifier clientId = ClientIdentifier.create(frontendId, 0);
    doReturn(ticker).when(mockActorContext).ticker();
    doReturn(clientId).when(mockActorContext).getIdentifier();
    doReturn(getClass().getSimpleName()).when(mockActorContext).persistenceId();
    doReturn(mockSelf).when(mockActorContext).self();
}
Also used : ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) FrontendType(org.opendaylight.controller.cluster.access.concepts.FrontendType) FrontendIdentifier(org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier) Before(org.junit.Before)

Example 4 with FrontendIdentifier

use of org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier in project controller by opendaylight.

the class ActorBehaviorTest method testRecoveryAfterRestartFrontendIdMismatch.

@Test
public void testRecoveryAfterRestartFrontendIdMismatch() throws Exception {
    system.stop(mockedActor);
    // start actor again
    mockedActor = system.actorOf(MockedActor.props(id, initialBehavior));
    probe.expectMsgClass(MockedSnapshotStore.LoadRequest.class);
    // offer snapshot with incorrect client id
    final SnapshotMetadata metadata = saveRequest.getMetadata();
    final FrontendIdentifier anotherFrontend = FrontendIdentifier.create(MemberName.forName("another"), FrontendType.forName("type-2"));
    final ClientIdentifier incorrectClientId = ClientIdentifier.create(anotherFrontend, 0);
    probe.watch(mockedActor);
    probe.reply(Optional.of(new SelectedSnapshot(metadata, incorrectClientId)));
    // actor should be stopped
    probe.expectTerminated(mockedActor, TIMEOUT);
}
Also used : ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) SelectedSnapshot(akka.persistence.SelectedSnapshot) SnapshotMetadata(akka.persistence.SnapshotMetadata) FrontendIdentifier(org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier) Test(org.junit.Test)

Example 5 with FrontendIdentifier

use of org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier in project controller by opendaylight.

the class Shard method updateAccess.

private Optional<Long> updateAccess(final SimpleShardDataTreeCohort cohort) {
    final FrontendIdentifier frontend = cohort.getIdentifier().getHistoryId().getClientId().getFrontendId();
    final LeaderFrontendState state = knownFrontends.get(frontend);
    if (state == null) {
        // Not tell-based protocol, do nothing
        return Optional.absent();
    }
    if (isIsolatedLeader()) {
        // liveness of frontend when we see it attempting to communicate. Use the last access timer.
        return Optional.of(state.getLastSeenTicks());
    }
    // If this frontend has freshly connected, give it some time to catch up before killing its transactions.
    return Optional.of(state.getLastConnectTicks());
}
Also used : FrontendIdentifier(org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier)

Aggregations

FrontendIdentifier (org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier)9 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)5 Before (org.junit.Before)2 LocalHistoryIdentifier (org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier)2 SelectedSnapshot (akka.persistence.SelectedSnapshot)1 SnapshotMetadata (akka.persistence.SnapshotMetadata)1 UnsignedLong (com.google.common.primitives.UnsignedLong)1 Test (org.junit.Test)1 FrontendType (org.opendaylight.controller.cluster.access.concepts.FrontendType)1 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)1 FrontendClientMetadata (org.opendaylight.controller.cluster.datastore.persisted.FrontendClientMetadata)1