Search in sources :

Example 1 with Entity

use of org.opendaylight.mdsal.eos.binding.api.Entity 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 Entity

use of org.opendaylight.mdsal.eos.binding.api.Entity 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 Entity

use of org.opendaylight.mdsal.eos.binding.api.Entity in project openflowplugin by opendaylight.

the class LLDPDiscoveryUtils method getCurrentOwnershipStatus.

private static java.util.Optional<EntityOwnershipState> getCurrentOwnershipStatus(final EntityOwnershipService eos, final String nodeId) {
    Entity entity = createNodeEntity(nodeId);
    Optional<EntityOwnershipState> ownershipStatus = eos.getOwnershipState(entity);
    if (ownershipStatus.isPresent()) {
        LOG.debug("Fetched ownership status for node {} is {}", nodeId, ownershipStatus.get());
        return java.util.Optional.of(ownershipStatus.get());
    }
    return java.util.Optional.empty();
}
Also used : Entity(org.opendaylight.mdsal.eos.binding.api.Entity) EntityOwnershipState(org.opendaylight.mdsal.eos.common.api.EntityOwnershipState)

Example 4 with Entity

use of org.opendaylight.mdsal.eos.binding.api.Entity in project openflowplugin by opendaylight.

the class ContextChainHolderImplTest method ownershipChangedButHasOwner.

@Test
public void ownershipChangedButHasOwner() throws Exception {
    registration.close();
    contextChainHolder.createContextChain(connectionContext);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_FLOW_REGISTRY_FILL);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_GATHERING);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.RPC_REGISTRATION);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.MASTER_ON_DEVICE);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_SUBMIT);
    EntityOwnershipChange ownershipChange = new EntityOwnershipChange(new Entity(ENTITY_TEST, OPENFLOW_TEST), EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NEW_OWNER);
    contextChainHolder.ownershipChanged(ownershipChange);
    Mockito.verify(deviceManager, Mockito.never()).removeDeviceFromOperationalDS(Mockito.any());
}
Also used : Entity(org.opendaylight.mdsal.eos.binding.api.Entity) EntityOwnershipChange(org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange) Test(org.junit.Test)

Example 5 with Entity

use of org.opendaylight.mdsal.eos.binding.api.Entity in project openflowplugin by opendaylight.

the class ContextChainHolderImplTest method ownershipChanged.

@Test
public void ownershipChanged() throws Exception {
    registration.close();
    contextChainHolder.createContextChain(connectionContext);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_FLOW_REGISTRY_FILL);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_GATHERING);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.RPC_REGISTRATION);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.MASTER_ON_DEVICE);
    contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_SUBMIT);
    EntityOwnershipChange ownershipChange = new EntityOwnershipChange(new Entity(ENTITY_TEST, OPENFLOW_TEST), EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NO_OWNER);
    contextChainHolder.ownershipChanged(ownershipChange);
    Mockito.verify(deviceManager).removeDeviceFromOperationalDS(Mockito.any());
}
Also used : Entity(org.opendaylight.mdsal.eos.binding.api.Entity) EntityOwnershipChange(org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange) Test(org.junit.Test)

Aggregations

Entity (org.opendaylight.mdsal.eos.binding.api.Entity)8 CandidateAlreadyRegisteredException (org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException)3 Test (org.junit.Test)2 EntityOwnershipChange (org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange)2 EntityOwnershipState (org.opendaylight.mdsal.eos.common.api.EntityOwnershipState)1