* Mandatory
*/
public void read_config(InputStream in) throws Exception {
JsonFactory f = new MappingJsonFactory();
JsonParser jp = f.createJsonParser(in);
JsonToken current;
current = jp.nextToken();
if (current != JsonToken.START_OBJECT) {
logger.warn("read_config: Error: START_OBJECT not found : quiting.");
return;
}
current = jp.nextToken();
String fieldName = jp.getCurrentName();
current = jp.nextToken();
if (fieldName.equals("config")) {
if (current != JsonToken.START_OBJECT) {
logger.warn("read_config: Error: START_OBJECT not found after config : quiting.");
return;
}
current = jp.nextToken();
String fieldName2 = jp.getCurrentName();
if (fieldName2.equals("metric_groups")) {
current = jp.nextToken();
if (current != JsonToken.START_ARRAY) {
logger.warn("read_config: Error: START_ARRAY not found after metric_groups : quiting.");
return;
}
current = jp.nextToken();
while (current != JsonToken.END_ARRAY) {
if (current != JsonToken.START_OBJECT) {
logger.warn("read_config: Error: START_OBJECT not found after metric_groups START_ARRAY : quiting.");
return;
}
current = jp.nextToken();
JsonNode node1 = jp.readValueAsTree();
String node1string = write_tostring(node1);
metricgroupMap.put(node1.get("name").asText(),node1string);
current = jp.nextToken();
}
current = jp.nextToken();
String fieldName3 = jp.getCurrentName();
if (fieldName3.equals("dashboards")) {
current = jp.nextToken();
if (current != JsonToken.START_ARRAY) {
logger.warn("read_config: Error: START_ARRAY not found after dashboards : quiting.");
return;
}
current = jp.nextToken();
while (current != JsonToken.END_ARRAY) {
if (current != JsonToken.START_OBJECT) {
logger.warn("read_config: Error: START_OBJECT not found after dashboards START_ARRAY : quiting.");
return;
}
current = jp.nextToken();
JsonNode node = jp.readValueAsTree();
String nodestring = write_tostring(node);
dashMap.put(node.get("name").asText(),nodestring);
current = jp.nextToken();
}
if(jp.nextToken() != JsonToken.END_OBJECT) {
logger.warn("read_config: Error: END_OBJECT expected, not found (1): quiting.");
return;
}
if(jp.nextToken() != JsonToken.END_OBJECT) {
logger.warn("read_config: Error: END_OBJECT expected, not found (2): quiting.");
return;
}
} else {
logger.warn("read_config: Error: Expected dashboards : quiting.");