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
8 package org.opendaylight.openflowplugin.impl.services;
10 import com.google.common.base.Function;
11 import com.google.common.util.concurrent.JdkFutureAdapters;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.concurrent.Future;
14 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
15 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
23 import org.opendaylight.yangtools.yang.common.RpcResult;
24 import org.slf4j.Logger;
26 public class SalPortServiceImpl extends CommonService implements SalPortService {
27 private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalPortServiceImpl.class);
30 public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
31 return this.<UpdatePortOutput, Void> handleServiceCall(PRIMARY_CONNECTION,
32 new Function<DataCrate<UpdatePortOutput>, ListenableFuture<RpcResult<Void>>>() {
34 public ListenableFuture<RpcResult<Void>> apply(final DataCrate<UpdatePortOutput> data) {
35 messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
37 final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
38 final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, version);
39 final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
40 final Xid xid = data.getRequestContext().getXid();
41 mdInput.setXid(xid.getValue());
42 return JdkFutureAdapters.listenInPoolThread(provideConnectionAdapter(data.getiDConnection()).portMod(mdInput.build()));