当前位置: 首页>>代码示例>>Java>>正文


Java EntityOwnershipState类代码示例

本文整理汇总了Java中org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState的典型用法代码示例。如果您正苦于以下问题:Java EntityOwnershipState类的具体用法?Java EntityOwnershipState怎么用?Java EntityOwnershipState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityOwnershipState类属于org.opendaylight.controller.md.sal.common.api.clustering包,在下文中一共展示了EntityOwnershipState类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInit

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
@Test
public void testInit() throws CandidateAlreadyRegisteredException {
    // Indicate that this is the owner
    when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
            Optional.of(new EntityOwnershipState(true, true)));

    try (SouthboundProvider southboundProvider = new SouthboundProvider(
            getDataBroker(),
            entityOwnershipService,
            Mockito.mock(OvsdbConnection.class),
            Mockito.mock(DOMSchemaService.class),
            Mockito.mock(BindingNormalizedNodeSerializer.class))) {

        // Initiate the session
        southboundProvider.init();

        // Verify that at least one listener was registered
        verify(entityOwnershipService, atLeastOnce()).registerListener(
                anyString(), any(EntityOwnershipListener.class));

        // Verify that a candidate was registered
        verify(entityOwnershipService).registerCandidate(any(Entity.class));
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:25,代码来源:SouthboundProviderTest.java

示例2: testGetDb

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
@Test
public void testGetDb() {
    when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
            Optional.of(new EntityOwnershipState(true, true)));

    try (SouthboundProvider southboundProvider = new SouthboundProvider(
            getDataBroker(),
            entityOwnershipService,
            Mockito.mock(OvsdbConnection.class),
            Mockito.mock(DOMSchemaService.class),
            Mockito.mock(BindingNormalizedNodeSerializer.class))) {

        southboundProvider.init();

        assertEquals(getDataBroker(), SouthboundProvider.getDb());
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:18,代码来源:SouthboundProviderTest.java

示例3: toEntityOwnershipState

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
private Optional<EntityOwnershipState> toEntityOwnershipState(
        Optional<org.opendaylight.mdsal.eos.common.api.EntityOwnershipState> from) {
    if(!from.isPresent()) {
        return Optional.absent();
    }

    org.opendaylight.mdsal.eos.common.api.EntityOwnershipState fromState = from.get();
    return Optional.of(new EntityOwnershipState(
            fromState == org.opendaylight.mdsal.eos.common.api.EntityOwnershipState.IS_OWNER,
            fromState != org.opendaylight.mdsal.eos.common.api.EntityOwnershipState.NO_OWNER));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:LegacyEntityOwnershipServiceAdapter.java

示例4: registerEntityForOwnership

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
private void registerEntityForOwnership(OvsdbConnectionInstance ovsdbConnectionInstance) {

        Entity candidateEntity = getEntityFromConnectionInstance(ovsdbConnectionInstance);
        entityConnectionMap.put(candidateEntity, ovsdbConnectionInstance);
        ovsdbConnectionInstance.setConnectedEntity(candidateEntity);
        try {
            EntityOwnershipCandidateRegistration registration =
                    entityOwnershipService.registerCandidate(candidateEntity);
            ovsdbConnectionInstance.setDeviceOwnershipCandidateRegistration(registration);
            LOG.info("OVSDB entity {} is registered for ownership.", candidateEntity);

            //If entity already has owner, it won't get notification from EntityOwnershipService
            //so cache the connection instances.
            Optional<EntityOwnershipState> ownershipStateOpt =
                    entityOwnershipService.getOwnershipState(candidateEntity);
            if (ownershipStateOpt.isPresent()) {
                EntityOwnershipState ownershipState = ownershipStateOpt.get();
                if (ownershipState.hasOwner() && !ownershipState.isOwner()) {
                    LOG.info("OVSDB entity {} is already owned by other southbound plugin "
                                    + "instance, so *this* instance is NOT an OWNER of the device",
                            ovsdbConnectionInstance.getConnectionInfo());
                    putConnectionInstance(ovsdbConnectionInstance.getMDConnectionInfo(),ovsdbConnectionInstance);
                }
            }
        } catch (CandidateAlreadyRegisteredException e) {
            LOG.warn("OVSDB entity {} was already registered for ownership", candidateEntity, e);
        }

    }
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:30,代码来源:OvsdbConnectionManager.java

示例5: init

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
/**
 * Used by blueprint when starting the container.
 */
public void init() {
    LOG.info("SouthboundProvider Session Initiated");
    this.txInvoker = new TransactionInvokerImpl(db);
    cm = new OvsdbConnectionManager(db,txInvoker,entityOwnershipService, ovsdbConnection, instanceIdentifierCodec);
    ovsdbDataTreeChangeListener = new OvsdbDataTreeChangeListener(db, cm, instanceIdentifierCodec);

    //Register listener for entityOnwership changes
    providerOwnershipChangeListener =
            new SouthboundPluginInstanceEntityOwnershipListener(this,this.entityOwnershipService);

    //register instance entity to get the ownership of the provider
    Entity instanceEntity = new Entity(ENTITY_TYPE, ENTITY_TYPE);
    try {
        Optional<EntityOwnershipState> ownershipStateOpt = entityOwnershipService.getOwnershipState(instanceEntity);
        registration = entityOwnershipService.registerCandidate(instanceEntity);
        if (ownershipStateOpt.isPresent()) {
            EntityOwnershipState ownershipState = ownershipStateOpt.get();
            if (ownershipState.hasOwner() && !ownershipState.isOwner()) {
                ovsdbConnection.registerConnectionListener(cm);
                ovsdbConnection.startOvsdbManager();
                LOG.info("*This* instance of OVSDB southbound provider is set as a SLAVE instance");
            }
        }
    } catch (CandidateAlreadyRegisteredException e) {
        LOG.warn("OVSDB Southbound Provider instance entity {} was already "
                + "registered for ownership", instanceEntity, e);
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:32,代码来源:SouthboundProvider.java

示例6: testInitWithClose

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
@Test
public void testInitWithClose() throws CandidateAlreadyRegisteredException {
    // Indicate that this is the owner
    when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
            Optional.of(new EntityOwnershipState(true, true)));

    try (SouthboundProvider southboundProvider = new SouthboundProvider(
            getDataBroker(),
            entityOwnershipService,
            Mockito.mock(OvsdbConnection.class),
            Mockito.mock(DOMSchemaService.class),
            Mockito.mock(BindingNormalizedNodeSerializer.class))) {

        // Initiate the session
        southboundProvider.init();

        // Verify that at least one listener was registered
        verify(entityOwnershipService, atLeastOnce()).registerListener(
                anyString(), any(EntityOwnershipListener.class));

        // Verify that a candidate was registered
        verify(entityOwnershipService).registerCandidate(any(Entity.class));

        //Close the session
        southboundProvider.close();
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:28,代码来源:SouthboundProviderTest.java

示例7: init

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
/**
 * Used by blueprint when starting the container.
 */
public void init() {
    LOG.info("HwvtepSouthboundProvider Session Initiated");
    txInvoker = new TransactionInvokerImpl(db);
    cm = new HwvtepConnectionManager(db, txInvoker, entityOwnershipService);
    hwvtepDTListener = new HwvtepDataChangeListener(db, cm);
    hwvtepReconciliationManager = new HwvtepReconciliationManager(db, cm);
    //Register listener for entityOnwership changes
    providerOwnershipChangeListener =
            new HwvtepsbPluginInstanceEntityOwnershipListener(this,this.entityOwnershipService);

    //register instance entity to get the ownership of the provider
    Entity instanceEntity = new Entity(ENTITY_TYPE, ENTITY_TYPE);
    try {
        Optional<EntityOwnershipState> ownershipStateOpt = entityOwnershipService.getOwnershipState(instanceEntity);
        registration = entityOwnershipService.registerCandidate(instanceEntity);
        if (ownershipStateOpt.isPresent()) {
            EntityOwnershipState ownershipState = ownershipStateOpt.get();
            if (ownershipState.hasOwner() && !ownershipState.isOwner()) {
                ovsdbConnection.registerConnectionListener(cm);
                ovsdbConnection.startOvsdbManager();
            }
        }
    } catch (CandidateAlreadyRegisteredException e) {
        LOG.warn("HWVTEP Southbound Provider instance entity {} was already "
                + "registered for ownership", instanceEntity, e);
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:31,代码来源:HwvtepSouthboundProvider.java

示例8: registerEntityForOwnership

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
private void registerEntityForOwnership(HwvtepConnectionInstance hwvtepConnectionInstance) {

        Entity candidateEntity = getEntityFromConnectionInstance(hwvtepConnectionInstance);
        entityConnectionMap.put(candidateEntity, hwvtepConnectionInstance);
        hwvtepConnectionInstance.setConnectedEntity(candidateEntity);

        try {
            EntityOwnershipCandidateRegistration registration =
                    entityOwnershipService.registerCandidate(candidateEntity);
            hwvtepConnectionInstance.setDeviceOwnershipCandidateRegistration(registration);
            LOG.info("HWVTEP entity {} is registered for ownership.", candidateEntity);

            //If entity already has owner, it won't get notification from EntityOwnershipService
            //so cache the connection instances.
            Optional<EntityOwnershipState> ownershipStateOpt =
                    entityOwnershipService.getOwnershipState(candidateEntity);
            if (ownershipStateOpt.isPresent()) {
                EntityOwnershipState ownershipState = ownershipStateOpt.get();
                if (ownershipState.hasOwner() && !ownershipState.isOwner()) {
                    if (getConnectionInstance(hwvtepConnectionInstance.getMDConnectionInfo()) != null) {
                        LOG.info("OVSDB entity {} is already owned by other southbound plugin "
                                + "instance, so *this* instance is NOT an OWNER of the device",
                                hwvtepConnectionInstance.getConnectionInfo());
                        putConnectionInstance(hwvtepConnectionInstance.getMDConnectionInfo(),hwvtepConnectionInstance);
                    }
                }
            }
        } catch (CandidateAlreadyRegisteredException e) {
            LOG.warn("OVSDB entity {} was already registered for ownership", candidateEntity, e);
        }

    }
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:33,代码来源:HwvtepConnectionManager.java

示例9: getOwnershipState

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
@Override
public Optional<EntityOwnershipState> getOwnershipState(Entity forEntity) {
    return toEntityOwnershipState(domService.getOwnershipState(toDOMEntity(forEntity)));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:LegacyEntityOwnershipServiceAdapter.java

示例10: getOwnershipState

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
@Override
public Optional<EntityOwnershipState> getOwnershipState(Entity forEntity) {
    return Optional.of(STATE);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:TestEntityOwnershipService.java

示例11: testHandleOwnershipChange

import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; //导入依赖的package包/类
@Test
public void testHandleOwnershipChange() throws ReadFailedException {
    when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
            Optional.of(new EntityOwnershipState(false, true)));
    Entity entity = new Entity("ovsdb-southbound-provider", "ovsdb-southbound-provider");
    KeyedInstanceIdentifier<Topology, TopologyKey> topologyIid = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));

    try (SouthboundProvider southboundProvider = new SouthboundProvider(
            getDataBroker(),
            entityOwnershipService,
            Mockito.mock(OvsdbConnection.class),
            Mockito.mock(DOMSchemaService.class),
            Mockito.mock(BindingNormalizedNodeSerializer.class))) {

        southboundProvider.init();

        // At this point the OVSDB topology must not be present in either tree
        assertFalse(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
                topologyIid).checkedGet().isPresent());
        assertFalse(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
                topologyIid).checkedGet().isPresent());

        // Become owner
        southboundProvider.handleOwnershipChange(new EntityOwnershipChange(entity, false, true, true));

        // Now the OVSDB topology must be present in both trees
        assertTrue(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
                topologyIid).checkedGet().isPresent());
        assertTrue(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
                topologyIid).checkedGet().isPresent());

        // Verify idempotency
        southboundProvider.handleOwnershipChange(new EntityOwnershipChange(entity, false, true, true));

        // The OVSDB topology must be present in both trees
        assertTrue(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
                topologyIid).checkedGet().isPresent());
        assertTrue(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
                topologyIid).checkedGet().isPresent());
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:44,代码来源:SouthboundProviderTest.java


注:本文中的org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。