X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Futil%2FMdSalRegistrationUtils.java;h=ced0513226c1f5f685cdd422b1cf58f18604d587;hb=cfe3a97837951ebbedb337dc988027f10c49f714;hp=70390535baa8042c31b53b368870badeea7e3172;hpb=0712bdd50b485488a540d70b72c62ce6fe1ef5eb;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java index 70390535ba..ced0513226 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -8,24 +8,32 @@ package org.opendaylight.openflowplugin.impl.util; import com.google.common.base.Preconditions; -import com.google.common.base.Verify; -import com.google.common.reflect.TypeToken; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.CheckForNull; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import javax.annotation.Nonnull; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext; import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator; -import org.opendaylight.openflowplugin.impl.services.FlowCapableTransactionServiceImpl; -import org.opendaylight.openflowplugin.impl.services.NodeConfigServiceImpl; -import org.opendaylight.openflowplugin.impl.services.PacketProcessingServiceImpl; -import org.opendaylight.openflowplugin.impl.services.SalEchoServiceImpl; -import org.opendaylight.openflowplugin.impl.services.SalExperimenterMessageServiceImpl; -import org.opendaylight.openflowplugin.impl.services.SalFlowServiceImpl; -import org.opendaylight.openflowplugin.impl.services.SalGroupServiceImpl; -import org.opendaylight.openflowplugin.impl.services.SalMeterServiceImpl; -import org.opendaylight.openflowplugin.impl.services.SalPortServiceImpl; -import org.opendaylight.openflowplugin.impl.services.SalTableServiceImpl; +import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider; +import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider; +import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory; +import org.opendaylight.openflowplugin.impl.services.sal.FlowCapableTransactionServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.NodeConfigServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.PacketProcessingServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalAsyncConfigServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalBundleServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalEchoServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalExperimenterMessageServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalExperimenterMpMessageServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalFlatBatchServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalFlowServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalFlowsBatchServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalGroupServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalGroupsBatchServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalMeterServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalMetersBatchServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalPortServiceImpl; +import org.opendaylight.openflowplugin.impl.services.sal.SalTableServiceImpl; import org.opendaylight.openflowplugin.impl.statistics.services.OpendaylightFlowStatisticsServiceImpl; import org.opendaylight.openflowplugin.impl.statistics.services.OpendaylightFlowTableStatisticsServiceImpl; import org.opendaylight.openflowplugin.impl.statistics.services.OpendaylightGroupStatisticsServiceImpl; @@ -33,8 +41,16 @@ import org.opendaylight.openflowplugin.impl.statistics.services.OpendaylightMete import org.opendaylight.openflowplugin.impl.statistics.services.OpendaylightPortStatisticsServiceImpl; import org.opendaylight.openflowplugin.impl.statistics.services.OpendaylightQueueStatisticsServiceImpl; import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.OpendaylightFlowStatisticsServiceDelegateImpl; +import org.opendaylight.openflowplugin.impl.statistics.services.direct.OpendaylightDirectStatisticsServiceImpl; +import org.opendaylight.openflowplugin.impl.statistics.services.direct.multilayer.MultiLayerDirectStatisticsProviderInitializer; +import org.opendaylight.openflowplugin.impl.statistics.services.direct.singlelayer.SingleLayerDirectStatisticsProviderInitializer; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; +import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.SalAsyncConfigService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService; import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SalEchoService; import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SalExperimenterMessageService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SalExperimenterMpMessageService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService; @@ -44,6 +60,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111. import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService; import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.SalBundleService; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService; @@ -51,117 +68,133 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216. import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService; -public class MdSalRegistrationUtils { +public final class MdSalRegistrationUtils { //TODO: Make one register and one unregister method for all services - - private static final TypeToken> COMPOSITE_SERVICE_TYPE_TOKEN = - new TypeToken>() { - //NOBODY - }; - private MdSalRegistrationUtils() { throw new IllegalStateException(); } /** - * Method registers all OF services for role {@link OfpRole#BECOMEMASTER} - * @param rpcContext - registration processing is implemented in {@link RpcContext} - * @param deviceContext - every service needs {@link DeviceContext} as input parameter - * @param newRole - role validation for {@link OfpRole#BECOMEMASTER} + * 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 registerMasterServices(@CheckForNull final RpcContext rpcContext, - @CheckForNull final DeviceContext deviceContext, @CheckForNull final OfpRole newRole) { - Preconditions.checkArgument(rpcContext != null); - Preconditions.checkArgument(deviceContext != null); - Preconditions.checkArgument(newRole != null); - Verify.verify(OfpRole.BECOMEMASTER.equals(newRole), "Service call with bad Role {} we expect role BECOMEMASTER", newRole); + 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); - rpcContext.registerRpcServiceImplementation(SalEchoService.class, new SalEchoServiceImpl(rpcContext, 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); - rpcContext.registerRpcServiceImplementation(SalFlowService.class, new SalFlowServiceImpl(rpcContext, deviceContext)); - //TODO: add constructors with rcpContext and deviceContext to meter, group, table constructors - rpcContext.registerRpcServiceImplementation(FlowCapableTransactionService.class, new FlowCapableTransactionServiceImpl(rpcContext, deviceContext)); - rpcContext.registerRpcServiceImplementation(SalMeterService.class, new SalMeterServiceImpl(rpcContext, deviceContext)); - rpcContext.registerRpcServiceImplementation(SalGroupService.class, new SalGroupServiceImpl(rpcContext, deviceContext)); - rpcContext.registerRpcServiceImplementation(SalTableService.class, new SalTableServiceImpl(rpcContext, deviceContext)); - rpcContext.registerRpcServiceImplementation(SalPortService.class, new SalPortServiceImpl(rpcContext, deviceContext)); - rpcContext.registerRpcServiceImplementation(PacketProcessingService.class, new PacketProcessingServiceImpl(rpcContext, deviceContext)); - rpcContext.registerRpcServiceImplementation(NodeConfigService.class, new NodeConfigServiceImpl(rpcContext, deviceContext)); - rpcContext.registerRpcServiceImplementation(OpendaylightFlowStatisticsService.class, new OpendaylightFlowStatisticsServiceImpl(rpcContext, deviceContext)); - // TODO: experimenter symmetric and multipart message services - rpcContext.registerRpcServiceImplementation(SalExperimenterMessageService.class, new SalExperimenterMessageServiceImpl(rpcContext, deviceContext)); - } + // 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)); - /** - * Method unregisters all services in first step. So we don't need to call {@link MdSalRegistrationUtils#unregisterServices(RpcContext)} - * directly before by change role from {@link OfpRole#BECOMEMASTER} to {@link OfpRole#BECOMESLAVE}. - * Method registers {@link SalEchoService} in next step only because we would like to have SalEchoService as local service for all apps - * to be able actively check connection status for slave connection too. - * @param rpcContext - registration/unregistration processing is implemented in {@link RpcContext} - * @param newRole - role validation for {@link OfpRole#BECOMESLAVE} - */ - public static void registerSlaveServices(@CheckForNull final RpcContext rpcContext, @CheckForNull final OfpRole newRole) { - Preconditions.checkArgument(rpcContext != null); - Preconditions.checkArgument(newRole != null); - Verify.verify(OfpRole.BECOMESLAVE.equals(newRole), "Service call with bad Role {} we expect role BECOMESLAVE", newRole); + // 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))); - unregisterServices(rpcContext); - } + // register flat batch services + rpcContext.registerRpcServiceImplementation(SalFlatBatchService.class, new SalFlatBatchServiceImpl( + new SalFlowsBatchServiceImpl(salFlowService, flowCapableTransactionService), + new SalGroupsBatchServiceImpl(salGroupService, flowCapableTransactionService), + new SalMetersBatchServiceImpl(salMeterService, flowCapableTransactionService) + )); - /** - * Method unregisters all OF services. - * @param rpcContext - unregistration processing is implemented in {@link RpcContext} - */ - public static void unregisterServices(@CheckForNull final RpcContext rpcContext) { - Preconditions.checkArgument(rpcContext != null); + // register experimenter services + rpcContext.registerRpcServiceImplementation(SalExperimenterMessageService.class, + new SalExperimenterMessageServiceImpl(rpcContext, deviceContext, extensionConverterProvider)); + rpcContext.registerRpcServiceImplementation(SalExperimenterMpMessageService.class, + new SalExperimenterMpMessageServiceImpl(rpcContext, deviceContext, extensionConverterProvider)); - rpcContext.unregisterRpcServiceImplementation(SalEchoService.class); - rpcContext.unregisterRpcServiceImplementation(SalFlowService.class); - //TODO: add constructors with rcpContext and deviceContext to meter, group, table constructors - rpcContext.unregisterRpcServiceImplementation(FlowCapableTransactionService.class); - rpcContext.unregisterRpcServiceImplementation(SalMeterService.class); - rpcContext.unregisterRpcServiceImplementation(SalGroupService.class); - rpcContext.unregisterRpcServiceImplementation(SalTableService.class); - rpcContext.unregisterRpcServiceImplementation(SalPortService.class); - rpcContext.unregisterRpcServiceImplementation(PacketProcessingService.class); - rpcContext.unregisterRpcServiceImplementation(NodeConfigService.class); - rpcContext.unregisterRpcServiceImplementation(OpendaylightFlowStatisticsService.class); - // TODO: experimenter symmetric and multipart message services - rpcContext.unregisterRpcServiceImplementation(SalExperimenterMessageService.class); + //register onf extension bundles + rpcContext.registerRpcServiceImplementation(SalBundleService.class, + new SalBundleServiceImpl(new SalExperimenterMessageServiceImpl( + rpcContext, deviceContext, extensionConverterProvider))); } /** * Support deprecated statistic related services for backward compatibility. The only exception from deprecation is * the aggregated flow statistic with match criteria input. * - * @param rpcContext - * @param deviceContext - * @param notificationPublishService - * @param compatibilityXidSeed + * @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 notificationPublishService - notification service + * + * @param convertorExecutor - convertor executor */ public static void registerStatCompatibilityServices(final RpcContext rpcContext, final DeviceContext deviceContext, final NotificationPublishService notificationPublishService, - final AtomicLong compatibilityXidSeed) { + final ConvertorExecutor convertorExecutor) { + + AtomicLong compatibilityXidSeed = new AtomicLong(); // pickup low statistics service final OpendaylightFlowStatisticsService flowStatisticsService = Preconditions.checkNotNull( rpcContext.lookupRpcService(OpendaylightFlowStatisticsService.class)); - Preconditions.checkArgument(COMPOSITE_SERVICE_TYPE_TOKEN.isAssignableFrom(flowStatisticsService.getClass())); + // attach delegate to flow statistics service (to cover all but aggregated stats with match filter input) final OpendaylightFlowStatisticsServiceDelegateImpl flowStatisticsDelegate = - new OpendaylightFlowStatisticsServiceDelegateImpl(rpcContext, deviceContext, notificationPublishService, new AtomicLong()); + new OpendaylightFlowStatisticsServiceDelegateImpl(rpcContext, deviceContext, notificationPublishService, + new AtomicLong(), convertorExecutor); ((Delegator) flowStatisticsService).setDelegate(flowStatisticsDelegate); // register all statistics (deprecated) services rpcContext.registerRpcServiceImplementation(OpendaylightFlowTableStatisticsService.class, - new OpendaylightFlowTableStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService)); + new OpendaylightFlowTableStatisticsServiceImpl(rpcContext, deviceContext, + compatibilityXidSeed, notificationPublishService)); rpcContext.registerRpcServiceImplementation(OpendaylightGroupStatisticsService.class, - new OpendaylightGroupStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService)); + new OpendaylightGroupStatisticsServiceImpl(rpcContext, deviceContext, + compatibilityXidSeed, notificationPublishService, convertorExecutor)); rpcContext.registerRpcServiceImplementation(OpendaylightMeterStatisticsService.class, - new OpendaylightMeterStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService)); + new OpendaylightMeterStatisticsServiceImpl(rpcContext, deviceContext, + compatibilityXidSeed, notificationPublishService, convertorExecutor)); rpcContext.registerRpcServiceImplementation(OpendaylightQueueStatisticsService.class, - new OpendaylightQueueStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService)); + new OpendaylightQueueStatisticsServiceImpl(rpcContext, deviceContext, + compatibilityXidSeed, notificationPublishService)); rpcContext.registerRpcServiceImplementation(OpendaylightPortStatisticsService.class, - new OpendaylightPortStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService)); + new OpendaylightPortStatisticsServiceImpl(rpcContext, deviceContext, + compatibilityXidSeed, notificationPublishService)); } }