Search in sources :

Example 36 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.

the class MultipartRequestOnTheFlyCallbackTest method initialization.

@Before
public void initialization() {
    when(mockedDeviceContext.getMessageSpy()).thenReturn(new MessageIntelligenceAgencyImpl());
    when(mockedNodeId.toString()).thenReturn(DUMMY_NODE_ID);
    when(mockedPrimaryConnection.getNodeId()).thenReturn(mockedNodeId);
    when(mockedPrimaryConnection.getFeatures()).thenReturn(mockedFeaturesReply);
    when(mockedFeaturesReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    when(mockedFeaturesReply.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
    when(mocketGetFeaturesOutput.getTables()).thenReturn(tableId);
    when(mocketGetFeaturesOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    when(mocketGetFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
    when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnection);
    when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
    when(mockedDeviceInfo.getNodeId()).thenReturn(mockedNodeId);
    when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
    when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
    when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
    when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(mockedFlowRegistry);
    when(mockedFlowRegistry.retrieveDescriptor(Matchers.any(FlowRegistryKey.class))).thenReturn(mockedFlowDescriptor);
    final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
    final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
    flowNodeBuilder.setTable(Collections.<Table>emptyList());
    final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
    final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
    when(mockedReadOnlyTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
    when(mockedDeviceContext.getReadTransaction()).thenReturn(mockedReadOnlyTx);
    dummyRequestContext = new AbstractRequestContext<List<MultipartReply>>(DUMMY_XID) {

        @Override
        public void close() {
        // NOOP
        }
    };
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    multipartRequestOnTheFlyCallback = new MultiLayerFlowMultipartRequestOnTheFlyCallback<>(dummyRequestContext, String.class, mockedDeviceContext, dummyEventIdentifier, MultipartWriterProviderFactory.createDefaultProvider(mockedDeviceContext), convertorManager);
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) Optional(com.google.common.base.Optional) MessageIntelligenceAgencyImpl(org.opendaylight.openflowplugin.impl.statistics.ofpspecific.MessageIntelligenceAgencyImpl) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) List(java.util.List) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager) Before(org.junit.Before)

Example 37 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.

the class OpenflowpluginGroupTestServiceProvider method register.

public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(final ProviderContext ctx) {
    RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = ctx.<SalGroupService>addRoutedRpcImplementation(SalGroupService.class, this);
    setGroupRegistration(addRoutedRpcImplementation);
    InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier.<Nodes>builder(Nodes.class);
    NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
    NodeKey nodeKey = new NodeKey(nodeId);
    InstanceIdentifierBuilder<Node> nodeIndentifier = builder1.<Node, NodeKey>child(Node.class, nodeKey);
    InstanceIdentifier<Node> instance = nodeIndentifier.build();
    groupRegistration.registerPath(NodeContext.class, instance);
    RoutedRpcRegistration<SalGroupService> groupRegistration1 = this.getGroupRegistration();
    return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {

        @Override
        protected void removeRegistration() {
            groupRegistration1.close();
        }
    };
}
Also used : AbstractObjectRegistration(org.opendaylight.yangtools.concepts.AbstractObjectRegistration) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) SalGroupService(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 38 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.

the class OpenflowpluginMeterTestServiceProvider method register.

public ObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(final ProviderContext ctx) {
    RoutedRpcRegistration<SalMeterService> addRoutedRpcImplementation = ctx.<SalMeterService>addRoutedRpcImplementation(SalMeterService.class, this);
    setMeterRegistration(addRoutedRpcImplementation);
    InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier.<Nodes>builder(Nodes.class);
    NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
    NodeKey nodeKey = new NodeKey(nodeId);
    InstanceIdentifierBuilder<Node> nodeIndentifier = builder1.<Node, NodeKey>child(Node.class, nodeKey);
    InstanceIdentifier<Node> instance = nodeIndentifier.build();
    meterRegistration.registerPath(NodeContext.class, instance);
    RoutedRpcRegistration<SalMeterService> meterRegistration1 = this.getMeterRegistration();
    return new AbstractObjectRegistration<OpenflowpluginMeterTestServiceProvider>(this) {

        @Override
        protected void removeRegistration() {
            meterRegistration1.close();
        }
    };
}
Also used : AbstractObjectRegistration(org.opendaylight.yangtools.concepts.AbstractObjectRegistration) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) SalMeterService(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 39 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project genius by opendaylight.

the class NodeConnectorStatsImpl method remove.

@Override
protected void remove(InstanceIdentifier<Node> identifier, Node node) {
    NodeId nodeId = node.getId();
    String nodeVal = nodeId.getValue().split(":")[1];
    BigInteger dpId = new BigInteger(nodeVal);
    if (nodes.contains(dpId)) {
        nodes.remove(dpId);
        // remove counters set from node
        Set<Counter> nodeMetricCounterSet = metricsCountersPerNodeMap.remove(dpId);
        if (nodeMetricCounterSet != null) {
            // remove counters
            nodeMetricCounterSet.forEach(UncheckedCloseable::close);
        }
    }
    if (nodes.size() > 0) {
        delayStatsQuery = ifmConfig.getIfmStatsDefPollInterval() / nodes.size();
    } else {
        stopPortStatRequestTask();
        delayStatsQuery = 0;
    }
}
Also used : UncheckedCloseable(org.opendaylight.infrautils.utils.UncheckedCloseable) Counter(org.opendaylight.infrautils.metrics.Counter) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) BigInteger(java.math.BigInteger)

Example 40 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project genius by opendaylight.

the class NodeConnectorStatsImpl method getCounter.

/*
     * This method returns counter and also creates counter if does not exist.
     *
     * @param counterName name of the counter
     * @param switchId datapath-id value
     * @param port port-id value
     * @param aliasId alias-id value
     * @param tableId table-id value of switch
     * @return counter object
     */
private Counter getCounter(String counterName, BigInteger switchId, String port, String aliasId, String tableId) {
    /*
         * Pattern to be followed for key generation:
         *
         * genius.interfacemanager.entitycounter{entitytype=port,switchid=value,portid=value,aliasid=value,
         * name=counterName}
         * genius.interfacemanager.entitycounter{entitytype=flowtable,switchid=value,flowtableid=value,name=counterName}
         */
    Counter counter = null;
    if (port != null) {
        Labeled<Labeled<Labeled<Labeled<Labeled<Counter>>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("genius").module("interfacemanager").id(CounterConstants.CNT_TYPE_ENTITY_CNT_ID).build(), CounterConstants.LBL_KEY_ENTITY_TYPE, CounterConstants.LBL_KEY_SWITCHID, CounterConstants.LBL_KEY_PORTID, CounterConstants.LBL_KEY_ALIASID, CounterConstants.LBL_KEY_COUNTER_NAME);
        counter = labeledCounter.label(CounterConstants.LBL_VAL_ENTITY_TYPE_PORT).label(switchId.toString()).label(port).label(aliasId).label(counterName);
    }
    if (tableId != null) {
        Labeled<Labeled<Labeled<Labeled<Counter>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("genius").module("interfacemanager").id(CounterConstants.CNT_TYPE_ENTITY_CNT_ID).build(), CounterConstants.LBL_KEY_ENTITY_TYPE, CounterConstants.LBL_KEY_SWITCHID, CounterConstants.LBL_KEY_FLOWTBLID, CounterConstants.LBL_KEY_COUNTER_NAME);
        counter = labeledCounter.label(CounterConstants.LBL_VAL_ENTITY_TYPE_FLOWTBL).label(switchId.toString()).label(tableId).label(counterName);
    }
    // create counters set for node if absent.
    // and then populate counter set with counter object
    // which will be needed to close counters when node is removed.
    metricsCountersPerNodeMap.computeIfAbsent(switchId, counterSet -> ConcurrentHashMap.newKeySet()).add(counter);
    return counter;
}
Also used : InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) ScheduledFuture(java.util.concurrent.ScheduledFuture) MetricDescriptor(org.opendaylight.infrautils.metrics.MetricDescriptor) UncheckedCloseable(org.opendaylight.infrautils.utils.UncheckedCloseable) LoggerFactory(org.slf4j.LoggerFactory) AsyncClusteredDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase) GetFlowStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput) PreDestroy(javax.annotation.PreDestroy) Future(java.util.concurrent.Future) InterfaceChildCache(org.opendaylight.genius.interfacemanager.listeners.InterfaceChildCache) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Optional(com.google.common.base.Optional) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Map(java.util.Map) BigInteger(java.math.BigInteger) ThreadFactory(java.util.concurrent.ThreadFactory) GetFlowStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInputBuilder) GetFlowStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput) GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) EntityOwnershipUtils(org.opendaylight.genius.utils.clustering.EntityOwnershipUtils) IfmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.config.rev160406.IfmConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Set(java.util.Set) Executors(java.util.concurrent.Executors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) OpendaylightDirectStatisticsService(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) List(java.util.List) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) Labeled(org.opendaylight.infrautils.metrics.Labeled) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) IfmConstants(org.opendaylight.genius.interfacemanager.IfmConstants) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) Inject(javax.inject.Inject) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Nonnull(javax.annotation.Nonnull) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Logger(org.slf4j.Logger) FutureCallback(com.google.common.util.concurrent.FutureCallback) TimeUnit(java.util.concurrent.TimeUnit) Futures(com.google.common.util.concurrent.Futures) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) PortNameCache(org.opendaylight.genius.interfacemanager.listeners.PortNameCache) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Counter(org.opendaylight.infrautils.metrics.Counter) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) Counter(org.opendaylight.infrautils.metrics.Counter) Labeled(org.opendaylight.infrautils.metrics.Labeled)

Aggregations

Test (org.junit.Test)25 InetSocketAddress (java.net.InetSocketAddress)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)9 Before (org.junit.Before)8 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)8 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)6 Optional (com.google.common.base.Optional)5 ChannelFuture (io.netty.channel.ChannelFuture)5 ChannelHandler (io.netty.channel.ChannelHandler)5 TimeUnit (java.util.concurrent.TimeUnit)5 Channel (io.netty.channel.Channel)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4 Notification (org.opendaylight.yangtools.yang.binding.Notification)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4