test_class.declarator: SNAPSHOT_MANAGER_EXECUTOR = Executors.newFixedThreadPool(2)
test_class.modifier: private static final
test_class.original_string: private static final ExecutorService SNAPSHOT_MANAGER_EXECUTOR = Executors.newFixedThreadPool(2);
test_class.type: ExecutorService
test_class.var_name: SNAPSHOT_MANAGER_EXECUTOR
test_class.file: src/server/src/test/java/io/cassandrareaper/service/SnapshotServiceTest.java
test_class.identifier: SnapshotServiceTest
test_case.body: @Test
    public void testClearSnapshotClusterWide()
        throws InterruptedException, ReaperException, ClassNotFoundException, IOException {
  
      JmxProxy proxy = (JmxProxy) mock(Class.forName("io.cassandrareaper.jmx.JmxProxyImpl"));
      StorageServiceMBean storageMBean = Mockito.mock(StorageServiceMBean.class);
      JmxProxyTest.mockGetStorageServiceMBean(proxy, storageMBean);
  
      AppContext cxt = new AppContext();
      cxt.config = TestRepairConfiguration.defaultConfig();
      cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class);
      when(cxt.jmxConnectionFactory.connectAny(any(Collection.class))).thenReturn(proxy);
      ClusterFacade clusterFacadeSpy = Mockito.spy(ClusterFacade.create(cxt));
      Mockito.doReturn(Arrays.asList("127.0.0.1", "127.0.0.2")).when(clusterFacadeSpy).getLiveNodes(any());
      Mockito.doReturn(Arrays.asList("127.0.0.1", "127.0.0.2"))
          .when(clusterFacadeSpy)
          .getLiveNodes(any(), any());
      cxt.storage = mock(IStorage.class);
  
      Cluster cluster = Cluster.builder()
          .withName("testCluster")
          .withPartitioner("murmur3")
          .withSeedHosts(ImmutableSet.of("127.0.0.1"))
          .build();
  
      when(cxt.storage.getCluster(anyString())).thenReturn(cluster);
  
      SnapshotService
          .create(cxt, SNAPSHOT_MANAGER_EXECUTOR, () -> clusterFacadeSpy)
          .clearSnapshotClusterWide("snapshot", "testCluster");
  
      verify(storageMBean, times(2)).clearSnapshot("snapshot");
    }
