MessageSpy is used in services 62/18762/4
authorMartin Bobak <mbobak@cisco.com>
Tue, 21 Apr 2015 16:22:29 +0000 (18:22 +0200)
committerMartin Bobak <mbobak@cisco.com>
Wed, 22 Apr 2015 08:31:20 +0000 (10:31 +0200)
Change-Id: Ie27d467f2e97fdfda58ff47c83fc3b5215bad2b1
Signed-off-by: Martin Bobak <mbobak@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/CommonService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/OFJResult2RequestCtxFuture.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalPortServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalTableServiceImpl.java

index 94554e5fcd6ed5ed393eff31ba3ce8cc4208ef92..3b9f20ce3a2f74833aecd70d991f54312ba9ff05 100644 (file)
@@ -247,7 +247,11 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable {
                 MultipartType.OFPMPPORTDESC, deviceContext, deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
 
         final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture =
-                Futures.allAsList(Arrays.asList(replyDesc, replyMeterFeature, replyGroupFeatures, replyTableFeatures, replyPortDescription));
+                Futures.allAsList(Arrays.asList(replyDesc,
+                        replyMeterFeature,
+                        replyGroupFeatures,
+//                        replyTableFeatures,
+                        replyPortDescription));
 
         Futures.addCallback(deviceFeaturesFuture, new FutureCallback<List<RpcResult<List<MultipartReply>>>>() {
             @Override
@@ -260,7 +264,11 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable {
                 // FIXME : remove session
             }
         });
-        return Futures.allAsList(Arrays.asList(replyDesc, replyMeterFeature, replyGroupFeatures, replyTableFeatures, replyPortDescription));
+        return Futures.allAsList(Arrays.asList(replyDesc,
+                replyMeterFeature,
+                replyGroupFeatures,
+//                replyTableFeatures,
+                replyPortDescription));
     }
 
     @Override
