use of com.alibaba.cobar.manager.dataobject.cobarnode.DataSources in project cobar by alibaba.
the class CobarNodeInstantPerfValueAjax method handleRequest.
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
AjaxParams params = new AjaxParams(request);
CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
JSONArray array = null;
String jsonRst = null;
String st = params.getValueType();
if (null == st || st.equals("")) {
throw new IllegalArgumentException("parameter 'cobarControlValueType' is unknown: " + st);
}
int type = typeMap.get(st);
switch(type) {
case TYPE_SERVER_STATUS:
jsonRst = JSONObject.fromObject(getServerStatus(params)).toString(2);
break;
case TYPE_PROCESSOR_STATUS:
List<Map<String, Object>> listProcessor = listProcessorStatus(params);
array = JSONArray.fromObject(listProcessor);
jsonRst = array.toString(2);
break;
case TYPE_THREAD_POOL:
List<Map<String, Object>> listThreadpool = listThreadPool(params);
array = JSONArray.fromObject(listThreadpool);
jsonRst = array.toString(2);
break;
case TYPE_COMMAND:
List<Map<String, Object>> listCommand = listCommand(params);
array = JSONArray.fromObject(listCommand);
jsonRst = array.toString(2);
break;
case TYPE_DATANODES:
List<Map<String, Object>> listDatanode = listDatanode(params);
array = JSONArray.fromObject(listDatanode);
jsonRst = array.toString(2);
break;
case TYPE_DATABASES:
List<String> listDatabase = null;
if (perfAccesser.checkConnection()) {
listDatabase = perfAccesser.listDataBases();
}
array = JSONArray.fromObject(listDatabase);
jsonRst = array.toString(2);
break;
case TYPE_DATASOURCES:
List<DataSources> listDatasource = null;
if (perfAccesser.checkConnection()) {
listDatasource = perfAccesser.listDataSources();
}
array = JSONArray.fromObject(listDatasource);
jsonRst = array.toString(2);
break;
case TYPE_CONNECTION:
List<Map<String, Object>> listConnection = listConnection(params);
array = JSONArray.fromObject(listConnection);
jsonRst = array.toString(2);
break;
default:
throw new IllegalArgumentException("parameter 'cobarNodeInstantPerfValueType' is known: " + params.getValueType());
}
perfAccesser = null;
response.setHeader("Content-Type", "text/json; charset=utf-8");
OutputStream out = response.getOutputStream();
out.write(jsonRst.getBytes("utf-8"));
out.flush();
}
Aggregations