Search in sources :

Example 1 with LocalHistoryRequest

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

the class Shard method handleRequest.

@Nullable
private RequestSuccess<?, ?> handleRequest(final RequestEnvelope envelope, final long now) throws RequestException {
    // We are not the leader, hence we want to fail-fast.
    if (!isLeader() || paused || !isLeaderActive()) {
        LOG.debug("{}: not currently active leader, rejecting request {}. isLeader: {}, isLeaderActive: {}," + "isLeadershipTransferInProgress: {}, paused: {}", persistenceId(), envelope, isLeader(), isLeaderActive(), isLeadershipTransferInProgress(), paused);
        throw new NotLeaderException(getSelf());
    }
    final Request<?, ?> request = envelope.getMessage();
    if (request instanceof TransactionRequest) {
        final TransactionRequest<?> txReq = (TransactionRequest<?>) request;
        final ClientIdentifier clientId = txReq.getTarget().getHistoryId().getClientId();
        return getFrontend(clientId).handleTransactionRequest(txReq, envelope, now);
    } else if (request instanceof LocalHistoryRequest) {
        final LocalHistoryRequest<?> lhReq = (LocalHistoryRequest<?>) request;
        final ClientIdentifier clientId = lhReq.getTarget().getClientId();
        return getFrontend(clientId).handleLocalHistoryRequest(lhReq, envelope, now);
    } else {
        LOG.warn("{}: rejecting unsupported request {}", persistenceId(), request);
        throw new UnsupportedRequestException(request);
    }
}
Also used : NotLeaderException(org.opendaylight.controller.cluster.access.commands.NotLeaderException) ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) LocalHistoryRequest(org.opendaylight.controller.cluster.access.commands.LocalHistoryRequest) UnsupportedRequestException(org.opendaylight.controller.cluster.access.concepts.UnsupportedRequestException) TransactionRequest(org.opendaylight.controller.cluster.access.commands.TransactionRequest) Nullable(javax.annotation.Nullable)

Example 2 with LocalHistoryRequest

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

the class BouncingReconnectForwarder method findCohort.

private ProxyReconnectCohort findCohort(final ConnectionEntry entry) throws CohortNotFoundException {
    final Request<?, ?> request = entry.getRequest();
    final LocalHistoryIdentifier historyId;
    if (request instanceof TransactionRequest) {
        historyId = ((TransactionRequest<?>) request).getTarget().getHistoryId();
    } else if (request instanceof LocalHistoryRequest) {
        historyId = ((LocalHistoryRequest<?>) request).getTarget();
    } else {
        throw new IllegalArgumentException("Unhandled request " + request);
    }
    final ProxyReconnectCohort cohort = cohorts.get(historyId);
    if (cohort == null) {
        LOG.warn("Cohort for request {} not found, aborting it", request);
        throw new CohortNotFoundException(historyId);
    }
    return cohort;
}
Also used : LocalHistoryRequest(org.opendaylight.controller.cluster.access.commands.LocalHistoryRequest) LocalHistoryIdentifier(org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier) TransactionRequest(org.opendaylight.controller.cluster.access.commands.TransactionRequest)

Aggregations

LocalHistoryRequest (org.opendaylight.controller.cluster.access.commands.LocalHistoryRequest)2 TransactionRequest (org.opendaylight.controller.cluster.access.commands.TransactionRequest)2 Nullable (javax.annotation.Nullable)1 NotLeaderException (org.opendaylight.controller.cluster.access.commands.NotLeaderException)1 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)1 LocalHistoryIdentifier (org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier)1 UnsupportedRequestException (org.opendaylight.controller.cluster.access.concepts.UnsupportedRequestException)1