Search in sources :

Example 6 with ConnectClientSuccess

use of org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess in project controller by opendaylight.

the class AbstractShardBackendResolver method onConnectResponse.

private void onConnectResponse(final String shardName, final long cookie, final CompletableFuture<ShardBackendInfo> future, final Object response, final Throwable failure) {
    if (failure != null) {
        LOG.debug("Connect attempt to {} failed, will retry", shardName, failure);
        future.completeExceptionally(wrap("Connection attempt failed", failure));
        return;
    }
    if (response instanceof RequestFailure) {
        final Throwable cause = ((RequestFailure<?, ?>) response).getCause().unwrap();
        LOG.debug("Connect attempt to {} failed to process", shardName, cause);
        final Throwable result = cause instanceof NotLeaderException ? wrap("Leader moved during establishment", cause) : cause;
        future.completeExceptionally(result);
        return;
    }
    LOG.debug("Resolved backend information to {}", response);
    Preconditions.checkArgument(response instanceof ConnectClientSuccess, "Unhandled response %s", response);
    final ConnectClientSuccess success = (ConnectClientSuccess) response;
    future.complete(new ShardBackendInfo(success.getBackend(), nextSessionId.getAndIncrement(), success.getVersion(), shardName, UnsignedLong.fromLongBits(cookie), success.getDataTree(), success.getMaxMessages()));
}
Also used : ConnectClientSuccess(org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess) NotLeaderException(org.opendaylight.controller.cluster.access.commands.NotLeaderException) RequestFailure(org.opendaylight.controller.cluster.access.concepts.RequestFailure)

Aggregations

ConnectClientSuccess (org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess)6 TestProbe (akka.testkit.TestProbe)4 Test (org.junit.Test)3 NotLeaderException (org.opendaylight.controller.cluster.access.commands.NotLeaderException)2 Failure (akka.actor.Status.Failure)1 Before (org.junit.Before)1 ABIVersion (org.opendaylight.controller.cluster.access.ABIVersion)1 ClientActorContext (org.opendaylight.controller.cluster.access.client.ClientActorContext)1 ConnectClientRequest (org.opendaylight.controller.cluster.access.commands.ConnectClientRequest)1 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)1 RequestException (org.opendaylight.controller.cluster.access.concepts.RequestException)1 RequestFailure (org.opendaylight.controller.cluster.access.concepts.RequestFailure)1 RuntimeRequestException (org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException)1 UnsupportedRequestException (org.opendaylight.controller.cluster.access.concepts.UnsupportedRequestException)1 ActorContext (org.opendaylight.controller.cluster.datastore.utils.ActorContext)1 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)1 DataTree (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree)1 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)1