Search in sources :

Example 6 with KeyedInstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier in project controller by opendaylight.

the class RpcbenchmarkProvider method startTest.

@Override
public Future<RpcResult<StartTestOutput>> startTest(final StartTestInput input) {
    LOG.debug("startTest {}", input);
    final RTCClient client;
    final List<RoutedRpcRegistration<?>> rpcRegs = new ArrayList<>();
    switch(input.getOperation()) {
        case ROUTEDRTC:
            List<InstanceIdentifier<?>> routeIid = new ArrayList<>();
            for (int i = 0; i < input.getNumServers().intValue(); i++) {
                GlobalBindingRTCServer server = new GlobalBindingRTCServer();
                RoutedRpcRegistration<RpcbenchPayloadService> routedReg = providerRegistry.addRoutedRpcImplementation(RpcbenchPayloadService.class, server);
                KeyedInstanceIdentifier<RpcRoute, RpcRouteKey> iid = InstanceIdentifier.create(RpcbenchRpcRoutes.class).child(RpcRoute.class, new RpcRouteKey(Integer.toString(i)));
                routeIid.add(iid);
                routedReg.registerPath(NodeContext.class, iid);
                rpcRegs.add(routedReg);
            }
            client = new RoutedBindingRTClient(providerRegistry, input.getPayloadSize().intValue(), routeIid);
            break;
        case GLOBALRTC:
            client = new GlobalBindingRTCClient(providerRegistry, input.getPayloadSize().intValue());
            break;
        default:
            LOG.error("Unsupported server/client type {}", input.getOperation());
            throw new IllegalArgumentException("Unsupported server/client type" + input.getOperation());
    }
    try {
        ExecutorService executor = Executors.newFixedThreadPool(input.getNumClients().intValue());
        final Runnable testRun = () -> client.runTest(input.getIterations().intValue());
        LOG.info("Test Started");
        long startTime = System.nanoTime();
        for (int i = 0; i < input.getNumClients().intValue(); i++) {
            executor.submit(testRun);
        }
        executor.shutdown();
        try {
            executor.awaitTermination(testTimeout, TimeUnit.MINUTES);
        } catch (final InterruptedException e) {
            LOG.error("Out of time: test did not finish within the {} min deadline ", testTimeout);
        }
        long endTime = System.nanoTime();
        LOG.info("Test Done");
        long elapsedTime = endTime - startTime;
        StartTestOutput output = new StartTestOutputBuilder().setRate((long) 0).setGlobalRtcClientError(client.getRpcError()).setGlobalRtcClientOk(client.getRpcOk()).setExecTime(TimeUnit.NANOSECONDS.toMillis(elapsedTime)).setRate((client.getRpcOk() + client.getRpcError()) * 1000000000 / elapsedTime).build();
        return RpcResultBuilder.success(output).buildFuture();
    } finally {
        for (RoutedRpcRegistration<?> routedRpcRegistration : rpcRegs) {
            routedRpcRegistration.close();
        }
    }
}
Also used : RpcRoute(org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.rpcbench.rpc.routes.RpcRoute) RpcbenchRpcRoutes(org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchRpcRoutes) ArrayList(java.util.ArrayList) RoutedRpcRegistration(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration) RpcbenchPayloadService(org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchPayloadService) ExecutorService(java.util.concurrent.ExecutorService) StartTestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.StartTestOutput) StartTestOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.StartTestOutputBuilder) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) RpcRouteKey(org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.rpcbench.rpc.routes.RpcRouteKey)

Example 7 with KeyedInstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method updateBestPaths.

