use of org.opendaylight.mdsal.dom.api.DOMActionImplementation in project controller by opendaylight.
the class OpsRegistrar method updateRemoteActionEndpoints.
/**
* Updates the action endpoints, Adding new registrations first before removing previous registrations.
*/
private void updateRemoteActionEndpoints(final Map<Address, Optional<RemoteActionEndpoint>> actionEndpoints) {
/*
* Updating Action providers is a two-step process. We first add the newly-discovered RPCs and then close
* the old registration. This minimizes churn observed by listeners, as they will not observe RPC
* unavailability which would occur if we were to do it the other way around.
*
* Note that when an Action moves from one remote node to another, we also do not want to expose the gap,
* hence we register all new implementations before closing all registrations.
*/
final Collection<ObjectRegistration<?>> prevRegs = new ArrayList<>(actionEndpoints.size());
for (Entry<Address, Optional<RemoteActionEndpoint>> e : actionEndpoints.entrySet()) {
LOG.debug("Updating action registrations for {}", e.getKey());
final ObjectRegistration<DOMActionImplementation> prevReg;
final Optional<RemoteActionEndpoint> maybeEndpoint = e.getValue();
if (maybeEndpoint.isPresent()) {
final RemoteActionEndpoint endpoint = maybeEndpoint.get();
final RemoteActionImplementation impl = new RemoteActionImplementation(endpoint.getRouter(), config);
prevReg = actionRegs.put(e.getKey(), actionProviderService.registerActionImplementation(impl, endpoint.getActions()));
} else {
prevReg = actionRegs.remove(e.getKey());
}
if (prevReg != null) {
prevRegs.add(prevReg);
}
}
prevRegs.forEach(ObjectRegistration::close);
}
Aggregations