@Test public void testComputeComponentStatusWithNoError() { ComponentStatus componentStatus = new ComponentStatusBuilder() .component(Component.PHOTON_CONTROLLER) .instances(ImmutableList.of( new ComponentInstanceBuilder().status(StatusType.READY).build(), new ComponentInstanceBuilder().status(StatusType.INITIALIZING).build() )) .build(); StatusFeClientUtils.computeSingleComponentStatus(componentStatus); assertThat(componentStatus.getStatus(), is(StatusType.INITIALIZING)); assertThat(componentStatus.getStats().get(StatusType.READY.toString()), is("1")); assertThat(componentStatus.getStats().get(StatusType.INITIALIZING.toString()), is("1")); }
public static void computeSingleComponentStatus(ComponentStatus componentStatus) { Map<StatusType, Long> stats = componentStatus.getInstances().stream() .filter(instance -> instance.getStatus() != null) .collect(Collectors.groupingBy(instance -> instance.getStatus(), Collectors.counting())); componentStatus.setStats(stats.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey().toString(), e -> Long.toString(e.getValue())))); componentStatus.setStatus(getSingleComponentStatus(stats.keySet())); }
StatusFeClientUtils { public static void computeSingleComponentStatus(ComponentStatus componentStatus) { Map<StatusType, Long> stats = componentStatus.getInstances().stream() .filter(instance -> instance.getStatus() != null) .collect(Collectors.groupingBy(instance -> instance.getStatus(), Collectors.counting())); componentStatus.setStats(stats.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey().toString(), e -> Long.toString(e.getValue())))); componentStatus.setStatus(getSingleComponentStatus(stats.keySet())); } }
StatusFeClientUtils { public static void computeSingleComponentStatus(ComponentStatus componentStatus) { Map<StatusType, Long> stats = componentStatus.getInstances().stream() .filter(instance -> instance.getStatus() != null) .collect(Collectors.groupingBy(instance -> instance.getStatus(), Collectors.counting())); componentStatus.setStats(stats.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey().toString(), e -> Long.toString(e.getValue())))); componentStatus.setStatus(getSingleComponentStatus(stats.keySet())); }  }
StatusFeClientUtils { public static void computeSingleComponentStatus(ComponentStatus componentStatus) { Map<StatusType, Long> stats = componentStatus.getInstances().stream() .filter(instance -> instance.getStatus() != null) .collect(Collectors.groupingBy(instance -> instance.getStatus(), Collectors.counting())); componentStatus.setStats(stats.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey().toString(), e -> Long.toString(e.getValue())))); componentStatus.setStatus(getSingleComponentStatus(stats.keySet())); }  static void computeSingleComponentStatus(ComponentStatus componentStatus); }
StatusFeClientUtils { public static void computeSingleComponentStatus(ComponentStatus componentStatus) { Map<StatusType, Long> stats = componentStatus.getInstances().stream() .filter(instance -> instance.getStatus() != null) .collect(Collectors.groupingBy(instance -> instance.getStatus(), Collectors.counting())); componentStatus.setStats(stats.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey().toString(), e -> Long.toString(e.getValue())))); componentStatus.setStatus(getSingleComponentStatus(stats.keySet())); }  static void computeSingleComponentStatus(ComponentStatus componentStatus); static final Map<StatusType, Integer> STATUS_MAP; }