use of org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException in project netvirt by opendaylight.
the class Ipv6ServiceEosHandler method registerEosListener.
private void registerEosListener() {
listenerRegistration = entityOwnershipService.registerListener(EOS_ENTITY_OWNER, this);
Entity instanceEntity = new Entity(EOS_ENTITY_OWNER, EOS_ENTITY_OWNER);
try {
candidateRegistration = entityOwnershipService.registerCandidate(instanceEntity);
} catch (CandidateAlreadyRegisteredException e) {
LOG.warn("Instance entity {} was already registered", instanceEntity);
}
LOG.trace("Entity ownership registration successful");
}
use of org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException in project netvirt by opendaylight.
the class QosEosHandler method registerQosAlertEosListener.
private void registerQosAlertEosListener() {
listenerRegistration = entityOwnershipService.registerListener(QosConstants.QOS_ALERT_OWNER_ENTITY_TYPE, this);
Entity instanceEntity = new Entity(QosConstants.QOS_ALERT_OWNER_ENTITY_TYPE, QosConstants.QOS_ALERT_OWNER_ENTITY_TYPE);
try {
candidateRegistration = entityOwnershipService.registerCandidate(instanceEntity);
} catch (CandidateAlreadyRegisteredException e) {
LOG.warn("qosalert instance entity {} was already " + "registered for ownership", instanceEntity);
}
LOG.trace("entity ownership registeration successful");
}
use of org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException in project controller by opendaylight.
the class DistributedEntityOwnershipService method registerCandidate.
@Override
public DOMEntityOwnershipCandidateRegistration registerCandidate(final DOMEntity entity) throws CandidateAlreadyRegisteredException {
Preconditions.checkNotNull(entity, "entity cannot be null");
if (registeredEntities.putIfAbsent(entity, entity) != null) {
throw new CandidateAlreadyRegisteredException(entity);
}
RegisterCandidateLocal registerCandidate = new RegisterCandidateLocal(entity);
LOG.debug("Registering candidate with message: {}", registerCandidate);
executeLocalEntityOwnershipShardOperation(registerCandidate);
return new DistributedEntityOwnershipCandidateRegistration(entity, this);
}
use of org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException in project controller by opendaylight.
the class DistributedEntityOwnershipServiceTest method testRegisterCandidate.
@Test
public void testRegisterCandidate() throws Exception {
DistributedEntityOwnershipService service = spy(DistributedEntityOwnershipService.start(dataStore.getActorContext(), EntityOwnerSelectionStrategyConfig.newBuilder().build()));
YangInstanceIdentifier entityId = YangInstanceIdentifier.of(QNAME);
DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
verifyRegisterCandidateLocal(service, entity);
verifyEntityOwnershipCandidateRegistration(entity, reg);
verifyEntityCandidate(service.getLocalEntityOwnershipShard(), ENTITY_TYPE, entityId, dataStore.getActorContext().getCurrentMemberName().getName());
try {
service.registerCandidate(entity);
fail("Expected CandidateAlreadyRegisteredException");
} catch (CandidateAlreadyRegisteredException e) {
// expected
assertEquals("getEntity", entity, e.getEntity());
}
// Register a different entity - should succeed
reset(service);
DOMEntity entity2 = new DOMEntity(ENTITY_TYPE2, entityId);
DOMEntityOwnershipCandidateRegistration reg2 = service.registerCandidate(entity2);
verifyEntityOwnershipCandidateRegistration(entity2, reg2);
verifyEntityCandidate(service.getLocalEntityOwnershipShard(), ENTITY_TYPE2, entityId, dataStore.getActorContext().getCurrentMemberName().getName());
service.close();
}
use of org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException in project genius by opendaylight.
the class ItmProvider method registerEntityForOwnership.
private void registerEntityForOwnership() {
try {
Entity registryCandidate = new Entity(ITMConstants.ITM_CONFIG_ENTITY, ITMConstants.ITM_CONFIG_ENTITY);
entityOwnershipService.registerCandidate(registryCandidate);
} catch (CandidateAlreadyRegisteredException e) {
LOG.error("failed to register entity {} for entity-ownership-service", e.getEntity());
}
}
Aggregations