/** * Indicates to the client whether this task is monitoring a currently active * RPC call to a database command. (as defined by * o.a.h.h.client.Operation) * @return true if the monitored handler is currently servicing an RPC call * to a database command. */ public synchronized boolean isOperationRunning() { if(!isRPCRunning()) { return false; } for(Object param : params) { if (param instanceof Operation) { return true; } } return false; }
public synchronized Map<String, Object> toMap() { // only include RPC info if the Handler is actively servicing an RPC call Map<String, Object> map = super.toMap(); if (getState() != State.RUNNING) { return map; } Map<String, Object> rpcJSON = new HashMap<String, Object>(); ArrayList paramList = new ArrayList(); map.put("rpcCall", rpcJSON); rpcJSON.put("queuetimems", getRPCQueueTime()); rpcJSON.put("starttimems", getRPCStartTime()); rpcJSON.put("clientaddress", clientAddress); rpcJSON.put("remoteport", remotePort); rpcJSON.put("packetlength", getRPCPacketLength()); rpcJSON.put("method", methodName); rpcJSON.put("params", paramList); for(Object param : params) { if(param instanceof byte []) { paramList.add(Bytes.toStringBinary((byte []) param)); } else if (param instanceof Operation) { paramList.add(((Operation) param).toMap()); } else { paramList.add(param.toString()); } } return map; }
/** * Indicates to the client whether this task is monitoring a currently active * RPC call to a database command. (as defined by * o.a.h.h.client.Operation) * @return true if the monitored handler is currently servicing an RPC call * to a database command. */ public boolean isOperationRunning() { if(!isRPCRunning()) { return false; } for(Object param : params) { if (param instanceof Operation) { return true; } } return false; }
/** * Indicates to the client whether this task is monitoring a currently active * RPC call to a database command. (as defined by * o.a.h.h.client.Operation) * @return true if the monitored handler is currently servicing an RPC call * to a database command. */ @Override public synchronized boolean isOperationRunning() { if(!isRPCRunning()) { return false; } for(Object param : params) { if (param instanceof Operation) { return true; } } return false; }
@Override public synchronized Map<String, Object> toMap() { // only include RPC info if the Handler is actively servicing an RPC call Map<String, Object> map = super.toMap(); if (getState() != State.RUNNING) { return map; } Map<String, Object> rpcJSON = new HashMap<>(); ArrayList paramList = new ArrayList(); map.put("rpcCall", rpcJSON); rpcJSON.put("queuetimems", getRPCQueueTime()); rpcJSON.put("starttimems", getRPCStartTime()); rpcJSON.put("clientaddress", clientAddress); rpcJSON.put("remoteport", remotePort); rpcJSON.put("packetlength", getRPCPacketLength()); rpcJSON.put("method", methodName); rpcJSON.put("params", paramList); for(Object param : params) { if(param instanceof byte []) { paramList.add(Bytes.toStringBinary((byte []) param)); } else if (param instanceof Operation) { paramList.add(((Operation) param).toMap()); } else { paramList.add(param.toString()); } } return map; }
/** * Logs an RPC response to the LOG file, producing valid JSON objects for * client Operations. * @param params The parameters received in the call. * @param methodName The name of the method invoked * @param call The string representation of the call * @param tag The tag that will be used to indicate this event in the log. * @param clientAddress The address of the client who made this call. * @param startTime The time that the call was initiated, in ms. * @param processingTime The duration that the call took to run, in ms. * @param qTime The duration that the call spent on the queue * prior to being initiated, in ms. * @param responseSize The size in bytes of the response buffer. */ void logResponse(Object[] params, String methodName, String call, String tag, String clientAddress, long startTime, int processingTime, int qTime, long responseSize) throws IOException { // base information that is reported regardless of type of call Map<String, Object> responseInfo = new HashMap<String, Object>(); responseInfo.put("starttimems", startTime); responseInfo.put("processingtimems", processingTime); responseInfo.put("queuetimems", qTime); responseInfo.put("responsesize", responseSize); responseInfo.put("client", clientAddress); responseInfo.put("class", server == null? "": server.getClass().getSimpleName()); responseInfo.put("method", methodName); if (params.length == 2 && server instanceof HRegionServer && params[0] instanceof byte[] && params[1] instanceof Operation) { // if the slow process is a query, we want to log its table as well // as its own fingerprint TableName tableName = TableName.valueOf( HRegionInfo.parseRegionName((byte[]) params[0])[0]); responseInfo.put("table", tableName.getNameAsString()); // annotate the response map with operation details responseInfo.putAll(((Operation) params[1]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + MAPPER.writeValueAsString(responseInfo)); } else if (params.length == 1 && server instanceof HRegionServer && params[0] instanceof Operation) { // annotate the response map with operation details responseInfo.putAll(((Operation) params[0]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + MAPPER.writeValueAsString(responseInfo)); } else { // can't get JSON details, so just report call.toString() along with // a more generic tag. responseInfo.put("call", call); LOG.warn("(response" + tag + "): " + MAPPER.writeValueAsString(responseInfo)); } }
/** * Logs an RPC response to the LOG file, producing valid JSON objects for * client Operations. * @param call The call to log. * @param tag The tag that will be used to indicate this event in the log. * @param clientAddress The address of the client who made this call. * @param startTime The time that the call was initiated, in ms. * @param processingTime The duration that the call took to run, in ms. * @param qTime The duration that the call spent on the queue * prior to being initiated, in ms. * @param responseSize The size in bytes of the response buffer. */ private void logResponse(Invocation call, String tag, String clientAddress, long startTime, int processingTime, int qTime, long responseSize) throws IOException { Object params[] = call.getParameters(); // for JSON encoding ObjectMapper mapper = new ObjectMapper(); // base information that is reported regardless of type of call Map<String, Object> responseInfo = new HashMap<String, Object>(); responseInfo.put("starttimems", startTime); responseInfo.put("processingtimems", processingTime); responseInfo.put("queuetimems", qTime); responseInfo.put("responsesize", responseSize); responseInfo.put("client", clientAddress); responseInfo.put("class", instance.getClass().getSimpleName()); responseInfo.put("method", call.getMethodName()); if (params.length == 2 && instance instanceof HRegionServer && params[0] instanceof byte[] && params[1] instanceof Operation) { // if the slow process is a query, we want to log its table as well // as its own fingerprint byte [] tableName = HRegionInfo.parseRegionName((byte[]) params[0])[0]; responseInfo.put("table", Bytes.toStringBinary(tableName)); // annotate the response map with operation details responseInfo.putAll(((Operation) params[1]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + mapper.writeValueAsString(responseInfo)); } else if (params.length == 1 && instance instanceof HRegionServer && params[0] instanceof Operation) { // annotate the response map with operation details responseInfo.putAll(((Operation) params[0]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + mapper.writeValueAsString(responseInfo)); } else { // can't get JSON details, so just report call.toString() along with // a more generic tag. responseInfo.put("call", call.toString()); LOG.warn("(response" + tag + "): " + mapper.writeValueAsString(responseInfo)); } }
/** * Logs an RPC response to the LOG file, producing valid JSON objects for * client Operations. * @param params The parameters received in the call. * @param methodName The name of the method invoked * @param call The string representation of the call * @param tag The tag that will be used to indicate this event in the log. * @param clientAddress The address of the client who made this call. * @param startTime The time that the call was initiated, in ms. * @param processingTime The duration that the call took to run, in ms. * @param qTime The duration that the call spent on the queue * prior to being initiated, in ms. * @param responseSize The size in bytes of the response buffer. */ void logResponse(Object[] params, String methodName, String call, String tag, String clientAddress, long startTime, int processingTime, int qTime, long responseSize) throws IOException { // base information that is reported regardless of type of call Map<String, Object> responseInfo = new HashMap<String, Object>(); responseInfo.put("starttimems", startTime); responseInfo.put("processingtimems", processingTime); responseInfo.put("queuetimems", qTime); responseInfo.put("responsesize", responseSize); responseInfo.put("client", clientAddress); responseInfo.put("class", serverInstance == null? "": serverInstance.getClass().getSimpleName()); responseInfo.put("method", methodName); if (params.length == 2 && serverInstance instanceof HRegionServer && params[0] instanceof byte[] && params[1] instanceof Operation) { // if the slow process is a query, we want to log its table as well // as its own fingerprint TableName tableName = TableName.valueOf( HRegionInfo.parseRegionName((byte[]) params[0])[0]); responseInfo.put("table", tableName.getNameAsString()); // annotate the response map with operation details responseInfo.putAll(((Operation) params[1]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + MAPPER.writeValueAsString(responseInfo)); } else if (params.length == 1 && serverInstance instanceof HRegionServer && params[0] instanceof Operation) { // annotate the response map with operation details responseInfo.putAll(((Operation) params[0]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + MAPPER.writeValueAsString(responseInfo)); } else { // can't get JSON details, so just report call.toString() along with // a more generic tag. responseInfo.put("call", call); LOG.warn("(response" + tag + "): " + MAPPER.writeValueAsString(responseInfo)); } }
/** * Logs an RPC response to the LOG file, producing valid JSON objects for * client Operations. * @param call The call to log. * @param tag The tag that will be used to indicate this event in the log. * @param client The address of the client who made this call. * @param startTime The time that the call was initiated, in ms. * @param processingTime The duration that the call took to run, in ms. * @param qTime The duration that the call spent on the queue * prior to being initiated, in ms. * @param responseSize The size in bytes of the response buffer. */ private void logResponse(Invocation call, String tag, String clientAddress, long startTime, int processingTime, int qTime, long responseSize) throws IOException { Object params[] = call.getParameters(); // for JSON encoding ObjectMapper mapper = new ObjectMapper(); // base information that is reported regardless of type of call Map<String, Object> responseInfo = new HashMap<String, Object>(); responseInfo.put("starttimems", startTime); responseInfo.put("processingtimems", processingTime); responseInfo.put("queuetimems", qTime); responseInfo.put("responsesize", responseSize); responseInfo.put("client", clientAddress); responseInfo.put("class", instance.getClass().getSimpleName()); responseInfo.put("method", call.getMethodName()); if (params.length == 2 && instance instanceof HRegionServer && params[0] instanceof byte[] && params[1] instanceof Operation) { // if the slow process is a query, we want to log its table as well // as its own fingerprint byte [] tableName = HRegionInfo.parseRegionName((byte[]) params[0])[0]; responseInfo.put("table", Bytes.toStringBinary(tableName)); // annotate the response map with operation details responseInfo.putAll(((Operation) params[1]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + mapper.writeValueAsString(responseInfo)); } else if (params.length == 1 && instance instanceof HRegionServer && params[0] instanceof Operation) { // annotate the response map with operation details responseInfo.putAll(((Operation) params[0]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + mapper.writeValueAsString(responseInfo)); } else { // can't get JSON details, so just report call.toString() along with // a more generic tag. responseInfo.put("call", call.toString()); LOG.warn("(response" + tag + "): " + mapper.writeValueAsString(responseInfo)); } }
/** * Logs an RPC response to the LOG file, producing valid JSON objects for * client Operations. * @param params The parameters received in the call. * @param methodName The name of the method invoked * @param call The string representation of the call * @param tag The tag that will be used to indicate this event in the log. * @param clientAddress The address of the client who made this call. * @param startTime The time that the call was initiated, in ms. * @param processingTime The duration that the call took to run, in ms. * @param qTime The duration that the call spent on the queue * prior to being initiated, in ms. * @param responseSize The size in bytes of the response buffer. */ void logResponse(Object[] params, String methodName, String call, String tag, String clientAddress, long startTime, int processingTime, int qTime, long responseSize) throws IOException { // for JSON encoding ObjectMapper mapper = new ObjectMapper(); // base information that is reported regardless of type of call Map<String, Object> responseInfo = new HashMap<String, Object>(); responseInfo.put("starttimems", startTime); responseInfo.put("processingtimems", processingTime); responseInfo.put("queuetimems", qTime); responseInfo.put("responsesize", responseSize); responseInfo.put("client", clientAddress); responseInfo.put("class", instance.getClass().getSimpleName()); responseInfo.put("method", methodName); if (params.length == 2 && instance instanceof HRegionServer && params[0] instanceof byte[] && params[1] instanceof Operation) { // if the slow process is a query, we want to log its table as well // as its own fingerprint byte [] tableName = HRegionInfo.parseRegionName((byte[]) params[0])[0]; responseInfo.put("table", Bytes.toStringBinary(tableName)); // annotate the response map with operation details responseInfo.putAll(((Operation) params[1]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + mapper.writeValueAsString(responseInfo)); } else if (params.length == 1 && instance instanceof HRegionServer && params[0] instanceof Operation) { // annotate the response map with operation details responseInfo.putAll(((Operation) params[0]).toMap()); // report to the log file LOG.warn("(operation" + tag + "): " + mapper.writeValueAsString(responseInfo)); } else { // can't get JSON details, so just report call.toString() along with // a more generic tag. responseInfo.put("call", call); LOG.warn("(response" + tag + "): " + mapper.writeValueAsString(responseInfo)); } }