/* * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.openflowplugin.impl.services; import com.google.common.util.concurrent.FutureCallback; import java.util.List; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory; import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; public abstract class AbstractMultipartCollectorService extends AbstractMultipartService { protected AbstractMultipartCollectorService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) { super(requestContextStack, deviceContext); } @Override protected FutureCallback createCallback(final RequestContext> context, final Class requestType) { final FutureCallback callback = super.createCallback(context, requestType); return new FutureCallback<>() { @Override public void onSuccess(final OfHeader result) { callback.onSuccess(result); } @Override public void onFailure(final Throwable throwable) { // If we failed getting table features, at least create empty tables if (MultipartType.OFPMPTABLEFEATURES.getClass().equals(requestType)) { DeviceInitializationUtil.makeEmptyTables( getTxFacade(), getDeviceInfo(), getDeviceContext().getPrimaryConnectionContext().getFeatures().getTables().toJava()); } callback.onFailure(throwable); } }; } @Override protected OfHeader buildRequest(final Xid xid, final MultipartType input) { return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue().toJava(), getVersion(), input, canUseSingleLayerSerialization()); } }