2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.services;
10 import com.google.common.util.concurrent.FutureCallback;
11 import java.util.List;
12 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
13 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
14 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
15 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
16 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
17 import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtil;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
21 public abstract class AbstractMultipartCollectorService<T extends OfHeader>
22 extends AbstractMultipartService<MultipartType, T> {
24 protected AbstractMultipartCollectorService(final RequestContextStack requestContextStack,
25 final DeviceContext deviceContext) {
26 super(requestContextStack, deviceContext);
30 protected FutureCallback<OfHeader> createCallback(RequestContext<List<T>> context, Class<?> requestType) {
31 final FutureCallback<OfHeader> callback = super.createCallback(context, requestType);
33 return new FutureCallback<OfHeader>() {
35 public void onSuccess(final OfHeader result) {
36 callback.onSuccess(result);
40 public void onFailure(final Throwable throwable) {
41 // If we failed getting table features, at least create empty tables
42 if (MultipartType.OFPMPTABLEFEATURES.getClass().equals(requestType)) {
43 DeviceInitializationUtil.makeEmptyTables(
46 getDeviceContext().getPrimaryConnectionContext().getFeatures().getTables());
49 callback.onFailure(throwable);
55 protected OfHeader buildRequest(final Xid xid, final MultipartType input) {
56 return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue(),
59 canUseSingleLayerSerialization());