public List<Object> getColumnValues(String string, List<Class<?>> types) { JsonArray array = getJsonArray(string); List<Object> result = new ArrayList<>(); for (int i = 0; i < types.size(); i++) { Class<?> type = types.get(i); if (String.class.equals(type)) { result.add(toListString(array.getJsonArray(i))); } else if (double.class.equals(type)) { result.add(toListDouble(array.getJsonArray(i))); } else if (float.class.equals(type)) { result.add(toListFloat(array.getJsonArray(i))); } else if (long.class.equals(type)) { result.add(toListLong(array.getJsonArray(i))); } else if (int.class.equals(type)) { result.add(toListInt(array.getJsonArray(i))); } else if (short.class.equals(type)) { result.add(toListShort(array.getJsonArray(i))); } else if (byte.class.equals(type)) { result.add(toListByte(array.getJsonArray(i))); } else if (Instant.class.equals(type)) { result.add(toListTimestamp(array.getJsonArray(i))); } else { throw new IllegalArgumentException("Column type " + type + " not supported"); } } return result; }
public List<Object> getColumnValues(String string, List<Class<?>> types) { JsonArray array = getJsonArray(string); List<Object> result = new ArrayList<>(); for (int i = 0; i < types.size(); i++) { Class<?> type = types.get(i); if (String.class.equals(type)) { result.add(toListString(array.getJsonArray(i))); } else if (double.class.equals(type)) { result.add(toListDouble(array.getJsonArray(i))); } else if (float.class.equals(type)) { result.add(toListFloat(array.getJsonArray(i))); } else if (long.class.equals(type)) { result.add(toListLong(array.getJsonArray(i))); } else if (int.class.equals(type)) { result.add(toListInt(array.getJsonArray(i))); } else if (short.class.equals(type)) { result.add(toListShort(array.getJsonArray(i))); } else if (byte.class.equals(type)) { result.add(toListByte(array.getJsonArray(i))); } else if (Timestamp.class.equals(type)) { result.add(toListTimestamp(array.getJsonArray(i))); } else { throw new IllegalArgumentException("Column type " + type + " not supported"); } } return result; }
public List<NodesTableItem> getNdbinfoNodesTable(String hostAddress, String agentPassword) throws AppException { List<NodesTableItem> resultList = new ArrayList<NodesTableItem>(); String url = createUrl("mysql", hostAddress, "ndbinfo", "nodes"); String jsonString = fetchContent(url, agentPassword); InputStream stream = new ByteArrayInputStream(jsonString.getBytes( StandardCharsets.UTF_8)); try { JsonArray json = Json.createReader(stream).readArray(); if (json.get(0).equals("Error")) { resultList.add(new NodesTableItem(null, json.getString(1), null, null, null)); return resultList; } for (int i = 0; i < json.size(); i++) { JsonArray node = json.getJsonArray(i); Integer nodeId = node.getInt(0); Long uptime = node.getJsonNumber(1).longValue(); String status = node.getString(2); Integer startPhase = node.getInt(3); Integer configGeneration = node.getInt(4); resultList.add(new NodesTableItem(nodeId, status, uptime, startPhase, configGeneration)); } } catch (Exception ex) { logger.log(Level.SEVERE, "Exception: {0}", ex); resultList.add(new NodesTableItem(null, "Error", null, null, null)); } return resultList; }