| | |
| | | }
|
| | | }
|
| | |
|
| | | public ModelAndView getResourceUsage(SMTAIServerRequest tranReq) throws Exception |
| | | {
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | |
| | | SMTAIServerApp.getApp().getDatasourceUsgaeToJson(jsonWr);
|
| | | |
| | | return tranReq.returnJson(jsonWr);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | dsDataSource.setTestOnReturn(_dbTestOnReturn);
|
| | | dsDataSource.setPoolPreparedStatements(_dbPoolPreparedStatements);
|
| | | dsDataSource.setMaxPoolPreparedStatementPerConnectionSize(_dbMaxPoolPreparedStatementPerConnectionSize);
|
| | | dsDataSource.setConnectionErrorRetryAttempts(0);
|
| | | dsDataSource.setTestWhileIdle(false); // 关闭空闲检测
|
| | | dsDataSource.setKeepAlive(false);
|
| | |
|
| | | return dsDataSource;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void getDatasourceUsgaeToJson(SMTJsonWriter jsonWr) throws Exception
|
| | | {
|
| | | if(_dsDataSource == null)
|
| | | return; |
| | | |
| | | jsonWr.beginMap("SYSTEM_DS");
|
| | | {
|
| | | jsonWr.addKeyValue("connect", _dsDataSource.getActiveCount() + _dsDataSource.getPoolingCount());
|
| | | }
|
| | | jsonWr.endMap();
|
| | | |
| | | for(SMTDataSource dataSource : this.getDataSourceMap().values())
|
| | | {
|
| | | dataSource.getDatasourceUsgaeToJson(jsonWr);
|
| | | }
|
| | | }
|
| | | |
| | | public SMTDatabase allocDatabase() throws Exception
|
| | | {
|
| | | if(_dsDataSource == null)
|
| | |
| | | private List<AIAttachFile> _listAttchFile = null;
|
| | | private Json _jsonAttachTables = null;
|
| | | private Json _jsonAttachMetrics = null;
|
| | | private long _lastSendChunkedStreamBlockTick = 0;
|
| | | private boolean _sendStarStream = false; // 将输出文字变成*
|
| | |
|
| | |
|
| | |
| | | {
|
| | | if(_sendStarStream)
|
| | | {
|
| | | if((System.currentTimeMillis() - _lastSendChunkedStreamBlockTick) < 2000)
|
| | | return;
|
| | | |
| | | _lastSendChunkedStreamBlockTick = System.currentTimeMillis();
|
| | | |
| | | stream = "#";
|
| | | if(stream.indexOf("\n") >= 0)
|
| | | stream += "\n";
|
| | |
| | |
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase;
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecord;
|
| | | import com.smtservlet.util.SMTJsonWriter;
|
| | |
|
| | | public abstract class SMTDataSource
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | public abstract SMTDatabase allocDatabase() throws Exception;
|
| | | public abstract void getDatasourceUsgaeToJson(SMTJsonWriter jsonWr) throws Exception;
|
| | | }
|
| | |
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase;
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecord;
|
| | | import com.smtservlet.util.Json;
|
| | | import com.smtservlet.util.SMTJsonWriter;
|
| | |
|
| | | public class SMTDataSourceJDBC extends SMTDataSource
|
| | | {
|
| | |
| | | throw new Exception("can't create connect data source : " + this.getId());
|
| | | }
|
| | | }
|
| | | |
| | | @Override
|
| | | public void getDatasourceUsgaeToJson(SMTJsonWriter jsonWr) throws Exception
|
| | | {
|
| | | if(_dsDataSource == null)
|
| | | return; |
| | | |
| | | jsonWr.beginMap(this.getId());
|
| | | {
|
| | | jsonWr.addKeyValue("connect", _dsDataSource.getActiveCount() + _dsDataSource.getPoolingCount());
|
| | | }
|
| | | jsonWr.endMap();
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | catch(Exception ex)
|
| | | {
|
| | | _logger.fatal("load dim value list from db error : " + _id, ex);
|
| | | _logger.fatal("load dim value list from db error : " + _id + ", error=" + ex.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | ]
|
| | | }
|
| | | ]
|
| | | },
|
| | | |
| | | "admin/system/get_resource_usage":{"map":{"class":"#SMTSystemManagerControl", "method":"getResourceUsage"},
|
| | | "swaggers":[
|
| | | { "tags" : ["资源管理"],
|
| | | "title" : "查看资源信息",
|
| | | "parameters" : [
|
| | | ]
|
| | | }
|
| | | ]
|
| | | }
|
| | | } |