public void execute()

in priam/src/main/java/com/netflix/priam/backupv2/SnapshotMetaTask.java [186:241]


    public void execute() throws Exception {
        if (!CassandraMonitor.hasCassadraStarted()) {
            logger.debug("Cassandra has not started, hence SnapshotMetaService will not run");
            return;
        }

        // Do not allow more than one snapshotMetaService to run at the same time. This is possible
        // as this happens on CRON.
        if (!lock.tryLock()) {
            logger.warn("SnapshotMetaService is already running! Try again later.");
            throw new Exception("SnapshotMetaService already running");
        }

        // Save start snapshot status
        Instant snapshotInstant = clock.instant();
        String token = instanceIdentity.getInstance().getToken();
        BackupMetadata backupMetadata =
                new BackupMetadata(
                        BackupVersion.SNAPSHOT_META_SERVICE,
                        token,
                        new Date(snapshotInstant.toEpochMilli()));
        snapshotStatusMgr.start(backupMetadata);

        try {
            snapshotName = generateSnapshotName(snapshotInstant);
            logger.info("Initializing SnapshotMetaService for taking a snapshot {}", snapshotName);

            // Perform a cleanup of old snapshot meta_v2.json files, if any, as we don't want our
            // disk to be filled by them.
            // These files may be leftover
            // 1) when Priam shutdown in middle of this service and may not be full JSON
            // 2) No permission to upload to backup file system.
            metaProxy.cleanupOldMetaFiles();

            // Take a new snapshot
            cassandraOperations.takeSnapshot(snapshotName);
            backupMetadata.setCassandraSnapshotSuccess(true);

            // Process the snapshot and upload the meta file.
            MetaFileWriterBuilder.UploadStep uploadStep = processSnapshot(snapshotInstant);
            backupMetadata.setSnapshotLocation(
                    config.getBackupPrefix() + File.separator + uploadStep.getRemoteMetaFilePath());
            uploadStep.uploadMetaFile();

            logger.info("Finished processing snapshot meta service");

            // Upload all the files from snapshot
            uploadFiles();
            snapshotStatusMgr.finish(backupMetadata);
        } catch (Exception e) {
            logger.error("Error while executing SnapshotMetaService", e);
            snapshotStatusMgr.failed(backupMetadata);
        } finally {
            lock.unlock();
        }
    }