Search in sources :

Example 1 with ABIVersion

use of org.opendaylight.controller.cluster.access.ABIVersion in project controller by opendaylight.

the class Shard method handleConnectClient.

@SuppressWarnings("checkstyle:IllegalCatch")
private void handleConnectClient(final ConnectClientRequest message) {
    try {
        final ClientIdentifier clientId = message.getTarget();
        final LeaderFrontendState existing = findFrontend(clientId);
        if (existing != null) {
            existing.touch();
        }
        if (!isLeader() || !isLeaderActive()) {
            LOG.info("{}: not currently leader, rejecting request {}. isLeader: {}, isLeaderActive: {}," + "isLeadershipTransferInProgress: {}.", persistenceId(), message, isLeader(), isLeaderActive(), isLeadershipTransferInProgress());
            throw new NotLeaderException(getSelf());
        }
        final ABIVersion selectedVersion = selectVersion(message);
        final LeaderFrontendState frontend;
        if (existing == null) {
            frontend = new LeaderFrontendState(persistenceId(), clientId, store);
            knownFrontends.put(clientId.getFrontendId(), frontend);
            LOG.debug("{}: created state {} for client {}", persistenceId(), frontend, clientId);
        } else {
            frontend = existing;
        }
        frontend.reconnect();
        message.getReplyTo().tell(new ConnectClientSuccess(message.getTarget(), message.getSequence(), getSelf(), ImmutableList.of(), store.getDataTree(), CLIENT_MAX_MESSAGES).toVersion(selectedVersion), ActorRef.noSender());
    } catch (RequestException | RuntimeException e) {
        message.getReplyTo().tell(new Failure(e), ActorRef.noSender());
    }
}
Also used : ConnectClientSuccess(org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess) NotLeaderException(org.opendaylight.controller.cluster.access.commands.NotLeaderException) ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) ABIVersion(org.opendaylight.controller.cluster.access.ABIVersion) RequestException(org.opendaylight.controller.cluster.access.concepts.RequestException) UnsupportedRequestException(org.opendaylight.controller.cluster.access.concepts.UnsupportedRequestException) RuntimeRequestException(org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException) Failure(akka.actor.Status.Failure)

Example 2 with ABIVersion

use of org.opendaylight.controller.cluster.access.ABIVersion in project controller by opendaylight.

the class ExistsTransactionRequestTest method cloneAsVersionTest.

@Test
public void cloneAsVersionTest() throws Exception {
    final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION;
    final ExistsTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion);
    Assert.assertEquals(cloneVersion, clone.getVersion());
    Assert.assertEquals(OBJECT.getPath(), clone.getPath());
    Assert.assertEquals(OBJECT.isSnapshotOnly(), clone.isSnapshotOnly());
}
Also used : ABIVersion(org.opendaylight.controller.cluster.access.ABIVersion) Test(org.junit.Test)

Example 3 with ABIVersion

use of org.opendaylight.controller.cluster.access.ABIVersion in project controller by opendaylight.

the class ReadTransactionRequestTest method cloneAsVersionTest.

@Test
public void cloneAsVersionTest() throws Exception {
    final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION;
    final ReadTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion);
    Assert.assertEquals(cloneVersion, clone.getVersion());
    Assert.assertEquals(OBJECT.getPath(), clone.getPath());
    Assert.assertEquals(OBJECT.isSnapshotOnly(), clone.isSnapshotOnly());
}
Also used : ABIVersion(org.opendaylight.controller.cluster.access.ABIVersion) Test(org.junit.Test)

Aggregations

ABIVersion (org.opendaylight.controller.cluster.access.ABIVersion)3 Test (org.junit.Test)2 Failure (akka.actor.Status.Failure)1 ConnectClientSuccess (org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess)1 NotLeaderException (org.opendaylight.controller.cluster.access.commands.NotLeaderException)1 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)1 RequestException (org.opendaylight.controller.cluster.access.concepts.RequestException)1 RuntimeRequestException (org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException)1 UnsupportedRequestException (org.opendaylight.controller.cluster.access.concepts.UnsupportedRequestException)1