use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class AdminAPI method getAdminCacheHitRates.
@Override
public void getAdminCacheHitRates(Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
try {
PostgresClient.getInstance(vertxContext.owner()).select("SELECT sum(heap_blks_read) as heap_read, sum(heap_blks_hit) as heap_hit," + " (sum(heap_blks_hit) - sum(heap_blks_read)) / sum(heap_blks_hit) as ratio " + "FROM pg_statio_user_tables;", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminCacheHitRatesResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
} catch (Exception e) {
log.error(e.getMessage());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(e.getMessage()));
}
}
use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class AdminAPI method getAdminTableIndexUsage.
@Override
public void getAdminTableIndexUsage(Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner()).select("SELECT relname, 100 * idx_scan / (seq_scan + idx_scan) percent_of_times_index_used, n_live_tup rows_in_table " + "FROM pg_stat_user_tables " + "ORDER BY n_live_tup DESC;", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminTableIndexUsageResponse.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.tools.utils.OutStream in project raml-module-builder by folio-org.
the class AdminAPI method putAdminLoglevel.
@Validate
@Override
public void putAdminLoglevel(Level level, String javaPackage, java.util.Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
try {
JsonObject updatedLoggers = LogUtil.updateLogConfiguration(javaPackage, level.name());
OutStream os = new OutStream();
os.setData(updatedLoggers);
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withJsonOK(os)));
} catch (Exception e) {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withPlainInternalServerError("ERROR" + e.getMessage())));
log.error(e.getMessage(), e);
}
}
use of org.folio.rest.tools.utils.OutStream in project raml-module-builder by folio-org.
the class AdminAPI method getAdminPostgresTableAccessStats.
@Validate
@Override
public void getAdminPostgresTableAccessStats(Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner()).select("SELECT schemaname,relname,seq_scan,idx_scan,cast(idx_scan " + "AS numeric) / (idx_scan + seq_scan) AS idx_scan_pct " + "FROM pg_stat_user_tables WHERE (idx_scan + seq_scan)>0 " + "ORDER BY idx_scan_pct;", 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.tools.utils.OutStream in project raml-module-builder by folio-org.
the class AdminAPI method getAdminPostgresActiveSessions.
@Validate
@Override
public void getAdminPostgresActiveSessions(String dbname, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
PostgresClient.getInstance(vertxContext.owner(), "public").select("SELECT pid , usename, " + "application_name, client_addr, client_hostname, " + "query, state from pg_stat_activity where datname='" + dbname + "'", reply -> {
if (reply.succeeded()) {
OutStream stream = new OutStream();
stream.setData(reply.result().getRows());
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresActiveSessionsResponse.withJsonOK(stream)));
} else {
log.error(reply.cause().getMessage(), reply.cause());
asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
}
});
}
Aggregations