report exceptions from datastore service with cause (INFRAUTILS-31) 85/72785/1
authorMichael Vorburger <vorburger@redhat.com>
Fri, 8 Jun 2018 09:54:02 +0000 (11:54 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Fri, 8 Jun 2018 09:54:02 +0000 (11:54 +0200)
JIRA: GENIUS-138
Change-Id: Ie0a9f6edeb69e2d4164c51d8340bd4f4a89aefab
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/genius/mdsalutil/diagstatus/internal/DatastoreServiceStatusProvider.java

index 471e85fdd81a8c8ba75f8af8bd65c8f9e1f45409..3c2b0607e4a5bea5014c83fed3c87a62196daff1 100644 (file)
@@ -46,9 +46,9 @@ public class DatastoreServiceStatusProvider implements ServiceStatusProvider {
 
     @Override
     public ServiceDescriptor getServiceDescriptor() {
-        ServiceState dataStoreServiceState;
-        String statusDesc;
         try {
+            ServiceState dataStoreServiceState;
+            String statusDesc;
             Boolean operSyncStatusValue = (Boolean) MBeanUtils.getMBeanAttribute("org.opendaylight.controller:type="
                             + "DistributedOperationalDatastore,Category=ShardManager,name=shard-manager-operational",
                     "SyncStatus");
@@ -67,14 +67,10 @@ public class DatastoreServiceStatusProvider implements ServiceStatusProvider {
                 dataStoreServiceState = ServiceState.ERROR;
                 statusDesc = "Unable to obtain the datastore status (getMBeanAttribute returned null?!)";
             }
+            return new ServiceDescriptor(DATASTORE_SERVICE_NAME, dataStoreServiceState, statusDesc);
         } catch (JMException e) {
             LOG.error("Unable to obtain the datastore status due to JMException", e);
-            dataStoreServiceState = ServiceState.ERROR;
-            statusDesc = "Unable to obtain the datastore status: " + e.getMessage();
-            // TODO use https://jira.opendaylight.org/browse/INFRAUTILS-31 here when available
-            // to report the details of the root cause of the JMX problem to diagstatus consumers.
+            return new ServiceDescriptor(DATASTORE_SERVICE_NAME, e);
         }
-
-        return new ServiceDescriptor(DATASTORE_SERVICE_NAME, dataStoreServiceState, statusDesc);
     }
 }