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


Java JSONBean类代码示例

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


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

示例1: dumpMetrics

import org.apache.hadoop.hbase.util.JSONBean; //导入依赖的package包/类
/**
 * Dump out a subset of regionserver mbeans only, not all of them, as json on System.out.
 */
public static String dumpMetrics() throws MalformedObjectNameException, IOException {
  StringWriter sw = new StringWriter(1024 * 100); // Guess this size
  try (PrintWriter writer = new PrintWriter(sw)) {
    JSONBean dumper = new JSONBean();
    try (JSONBean.Writer jsonBeanWriter = dumper.open(writer)) {
      MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
      jsonBeanWriter.write(mbeanServer,
        new ObjectName("java.lang:type=Memory"), null, false);
      jsonBeanWriter.write(mbeanServer,
        new ObjectName("Hadoop:service=HBase,name=RegionServer,sub=IPC"), null, false);
      jsonBeanWriter.write(mbeanServer,
        new ObjectName("Hadoop:service=HBase,name=RegionServer,sub=Replication"), null, false);
      jsonBeanWriter.write(mbeanServer,
        new ObjectName("Hadoop:service=HBase,name=RegionServer,sub=Server"), null, false);
    }
  }
  sw.close();
  return sw.toString();
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:DumpRegionServerMetrics.java

示例2: init

import org.apache.hadoop.hbase.util.JSONBean; //导入依赖的package包/类
/**
 * Initialize this servlet.
 */
@Override
public void init() throws ServletException {
  // Retrieve the MBean server
  mBeanServer = ManagementFactory.getPlatformMBeanServer();
  this.jsonBeanWriter = new JSONBean();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:JMXJsonServlet.java

示例3: abort

import org.apache.hadoop.hbase.util.JSONBean; //导入依赖的package包/类
/**
 * Cause the server to exit without closing the regions it is serving, the log
 * it is using and without notifying the master. Used unit testing and on
 * catastrophic events such as HDFS is yanked out from under hbase or we OOME.
 *
 * @param reason the reason we are aborting
 * @param cause  the exception that caused the abort, or null
 */
@Override public void abort(String reason, Throwable cause) {
  String msg = "ABORTING region server " + this + ": " + reason;
  if (cause != null) {
    LOG.fatal(msg, cause);
  } else {
    LOG.fatal(msg);
  }
  this.abortRequested = true;
  // HBASE-4014: show list of coprocessors that were loaded to help debug
  // regionserver crashes.Note that we're implicitly using
  // java.util.HashSet's toString() method to print the coprocessor names.
  LOG.fatal(
      "RegionServer abort: loaded coprocessors are: " + CoprocessorHost.getLoadedCoprocessors());
  // Try and dump metrics if abort -- might give clue as to how fatal came about....
  try {
    LOG.info("Dump of metrics as JSON on abort: " + JSONBean.dumpRegionServerMetrics());
  } catch (MalformedObjectNameException | IOException e) {
    LOG.warn("Failed dumping metrics", e);
  }

  // Do our best to report our abort to the master, but this may not work
  try {
    if (cause != null) {
      msg += "\nCause:\n" + StringUtils.stringifyException(cause);
    }
    // Report to the master but only if we have already registered with the master.
    if (rssStub != null && this.serverName != null) {
      ReportRSFatalErrorRequest.Builder builder = ReportRSFatalErrorRequest.newBuilder();
      ServerName sn = ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());
      builder.setServer(ProtobufUtil.toServerName(sn));
      builder.setErrorMessage(msg);
      rssStub.reportRSFatalError(null, builder.build());
    }
  } catch (Throwable t) {
    LOG.warn("Unable to report fatal error to master", t);
  }
  stop(reason);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:47,代码来源:HRegionServer.java

示例4: abort

import org.apache.hadoop.hbase.util.JSONBean; //导入依赖的package包/类
/**
 * Cause the server to exit without closing the regions it is serving, the log
 * it is using and without notifying the master. Used unit testing and on
 * catastrophic events such as HDFS is yanked out from under hbase or we OOME.
 *
 * @param reason the reason we are aborting
 * @param cause  the exception that caused the abort, or null
 */
@Override
public void abort(String reason, Throwable cause) {
    String msg = "ABORTING region server " + this + ": " + reason;
    if (cause != null) {
        LOG.fatal(msg, cause);
    } else {
        LOG.fatal(msg);
    }
    this.abortRequested = true;
    // HBASE-4014: show list of coprocessors that were loaded to help debug
    // regionserver crashes.Note that we're implicitly using
    // java.util.HashSet's toString() method to print the coprocessor names.
    LOG.fatal("RegionServer abort: loaded coprocessors are: " +
            CoprocessorHost.getLoadedCoprocessors());
    // Try and dump metrics if abort -- might give clue as to how fatal came about....
    try {
        LOG.info("Dump of metrics as JSON on abort: " + JSONBean.dumpRegionServerMetrics());
    } catch (MalformedObjectNameException | IOException e) {
        LOG.warn("Failed dumping metrics", e);
    }

    // Do our best to report our abort to the master, but this may not work
    try {
        if (cause != null) {
            msg += "\nCause:\n" + StringUtils.stringifyException(cause);
        }
        // Report to the master but only if we have already registered with the master.
        if (rssStub != null && this.serverName != null) {
            ReportRSFatalErrorRequest.Builder builder =
                    ReportRSFatalErrorRequest.newBuilder();
            ServerName sn =
                    ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());
            builder.setServer(ProtobufUtil.toServerName(sn));
            builder.setErrorMessage(msg);
            rssStub.reportRSFatalError(null, builder.build());
        }
    } catch (Throwable t) {
        LOG.warn("Unable to report fatal error to master", t);
    }
    stop(reason);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:50,代码来源:HRegionServer.java


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