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);
}
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();
}
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();
}
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);
}
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());
}
Aggregations