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 com.google.common.base.Function;
12 import com.google.common.util.concurrent.JdkFutureAdapters;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import java.util.List;
15 import java.util.concurrent.Future;
16 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
17 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
18 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
19 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
20 import org.opendaylight.openflowplugin.impl.services.CommonService;
21 import org.opendaylight.openflowplugin.impl.services.DataCrate;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
25 import org.opendaylight.yangtools.yang.common.RpcResult;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * Created by Martin Bobak <mbobak@cisco.com> on 4.4.2015.
32 public class StatisticsGatheringService extends CommonService {
34 private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringService.class);
36 public StatisticsGatheringService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
38 super(requestContextStack, deviceContext);
42 public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final MultipartType type) {
43 return handleServiceCall(
44 PRIMARY_CONNECTION, new Function<DataCrate<List<MultipartReply>>, ListenableFuture<RpcResult<Void>>>() {
46 public ListenableFuture<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
47 final Xid xid = data.getRequestContext().getXid();
48 deviceContext.getOpenflowMessageListenerFacade().registerMultipartXid(xid.getValue());
49 MultipartRequestInput multipartRequestInput = MultipartRequestInputFactory.
50 makeMultipartRequestInput(xid.getValue(),
53 final Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
54 .getConnectionAdapter().multipartRequest(multipartRequestInput);
55 return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);