@SuppressWarnings("unchecked") @Test public void testGetClusterStatus() throws BlurException, IOException, TException { List<Map<String, Object>> nodeStatus = NodeUtil.getClusterStatus(); assertEquals(3, ((Collection<String>) nodeStatus.get(0).get("online")).size()); assertEquals(0, ((Collection<String>) nodeStatus.get(0).get("offline")).size()); }
@SuppressWarnings("unchecked") public static List<Map<String, Object>> getClusterStatus() throws IOException, TException { List<Map<String, Object>> data = new ArrayList<Map<String, Object>>(); CachingBlurClient client = Config.getCachingBlurClient(); for (String cluster : client.shardClusterList()) { if (!onlineShards.containsKey(cluster)) { onlineShards.put(cluster, new HashSet<String>()); } Set<String> onlineShardsForCluster = onlineShards.get(cluster); List<String> currentShards = client.shardList(cluster); Collection<String> newShards = subtract(currentShards, onlineShardsForCluster); Collection<String> missingShards = subtract(onlineShardsForCluster, currentShards); onlineShardsForCluster.addAll(newShards); Map<String, Object> clusterObj = new HashMap<String, Object>(); clusterObj.put("name", cluster); clusterObj.put("online", onlineShardsForCluster); clusterObj.put("offline", missingShards); data.add(clusterObj); } return data; }
NodeUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> getClusterStatus() throws IOException, TException { List<Map<String, Object>> data = new ArrayList<Map<String, Object>>(); CachingBlurClient client = Config.getCachingBlurClient(); for (String cluster : client.shardClusterList()) { if (!onlineShards.containsKey(cluster)) { onlineShards.put(cluster, new HashSet<String>()); } Set<String> onlineShardsForCluster = onlineShards.get(cluster); List<String> currentShards = client.shardList(cluster); Collection<String> newShards = subtract(currentShards, onlineShardsForCluster); Collection<String> missingShards = subtract(onlineShardsForCluster, currentShards); onlineShardsForCluster.addAll(newShards); Map<String, Object> clusterObj = new HashMap<String, Object>(); clusterObj.put("name", cluster); clusterObj.put("online", onlineShardsForCluster); clusterObj.put("offline", missingShards); data.add(clusterObj); } return data; } }
NodeUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> getClusterStatus() throws IOException, TException { List<Map<String, Object>> data = new ArrayList<Map<String, Object>>(); CachingBlurClient client = Config.getCachingBlurClient(); for (String cluster : client.shardClusterList()) { if (!onlineShards.containsKey(cluster)) { onlineShards.put(cluster, new HashSet<String>()); } Set<String> onlineShardsForCluster = onlineShards.get(cluster); List<String> currentShards = client.shardList(cluster); Collection<String> newShards = subtract(currentShards, onlineShardsForCluster); Collection<String> missingShards = subtract(onlineShardsForCluster, currentShards); onlineShardsForCluster.addAll(newShards); Map<String, Object> clusterObj = new HashMap<String, Object>(); clusterObj.put("name", cluster); clusterObj.put("online", onlineShardsForCluster); clusterObj.put("offline", missingShards); data.add(clusterObj); } return data; }  }
NodeUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> getClusterStatus() throws IOException, TException { List<Map<String, Object>> data = new ArrayList<Map<String, Object>>(); CachingBlurClient client = Config.getCachingBlurClient(); for (String cluster : client.shardClusterList()) { if (!onlineShards.containsKey(cluster)) { onlineShards.put(cluster, new HashSet<String>()); } Set<String> onlineShardsForCluster = onlineShards.get(cluster); List<String> currentShards = client.shardList(cluster); Collection<String> newShards = subtract(currentShards, onlineShardsForCluster); Collection<String> missingShards = subtract(onlineShardsForCluster, currentShards); onlineShardsForCluster.addAll(newShards); Map<String, Object> clusterObj = new HashMap<String, Object>(); clusterObj.put("name", cluster); clusterObj.put("online", onlineShardsForCluster); clusterObj.put("offline", missingShards); data.add(clusterObj); } return data; }  static Map<String, Object> getControllerStatus(); static Collection<String> subtract(final Collection<String> a, final Collection<String> b); @SuppressWarnings("unchecked") static List<Map<String, Object>> getClusterStatus(); static Map<String, Object> getZookeeperStatus(); }
NodeUtil { @SuppressWarnings("unchecked") public static List<Map<String, Object>> getClusterStatus() throws IOException, TException { List<Map<String, Object>> data = new ArrayList<Map<String, Object>>(); CachingBlurClient client = Config.getCachingBlurClient(); for (String cluster : client.shardClusterList()) { if (!onlineShards.containsKey(cluster)) { onlineShards.put(cluster, new HashSet<String>()); } Set<String> onlineShardsForCluster = onlineShards.get(cluster); List<String> currentShards = client.shardList(cluster); Collection<String> newShards = subtract(currentShards, onlineShardsForCluster); Collection<String> missingShards = subtract(onlineShardsForCluster, currentShards); onlineShardsForCluster.addAll(newShards); Map<String, Object> clusterObj = new HashMap<String, Object>(); clusterObj.put("name", cluster); clusterObj.put("online", onlineShardsForCluster); clusterObj.put("offline", missingShards); data.add(clusterObj); } return data; }  static Map<String, Object> getControllerStatus(); static Collection<String> subtract(final Collection<String> a, final Collection<String> b); @SuppressWarnings("unchecked") static List<Map<String, Object>> getClusterStatus(); static Map<String, Object> getZookeeperStatus();  }