public String toJsonString() throws JsonProcessingException { return JsonUtils.objectToPrettyString(this); } }
public String toJsonString() throws Exception { return JsonUtils.objectToPrettyString(this); }
private void printIdealState(Map<String, Map<String, String>> idealState) throws JsonProcessingException { System.out.println(JsonUtils.objectToPrettyString(idealState)); }
public static String convertToJsonString(Object object) { try { return JsonUtils.objectToPrettyString(object); } catch (IOException e) { LOGGER.error("Failed to convert json into string: ", e); throw new WebApplicationException("Failed to convert json into string.", Response.Status.INTERNAL_SERVER_ERROR); } } }
@Override public String toString() { try { return JsonUtils.objectToPrettyString(toJSONConfig(this)); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
protected void printSegmentAssignment(Map<String, Map<String, String>> mapping) throws Exception { LOGGER.info(JsonUtils.objectToPrettyString(mapping)); Map<String, List<String>> serverToSegmentMapping = new TreeMap<>(); for (String segment : mapping.keySet()) { Map<String, String> serverToStateMap = mapping.get(segment); for (String server : serverToStateMap.keySet()) { if (!serverToSegmentMapping.containsKey(server)) { serverToSegmentMapping.put(server, new ArrayList<>()); } serverToSegmentMapping.get(server).add(segment); } } DescriptiveStatistics stats = new DescriptiveStatistics(); for (String server : serverToSegmentMapping.keySet()) { List<String> list = serverToSegmentMapping.get(server); LOGGER.info("server " + server + " has " + list.size() + " segments"); stats.addValue(list.size()); } LOGGER.info("Segment Distrbution stat"); LOGGER.info(stats.toString()); }
@Override public String dumpSnapshot(String tableName) throws Exception { ObjectNode ret = JsonUtils.newObjectNode(); ArrayNode routingTableSnapshot = JsonUtils.newArrayNode(); for (String currentTable : _routingTableBuilderMap.keySet()) { if (tableName == null || currentTable.startsWith(tableName)) { ObjectNode tableEntry = JsonUtils.newObjectNode(); tableEntry.put("tableName", currentTable); ArrayNode entries = JsonUtils.newArrayNode(); RoutingTableBuilder routingTableBuilder = _routingTableBuilderMap.get(currentTable); List<Map<String, List<String>>> routingTables = routingTableBuilder.getRoutingTables(); for (Map<String, List<String>> routingTable : routingTables) { entries.add(JsonUtils.objectToJsonNode(routingTable)); } tableEntry.set("routingTableEntries", entries); routingTableSnapshot.add(tableEntry); } } ret.set("routingTableSnapshot", routingTableSnapshot); ret.put("host", NetUtil.getHostnameOrAddress()); return JsonUtils.objectToPrettyString(ret); } }
return JsonUtils.objectToPrettyString(jsonSchema); } catch (JsonProcessingException e) { throw new RuntimeException(e);
public static void main(String[] args) throws IOException { SchemaBuilder schemaBuilder = new SchemaBuilder(); schemaBuilder.addSingleValueDimension("name", DataType.STRING); schemaBuilder.addSingleValueDimension("age", DataType.INT); schemaBuilder.addMetric("percent", DataType.FLOAT); schemaBuilder.addTime("days", TimeUnit.DAYS, DataType.LONG); Schema schema = schemaBuilder.build(); System.out.println(JsonUtils.objectToPrettyString(schema)); } }
private String getAllCrcMetadataForTable(String tableName) { // TODO // In the restlet.resource version, we see this code block below // seems to be wrong comparing the table name to have the table type, but we copy it here anyway. // Realtime table is not supported. if (TableNameBuilder.getTableTypeFromTableName(tableName) == CommonConstants.Helix.TableType.REALTIME) { throw new ControllerApplicationException(LOGGER, "Realtime table is not supported", Response.Status.FORBIDDEN); } // Check that the offline table exists. String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName); if (!_pinotHelixResourceManager.getAllTables().contains(offlineTableName)) { throw new ControllerApplicationException(LOGGER, "Offline table " + tableName + " does not exist.", BAD_REQUEST); } Map<String, String> segmentCrcForTable = _pinotHelixResourceManager.getSegmentsCrcForTable(offlineTableName); String result; try { result = JsonUtils.objectToPrettyString(segmentCrcForTable); } catch (JsonProcessingException e) { throw new ControllerApplicationException(LOGGER, String.format("Failed to write segment crc values for table: %s", tableName), Response.Status.INTERNAL_SERVER_ERROR); } return result; } }
public StarTreeIndexViewer(File segmentDir) throws Exception { IndexSegment indexSegment = ImmutableSegmentLoader.load(segmentDir, ReadMode.heap); dictionaries = new HashMap<>(); valueIterators = new HashMap<>(); SegmentMetadataImpl metadata = new SegmentMetadataImpl(segmentDir); for (String columnName : metadata.getAllColumns()) { DataSource dataSource = indexSegment.getDataSource(columnName); Block block = dataSource.nextBlock(); BlockValSet blockValSet = block.getBlockValueSet(); BlockSingleValIterator itr = (BlockSingleValIterator) blockValSet.iterator(); valueIterators.put(columnName, itr); dictionaries.put(columnName, dataSource.getDictionary()); } StarTree tree = indexSegment.getStarTrees().get(0).getStarTree(); _dimensionNames = tree.getDimensionNames(); StarTreeJsonNode jsonRoot = new StarTreeJsonNode("ROOT"); build(tree.getRoot(), jsonRoot); indexSegment.destroy(); String writeValueAsString = JsonUtils.objectToPrettyString(jsonRoot); LOGGER.info(writeValueAsString); startServer(segmentDir, writeValueAsString); }