index 7ab9586fafd606efff0fcd8b814b324ae249693a..321b4747e42e955e8bcd039743544a0454b60073 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext
 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.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -37,6 +38,8 @@ public abstract class CommonService {
     public RequestContextStack requestContextStack;
     public DeviceContext deviceContext;
     public ConnectionAdapter primaryConnectionAdapter;
+    public MessageSpy messageSpy;
+
 
     /**
      * @deprecated use {@link #CommonService(RequestContextStack, DeviceContext)}
@@ -53,6 +56,7 @@ public abstract class CommonService {
         this.datapathId = features.getDatapathId();
         this.version = features.getVersion();
         this.primaryConnectionAdapter = deviceContext.getPrimaryConnectionContext().getConnectionAdapter();
+        this.messageSpy = deviceContext.getMessageSpy();
     }
 
     protected long provideWaitTime() {
@@ -68,7 +72,7 @@ public abstract class CommonService {
         }
 
         final ConnectionContext auxiliaryConnectionContext =
-        deviceContext.getAuxiliaryConnectiobContexts(connectionID);
+                deviceContext.getAuxiliaryConnectiobContexts(connectionID);
         if (auxiliaryConnectionContext != null) {
             return auxiliaryConnectionContext.getConnectionAdapter();
         }
@@ -77,7 +81,7 @@ public abstract class CommonService {
     }
 
     public <T, F> Future<RpcResult<T>> handleServiceCall(final BigInteger connectionID,
-                                                                            final Function<DataCrate<T>, ListenableFuture<RpcResult<F>>> function) {
+                                                         final Function<DataCrate<T>, ListenableFuture<RpcResult<F>>> function) {
         LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
 
         final RequestContext<T> requestContext = requestContextStack.createRequestContext();
@@ -96,6 +100,7 @@ public abstract class CommonService {
             OFJResult2RequestCtxFuture.processResultFromOfJava(resultFromOFLib);
 
         } else {
+            messageSpy.spyMessage(requestContext, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_FAILURE);
             RequestContextUtil.closeRequstContext(requestContext);
         }
         return result;
index 4899279ccb9329e0660ef91d139ccfa86fa0630f..ea3dbd380bad0cac844ee237b6897f4562c696de 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -38,6 +39,8 @@ public class OFJResult2RequestCtxFuture<T> {
             @Override
             public void onSuccess(final RpcResult<F> fRpcResult) {
                 if (!fRpcResult.isSuccessful()) {
+                    deviceContext.getMessageSpy().spyMessage(requestContext, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
+
                     // remove current request from request cache in deviceContext
                     deviceContext.getRequests().remove(requestContext.getXid().getValue());
                     // handle requestContext failure
@@ -57,9 +60,12 @@ public class OFJResult2RequestCtxFuture<T> {
             @Override
             public void onFailure(final Throwable throwable) {
                 if (futureResultFromOfLib.isCancelled()) {
+                    deviceContext.getMessageSpy().spyMessage(requestContext, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
+
                     LOG.trace("Asymmetric message - no response from OF Java expected for XID {}. Closing as successful.", requestContext.getXid().getValue());
                     requestContext.getFuture().set(RpcResultBuilder.<T>success().build());
                 } else {
+                    deviceContext.getMessageSpy().spyMessage(requestContext, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
                     LOG.trace("Exception occured while processing OF Java response for XID {}.", requestContext.getXid().getValue(), throwable);
                     requestContext.getFuture().set(
                             RpcResultBuilder.<T>failed()
index a0cda7447461f90916f04090f340e14f48ee1527..8eb53f2148303fe8e36b92ae9369779a9459e9f1 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowHashFactory;
 import org.opendaylight.openflowplugin.impl.util.FlowUtil;
@@ -45,6 +46,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Upda
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
@@ -108,11 +110,13 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
         Futures.addCallback(future, new FutureCallback() {
             @Override
             public void onSuccess(final Object o) {
+                messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
                 LOG.debug("flow add finished without error, id={}", flowId.getValue());
             }
 
             @Override
             public void onFailure(final Throwable throwable) {
+                messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_FAILURE);
                 deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
                 LOG.trace("Service call for adding flows failed, id={}.", flowId.getValue(), throwable);
             }
@@ -134,12 +138,14 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
                         Futures.addCallback(future, new FutureCallback() {
                             @Override
                             public void onSuccess(final Object o) {
+                                messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
                                 FlowHash flowHash = FlowHashFactory.create(input);
                                 deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
                             }
 
                             @Override
                             public void onFailure(final Throwable throwable) {
+                                messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_FAILURE);
                                 StringBuffer errors = new StringBuffer();
                                 try {
                                     RpcResult<Void> result = future.get();
@@ -189,6 +195,7 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
         Futures.addCallback(future, new FutureCallback() {
             @Override
             public void onSuccess(final Object o) {
+                messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
                 FlowHash flowHash = FlowHashFactory.create(original);
                 deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
 
@@ -201,7 +208,7 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
 
             @Override
             public void onFailure(final Throwable throwable) {
-
+                messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_FAILURE);
             }
         });
         return future;
@@ -270,11 +277,12 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
         return createResultForFlowMod(data, data.getFlowModInputBuilder());
     }
 
-    protected <T> ListenableFuture<RpcResult<Void>> createResultForFlowMod(final DataCrate<T> data, final FlowModInputBuilder flowModInput) {
+    protected <T> ListenableFuture<RpcResult<Void>> createResultForFlowMod(final DataCrate<T> data, final FlowModInputBuilder flowModInputBuilder) {
         final Xid xid = data.getRequestContext().getXid();
-        flowModInput.setXid(xid.getValue());
+        flowModInputBuilder.setXid(xid.getValue());
+        final FlowModInput flowModInput = flowModInputBuilder.build();
         Future<RpcResult<Void>> flowModResult = provideConnectionAdapter(data.getiDConnection()).flowMod(
-                flowModInput.build());
+                flowModInput);
 
         final ListenableFuture<RpcResult<Void>> result = JdkFutureAdapters.listenInPoolThread(flowModResult);
         final RequestContext requestContext = data.getRequestContext();
@@ -284,6 +292,7 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
             public void onSuccess(final RpcResult<Void> voidRpcResult) {
                 if (!voidRpcResult.isSuccessful()) {
                     // remove current request from request cache in deviceContext
+                    messageSpy.spyMessage(flowModInput, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
                     deviceContext.getRequests().remove(requestContext.getXid().getValue());
                     // handle requestContext failure
                     StringBuilder rpcErrors = new StringBuilder();
@@ -303,9 +312,11 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
             @Override
             public void onFailure(final Throwable throwable) {
                 if (result.isCancelled()) {
+                    messageSpy.spyMessage(flowModInput, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
                     LOG.trace("Asymmetric message - no response from OF Java expected for XID {}. Closing as successful.", requestContext.getXid().getValue());
                     requestContext.getFuture().set(RpcResultBuilder.<T>success().build());
                 } else {
+                    messageSpy.spyMessage(flowModInput, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
                     LOG.trace("Exception occured while processing OF Java response for XID {}.", requestContext.getXid().getValue(), throwable);
                     requestContext.getFuture().set(
                             RpcResultBuilder.<T>failed()
index 907ab2a51c53e7a5a97851e1cc9f66f464ae5a6b..6685c4471b27ed48f3c1aedaf7017c6afefb9bdf 100644 (file)
@@ -14,6 +14,7 @@ import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 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.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
@@ -29,6 +30,7 @@ import org.slf4j.Logger;
 
 public class SalGroupServiceImpl extends CommonService implements SalGroupService {
 
+
     public SalGroupServiceImpl(RequestContextStack requestContextStack, DeviceContext deviceContext) {
         super(requestContextStack, deviceContext);
     }
@@ -38,8 +40,8 @@ public class SalGroupServiceImpl extends CommonService implements SalGroupServic
     @Override
     public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
         deviceContext.getDeviceGroupRegistry().store(input.getGroupId());
-        return this.<AddGroupOutput, Void> handleServiceCall( PRIMARY_CONNECTION,
-                 new Function<DataCrate<AddGroupOutput>,ListenableFuture<RpcResult<Void>>>() {
+        return this.<AddGroupOutput, Void>handleServiceCall(PRIMARY_CONNECTION,
+                new Function<DataCrate<AddGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
                     public ListenableFuture<RpcResult<Void>> apply(final DataCrate<AddGroupOutput> data) {
@@ -50,7 +52,7 @@ public class SalGroupServiceImpl extends CommonService implements SalGroupServic
 
     @Override
     public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
-        return this.<UpdateGroupOutput, Void> handleServiceCall(PRIMARY_CONNECTION,
+        return this.<UpdateGroupOutput, Void>handleServiceCall(PRIMARY_CONNECTION,
                 new Function<DataCrate<UpdateGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
@@ -63,7 +65,7 @@ public class SalGroupServiceImpl extends CommonService implements SalGroupServic
     @Override
     public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
         deviceContext.getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
-        return this.<RemoveGroupOutput, Void> handleServiceCall(PRIMARY_CONNECTION,
+        return this.<RemoveGroupOutput, Void>handleServiceCall(PRIMARY_CONNECTION,
                 new Function<DataCrate<RemoveGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
@@ -74,6 +76,7 @@ public class SalGroupServiceImpl extends CommonService implements SalGroupServic
     }
 
     <T> ListenableFuture<RpcResult<Void>> convertAndSend(final Group iputGroup, final DataCrate<T> data) {
+        messageSpy.spyMessage(iputGroup, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
         final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(iputGroup, version, datapathId);
         final Xid xid = data.getRequestContext().getXid();
         ofGroupModInput.setXid(xid.getValue());
index 223778d3cfc06d19bc67c612ae8bd9b95f4d4932..4d17b71c8209b3d40552752e6921cde4fa911aca 100644 (file)
@@ -14,6 +14,7 @@ import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 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.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
@@ -71,6 +72,8 @@ public class SalMeterServiceImpl extends CommonService implements SalMeterServic
     }
 
     <T> ListenableFuture<RpcResult<Void>> convertAndSend(final Meter iputMeter, final DataCrate<T> data) {
+        messageSpy.spyMessage(iputMeter, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
+
         final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(iputMeter, version);
         final Xid xid = data.getRequestContext().getXid();
         ofMeterModInput.setXid(xid.getValue());
index 4a6b441dd138975a62e54ca955a272f6d60ae85e..a7bca88f3809f8b9b4cd4a106e0101524bd98359 100644 (file)
@@ -12,6 +12,7 @@ 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;
@@ -31,6 +32,8 @@ public class SalPortServiceImpl extends CommonService implements SalPortService
                 new Function<DataCrate<UpdatePortOutput>, ListenableFuture<RpcResult<Void>>>() {
                     @Override
                     public ListenableFuture<RpcResult<Void>> apply(final DataCrate<UpdatePortOutput> data) {
+                        messageSpy.spyMessage(input, 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);
index 1a1bcb0e302eba4aac136f3a303e624c29539664..2856da15dfaa16b7c854a2d68e06fd480b0ab17c 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.OFConstants;
 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.TableFeaturesConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
@@ -48,6 +49,7 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
 
             @Override
             public ListenableFuture<RpcResult<UpdateTableOutput>> apply(final DataCrate<UpdateTableOutput> data) {
+                messageSpy.spyMessage(input, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS);
 
                 final SettableFuture<RpcResult<UpdateTableOutput>> result = SettableFuture.create();