ekaterinadimitrova2 commented on code in PR #2807:
URL: https://github.com/apache/cassandra/pull/2807#discussion_r1374820936


##########
src/java/org/apache/cassandra/db/SystemKeyspace.java:
##########
@@ -1926,4 +1969,109 @@ public static TopPartitionTracker.StoredTopPartitions 
getTopPartitions(TableMeta
             return TopPartitionTracker.StoredTopPartitions.EMPTY;
         }
     }
+
+    /**
+     * Insert the cluster metadata snapshot into the {@code metadata_snapshot} 
table.
+     *
+     * @param epoch the snapshot epoch
+     * @param period the period to which the snapshot belong
+     * @param snapshot the snapshot to store
+     */
+    public static void storeSnapshot(Epoch epoch, long period, ByteBuffer 
snapshot)
+    {
+        logger.info("Storing snapshot of cluster metadata at epoch {} (period 
{})", epoch, period);
+        String query = String.format("INSERT INTO %s.%s (epoch, period, 
snapshot) VALUES (?, ?, ?)", SchemaConstants.SYSTEM_KEYSPACE_NAME, 
SNAPSHOT_TABLE_NAME);
+        executeInternal(query, epoch.getEpoch(), period, snapshot);
+    }
+
+    /**
+     * Retrieves the cluster metadata snapshot for the specified epoch from 
the {@code metadata_snapshot} table.
+     *
+     * @param epoch the epoch for which the snapshot must be retrieved
+     * @return the cluster metadata snapshot for the specified epoch or {@code 
null} if no snapshot exists for the epoch.
+     */
+    public static ByteBuffer getSnapshot(Epoch epoch)
+    {
+        logger.info("Getting snapshot of epoch = {}", epoch);
+        String query = String.format("SELECT SNAPSHOT FROM %s.%s WHERE epoch = 
?", SchemaConstants.SYSTEM_KEYSPACE_NAME, SNAPSHOT_TABLE_NAME);

Review Comment:
   ```suggestion
           String query = String.format("SELECT snapshot FROM %s.%s WHERE epoch 
= ?", SchemaConstants.SYSTEM_KEYSPACE_NAME, SNAPSHOT_TABLE_NAME);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to