test_case.class_method_signature: SnapshotServiceTest.testClearSnapshotClusterWide()
test_case.full_signature: @Test public void testClearSnapshotClusterWide()
test_case.identifier: testClearSnapshotClusterWide
test_case.invocations: mock forName mock mockGetStorageServiceMBean defaultConfig mock thenReturn when connectAny any spy create getLiveNodes when doReturn asList any getLiveNodes when doReturn asList any any mock build withSeedHosts withPartitioner withName builder of thenReturn when getCluster anyString clearSnapshotClusterWide create clearSnapshot verify times
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testClearSnapshotClusterWide()
focal_class.declarator: SNAPSHOT_PREFIX = "reaper"
focal_class.modifier: public static final
focal_class.original_string: public static final String SNAPSHOT_PREFIX = "reaper";
focal_class.type: String
focal_class.var_name: SNAPSHOT_PREFIX
focal_class.declarator: FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss")
focal_class.modifier: private static final
focal_class.original_string: private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss");
focal_class.type: DateTimeFormatter
focal_class.var_name: FORMATTER
focal_class.declarator: LOG = LoggerFactory.getLogger(SnapshotService.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(SnapshotService.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: context
focal_class.modifier: private final
focal_class.original_string: private final AppContext context;
focal_class.type: AppContext
focal_class.var_name: context
focal_class.declarator: clusterFacade
focal_class.modifier: private final
focal_class.original_string: private final ClusterFacade clusterFacade;
focal_class.type: ClusterFacade
focal_class.var_name: clusterFacade
focal_class.declarator: executor
focal_class.modifier: private final
focal_class.original_string: private final ExecutorService executor;
focal_class.type: ExecutorService
focal_class.var_name: executor
focal_class.declarator: cache = CacheBuilder.newBuilder().weakValues().maximumSize(1000).build()
focal_class.modifier: private final
focal_class.original_string: private final Cache<String, Snapshot> cache = CacheBuilder.newBuilder().weakValues().maximumSize(1000).build();
focal_class.type: Cache<String, Snapshot>
focal_class.var_name: cache
focal_class.file: src/server/src/main/java/io/cassandrareaper/service/SnapshotService.java
focal_class.identifier: SnapshotService
focal_class.class_method_signature: SnapshotService.SnapshotService(AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.full_signature: private  SnapshotService(AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.identifier: SnapshotService
focal_class.modifiers: private
focal_class.parameters: (AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.signature:  SnapshotService(AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.class_method_signature: SnapshotService.create(
        AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.full_signature: @VisibleForTesting static SnapshotService create(
        AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.identifier: create
focal_class.modifiers: @VisibleForTesting static
focal_class.parameters: (
        AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.return: SnapshotService
focal_class.signature: SnapshotService create(
        AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier)
focal_class.class_method_signature: SnapshotService.create(AppContext context, ExecutorService executor)
focal_class.full_signature: public static SnapshotService create(AppContext context, ExecutorService executor)
focal_class.identifier: create
focal_class.modifiers: public static
focal_class.parameters: (AppContext context, ExecutorService executor)
focal_class.return: SnapshotService
focal_class.signature: SnapshotService create(AppContext context, ExecutorService executor)
focal_class.class_method_signature: SnapshotService.takeSnapshot(String snapshotName, Node host, String... keyspaces)
focal_class.full_signature: public Pair<Node, String> takeSnapshot(String snapshotName, Node host, String... keyspaces)
focal_class.identifier: takeSnapshot
focal_class.modifiers: public
focal_class.parameters: (String snapshotName, Node host, String... keyspaces)
focal_class.return: Pair<Node, String>
focal_class.signature: Pair<Node, String> takeSnapshot(String snapshotName, Node host, String... keyspaces)
focal_class.class_method_signature: SnapshotService.takeSnapshotTask(String snapshotName, Node host, String... keyspace)
focal_class.full_signature:  Callable<Pair<Node, String>> takeSnapshotTask(String snapshotName, Node host, String... keyspace)
focal_class.identifier: takeSnapshotTask
focal_class.parameters: (String snapshotName, Node host, String... keyspace)
focal_class.return: Callable<Pair<Node, String>>
focal_class.signature: Callable<Pair<Node, String>> takeSnapshotTask(String snapshotName, Node host, String... keyspace)
focal_class.class_method_signature: SnapshotService.takeSnapshotClusterWide(
        String snapshotName,
        String clusterName,
        String owner,
        String cause,
        String... keyspace)
focal_class.full_signature: public List<Pair<Node, String>> takeSnapshotClusterWide(
        String snapshotName,
        String clusterName,
        String owner,
        String cause,
        String... keyspace)
focal_class.identifier: takeSnapshotClusterWide
focal_class.modifiers: public
focal_class.parameters: (
        String snapshotName,
        String clusterName,
        String owner,
        String cause,
        String... keyspace)
focal_class.return: List<Pair<Node, String>>
focal_class.signature: List<Pair<Node, String>> takeSnapshotClusterWide(
        String snapshotName,
        String clusterName,
        String owner,
        String cause,
        String... keyspace)
focal_class.class_method_signature: SnapshotService.listSnapshotsGroupedByName(Node host)
focal_class.full_signature: public Map<String, List<Snapshot>> listSnapshotsGroupedByName(Node host)
focal_class.identifier: listSnapshotsGroupedByName
focal_class.modifiers: public
focal_class.parameters: (Node host)
focal_class.return: Map<String, List<Snapshot>>
focal_class.signature: Map<String, List<Snapshot>> listSnapshotsGroupedByName(Node host)
focal_class.class_method_signature: SnapshotService.listSnapshots(Node host)
focal_class.full_signature: public List<Snapshot> listSnapshots(Node host)
focal_class.identifier: listSnapshots
focal_class.modifiers: public
focal_class.parameters: (Node host)
focal_class.return: List<Snapshot>
focal_class.signature: List<Snapshot> listSnapshots(Node host)
focal_class.class_method_signature: SnapshotService.listSnapshotsClusterWide(String clusterName)
focal_class.full_signature: public Map<String, Map<String, List<Snapshot>>> listSnapshotsClusterWide(String clusterName)
focal_class.identifier: listSnapshotsClusterWide
focal_class.modifiers: public
focal_class.parameters: (String clusterName)
focal_class.return: Map<String, Map<String, List<Snapshot>>>
focal_class.signature: Map<String, Map<String, List<Snapshot>>> listSnapshotsClusterWide(String clusterName)
focal_class.class_method_signature: SnapshotService.listSnapshotTask(Node host)
focal_class.full_signature:  Callable<List<Snapshot>> listSnapshotTask(Node host)
focal_class.identifier: listSnapshotTask
focal_class.parameters: (Node host)
focal_class.return: Callable<List<Snapshot>>
focal_class.signature: Callable<List<Snapshot>> listSnapshotTask(Node host)
focal_class.class_method_signature: SnapshotService.clearSnapshot(String snapshotName, Node host)
focal_class.full_signature: public void clearSnapshot(String snapshotName, Node host)
focal_class.identifier: clearSnapshot
focal_class.modifiers: public
focal_class.parameters: (String snapshotName, Node host)
focal_class.return: void
focal_class.signature: void clearSnapshot(String snapshotName, Node host)
focal_class.class_method_signature: SnapshotService.clearSnapshotTask(String snapshotName, Node host)
focal_class.full_signature:  Callable<Node> clearSnapshotTask(String snapshotName, Node host)
focal_class.identifier: clearSnapshotTask
focal_class.parameters: (String snapshotName, Node host)
focal_class.return: Callable<Node>
focal_class.signature: Callable<Node> clearSnapshotTask(String snapshotName, Node host)
focal_class.class_method_signature: SnapshotService.clearSnapshotClusterWide(String snapshotName, String clusterName)
focal_class.full_signature: public void clearSnapshotClusterWide(String snapshotName, String clusterName)
focal_class.identifier: clearSnapshotClusterWide
focal_class.modifiers: public
focal_class.parameters: (String snapshotName, String clusterName)
focal_class.return: void
focal_class.signature: void clearSnapshotClusterWide(String snapshotName, String clusterName)
focal_class.class_method_signature: SnapshotService.formatSnapshotName(String snapshotName)
focal_class.full_signature: public String formatSnapshotName(String snapshotName)
focal_class.identifier: formatSnapshotName
focal_class.modifiers: public
focal_class.parameters: (String snapshotName)
focal_class.return: String
focal_class.signature: String formatSnapshotName(String snapshotName)
focal_class.class_method_signature: SnapshotService.enrichSnapshotWithMetadata(Snapshot snapshot)
focal_class.full_signature: private Snapshot enrichSnapshotWithMetadata(Snapshot snapshot)
focal_class.identifier: enrichSnapshotWithMetadata
focal_class.modifiers: private
focal_class.parameters: (Snapshot snapshot)
focal_class.return: Snapshot
focal_class.signature: Snapshot enrichSnapshotWithMetadata(Snapshot snapshot)
focal_method.body: public void clearSnapshotClusterWide(String snapshotName, String clusterName) throws ReaperException {
      try {
        Cluster cluster = context.storage.getCluster(clusterName);
        List<String> liveNodes = clusterFacade.getLiveNodes(cluster);
  
        List<Callable<Node>> clearSnapshotTasks = liveNodes
                .stream()
                .map(host -> Node.builder().withCluster(cluster).withHostname(host).build())
                .map(node -> clearSnapshotTask(snapshotName, node))
                .collect(Collectors.toList());
  
        List<Future<Node>> futures = executor.invokeAll(clearSnapshotTasks);
        for (Future<Node> future : futures) {
          future.get();
        }
  
        context.storage.deleteSnapshot(Snapshot.builder().withClusterName(clusterName).withName(snapshotName).build());
      } catch (ExecutionException e) {
        LOG.error("Failed clearing {} snapshot for cluster {}", snapshotName, clusterName, e);
      } catch (InterruptedException e) {
        LOG.error("Interrupted clearing {} snapshot for cluster {}", snapshotName, clusterName, e);
        throw new ReaperException(e);
      }
    }
focal_method.class_method_signature: SnapshotService.clearSnapshotClusterWide(String snapshotName, String clusterName)
focal_method.full_signature: public void clearSnapshotClusterWide(String snapshotName, String clusterName)
focal_method.identifier: clearSnapshotClusterWide
focal_method.invocations: getCluster getLiveNodes collect map map stream build withHostname withCluster builder clearSnapshotTask toList invokeAll get deleteSnapshot build withName withClusterName builder error error
focal_method.modifiers: public
focal_method.parameters: (String snapshotName, String clusterName)
focal_method.return: void
focal_method.signature: void clearSnapshotClusterWide(String snapshotName, String clusterName)