import java.util.function.Consumer;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
import org.opendaylight.mdsal.eos.common.api.GenericEntity;
import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipCandidateRegistration;
final List<ListenableFuture<Void>> serviceCloseFutureList = new ArrayList<>();
if (hasOwnership) {
for (final ClusterSingletonServiceRegistrationDelegator service : serviceGroup) {
- serviceCloseFutureList.add(service.closeServiceInstance());
+ try {
+ serviceCloseFutureList.add(service.closeServiceInstance());
+ } catch (final RuntimeException e) {
+ LOG.warn("Unexpected exception while closing service: {}, resuming with next..",
+ service.getIdentifier());
+ }
}
hasOwnership = false;
}
Verify.verify(!hasOwnership);
Verify.verify(serviceEntityCandidateReg == null);
serviceEntityCandidateReg = entityOwnershipService.registerCandidate(serviceEntity);
- } catch (final Exception e) {
+ } catch (final RuntimeException | InterruptedException | CandidateAlreadyRegisteredException e) {
LOG.debug("Unexpected error by registration service Provider {}", clusterSingletonGroupIdentifier, e);
needCloseProviderInstance = true;
throw new RuntimeException(e);
if (hasOwnership) {
service.instantiateServiceInstance();
}
- } catch (final Exception e) {
+ } catch (final RuntimeException | InterruptedException e) {
LOG.debug("Unexpected error by registration service Provider {}", clusterSingletonGroupIdentifier, e);
needCloseProviderInstance = true;
throw new RuntimeException(e);
} else {
needCloseProviderInstance = true;
}
- } catch (final Exception e) {
+ } catch (final RuntimeException | InterruptedException e) {
LOG.debug("Unexpected error by registration service Provider {}", clusterSingletonGroupIdentifier, e);
needCloseProviderInstance = true;
throw new RuntimeException(e);
} else {
LOG.debug("Service {} is closed, so don't take leadership", clusterSingletonGroupIdentifier);
}
- } catch (final Exception e) {
+ } catch (final RuntimeException | InterruptedException e) {
LOG.error("Unexpected exception state for service Provider {} in TakeLeadership",
clusterSingletonGroupIdentifier, e);
needCloseProviderInstance = true;
if (hasOwnership) {
Verify.verify(asyncCloseEntityCandidateReg != null);
for (final ClusterSingletonServiceRegistrationDelegator service : serviceGroup) {
- serviceCloseFutureList.add(service.closeServiceInstance());
+ try {
+ serviceCloseFutureList.add(service.closeServiceInstance());
+ } catch (final RuntimeException e) {
+ LOG.error("Unexpected exception while closing service: {}, resuming with next..",
+ service.getIdentifier());
+ }
}
hasOwnership = false;
}
* instance has fully closed prior to relinquishing service ownership.
*/
needReleaseLock = false;
- } catch (final Exception e) {
+ } catch (final InterruptedException e) {
LOG.error("Unexpected exception state for service Provider {} in LostLeadership",
clusterSingletonGroupIdentifier, e);
needCloseProviderInstance = true;