Search in sources :

Example 1 with MultipartWriterProvider

use of org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider in project openflowplugin by opendaylight.

the class OF13DeviceInitializer method initializeNodeInformation.

@Override
protected Future<Void> initializeNodeInformation(@Nonnull final DeviceContext deviceContext, final boolean switchFeaturesMandatory, final boolean skipTableFeatures, @Nullable final MultipartWriterProvider multipartWriterProvider, @Nullable final ConvertorExecutor convertorExecutor) {
    final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
    final DeviceState deviceState = Preconditions.checkNotNull(deviceContext.getDeviceState());
    final DeviceInfo deviceInfo = Preconditions.checkNotNull(deviceContext.getDeviceInfo());
    final Capabilities capabilities = connectionContext.getFeatures().getCapabilities();
    LOG.debug("Setting capabilities for device {}", deviceInfo);
    DeviceStateUtil.setDeviceStateBasedOnV13Capabilities(deviceState, capabilities);
    // First process description reply, write data to DS and write consequent data if successful
    return Futures.transformAsync(requestMultipart(MultipartType.OFPMPDESC, deviceContext), (AsyncFunction<RpcResult<List<OfHeader>>, Void>) input -> {
        translateAndWriteResult(MultipartType.OFPMPDESC, input.getResult(), deviceContext, multipartWriterProvider, convertorExecutor);
        final List<ListenableFuture<RpcResult<List<OfHeader>>>> futures = new ArrayList<>();
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPMETERFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPGROUPFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPTABLEFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPPORTDESC, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        return Futures.transform(switchFeaturesMandatory ? Futures.allAsList(futures) : Futures.successfulAsList(futures), new Function<List<RpcResult<List<OfHeader>>>, Void>() {

            @Nullable
            @Override
            public Void apply(@Nullable final List<RpcResult<List<OfHeader>>> input) {
                LOG.info("Static node {} successfully finished collecting", deviceContext.getDeviceInfo());
                return null;
            }
        }, MoreExecutors.directExecutor());
    }, MoreExecutors.directExecutor());
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) MultipartWriterProvider(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFeatures) LoggerFactory(org.slf4j.LoggerFactory) MultiLayerMultipartCollectorService(org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerMultipartCollectorService) DeviceState(org.opendaylight.openflowplugin.api.openflow.device.DeviceState) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) DeviceStateUtil(org.opendaylight.openflowplugin.impl.util.DeviceStateUtil) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) SingleLayerMultipartCollectorService(org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerMultipartCollectorService) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) Function(com.google.common.base.Function) Logger(org.slf4j.Logger) MultipartReplyTranslatorUtil(org.opendaylight.openflowplugin.impl.common.MultipartReplyTranslatorUtil) DeviceInitializationUtil(org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtil) Collectors(java.util.stream.Collectors) FutureCallback(com.google.common.util.concurrent.FutureCallback) Objects(java.util.Objects) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) AsyncFunction(com.google.common.util.concurrent.AsyncFunction) Function(com.google.common.base.Function) AsyncFunction(com.google.common.util.concurrent.AsyncFunction) DeviceState(org.opendaylight.openflowplugin.api.openflow.device.DeviceState) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ArrayList(java.util.ArrayList) List(java.util.List) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) Nullable(javax.annotation.Nullable)

Example 2 with MultipartWriterProvider

use of org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider in project openflowplugin by opendaylight.

the class StatisticsManagerImpl method createContext.

@Override
public StatisticsContext createContext(@Nonnull final DeviceContext deviceContext, final boolean useReconciliationFramework) {
    final MultipartWriterProvider statisticsWriterProvider = MultipartWriterProviderFactory.createDefaultProvider(deviceContext);
    final StatisticsContext statisticsContext = new StatisticsContextImpl<>(deviceContext, converterExecutor, statisticsWriterProvider, executorService, config, !isStatisticsFullyDisabled && config.isIsStatisticsPollingOn(), useReconciliationFramework);
    contexts.put(deviceContext.getDeviceInfo(), statisticsContext);
    return statisticsContext;
}
Also used : MultipartWriterProvider(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext)

Example 3 with MultipartWriterProvider

use of org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider in project openflowplugin by opendaylight.

the class MdSalRegistrationUtils method registerServices.

/**
 * Method registers all OF services for role {@link OfpRole#BECOMEMASTER}.
 *
 * @param rpcContext    - registration processing is implemented in
 *        {@link org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext}
 *
 * @param deviceContext - every service needs
 *        {@link org.opendaylight.openflowplugin.api.openflow.device.DeviceContext} as input parameter
 *
 * @param convertorExecutor convertor executor
 */
