RepairRunService { static int computeGlobalSegmentCount( int segmentCountPerNode, Map<String, List<RingRange>> endpointToRange) { Preconditions.checkArgument(1 <= endpointToRange.keySet().size()); return endpointToRange.keySet().size() * (segmentCountPerNode != 0 ? segmentCountPerNode : DEFAULT_SEGMENT_COUNT_PER_NODE); } private  RepairRunService(AppContext context); static RepairRunService create(AppContext context); RepairRun registerRepairRun(
      Cluster cluster,
      RepairUnit repairUnit,
      Optional<String> cause,
      String owner,
      int segments,
      int segmentsPerNode,
      RepairParallelism repairParallelism,
      Double intensity); Set<String> getTableNamesBasedOnParam(
      Cluster cluster,
      String keyspace,
      Optional<String> tableNamesParam); Set<String> getNodesToRepairBasedOnParam(
      Cluster cluster,
      Optional<String> nodesToRepairParam); static Set<String> getDatacentersToRepairBasedOnParam(Cluster cluster, Optional<String> datacenters); static final Splitter COMMA_SEPARATED_LIST_SPLITTER; static final int DEFAULT_SEGMENT_COUNT_PER_NODE; }
@Test public void computeGlobalSegmentCountSubdivisionOkTest() { Map<List<String>, List<String>> rangeToEndpoint = Maps.newHashMap(); for (int i = 0; i < 10; i++) { rangeToEndpoint.put( Arrays.asList(i + "", (i + 1) + ""), Arrays.asList("node1", "node2", "node3")); } Map<String, List<RingRange>> endpointToRange = Maps.newHashMap(); endpointToRange.put("node1", Lists.newArrayList()); endpointToRange.put("node2", Lists.newArrayList()); endpointToRange.put("node3", Lists.newArrayList()); assertEquals(30, RepairRunService.computeGlobalSegmentCount(10, endpointToRange)); }
@Test public void computeGlobalSegmentCountSubdivisionNotOkTest() { Map<List<String>, List<String>> rangeToEndpoint = Maps.newHashMap(); for (int i = 0; i < 60; i++) { rangeToEndpoint.put( Arrays.asList(i + "", (i + 1) + ""), Arrays.asList("node1", "node2", "node3")); } Map<String, List<RingRange>> endpointToRange = Maps.newHashMap(); endpointToRange.put("node1", Lists.newArrayList()); endpointToRange.put("node2", Lists.newArrayList()); endpointToRange.put("node3", Lists.newArrayList()); assertEquals(30, RepairRunService.computeGlobalSegmentCount(10, endpointToRange)); }
@Test public void computeGlobalSegmentCountSingleTokenPerNodeTest() { Map<List<String>, List<String>> rangeToEndpoint = Maps.newHashMap(); for (int i = 0; i < 3; i++) { rangeToEndpoint.put( Arrays.asList(i + "", (i + 1) + ""), Arrays.asList("node1", "node2", "node3")); } Map<String, List<RingRange>> endpointToRange = Maps.newHashMap(); endpointToRange.put("node1", Lists.newArrayList()); endpointToRange.put("node2", Lists.newArrayList()); endpointToRange.put("node3", Lists.newArrayList()); assertEquals(48, RepairRunService.computeGlobalSegmentCount(0, endpointToRange)); }
@Test public void computeGlobalSegmentCount256TokenPerNodeTest() { Map<List<String>, List<String>> rangeToEndpoint = Maps.newHashMap(); for (int i = 0; i < 768; i++) { rangeToEndpoint.put( Arrays.asList(i + "", (i + 1) + ""), Arrays.asList("node1", "node2", "node3")); } Map<String, List<RingRange>> endpointToRange = Maps.newHashMap(); endpointToRange.put("node1", Lists.newArrayList()); endpointToRange.put("node2", Lists.newArrayList()); endpointToRange.put("node3", Lists.newArrayList()); assertEquals(48, RepairRunService.computeGlobalSegmentCount(0, endpointToRange)); }