test_class.file: src/server/src/test/java/io/cassandrareaper/service/RepairRunServiceTest.java
test_class.identifier: RepairRunServiceTest
test_case.body: @Test
    public void filterSegmentsByNodesTest() throws ReaperException {
      Map<List<String>, List<String>> rangeToEndpoint = Maps.newHashMap();
      rangeToEndpoint.put(Arrays.asList("1", "2"), Arrays.asList("node1", "node2", "node3"));
      rangeToEndpoint.put(Arrays.asList("2", "4"), Arrays.asList("node1", "node2", "node3"));
      rangeToEndpoint.put(Arrays.asList("4", "6"), Arrays.asList("node1"));
      rangeToEndpoint.put(Arrays.asList("6", "8"), Arrays.asList("node1", "node2"));
  
      List<Segment> segments = Arrays.asList(
              Segment.builder().withTokenRange(new RingRange("1", "2")).build(),
              Segment.builder().withTokenRange(new RingRange("2", "3")).build(),
              Segment.builder().withTokenRange(new RingRange("3", "4")).build(),
              Segment.builder().withTokenRange(new RingRange("4", "5")).build(),
              Segment.builder().withTokenRange(new RingRange("5", "6")).build(),
              Segment.builder().withTokenRange(new RingRange("6", "8")).build());
  
      final RepairUnit repairUnit1 = mock(RepairUnit.class);
      when(repairUnit1.getNodes()).thenReturn(new HashSet<String>(Arrays.asList("node3", "node2")));
  
      final RepairUnit repairUnit2 = mock(RepairUnit.class);
      when(repairUnit2.getNodes()).thenReturn(new HashSet<String>(Arrays.asList("node1")));
  
      final RepairUnit repairUnit3 = mock(RepairUnit.class);
      when(repairUnit3.getNodes()).thenReturn(new HashSet<String>(Arrays.asList("node3")));
  
      List<Segment> filtered = RepairRunService.filterSegmentsByNodes(
              segments, repairUnit1, RepairRunService.buildEndpointToRangeMap(rangeToEndpoint));
  
      assertEquals(filtered.size(), 4);
  
      filtered = RepairRunService.filterSegmentsByNodes(segments, repairUnit2,
          RepairRunService.buildEndpointToRangeMap(rangeToEndpoint));
      assertEquals(filtered.size(), 6);
  
      filtered = RepairRunService.filterSegmentsByNodes(segments, repairUnit3,
          RepairRunService.buildEndpointToRangeMap(rangeToEndpoint));
      assertEquals(filtered.size(), 3);
  
      final RepairUnit repairUnitWithNoNodes = mock(RepairUnit.class);
      when(repairUnitWithNoNodes.getNodes()).thenReturn(new HashSet<String>());
  
      filtered = RepairRunService.filterSegmentsByNodes(segments, repairUnitWithNoNodes,
          RepairRunService.buildEndpointToRangeMap(rangeToEndpoint));
      assertEquals(filtered.size(), 6);
  
    }
test_case.class_method_signature: RepairRunServiceTest.filterSegmentsByNodesTest()
test_case.full_signature: @Test public void filterSegmentsByNodesTest()
test_case.identifier: filterSegmentsByNodesTest
test_case.invocations: newHashMap put asList asList put asList asList put asList asList put asList asList asList build withTokenRange builder build withTokenRange builder build withTokenRange builder build withTokenRange builder build withTokenRange builder build withTokenRange builder mock thenReturn when getNodes asList mock thenReturn when getNodes asList mock thenReturn when getNodes asList filterSegmentsByNodes buildEndpointToRangeMap assertEquals size filterSegmentsByNodes buildEndpointToRangeMap assertEquals size filterSegmentsByNodes buildEndpointToRangeMap assertEquals size mock thenReturn when getNodes filterSegmentsByNodes buildEndpointToRangeMap assertEquals size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void filterSegmentsByNodesTest()
focal_class.declarator: COMMA_SEPARATED_LIST_SPLITTER
        = Splitter.on(',').trimResults(CharMatcher.anyOf(" ()[]\"'")).omitEmptyStrings()
