Search in sources :

Example 86 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method getPrefixShardRole.

private RpcResult<GetPrefixShardRoleOutput> getPrefixShardRole(final MemberNode memberNode, final InstanceIdentifier<?> identifier, final BindingNormalizedNodeSerializer serializer) throws Exception {
    final GetPrefixShardRoleInput input = new GetPrefixShardRoleInputBuilder().setDataStoreType(DataStoreType.Config).setShardPrefix(identifier).build();
    final ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(), memberNode.operDataStore(), serializer);
    return service.getPrefixShardRole(input).get(10, TimeUnit.SECONDS);
}
Also used : GetPrefixShardRoleInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetPrefixShardRoleInput) GetPrefixShardRoleInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetPrefixShardRoleInputBuilder)

Example 87 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method testChangeMemberVotingStatesForShard.

@Test
public void testChangeMemberVotingStatesForShard() throws Exception {
    String name = "testChangeMemberVotingStatusForShard";
    String moduleShardsConfig = "module-shards-member1-and-2-and-3.conf";
    final MemberNode leaderNode1 = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name).moduleShardsConfig(moduleShardsConfig).datastoreContextBuilder(DatastoreContext.newBuilder().shardHeartbeatIntervalInMillis(300).shardElectionTimeoutFactor(1)).build();
    final MemberNode replicaNode2 = MemberNode.builder(memberNodes).akkaConfig("Member2").testName(name).moduleShardsConfig(moduleShardsConfig).build();
    final MemberNode replicaNode3 = MemberNode.builder(memberNodes).akkaConfig("Member3").testName(name).moduleShardsConfig(moduleShardsConfig).build();
    leaderNode1.configDataStore().waitTillReady();
    replicaNode3.configDataStore().waitTillReady();
    verifyRaftPeersPresent(leaderNode1.configDataStore(), "cars", "member-2", "member-3");
    verifyRaftPeersPresent(replicaNode2.configDataStore(), "cars", "member-1", "member-3");
    verifyRaftPeersPresent(replicaNode3.configDataStore(), "cars", "member-1", "member-2");
    // Invoke RPC service on member-3 to change voting status
    ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(), replicaNode3.operDataStore(), null);
    RpcResult<Void> rpcResult = service3.changeMemberVotingStatesForShard(new ChangeMemberVotingStatesForShardInputBuilder().setShardName("cars").setDataStoreType(DataStoreType.Config).setMemberVotingState(ImmutableList.of(new MemberVotingStateBuilder().setMemberName("member-2").setVoting(FALSE).build(), new MemberVotingStateBuilder().setMemberName("member-3").setVoting(FALSE).build())).build()).get(10, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    verifyVotingStates(leaderNode1.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE), new SimpleEntry<>("member-2", FALSE), new SimpleEntry<>("member-3", FALSE));
    verifyVotingStates(replicaNode2.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE), new SimpleEntry<>("member-2", FALSE), new SimpleEntry<>("member-3", FALSE));
    verifyVotingStates(replicaNode3.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE), new SimpleEntry<>("member-2", FALSE), new SimpleEntry<>("member-3", FALSE));
}
Also used : MemberNode(org.opendaylight.controller.cluster.datastore.MemberNode) MemberVotingStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingStateBuilder) ChangeMemberVotingStatesForShardInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForShardInputBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 88 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method doAddShardReplica.

private static void doAddShardReplica(MemberNode memberNode, String shardName, String... peerMemberNames) throws Exception {
    memberNode.waitForMembersUp(peerMemberNames);
    ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(), memberNode.operDataStore(), null);
    RpcResult<Void> rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setShardName(shardName).setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    verifyRaftPeersPresent(memberNode.configDataStore(), shardName, peerMemberNames);
    Optional<ActorRef> optional = memberNode.operDataStore().getActorContext().findLocalShard(shardName);
    assertFalse("Oper shard present", optional.isPresent());
    rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setShardName(shardName).setDataStoreType(DataStoreType.Operational).build()).get(10, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    verifyRaftPeersPresent(memberNode.operDataStore(), shardName, peerMemberNames);
}
Also used : AddShardReplicaInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddShardReplicaInputBuilder) ActorRef(akka.actor.ActorRef)

