X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fservices%2FNodeConfigServiceImpl.java;fp=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fservices%2FNodeConfigServiceImpl.java;h=420dc80827b4209d86296f76fafbe09b12f01436;hb=b55780a64bdcd852e705d01255d837dab8996325;hp=c83cc4143ae132beefd2f9d7ae1bad0995773280;hpb=8f5238390c79f7b36e52b43ecf6229ef3a8438dc;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImpl.java index c83cc4143a..420dc80827 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImpl.java @@ -7,67 +7,37 @@ */ package org.opendaylight.openflowplugin.impl.services; -import com.google.common.util.concurrent.FutureCallback; import java.util.concurrent.Future; -import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; 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.api.openflow.statistics.ofpspecific.MessageSpy; import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService; import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder; -import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -public class NodeConfigServiceImpl extends CommonService implements NodeConfigService { +public final class NodeConfigServiceImpl extends AbstractSimpleService implements NodeConfigService { public NodeConfigServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) { - super(requestContextStack, deviceContext); + super(requestContextStack, deviceContext, SetConfigOutput.class); } @Override public Future> setConfig(final SetConfigInput input) { - final RequestContext requestContext = createRequestContext(); - if (requestContext == null) { - return failedFuture(); - } + return handleServiceCall(input); + } + @Override + protected OfHeader buildRequest(final Xid xid, final SetConfigInput input) { SetConfigInputBuilder builder = new SetConfigInputBuilder(); SwitchConfigFlag flag = SwitchConfigFlag.valueOf(input.getFlag()); - final Xid xid = requestContext.getXid(); builder.setXid(xid.getValue()); builder.setFlags(flag); builder.setMissSendLen(input.getMissSearchLength()); builder.setVersion(getVersion()); - final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput setConfigInput = builder.build(); - - final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider(); - outboundQueue.commitEntry(xid.getValue(), setConfigInput, new FutureCallback() { - @Override - public void onSuccess(final OfHeader ofHeader) { - RpcResultBuilder rpcResultBuilder = RpcResultBuilder.success((SetConfigOutput)ofHeader); - requestContext.setResult(rpcResultBuilder.build()); - RequestContextUtil.closeRequstContext(requestContext); - - getMessageSpy().spyMessage(setConfigInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS); - } - - @Override - public void onFailure(final Throwable throwable) { - RpcResultBuilder rpcResultBuilder = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable); - requestContext.setResult(rpcResultBuilder.build()); - RequestContextUtil.closeRequstContext(requestContext); - - getMessageSpy().spyMessage(setConfigInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE); - } - }); - return requestContext.getFuture(); - + return builder.build(); } }