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 javax.annotation.Nonnull;
13 import javax.annotation.Nullable;
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
15 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
16 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
17 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
18 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
19 import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtil;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
23 public abstract class AbstractMultipartCollectorService<T extends OfHeader>
24 extends AbstractMultipartService<MultipartType, T> {
26 protected AbstractMultipartCollectorService(final RequestContextStack requestContextStack,
27 final DeviceContext deviceContext) {
28 super(requestContextStack, deviceContext);
32 protected FutureCallback<OfHeader> createCallback(RequestContext<List<T>> context, Class<?> requestType) {
33 final FutureCallback<OfHeader> callback = super.createCallback(context, requestType);
35 return new FutureCallback<OfHeader>() {
37 public void onSuccess(@Nullable final OfHeader result) {
38 callback.onSuccess(result);
42 public void onFailure(@Nonnull final Throwable throwable) {
43 // If we failed getting table features, at least create empty tables
44 if (MultipartType.OFPMPTABLEFEATURES.getClass().equals(requestType)) {
45 DeviceInitializationUtil.makeEmptyTables(
48 getDeviceContext().getPrimaryConnectionContext().getFeatures().getTables());
51 callback.onFailure(throwable);
57 protected OfHeader buildRequest(final Xid xid, final MultipartType input) {
58 return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue(),
61 canUseSingleLayerSerialization());