@Override
public void updateBestPaths(final RouteEntryDependenciesContainer entryDependencies, final Identifier routeKey, final WriteTransaction tx) {
    final RIBSupport ribSupport = entryDependencies.getRibSupport();
    final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDependencies.getLocRibTableTarget();
    if (this.bestPathRemoved != null) {
        this.bestPathRemoved.forEach(path -> {
            final Identifier newRouteKey = ribSupport.createNewRouteKey(path.getPathId(), routeKey);
            final InstanceIdentifier routeTarget = ribSupport.createRouteIdentifier(locRibTarget, newRouteKey);
            LOG.debug("Delete route from LocRib {}", routeTarget);
            tx.delete(LogicalDatastoreType.OPERATIONAL, routeTarget);
        });
        this.bestPathRemoved = null;
    }
    if (this.removedPaths != null) {
        this.removedPaths.forEach(removedPath -> {
            final Identifier routeKeyAddPath = ribSupport.createNewRouteKey(removedPath.getPathId(), routeKey);
            final Identifier routeKeyNonAddPath = ribSupport.createNewRouteKey(NON_PATH_ID_VALUE, routeKey);
            fillAdjRibsOut(true, null, null, null, routeKeyNonAddPath, routeKeyAddPath, RouterIds.createPeerId(removedPath.getRouteId()), entryDependencies.getLocalTablesKey(), entryDependencies, tx);
        });
        this.removedPaths = null;
    }
    if (this.newBestPathToBeAdvertised != null) {
        this.newBestPathToBeAdvertised.forEach(path -> addPathToDataStore(entryDependencies, path, isFirstBestPath(this.bestPath.indexOf(path)), routeKey, tx));
        this.newBestPathToBeAdvertised = null;
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)

Example 8 with KeyedInstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method addPathToDataStore.

private void addPathToDataStore(final RouteEntryDependenciesContainer entryDep, final AddPathBestPath path, final boolean isFirstBestPath, final Identifier routeKey, final WriteTransaction tx) {
    final RIBSupport ribSup = entryDep.getRibSupport();
    final Identifier routeKeyAddPath = ribSup.createNewRouteKey(path.getPathId(), routeKey);
    final Identifier routeKeyAddNonPath = ribSup.createNewRouteKey(NON_PATH_ID_VALUE, routeKey);
    final Route routeAddPath = createRoute(ribSup, routeKeyAddPath, path.getPathId(), path);
    final Route routeNonAddPath = createRoute(ribSup, routeKeyAddNonPath, NON_PATH_ID_VALUE, path);
    final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
    final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, routeKeyAddPath);
    LOG.debug("Write route to LocRib {}", routeAddPath);
    tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, routeAddPath);
    fillAdjRibsOut(isFirstBestPath, path.getAttributes(), routeNonAddPath, routeAddPath, routeKeyAddNonPath, routeKeyAddPath, path.getPeerId(), entryDep.getLocalTablesKey(), entryDep, tx);
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 9 with KeyedInstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier in project bgpcep by opendaylight.

the class TopologyStatsProviderImpl method updatePcepStats.

private synchronized void updatePcepStats() {
    final WriteTransaction tx = TopologyStatsProviderImpl.this.transactionChain.newWriteOnlyTransaction();
    for (final Map.Entry<KeyedInstanceIdentifier<Node, NodeKey>, PcepSessionState> entry : this.statsMap.entrySet()) {
        final PcepTopologyNodeStatsAug nodeStatsAug = new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(new PcepSessionStateBuilder(entry.getValue()).build()).build();
        final InstanceIdentifier<PcepTopologyNodeStatsAug> statId = entry.getKey().augmentation(PcepTopologyNodeStatsAug.class);
        tx.put(LogicalDatastoreType.OPERATIONAL, statId, nodeStatsAug);
    }
    tx.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) PcepTopologyNodeStatsAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAugBuilder) PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAug) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState) PcepSessionStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with KeyedInstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier in project openflowplugin by opendaylight.

the class NodeConnectorRefToPortTranslator method fromNodeConnectorRef.

/**
 * Gets port number from {@link NodeConnectorRef}.
 * @param nodeConnectorRef Node connector reference
 * @param version Openflow version
 * @return port number
 */
@SuppressWarnings("unchecked")
@Nullable
public static Long fromNodeConnectorRef(@Nonnull NodeConnectorRef nodeConnectorRef, short version) {
    Preconditions.checkNotNull(nodeConnectorRef);
    Long port = null;
    final InstanceIdentifier<?> value = nodeConnectorRef.getValue();
    if (value instanceof KeyedInstanceIdentifier) {
        KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> identifier = (KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey>) value;
        OpenflowVersion ofVersion = OpenflowVersion.get(version);
        String nodeConnectorId = identifier.getKey().getId().getValue();
        port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, nodeConnectorId);
    }
    return port;
}
Also used : NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) Nullable(javax.annotation.Nullable)

Aggregations

KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)11 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Tables (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables)6 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)5 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Map (java.util.Map)2 Nullable (javax.annotation.Nullable)2 RoutedRpcRegistration (org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration)2 PeerKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.PeerKey)2 MoreObjects (com.google.common.base.MoreObjects)1 ToStringHelper (com.google.common.base.MoreObjects.ToStringHelper)1 Objects (com.google.common.base.Objects)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 CacheLoader (com.google.common.cache.CacheLoader)1 LoadingCache (com.google.common.cache.LoadingCache)1 ImmutableMap (com.google.common.collect.ImmutableMap)1