[CARBONDATA-3616]: Load and drop table operations fail when index server is stopped with indexserver
and prepriming property enabled

Modification Reason: If index server is stopped and all it's properties are enabled,
then it tries to connect to the index Server.

Modification Content: Added try catch while prpriming and trying to clear datamaps.

This closes #3506
diff --git a/core/src/main/java/org/apache/carbondata/core/datamap/DataMapUtil.java b/core/src/main/java/org/apache/carbondata/core/datamap/DataMapUtil.java
index a9020e7..1a1200c 100644
--- a/core/src/main/java/org/apache/carbondata/core/datamap/DataMapUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/datamap/DataMapUtil.java
@@ -116,7 +116,14 @@
     DistributableDataMapFormat dataMapFormat =
         new DistributableDataMapFormat(carbonTable, validAndInvalidSegmentsInfo.getValidSegments(),
             invalidSegment, true, dataMapToClear);
-    dataMapJob.execute(dataMapFormat);
+    try {
+      dataMapJob.execute(dataMapFormat);
+    } catch (Exception e) {
+      // Consider a scenario where clear datamap job is called from drop table
+      // and index server crashes, in this no exception should be thrown and
+      // drop table should complete.
+      LOGGER.error("Failed to execute Datamap clear Job", e);
+    }
   }
 
   public static void executeClearDataMapJob(CarbonTable carbonTable, String jobClassName)
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/indexserver/PrePrimingListener.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/indexserver/PrePrimingListener.scala
index 4d5e633..0c2e4cf 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/indexserver/PrePrimingListener.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/indexserver/PrePrimingListener.scala
@@ -19,6 +19,7 @@
 
 import scala.collection.JavaConverters._
 
+import org.apache.carbondata.common.logging.LogServiceFactory
 import org.apache.carbondata.core.datamap.{DistributableDataMapFormat, Segment}
 import org.apache.carbondata.events.{Event, IndexServerLoadEvent,
   OperationContext, OperationEventListener}
@@ -26,6 +27,9 @@
 
 // Listener for the PrePriming Event. This listener calls the index server using an Asynccall
 object PrePrimingEventListener extends OperationEventListener {
+
+  private val LOGGER = LogServiceFactory.getLogService(this.getClass.getName)
+
   override def onEvent(event: Event,
       operationContext: OperationContext): Unit = {
     val prePrimingEvent = event.asInstanceOf[IndexServerLoadEvent]
@@ -40,7 +44,17 @@
       false,
       true)
     if (prePrimingEvent.segment.length != 0) {
-      IndexServer.getClient.getCount(dataMapFormat)
+      try {
+        IndexServer.getClient.getCount(dataMapFormat)
+      }
+      catch {
+        // Consider a scenario where prepriming is in progress and the index server crashes, in
+        // this case since we should not fail the corresponding operation where pre-priming is
+        // triggered. Because prepriming is an optimization for cache loading prior to query,
+        // so no exception should be thrown.
+        case ex: Exception =>
+          LOGGER.error(s"Prepriming failed for table ${carbonTable.getTableName} ", ex)
+      }
     }
   }
 }