public static void registerServices(@Nonnull final RpcContext rpcContext, @Nonnull final DeviceContext deviceContext, final ExtensionConverterProvider extensionConverterProvider, final ConvertorExecutor convertorExecutor) {
    // TODO: Use multipart writer provider from device context
    final MultipartWriterProvider multipartWriterProvider = MultipartWriterProviderFactory.createDefaultProvider(deviceContext);
    // create service instances
    final SalFlowServiceImpl salFlowService = new SalFlowServiceImpl(rpcContext, deviceContext, convertorExecutor);
    final FlowCapableTransactionServiceImpl flowCapableTransactionService = new FlowCapableTransactionServiceImpl(rpcContext, deviceContext);
    final SalAsyncConfigServiceImpl salAsyncConfigService = new SalAsyncConfigServiceImpl(rpcContext, deviceContext);
    final SalGroupServiceImpl salGroupService = new SalGroupServiceImpl(rpcContext, deviceContext, convertorExecutor);
    final SalMeterServiceImpl salMeterService = new SalMeterServiceImpl(rpcContext, deviceContext, convertorExecutor);
    // register routed service instances
    rpcContext.registerRpcServiceImplementation(SalEchoService.class, new SalEchoServiceImpl(rpcContext, deviceContext));
    rpcContext.registerRpcServiceImplementation(SalFlowService.class, salFlowService);
    rpcContext.registerRpcServiceImplementation(FlowCapableTransactionService.class, flowCapableTransactionService);
    rpcContext.registerRpcServiceImplementation(SalAsyncConfigService.class, salAsyncConfigService);
    rpcContext.registerRpcServiceImplementation(SalMeterService.class, salMeterService);
    rpcContext.registerRpcServiceImplementation(SalGroupService.class, salGroupService);
    rpcContext.registerRpcServiceImplementation(SalTableService.class, new SalTableServiceImpl(rpcContext, deviceContext, convertorExecutor, multipartWriterProvider));
    rpcContext.registerRpcServiceImplementation(SalPortService.class, new SalPortServiceImpl(rpcContext, deviceContext, convertorExecutor));
    rpcContext.registerRpcServiceImplementation(PacketProcessingService.class, new PacketProcessingServiceImpl(rpcContext, deviceContext, convertorExecutor));
    rpcContext.registerRpcServiceImplementation(NodeConfigService.class, new NodeConfigServiceImpl(rpcContext, deviceContext));
    rpcContext.registerRpcServiceImplementation(OpendaylightFlowStatisticsService.class, OpendaylightFlowStatisticsServiceImpl.createWithOook(rpcContext, deviceContext, convertorExecutor));
    // register direct statistics gathering services
    rpcContext.registerRpcServiceImplementation(OpendaylightDirectStatisticsService.class, new OpendaylightDirectStatisticsServiceImpl(deviceContext.canUseSingleLayerSerialization() ? SingleLayerDirectStatisticsProviderInitializer.createProvider(rpcContext, deviceContext, convertorExecutor, multipartWriterProvider) : MultiLayerDirectStatisticsProviderInitializer.createProvider(rpcContext, deviceContext, convertorExecutor, multipartWriterProvider)));
    // register flat batch services
    rpcContext.registerRpcServiceImplementation(SalFlatBatchService.class, new SalFlatBatchServiceImpl(new SalFlowsBatchServiceImpl(salFlowService, flowCapableTransactionService), new SalGroupsBatchServiceImpl(salGroupService, flowCapableTransactionService), new SalMetersBatchServiceImpl(salMeterService, flowCapableTransactionService)));
    // register experimenter services
    rpcContext.registerRpcServiceImplementation(SalExperimenterMessageService.class, new SalExperimenterMessageServiceImpl(rpcContext, deviceContext, extensionConverterProvider));
    rpcContext.registerRpcServiceImplementation(SalExperimenterMpMessageService.class, new SalExperimenterMpMessageServiceImpl(rpcContext, deviceContext, extensionConverterProvider));
    // register onf extension bundles
    rpcContext.registerRpcServiceImplementation(SalBundleService.class, new SalBundleServiceImpl(new SalExperimenterMessageServiceImpl(rpcContext, deviceContext, extensionConverterProvider)));
}
Also used : SalEchoServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalEchoServiceImpl) SalTableServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalTableServiceImpl) SalFlatBatchServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalFlatBatchServiceImpl) SalGroupServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalGroupServiceImpl) SalExperimenterMessageServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalExperimenterMessageServiceImpl) OpendaylightDirectStatisticsServiceImpl(org.opendaylight.openflowplugin.impl.statistics.services.direct.OpendaylightDirectStatisticsServiceImpl) SalExperimenterMpMessageServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalExperimenterMpMessageServiceImpl) SalPortServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalPortServiceImpl) SalAsyncConfigServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalAsyncConfigServiceImpl) MultipartWriterProvider(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider) SalFlowServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalFlowServiceImpl) FlowCapableTransactionServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.FlowCapableTransactionServiceImpl) SalMeterServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalMeterServiceImpl) SalBundleServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalBundleServiceImpl) SalGroupsBatchServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalGroupsBatchServiceImpl) PacketProcessingServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.PacketProcessingServiceImpl) NodeConfigServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.NodeConfigServiceImpl) SalMetersBatchServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalMetersBatchServiceImpl) SalFlowsBatchServiceImpl(org.opendaylight.openflowplugin.impl.services.sal.SalFlowsBatchServiceImpl)

Aggregations

MultipartWriterProvider (org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider)3 Function (com.google.common.base.Function)1 Preconditions (com.google.common.base.Preconditions)1 AsyncFunction (com.google.common.util.concurrent.AsyncFunction)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Future (java.util.concurrent.Future)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)1 DeviceContext (org.opendaylight.openflowplugin.api.openflow.device.DeviceContext)1 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)1 DeviceState (org.opendaylight.openflowplugin.api.openflow.device.DeviceState)1