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
9 package org.opendaylight.openflowplugin.impl.statistics.services.dedicated;
11 import java.util.List;
12 import java.util.concurrent.Future;
13 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
14 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
15 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
16 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
17 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer;
18 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
19 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartOnTheFlyService;
20 import org.opendaylight.openflowplugin.impl.services.ServiceException;
21 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCounter;
22 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
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.MultipartReply;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
26 import org.opendaylight.yangtools.yang.common.RpcResult;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * collects statistics and processes them on the fly
33 public class StatisticsGatheringOnTheFlyService extends AbstractMultipartOnTheFlyService<MultipartType> implements StatisticsGatherer {
35 private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringOnTheFlyService.class);
37 public StatisticsGatheringOnTheFlyService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
38 super(requestContextStack, deviceContext, convertorExecutor);
42 public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final EventIdentifier eventIdentifier, final MultipartType type) {
43 LOG.debug("Getting statistics (onTheFly) for node {} of type {}", getDeviceInfo().getNodeId(), type);
44 EventsTimeCounter.markStart(eventIdentifier);
45 setEventIdentifier(eventIdentifier);
46 return handleServiceCall(type);
50 protected OfHeader buildRequest(final Xid xid, final MultipartType input) throws ServiceException {
51 return MultipartRequestInputFactory.makeMultipartRequestInput(xid.getValue(), getVersion(), input);