/** * Copyright (c) 2015 Cisco Systems, Inc. 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.base.Function; import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.Future; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; public class SalPortServiceImpl extends CommonService implements SalPortService { private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalPortServiceImpl.class); @Override public Future> updatePort(final UpdatePortInput input) { return this. handleServiceCall(PRIMARY_CONNECTION, new Function, ListenableFuture>>() { @Override public ListenableFuture> apply(final DataCrate data) { messageSpy.spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS); final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0); final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, version); final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput); final Xid xid = data.getRequestContext().getXid(); mdInput.setXid(xid.getValue()); return JdkFutureAdapters.listenInPoolThread(provideConnectionAdapter(data.getiDConnection()).portMod(mdInput.build())); } }); } }