jvpp: added logs for sending and receiving event messages (VPP-982) 16/8516/5
authorMatej Perina <mperina@cisco.com>
Mon, 25 Sep 2017 07:42:42 +0000 (09:42 +0200)
committerDamjan Marion <dmarion.lists@gmail.com>
Tue, 3 Oct 2017 11:04:18 +0000 (11:04 +0000)
Change-Id: I47f9d12d934378f18c6f841b902af2a64ee7b187
Signed-off-by: Matej Perina <mperina@cisco.com>
src/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py
src/vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py
src/vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py
src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py

index 8761eb1..4fe7ab5 100644 (file)
@@ -140,6 +140,8 @@ JNIEXPORT jint JNICALL Java_io_fd_vpp_jvpp_${plugin_name}_JVpp${java_plugin_name
     $msg_initialization
 
     // send message:
+    if (CLIB_DEBUG > 1)
+        clib_warning ("Sending ${field_name} event message");
     vl_msg_api_send_shmem (plugin_main->vl_input_queue, (u8 *)&mp);
     if ((*env)->ExceptionCheck(env)) {
         return JNI_ERR;
@@ -229,6 +231,9 @@ static void vl_api_${handler_name}_t_handler (vl_api_${handler_name}_t * mp)
     jthrowable exc;
     $err_handler
 
+    if (CLIB_DEBUG > 1)
+        clib_warning ("Received ${handler_name} event message");
+
     jmethodID constructor = (*env)->GetMethodID(env, ${class_ref_name}Class, "<init>", "()V");
 
     // User does not have to provide callbacks for all VPP messages.
index 9aaa4c6..3cfc633 100644 (file)
@@ -246,6 +246,9 @@ jvpp_facade_callback_method_template = Template("""
 
         $plugin_package.$callback_package.$callback callback;
         final int replyId = reply.context;
+        if (LOG.isLoggable(java.util.logging.Level.FINE)) {
+            LOG.fine(String.format("Received $callback_dto event message: %s", reply));
+        }
         synchronized(requests) {
             callback = ($plugin_package.$callback_package.$callback) requests.remove(replyId);
         }
@@ -260,6 +263,9 @@ jvpp_facade_callback_notification_method_template = Template("""
     @Override
     @SuppressWarnings("unchecked")
     public void on$callback_dto($plugin_package.$dto_package.$callback_dto notification) {
+        if (LOG.isLoggable(java.util.logging.Level.FINE)) {
+            LOG.fine(String.format("Received $callback_dto event message: %s", notification));
+        }
         notificationCallback.on$callback_dto(notification);
     }
 """)
index 07947e3..b2f8d37 100644 (file)
@@ -31,6 +31,7 @@ public final class FutureJVpp${plugin_name}FacadeCallback implements $plugin_pac
 
     private final java.util.Map<java.lang.Integer, java.util.concurrent.CompletableFuture<? extends $base_package.$dto_package.JVppReply<?>>> requests;
     private final $plugin_package.$notification_package.Global${plugin_name}NotificationCallback notificationCallback;
+    private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(FutureJVpp${plugin_name}FacadeCallback.class.getName());
 
     public FutureJVpp${plugin_name}FacadeCallback(
         final java.util.Map<java.lang.Integer, java.util.concurrent.CompletableFuture<? extends $base_package.$dto_package.JVppReply<?>>> requestMap,
@@ -94,6 +95,9 @@ jvpp_facade_callback_method_template = Template("""
     public void on$callback_dto(final $plugin_package.$dto_package.$callback_dto reply) {
         final java.util.concurrent.CompletableFuture<$base_package.$dto_package.JVppReply<?>> completableFuture;
         final int replyId = reply.context;
+        if (LOG.isLoggable(java.util.logging.Level.FINE)) {
+            LOG.fine(String.format("Received $callback_dto event message: %s", reply));
+        }
         synchronized(requests) {
             completableFuture = (java.util.concurrent.CompletableFuture<$base_package.$dto_package.JVppReply<?>>) requests.get(replyId);
         }
@@ -111,6 +115,9 @@ jvpp_facade_callback_method_template = Template("""
 jvpp_facade_callback_notification_method_template = Template("""
     @Override
     public void on$callback_dto($plugin_package.$dto_package.$callback_dto notification) {
+        if (LOG.isLoggable(java.util.logging.Level.FINE)) {
+            LOG.fine(String.format("Received $callback_dto event message: %s", notification));
+        }
         notificationCallback.on$callback_dto(notification);
     }
 """)
@@ -121,6 +128,9 @@ jvpp_facade_details_callback_method_template = Template("""
     public void on$callback_dto(final $plugin_package.$dto_package.$callback_dto reply) {
         final $base_package.$future_package.AbstractFutureJVppInvoker.CompletableDumpFuture<$plugin_package.$dto_package.$callback_dto_reply_dump> completableFuture;
         final int replyId = reply.context;
+        if (LOG.isLoggable(java.util.logging.Level.FINE)) {
+            LOG.fine(String.format("Received $callback_dto event message: %s", reply));
+        }
         synchronized(requests) {
             completableFuture = ($base_package.$future_package.AbstractFutureJVppInvoker.CompletableDumpFuture<$plugin_package.$dto_package.$callback_dto_reply_dump>) requests.get(replyId);
         }
index 7bf9113..7af70be 100644 (file)
@@ -49,6 +49,7 @@ import java.nio.file.attribute.PosixFilePermission;
 import java.nio.file.attribute.PosixFilePermissions;
 import java.util.Set;
 import java.util.logging.Logger;
+import java.util.logging.Level;
 import $base_package.callback.JVppCallback;
 import $base_package.VppConnection;
 import $base_package.JVppRegistry;
@@ -139,6 +140,9 @@ method_native_template = Template(
 method_impl_template = Template("""    public final int $name($plugin_package.$dto_package.$request request) throws io.fd.vpp.jvpp.VppInvocationException {
         java.util.Objects.requireNonNull(request,"Null request object");
         connection.checkActive();
+        if(LOG.isLoggable(Level.FINE)) {
+            LOG.fine(String.format("Sending $name event message: %s", request));
+        }
         int result=${name}0(request);
         if(result<0){
             throw new io.fd.vpp.jvpp.VppInvocationException("${name}",result);
@@ -151,6 +155,7 @@ no_arg_method_template = Template("""    int $name() throws io.fd.vpp.jvpp.VppIn
 no_arg_method_native_template = Template("""    private static native int ${name}0() throws io.fd.vpp.jvpp.VppInvocationException;""")
 no_arg_method_impl_template = Template("""    public final int $name() throws io.fd.vpp.jvpp.VppInvocationException {
         connection.checkActive();
+        LOG.fine("Sending $name event message");
         int result=${name}0();
         if(result<0){
             throw new io.fd.vpp.jvpp.VppInvocationException("${name}",result);
index 94302d5..66de7a5 100644 (file)
@@ -62,6 +62,7 @@ public final class ${plugin_name}NotificationRegistryImpl implements ${plugin_na
     // TODO add a special NotificationCallback interface and only allow those to be registered
     private final java.util.concurrent.ConcurrentMap<Class<? extends $base_package.$dto_package.JVppNotification>, $base_package.$callback_package.JVppNotificationCallback> registeredCallbacks =
         new java.util.concurrent.ConcurrentHashMap<>();
+    private static java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(${plugin_name}NotificationRegistryImpl.class.getName());
 
     $register_callback_methods
     $handler_methods
@@ -87,6 +88,9 @@ handler_impl_template = Template("""
     @Override
     public void on$notification(
         final $plugin_package.$dto_package.$notification notification) {
+        if (LOG.isLoggable(java.util.logging.Level.FINE)) {
+            LOG.fine(String.format("Received $notification event message: %s", notification));
+        }
         final $base_package.$callback_package.JVppNotificationCallback jVppNotificationCallback = registeredCallbacks.get($plugin_package.$dto_package.$notification.class);
         if (null != jVppNotificationCallback) {
             (($plugin_package.$callback_package.$callback) registeredCallbacks