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