Remove unused routedRpcRegistration
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / direct / AbstractFlowDirectStatisticsService.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
9
10 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
11 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
12 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
13 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
14 import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatisticsBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
25
26 /**
27  * The Flow direct statistics service.
28  */
29 public abstract class AbstractFlowDirectStatisticsService<T extends OfHeader>
30         extends AbstractDirectStatisticsService<GetFlowStatisticsInput, GetFlowStatisticsOutput, T> {
31
32     protected AbstractFlowDirectStatisticsService(final RequestContextStack requestContextStack,
33                                                   final DeviceContext deviceContext,
34                                                   final ConvertorExecutor convertorExecutor,
35                                                   final MultipartWriterProvider statisticsWriterProvider) {
36         super(MultipartType.OFPMPFLOW, requestContextStack, deviceContext, convertorExecutor, statisticsWriterProvider);
37     }
38
39     /**
40      * Get flow ID from #{@link org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry} or
41      * create alien ID.
42      * @param flowStatistics flow statistics
43      * @return generated flow ID
44      */
45     protected FlowId generateFlowId(final FlowAndStatisticsMapList flowStatistics) {
46         final FlowStatisticsDataBuilder flowStatisticsDataBld = new FlowStatisticsDataBuilder()
47                 .setFlowStatistics(new FlowStatisticsBuilder(flowStatistics).build());
48
49         final FlowBuilder flowBuilder = new FlowBuilder(flowStatistics)
50             .withKey(FlowRegistryKeyFactory.DUMMY_FLOW_KEY)
51             .addAugmentation(flowStatisticsDataBld.build());
52
53         final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(getVersion(), flowBuilder.build());
54
55         getDeviceRegistry().getDeviceFlowRegistry().store(flowRegistryKey);
56         return getDeviceRegistry().getDeviceFlowRegistry().retrieveDescriptor(flowRegistryKey).getFlowId();
57     }
58
59 }