Search in sources :

Example 1 with CandidateAlreadyRegisteredException

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");
}
Also used : CandidateAlreadyRegisteredException(org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException) Entity(org.opendaylight.mdsal.eos.binding.api.Entity)

Example 2 with CandidateAlreadyRegisteredException

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");
}
Also used : CandidateAlreadyRegisteredException(org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException) Entity(org.opendaylight.mdsal.eos.binding.api.Entity)

Example 3 with CandidateAlreadyRegisteredException

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);
}
Also used : CandidateAlreadyRegisteredException(org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException) RegisterCandidateLocal(org.opendaylight.controller.cluster.datastore.entityownership.messages.RegisterCandidateLocal)

Example 4 with CandidateAlreadyRegisteredException

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();
}
Also used : CandidateAlreadyRegisteredException(org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException) DOMEntityOwnershipCandidateRegistration(org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration) DOMEntity(org.opendaylight.mdsal.eos.dom.api.DOMEntity) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 5 with CandidateAlreadyRegisteredException

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());
    }
}
Also used : CandidateAlreadyRegisteredException(org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException) Entity(org.opendaylight.mdsal.eos.binding.api.Entity)

Aggregations

CandidateAlreadyRegisteredException (org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException)5 Entity (org.opendaylight.mdsal.eos.binding.api.Entity)3 Test (org.junit.Test)1 RegisterCandidateLocal (org.opendaylight.controller.cluster.datastore.entityownership.messages.RegisterCandidateLocal)1 DOMEntity (org.opendaylight.mdsal.eos.dom.api.DOMEntity)1 DOMEntityOwnershipCandidateRegistration (org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1