use of io.mycat.beans.mycat.ResultSetBuilder in project Mycat2 by MyCATApache.
the class ShowProcessListSQLHandler method onExecute.
@Override
protected Future<Void> onExecute(SQLRequest<MySqlShowProcessListStatement> request, MycatDataContext dataContext, Response response) {
Map<Thread, Process> processMap = new LinkedHashMap<>(Process.getProcessMap());
MySqlShowProcessListStatement ast = request.getAst();
boolean full = ast.isFull();
int maxCount = full ? Integer.MAX_VALUE : 100;
MycatUser currentUser = full ? null : dataContext.getUser();
ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
resultSetBuilder.addColumnInfo("Id", JDBCType.INTEGER);
resultSetBuilder.addColumnInfo("User", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Host", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("db", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Command", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Time", JDBCType.BIGINT);
resultSetBuilder.addColumnInfo("State", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Info", JDBCType.VARCHAR);
long timestamp = System.currentTimeMillis();
int currentCount = 0;
for (Map.Entry<Thread, Process> entry : processMap.entrySet()) {
Thread holdThread = entry.getKey();
Process process = entry.getValue();
if (currentUser != null && !Objects.equals(process.getUser(), currentUser.getUserName())) {
continue;
}
resultSetBuilder.addObjectRowPayload(Arrays.asList(process.getId(), process.getUser(), process.getHost(), process.getDb(), process.getCommand(), timestamp - process.getCreateTimestamp().getTime(), process.getState(), process.getInfo()));
currentCount++;
if (currentCount >= maxCount) {
break;
}
}
return response.sendResultSet(resultSetBuilder.build());
// return response.proxySelectToPrototype(request.getAst().toString());
}
use of io.mycat.beans.mycat.ResultSetBuilder in project Mycat2 by MyCATApache.
the class MigrateUtil method show.
public static RowBaseIterator show(List<MigrateScheduler> schedulers) {
ResultSetBuilder builder = ResultSetBuilder.create();
builder.addColumnInfo("ID", JDBCType.VARCHAR);
builder.addColumnInfo("NAME", JDBCType.VARCHAR);
builder.addColumnInfo("PROCESS", JDBCType.VARCHAR);
builder.addColumnInfo("COMPLETE", JDBCType.INTEGER);
builder.addColumnInfo("INFO", JDBCType.VARCHAR);
builder.addColumnInfo("ERROR", JDBCType.VARCHAR);
builder.addColumnInfo("START_TIME", JDBCType.TIMESTAMP);
builder.addColumnInfo("END_TIME", JDBCType.TIMESTAMP);
builder.addColumnInfo("INPUT_ROW", JDBCType.BIGINT);
builder.addColumnInfo("OUTPUT_ROW", JDBCType.BIGINT);
for (MigrateScheduler scheduler : schedulers) {
String id = scheduler.getId();
String name = scheduler.getName();
int complete = scheduler.getFuture().isComplete() ? 1 : 0;
String process = scheduler.computeProcess() * 100 + "%";
String info = scheduler.toString();
builder.addObjectRowPayload(new Object[] { id, name, process, complete, info, scheduler.getFuture().cause(), scheduler.getStartTime(), scheduler.getEndTime(), scheduler.computeInputRow(), scheduler.getOutput().getRow().get() });
}
return builder.build();
}
Aggregations