/** * Get info about current operation of this river. Used for REST management operations handling. * * @return String with JSON formatted info. * @throws Exception */ @Override public String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception { XContentBuilder builder = jsonBuilder().prettyPrint(); builder.startObject(); builder.field("river_name", riverName().getName()); builder.field("info_date", currentDate); builder.startObject("indexing"); builder.field("state", closed ? "stopped" : "running"); if (!closed) builder.field("last_restart", lastRestartDate); else if (permanentStopDate != null) builder.field("stopped_permanently", permanentStopDate); builder.endObject(); if (esNode != null) { builder.startObject("node"); builder.field("id", esNode.getId()); builder.field("name", esNode.getName()); builder.endObject(); } if (coordinatorInstance != null) { List<SpaceIndexingInfo> currProjectIndexingInfo = coordinatorInstance.getCurrentSpaceIndexingInfo(); if (currProjectIndexingInfo != null) { builder.startArray("current_indexing"); for (SpaceIndexingInfo pi : currProjectIndexingInfo) { pi.buildDocument(builder, null, true, false); } builder.endArray(); } } List<String> pkeys = getAllIndexedSpaceKeys(); if (pkeys != null) { builder.startArray("indexed_spaces"); for (String spaceKey : pkeys) { builder.startObject(); builder.field(SpaceIndexingInfo.DOCFIELD_SPACE_KEY, spaceKey); SpaceIndexingInfo lastIndexing = getLastSpaceIndexingInfo(spaceKey); if (lastIndexing != null) { builder.field("last_indexing"); lastIndexing.buildDocument(builder, null, false, true); } builder.endObject(); } builder.endArray(); } builder.endObject(); return builder.string(); }