Example 89 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.

the class BindingDOMDataTreeChangeServiceAdapterTest method testRegisterDataTreeChangeListener.

@Test
public void testRegisterDataTreeChangeListener() {
    final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
    final DataTreeChangeService service = BindingDOMDataTreeChangeServiceAdapter.create(codec, this.mockDOMService);
    doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), any(DOMDataTreeChangeListener.class));
    final DataTreeIdentifier<Top> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TOP_PATH);
    final TestClusteredDataTreeChangeListener mockClusteredListener = new TestClusteredDataTreeChangeListener();
    service.registerDataTreeChangeListener(treeId, mockClusteredListener);
    verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), isA(ClusteredDOMDataTreeChangeListener.class));
    reset(this.mockDOMService);
    doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), any(DOMDataTreeChangeListener.class));
    final TestDataTreeChangeListener mockNonClusteredListener = new TestDataTreeChangeListener();
    service.registerDataTreeChangeListener(treeId, mockNonClusteredListener);
    verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), not(isA(ClusteredDOMDataTreeChangeListener.class)));
}
Also used : DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) DOMDataTreeIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier) DataTreeChangeService(org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService) DOMDataTreeChangeService(org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top) ClusteredDOMDataTreeChangeListener(org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener) DOMDataTreeChangeListener(org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener) ClusteredDOMDataTreeChangeListener(org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener) Test(org.junit.Test)

Example 90 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project bgpcep by opendaylight.

the class BmpMonitoringStationImpl method closeServiceInstance.

@Override
public synchronized ListenableFuture<Void> closeServiceInstance() {
    LOG.info("BMP Monitor Singleton Service {} instance closed, Monitor Id {}", getIdentifier().getValue(), this.monitorId.getValue());
    if (this.channel != null) {
        this.channel.close().addListener((ChannelFutureListener) future -> {
            Preconditions.checkArgument(future.isSuccess(), "Channel failed to close: %s", future.cause());
            BmpMonitoringStationImpl.this.sessionManager.close();
        });
    }
    final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, this.yangMonitorId);
    LOG.info("BMP monitoring station {} closed.", this.monitorId.getValue());
    return wTx.submit();
}
Also used : Router(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) MonitorId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.MonitorId) LoggerFactory(org.slf4j.LoggerFactory) KeyConstructorUtil.constructKeys(org.opendaylight.protocol.bmp.impl.app.KeyConstructorUtil.constructKeys) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) MonitoredRouter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev171207.odl.bmp.monitors.bmp.monitor.config.MonitoredRouter) Monitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.bmp.monitor.Monitor) Rfc2385Key(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key) InetAddress(java.net.InetAddress) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) BmpMonitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.BmpMonitor) Objects.requireNonNull(java.util.Objects.requireNonNull) ChannelFutureListener(io.netty.channel.ChannelFutureListener) BmpDeployerDependencies(org.opendaylight.protocol.bmp.impl.config.BmpDeployerDependencies) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Nonnull(javax.annotation.Nonnull) Logger(org.slf4j.Logger) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) InetSocketAddress(java.net.InetSocketAddress) QName(org.opendaylight.yangtools.yang.common.QName) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) Ipv4Util(org.opendaylight.protocol.util.Ipv4Util) List(java.util.List) BmpMonitoringStation(org.opendaylight.protocol.bmp.impl.spi.BmpMonitoringStation) BmpDispatcher(org.opendaylight.protocol.bmp.api.BmpDispatcher) DOMDataBroker(org.opendaylight.controller.md.sal.dom.api.DOMDataBroker) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction) Preconditions(com.google.common.base.Preconditions) InetAddresses(com.google.common.net.InetAddresses) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Aggregations

ArrayList (java.util.ArrayList)36 BigInteger (java.math.BigInteger)33 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)21 ExecutionException (java.util.concurrent.ExecutionException)19 CoreException (org.eclipse.core.runtime.CoreException)18 List (java.util.List)15 Test (org.junit.Test)15 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)15 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 BoundServices (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices)12 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)10 ServerPort (org.eclipse.wst.server.core.ServerPort)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)9 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)9