2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
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;
27 * The Flow direct statistics service.
29 public abstract class AbstractFlowDirectStatisticsService<T extends OfHeader>
30 extends AbstractDirectStatisticsService<GetFlowStatisticsInput, GetFlowStatisticsOutput, T> {
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);
40 * Get flow ID from #{@link org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry} or
42 * @param flowStatistics flow statistics
43 * @return generated flow ID
45 protected FlowId generateFlowId(final FlowAndStatisticsMapList flowStatistics) {
46 final FlowStatisticsDataBuilder flowStatisticsDataBld = new FlowStatisticsDataBuilder()
47 .setFlowStatistics(new FlowStatisticsBuilder(flowStatistics).build());
49 final FlowBuilder flowBuilder = new FlowBuilder(flowStatistics)
50 .withKey(FlowRegistryKeyFactory.DUMMY_FLOW_KEY)
51 .addAugmentation(flowStatisticsDataBld.build());
53 final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(getVersion(), flowBuilder.build());
55 getDeviceRegistry().getDeviceFlowRegistry().store(flowRegistryKey);
56 return getDeviceRegistry().getDeviceFlowRegistry().retrieveDescriptor(flowRegistryKey).getFlowId();