You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2020/01/14 09:59:27 UTC

[cassandra-diff] branch master updated: Allow diff tool to run in-jvm multiple times, and resolve some conflicting shading

This is an automated email from the ASF dual-hosted git repository.

marcuse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cassandra-diff.git


The following commit(s) were added to refs/heads/master by this push:
     new b933540  Allow diff tool to run in-jvm multiple times, and resolve some conflicting shading
b933540 is described below

commit b933540469dfccc48e2c35a93cd6807784feb16b
Author: Doug Rohrer <dr...@apple.com>
AuthorDate: Tue Jan 7 14:58:09 2020 -0500

    Allow diff tool to run in-jvm multiple times, and resolve some conflicting shading
    
    closes #4
---
 .../java/org/apache/cassandra/diff/DiffJob.java    |  3 ++
 .../java/org/apache/cassandra/diff/Differ.java     |  3 ++
 .../org/apache/cassandra/diff/JobMetadataDb.java   | 33 ++++++++++++++++------
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/spark-job/src/main/java/org/apache/cassandra/diff/DiffJob.java b/spark-job/src/main/java/org/apache/cassandra/diff/DiffJob.java
index bb14c25..26a74e6 100644
--- a/spark-job/src/main/java/org/apache/cassandra/diff/DiffJob.java
+++ b/spark-job/src/main/java/org/apache/cassandra/diff/DiffJob.java
@@ -149,7 +149,10 @@ public class DiffJob {
             throw new RuntimeException("Diff job failed", e);
         } finally {
             if (sc.isLocal())
+            {
                 Differ.shutdown();
+                JobMetadataDb.ProgressTracker.resetStatements();
+            }
         }
     }
 
diff --git a/spark-job/src/main/java/org/apache/cassandra/diff/Differ.java b/spark-job/src/main/java/org/apache/cassandra/diff/Differ.java
index 49576a2..2272b44 100644
--- a/spark-job/src/main/java/org/apache/cassandra/diff/Differ.java
+++ b/spark-job/src/main/java/org/apache/cassandra/diff/Differ.java
@@ -307,14 +307,17 @@ public class Differ implements Serializable
             if (srcDiffCluster != null) {
                 srcDiffCluster.stop();
                 srcDiffCluster.close();
+                srcDiffCluster = null;
             }
             if (targetDiffCluster != null) {
                 targetDiffCluster.stop();
                 targetDiffCluster.close();
+                targetDiffCluster = null;
             }
             if (journalSession != null) {
                 journalSession.close();
                 journalSession.getCluster().close();
+                journalSession = null;
             }
             COMPARISON_EXECUTOR.shutdown();
         }
diff --git a/spark-job/src/main/java/org/apache/cassandra/diff/JobMetadataDb.java b/spark-job/src/main/java/org/apache/cassandra/diff/JobMetadataDb.java
index 0ac6521..1eb121c 100644
--- a/spark-job/src/main/java/org/apache/cassandra/diff/JobMetadataDb.java
+++ b/spark-job/src/main/java/org/apache/cassandra/diff/JobMetadataDb.java
@@ -129,6 +129,15 @@ public class JobMetadataDb {
 
         }
 
+        public static void resetStatements()
+        {
+            updateStmt = null;
+            mismatchStmt = null;
+            errorSummaryStmt = null;
+            errorDetailStmt = null;
+            updateCompleteStmt = null;
+        }
+
         /**
          *
          * @param table
@@ -400,15 +409,23 @@ public class JobMetadataDb {
 
 
         public void markNotRunning(UUID jobId) {
-            logger.info("Marking job {} as not running", jobId);
-
-            ResultSet rs = session.execute(String.format("DELETE FROM %s.%s WHERE job_id = ? IF EXISTS",
-                                                         keyspace, Schema.RUNNING_JOBS),
-                                           jobId);
-            if (!rs.one().getBool("[applied]")) {
-                logger.warn("Non-fatal: Unable to mark job %s as not running, check logs for errors " +
-                            "during initialization as there may be no entry for this job in the {} table",
+            try
+            {
+                logger.info("Marking job {} as not running", jobId);
+
+                ResultSet rs = session.execute(String.format("DELETE FROM %s.%s WHERE job_id = ? IF EXISTS",
+                        keyspace, Schema.RUNNING_JOBS),
+                        jobId);
+                if (!rs.one().getBool("[applied]"))
+                {
+                    logger.warn("Non-fatal: Unable to mark job %s as not running, check logs for errors " +
+                                    "during initialization as there may be no entry for this job in the {} table",
                             jobId, Schema.RUNNING_JOBS);
+                }
+            } catch (Exception e) {
+                // Because this is called from another exception handler, we don't want to lose the original exception
+                // just because we may not have been able to mark the job as not running. Just log here
+                logger.error("Could not mark job {} as not running.", e);
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org