focal_class.modifier: public static final
focal_class.original_string: public static final Splitter COMMA_SEPARATED_LIST_SPLITTER
        = Splitter.on(',').trimResults(CharMatcher.anyOf(" ()[]\"'")).omitEmptyStrings();
focal_class.type: Splitter
focal_class.var_name: COMMA_SEPARATED_LIST_SPLITTER
focal_class.declarator: DEFAULT_SEGMENT_COUNT_PER_NODE = 16
focal_class.modifier: public static final
focal_class.original_string: public static final int DEFAULT_SEGMENT_COUNT_PER_NODE = 16;
focal_class.type: int
focal_class.var_name: DEFAULT_SEGMENT_COUNT_PER_NODE
focal_class.declarator: LOG = LoggerFactory.getLogger(RepairRunService.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(RepairRunService.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: repairUnitService
focal_class.modifier: private final
focal_class.original_string: private final RepairUnitService repairUnitService;
focal_class.type: RepairUnitService
focal_class.var_name: repairUnitService
focal_class.file: src/server/src/main/java/io/cassandrareaper/service/RepairRunService.java
focal_class.identifier: RepairRunService
focal_class.class_method_signature: RepairRunService.RepairRunService(AppContext context)
focal_class.full_signature: private  RepairRunService(AppContext context)
focal_class.identifier: RepairRunService
focal_class.modifiers: private
focal_class.parameters: (AppContext context)
focal_class.signature:  RepairRunService(AppContext context)
focal_class.class_method_signature: RepairRunService.create(AppContext context)
focal_class.full_signature: public static RepairRunService create(AppContext context)
focal_class.identifier: create
focal_class.modifiers: public static
focal_class.parameters: (AppContext context)
focal_class.return: RepairRunService
focal_class.signature: RepairRunService create(AppContext context)
focal_class.class_method_signature: RepairRunService.registerRepairRun(
        Cluster cluster,
        RepairUnit repairUnit,
        Optional<String> cause,
        String owner,
        int segments,
        int segmentsPerNode,
        RepairParallelism repairParallelism,
        Double intensity)
focal_class.full_signature: public RepairRun registerRepairRun(
        Cluster cluster,
        RepairUnit repairUnit,
        Optional<String> cause,
        String owner,
        int segments,
        int segmentsPerNode,
        RepairParallelism repairParallelism,
        Double intensity)
focal_class.identifier: registerRepairRun
focal_class.modifiers: public
focal_class.parameters: (
        Cluster cluster,
        RepairUnit repairUnit,
        Optional<String> cause,
        String owner,
        int segments,
        int segmentsPerNode,
        RepairParallelism repairParallelism,
        Double intensity)
focal_class.return: RepairRun
focal_class.signature: RepairRun registerRepairRun(
        Cluster cluster,
        RepairUnit repairUnit,
        Optional<String> cause,
        String owner,
        int segments,
        int segmentsPerNode,
        RepairParallelism repairParallelism,
        Double intensity)
focal_class.class_method_signature: RepairRunService.generateSegments(
        Cluster targetCluster, int segmentCount, int segmentCountPerNode, RepairUnit repairUnit)
focal_class.full_signature: private List<Segment> generateSegments(
        Cluster targetCluster, int segmentCount, int segmentCountPerNode, RepairUnit repairUnit)
focal_class.identifier: generateSegments
focal_class.modifiers: private
focal_class.parameters: (
        Cluster targetCluster, int segmentCount, int segmentCountPerNode, RepairUnit repairUnit)
focal_class.return: List<Segment>
focal_class.signature: List<Segment> generateSegments(
        Cluster targetCluster, int segmentCount, int segmentCountPerNode, RepairUnit repairUnit)
focal_class.class_method_signature: RepairRunService.computeGlobalSegmentCount(
        int segmentCountPerNode,
        Map<String, List<RingRange>> endpointToRange)
focal_class.full_signature: static int computeGlobalSegmentCount(
        int segmentCountPerNode,
        Map<String, List<RingRange>> endpointToRange)
focal_class.identifier: computeGlobalSegmentCount
focal_class.modifiers: static
focal_class.parameters: (
        int segmentCountPerNode,
        Map<String, List<RingRange>> endpointToRange)
focal_class.return: int
focal_class.signature: int computeGlobalSegmentCount(
        int segmentCountPerNode,
        Map<String, List<RingRange>> endpointToRange)
focal_class.class_method_signature: RepairRunService.filterSegmentsByNodes(
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)
focal_class.full_signature: static List<Segment> filterSegmentsByNodes(
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)
focal_class.identifier: filterSegmentsByNodes
focal_class.modifiers: static
focal_class.parameters: (
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)
focal_class.return: List<Segment>
focal_class.signature: List<Segment> filterSegmentsByNodes(
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)
focal_class.class_method_signature: RepairRunService.buildEndpointToRangeMap(Map<List<String>, List<String>> rangeToEndpoint)
focal_class.full_signature: @VisibleForTesting static Map<String, List<RingRange>> buildEndpointToRangeMap(Map<List<String>, List<String>> rangeToEndpoint)
focal_class.identifier: buildEndpointToRangeMap
focal_class.modifiers: @VisibleForTesting static
focal_class.parameters: (Map<List<String>, List<String>> rangeToEndpoint)
focal_class.return: Map<String, List<RingRange>>
focal_class.signature: Map<String, List<RingRange>> buildEndpointToRangeMap(Map<List<String>, List<String>> rangeToEndpoint)
focal_class.class_method_signature: RepairRunService.buildReplicasToRangeMap(
        Map<List<String>, List<String>> rangeToEndpoint)
focal_class.full_signature: @VisibleForTesting static Map<List<String>, List<RingRange>> buildReplicasToRangeMap(
        Map<List<String>, List<String>> rangeToEndpoint)
focal_class.identifier: buildReplicasToRangeMap
focal_class.modifiers: @VisibleForTesting static
focal_class.parameters: (
        Map<List<String>, List<String>> rangeToEndpoint)
focal_class.return: Map<List<String>, List<RingRange>>
focal_class.signature: Map<List<String>, List<RingRange>> buildReplicasToRangeMap(
        Map<List<String>, List<String>> rangeToEndpoint)
focal_class.class_method_signature: RepairRunService.createRepairSegments(
        List<Segment> tokenSegments,
        RepairUnit repairUnit)
focal_class.full_signature: private static List<RepairSegment.Builder> createRepairSegments(
        List<Segment> tokenSegments,
        RepairUnit repairUnit)
focal_class.identifier: createRepairSegments
focal_class.modifiers: private static
focal_class.parameters: (
        List<Segment> tokenSegments,
        RepairUnit repairUnit)
focal_class.return: List<RepairSegment.Builder>
focal_class.signature: List<RepairSegment.Builder> createRepairSegments(
        List<Segment> tokenSegments,
        RepairUnit repairUnit)
focal_class.class_method_signature: RepairRunService.createRepairSegmentsForIncrementalRepair(
        Map<String, RingRange> nodes,
        RepairUnit repairUnit)
focal_class.full_signature: private static List<RepairSegment.Builder> createRepairSegmentsForIncrementalRepair(
        Map<String, RingRange> nodes,
        RepairUnit repairUnit)
focal_class.identifier: createRepairSegmentsForIncrementalRepair
focal_class.modifiers: private static
focal_class.parameters: (
        Map<String, RingRange> nodes,
        RepairUnit repairUnit)
focal_class.return: List<RepairSegment.Builder>
focal_class.signature: List<RepairSegment.Builder> createRepairSegmentsForIncrementalRepair(
        Map<String, RingRange> nodes,
        RepairUnit repairUnit)
focal_class.class_method_signature: RepairRunService.getClusterNodes(Cluster targetCluster, RepairUnit repairUnit)
focal_class.full_signature: private Map<String,RingRange> getClusterNodes(Cluster targetCluster, RepairUnit repairUnit)
focal_class.identifier: getClusterNodes
focal_class.modifiers: private
focal_class.parameters: (Cluster targetCluster, RepairUnit repairUnit)
focal_class.return: Map<String,RingRange>
focal_class.signature: Map<String,RingRange> getClusterNodes(Cluster targetCluster, RepairUnit repairUnit)
focal_class.class_method_signature: RepairRunService.getTableNamesBasedOnParam(
        Cluster cluster,
        String keyspace,
        Optional<String> tableNamesParam)
focal_class.full_signature: public Set<String> getTableNamesBasedOnParam(
        Cluster cluster,
        String keyspace,
        Optional<String> tableNamesParam)
focal_class.identifier: getTableNamesBasedOnParam
focal_class.modifiers: public
focal_class.parameters: (
        Cluster cluster,
        String keyspace,
        Optional<String> tableNamesParam)
focal_class.return: Set<String>
focal_class.signature: Set<String> getTableNamesBasedOnParam(
        Cluster cluster,
        String keyspace,
        Optional<String> tableNamesParam)
focal_class.class_method_signature: RepairRunService.getNodesToRepairBasedOnParam(
        Cluster cluster,
        Optional<String> nodesToRepairParam)
focal_class.full_signature: public Set<String> getNodesToRepairBasedOnParam(
        Cluster cluster,
        Optional<String> nodesToRepairParam)
focal_class.identifier: getNodesToRepairBasedOnParam
focal_class.modifiers: public
focal_class.parameters: (
        Cluster cluster,
        Optional<String> nodesToRepairParam)
focal_class.return: Set<String>
focal_class.signature: Set<String> getNodesToRepairBasedOnParam(
        Cluster cluster,
        Optional<String> nodesToRepairParam)
focal_class.class_method_signature: RepairRunService.getDatacentersToRepairBasedOnParam(Cluster cluster, Optional<String> datacenters)
focal_class.full_signature: public static Set<String> getDatacentersToRepairBasedOnParam(Cluster cluster, Optional<String> datacenters)
focal_class.identifier: getDatacentersToRepairBasedOnParam
focal_class.modifiers: public static
focal_class.parameters: (Cluster cluster, Optional<String> datacenters)
focal_class.return: Set<String>
focal_class.signature: Set<String> getDatacentersToRepairBasedOnParam(Cluster cluster, Optional<String> datacenters)
focal_method.body: static List<Segment> filterSegmentsByNodes(
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange) {
  
      if (repairUnit.getNodes().isEmpty()) {
        return segments;
      } else {
        return segments
            .stream()
            .filter(
                segment -> {
                  RingRange firstRange = segment.getBaseRange();
                  for (Entry<String, List<RingRange>> entry : endpointToRange.entrySet()) {
                    if (repairUnit.getNodes().contains(entry.getKey())) {
                      for (RingRange range : entry.getValue()) {
                        if (range.encloses(firstRange)) {
                          return true;
                        }
                      }
                    }
                  }
                  return false;
                })
            .collect(Collectors.toList());
      }
    }
focal_method.class_method_signature: RepairRunService.filterSegmentsByNodes(
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)
focal_method.full_signature: static List<Segment> filterSegmentsByNodes(
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)
focal_method.identifier: filterSegmentsByNodes
focal_method.invocations: isEmpty getNodes collect filter stream getBaseRange entrySet contains getNodes getKey getValue encloses toList
focal_method.modifiers: static
focal_method.parameters: (
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)
focal_method.return: List<Segment>
focal_method.signature: List<Segment> filterSegmentsByNodes(
        List<Segment> segments,
        RepairUnit repairUnit,
        Map<String, List<RingRange>> endpointToRange)