use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method getAdminSlowQueries.
@Validate
@Override
public void getAdminSlowQueries(int querytimerunning, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
/**
* the queries returned are of this backend's most recent query. If state is active this field shows the currently
* executing query. In all other states, it shows the last query that was executed.
*/
PostgresClient.getInstance(vertxContext.owner()).select("SELECT EXTRACT(EPOCH FROM now() - query_start) as runtime, client_addr, usename, datname, state, query " + "FROM pg_stat_activity " + "WHERE now() - query_start > '" + querytimerunning + " seconds'::interval " + "ORDER BY runtime DESC;", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminSlowQueriesResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method getAdminListLockingQueries.
@Validate
@Override
public void getAdminListLockingQueries(String dbname, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner()).select("SELECT blockedq.pid AS blocked_pid, blockedq.query as blocked_query, " + "blockingq.pid AS blocking_pid, blockingq.query as blocking_query FROM pg_catalog.pg_locks blocked " + "JOIN pg_stat_activity blockedq ON blocked.pid = blockedq.pid " + "JOIN pg_catalog.pg_locks blocking ON (blocking.transactionid=blocked.transactionid AND blocked.pid != blocking.pid) " + "JOIN pg_stat_activity blockingq ON blocking.pid = blockingq.pid " + "WHERE NOT blocked.granted AND blockingq.datname='" + dbname + "';", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getResults());
System.out.println("locking q -> " + new io.vertx.core.json.JsonArray(reply.result().getResults()).encode());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminListLockingQueriesResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method getAdminTotalDbSize.
@Validate
@Override
public void getAdminTotalDbSize(String dbname, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner()).select("select pg_size_pretty(pg_database_size('" + dbname + "')) as db_size", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminTotalDbSizeResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method getAdminPostgresTableSize.
@Validate
@Override
public void getAdminPostgresTableSize(String dbname, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner()).select("SELECT relname as \"Table\", pg_size_pretty(pg_relation_size(relid)) As \" Table Size\"," + " pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as \"Index Size\"" + " FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresTableAccessStatsResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
}
use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.
the class AdminAPI method postAdminUploadmultipart.
@Validate
@Override
public void postAdminUploadmultipart(PersistMethod persistMethod, String busAddress, String fileName, MimeMultipart entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
if (entity != null) {
int parts = entity.getCount();
for (int i = 0; i < parts; i++) {
BodyPart bp = entity.getBodyPart(i);
System.out.println(bp.getFileName());
// System.out.println(bp.getContent());
// System.out.println("-----------------------------------------");
}
String name = "";
try {
if (fileName == null) {
name = entity.getBodyPart(0).getFileName();
} else {
name = fileName;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostAdminUploadmultipartResponse.withOK("TODO")));
}
Aggregations