@Override public void handle(Message<JsonObject> event) { Integer id = event.body.getInteger("id"); JsonObject params = event.body.getObject("op"); JsonObject state = event.body.getObject("state"); JsonObject meta = state.getObject("meta"); if (meta == null) { meta = new JsonObject(); } StringBuilder key = new StringBuilder(); key.append(HandlerUtils.determineKs(params, state, null)); key.append(' '); key.append(HandlerUtils.determineCf(params, state, null)); key.append(' '); key.append(params.getString("type")); meta.putObject(key.toString(), new JsonObject().putString("clazz", params.getString("clazz"))); state.putObject("meta", meta); event.reply(new JsonObject().putString(id.toString(), "OK").putObject("state", state)); }
public static void logControllerCommand( String request, int statusCode, String respond, String userID) { JsonObject jsonObj = new JsonObject(); Long timestamp = System.currentTimeMillis(); jsonObj.putNumber("time", timestamp); jsonObj.putString("type", "Controller"); if (userID != null) jsonObj.putString("userID", userID); jsonObj.putObject("request", new JsonObject(request)); JsonObject resJsonObj = new JsonObject(); resJsonObj.putString("code", "" + statusCode); if (respond != null && respond.length() != 0) { if (respond.length() > 1024) resJsonObj.putString("data", "deprecated because too long"); else resJsonObj.putObject("data", new JsonObject(respond)); } jsonObj.putObject("resonse", resJsonObj); collLog.insert(jsonToDBObject(jsonObj)); }
public static void logSANodeValue(String nodeID, String nodeName, String nodeValue) { JsonObject jsonObj = new JsonObject(); Long timestamp = System.currentTimeMillis(); jsonObj.putNumber("time", timestamp); jsonObj.putString("type", "SANode"); jsonObj.putString("nodeID", nodeID); jsonObj.putString("nodeName", nodeName); jsonObj.putObject("data", new JsonObject(nodeValue)); jsonObj.putArray("users", AccountManager.getRegisteredUserIDList(nodeID)); collLog.insert(jsonToDBObject(jsonObj)); }
@Override public void handleUser(Message<JsonObject> event) { Integer id = event.body.getInteger("id"); JsonObject params = event.body.getObject("op"); JsonObject state = event.body.getObject("state"); JsonObject meta = state.getObject("meta"); JsonObject metaColumn = state.getObject("metaColumn"); JsonObject metaRanged = state.getObject("metaRanged"); if (meta == null) { meta = new JsonObject(); } if (metaColumn == null) { metaColumn = new JsonObject(); } if (metaRanged == null) { metaRanged = new JsonObject(); } if (params.getString("type") != null) { StringBuilder key = new StringBuilder(); key.append(HandlerUtils.instance.determineKs(params, state, null)); key.append(' '); key.append(HandlerUtils.instance.determineCf(params, state, null)); key.append(' '); key.append(params.getString("type")); meta.putObject( key.toString(), new JsonObject().putString("clazz", params.getString("clazz"))); state.putObject("meta", meta); event.reply(new JsonObject().putString(id.toString(), "OK").putObject("state", state)); } else if (params.getField("name") != null) { Object o = params.getField("name"); ByteBuffer bb = HandlerUtils.instance.byteBufferForObject(o); StringBuilder key = new StringBuilder(); key.append(HandlerUtils.instance.determineKs(params, state, null)); key.append(' '); key.append(HandlerUtils.instance.determineCf(params, state, null)); key.append(' '); key.append(ByteBufferUtil.bytesToHex(bb)); metaColumn.putObject( key.toString(), new JsonObject().putString("clazz", params.getString("clazz"))); state.putObject("metaColumn", metaColumn); event.reply(new JsonObject().putString(id.toString(), "OK").putObject("state", state)); } else if (params.getField(Operations.RANGE_START) != null) { Object start = params.getField(Operations.RANGE_START); Object end = params.getField(Operations.RANGE_END); ByteBuffer sbuf = HandlerUtils.instance.byteBufferForObject(start); ByteBuffer ebuf = HandlerUtils.instance.byteBufferForObject(end); StringBuilder key = new StringBuilder(); key.append(HandlerUtils.instance.determineKs(params, state, null)); key.append(' '); key.append(HandlerUtils.instance.determineCf(params, state, null)); key.append(' '); key.append(ByteBufferUtil.bytesToHex(sbuf)); JsonObject value = new JsonObject(); value.putString("clazz", params.getString("clazz")); value.putString("end", ByteBufferUtil.bytesToHex(ebuf)); metaRanged.putObject(key.toString(), value); state.putObject("metaRanged", metaRanged); event.reply(new JsonObject().putString(id.toString(), "OK").putObject("state", state)); } else { throw new RuntimeException("hit bottom this is bad ok"); } }