当前位置: 首页>>代码示例>>Java>>正文


Java OutStream类代码示例

本文整理汇总了Java中org.folio.rest.tools.utils.OutStream的典型用法代码示例。如果您正苦于以下问题:Java OutStream类的具体用法?Java OutStream怎么用?Java OutStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OutStream类属于org.folio.rest.tools.utils包,在下文中一共展示了OutStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: putAdminLoglevel

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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);
  }

}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:18,代码来源:AdminAPI.java

示例2: getAdminPostgresActiveSessions

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
        }
      });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:24,代码来源:AdminAPI.java

示例3: getAdminPostgresTableAccessStats

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
        }
      });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:26,代码来源:AdminAPI.java

示例4: getAdminPostgresTableSize

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
      }
    });

}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:25,代码来源:AdminAPI.java

示例5: getAdminTableIndexUsage

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
      }
    });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:23,代码来源:AdminAPI.java

示例6: getAdminSlowQueries

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
      }
    });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:27,代码来源:AdminAPI.java

示例7: getAdminTotalDbSize

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
      }
    });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:21,代码来源:AdminAPI.java

示例8: postRmbtestsBooks

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@Validate
@Override
public void postRmbtestsBooks(Book entity, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
  OutStream stream = new OutStream();
  stream.setData(entity);
  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostRmbtestsBooksResponse.withJsonCreated("/dummy/location", stream)));
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:9,代码来源:BooksDemoAPI.java

示例9: postRmbtestsTest

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@Override
public void postRmbtestsTest(Reader entity, RoutingContext routingContext,
    Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler,
    Context vertxContext) throws Exception {

  OutStream os = new OutStream();
  try {
    os.setData(routingContext.getBodyAsJson());
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostRmbtestsTestResponse.withJsonOK(os)));
  } catch (Exception e) {
    log.error( e );
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(null));
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:15,代码来源:BooksDemoAPI.java

示例10: getAdminLoglevel

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@Validate
@Override
public void getAdminLoglevel(java.util.Map<String, String>okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  try {
    JsonObject loggers = LogUtil.getLogConfiguration();
    OutStream os = new OutStream();
    os.setData(loggers);
    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);
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:16,代码来源:AdminAPI.java

示例11: getAdminPostgresLoad

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@Validate
@Override
public void getAdminPostgresLoad(String dbname, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  PostgresClient.getInstance(vertxContext.owner()).select("SELECT pg_stat_reset()", reply -> {

        if(reply.succeeded()){
          /* wait 10 seconds for stats to gather and then query stats table for info */
          vertxContext.owner().setTimer(10000, new Handler<Long>() {
            @Override
            public void handle(Long timerID) {
              PostgresClient.getInstance(vertxContext.owner(), "public").select(
                  "SELECT numbackends as CONNECTIONS, xact_commit as TX_COMM, xact_rollback as "
                  + "TX_RLBCK, blks_read + blks_hit as READ_TOTAL, "
                  + "blks_hit * 100 / (blks_read + blks_hit) "
                  + "as BUFFER_HIT_PERCENT FROM pg_stat_database WHERE datname = '"+dbname+"'", reply2 -> {
                if(reply2.succeeded()){
                  OutStream stream = new OutStream();
                  stream.setData(reply2.result().getRows());
                  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresLoadResponse.
                    withJsonOK(stream)));
                }
                else{
                  log.error(reply2.cause().getMessage(), reply2.cause());
                  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresLoadResponse.
                    withPlainInternalServerError(reply2.cause().getMessage())));
                }
              });
            }
          });
        }
        else{
          log.error(reply.cause().getMessage(), reply.cause());
          asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
        }
      });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:39,代码来源:AdminAPI.java

示例12: getAdminCacheHitRates

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:28,代码来源:AdminAPI.java

示例13: getAdminHealth

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@Override
public void getAdminHealth(Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  OutStream stream = new OutStream();
  stream.setData("OK");
  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminHealthResponse.withAnyOK(stream)));

}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:10,代码来源:AdminAPI.java

示例14: getAdminDbCacheSummary

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@Override
public void getAdminDbCacheSummary(Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  PostgresClient.getInstance(vertxContext.owner()).select(
    "CREATE EXTENSION IF NOT EXISTS \"pg_buffercache\"", reply1 -> {
      if(reply1.succeeded()){
        PostgresClient.getInstance(vertxContext.owner()).select(
          "SELECT c.relname, pg_size_pretty(count(*) * 8192) as buffered, round(100.0 * count(*) / "+
              "(SELECT setting FROM pg_settings WHERE name='shared_buffers')::integer,1) AS buffers_percent,"+
              "round(100.0 * count(*) * 8192 / pg_relation_size(c.oid),1) AS percent_of_relation FROM pg_class c " +
              "INNER JOIN pg_buffercache b ON b.relfilenode = c.relfilenode INNER JOIN pg_database d "+
              "ON (b.reldatabase = d.oid AND d.datname = current_database()) GROUP BY c.oid,c.relname "+
              "ORDER BY 3 DESC LIMIT 20;", reply2 -> {
            if(reply2.succeeded()){

              OutStream stream = new OutStream();
              stream.setData(reply2.result().getRows());

              asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminDbCacheSummaryResponse.
                withJsonOK(stream)));
            }
            else{
              log.error(reply2.cause().getMessage(), reply2.cause());
              asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply2.cause().getMessage()));
            }
          });
      }
      else{
        log.error(reply1.cause().getMessage(), reply1.cause());
        asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply1.cause().getMessage()));
      }
    });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:35,代码来源:AdminAPI.java

示例15: getAdminListLockingQueries

import org.folio.rest.tools.utils.OutStream; //导入依赖的package包/类
@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()));
      }
  });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:29,代码来源:AdminAPI.java


注:本文中的org.folio.rest.tools.utils.OutStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。