water.util.Log类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中water.util.Log类的一些代码示例,展示了Log类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Log类的具体详情如下:
包路径:water.util.Log
类名称:Log

Log介绍

[英]Log for H2O. This class should be loaded before we start to print as it wraps around System.{out,err}. There are three kinds of message: INFO, WARN and ERRR, for general information, events that look wrong, and runtime exceptions. WARN messages and uncaught exceptions are printed on Standard output. Some INFO messages are also printed on standard output. Many more messages are printed to the log file in the ice directory and to the K/V store. Messages can come from a number of subsystems, Sys.RANDF for instance denotes the Random forest implementation. Subsystem names are five letter mnemonics to keep formatting nicely even. To print messages from a subsystem to the log file, set a property on the command line -Dlog.RANDF=true -Dlog.RANDF=false // turn off or call the API function Log.setFlag(Sys.RANDF); Log.unsetFlag(Sys.RANDF); // turn off OOME: when the VM is low on memory, OutOfMemoryError can be thrown in the logging framework while it is trying to print a message. In this case the first message that fails is recorded for later printout, and a number of messages can be discarded. The framework will attempt to print the recorded message later, and report the number of dropped messages, but this done in a best effort and lossy manner. Basically when an OOME occurs during logging, no guarantees are made about the messages.
[中]记录H2O。这个类应该在我们开始打印之前加载,因为它环绕着系统。{out,err}。有三种消息:INFO、WARN和ERRR,用于一般信息、看起来错误的事件和运行时异常。警告消息和未捕获异常打印在标准输出上。一些信息信息也打印在标准输出上。更多的消息被打印到ice目录中的日志文件和K/V存储中。消息可以来自多个子系统,如Sys。例如,RANDF表示随机林实现。子系统名称是五个字母的助记符,以保持格式均匀。要将子系统中的消息打印到日志文件,请在命令行-Dlog上设置一个属性。RANDF=true-Dlog。RANDF=false//关闭或调用API函数日志。setFlag(Sys.RANDF);日志未设置标志(Sys.RANDF);//关闭OOME:当VM内存不足时,日志框架在试图打印消息时会抛出OutOfMemoryError。在这种情况下,将记录第一条失败的消息,以便以后打印输出,并且可以丢弃许多消息。框架稍后将尝试打印记录的消息,并报告丢弃的消息数,但这是以尽最大努力和有损的方式完成的。基本上,当OOME在日志记录期间出现时,不会对消息做出任何保证。

代码示例

代码示例来源:origin: h2oai/h2o-2

/** Temporary log statement. Search for references to make sure they have been removed. */
static public void tmp(Object... objects) {
 info(objects);
}
public static String fixedLength(String s, int length) {

代码示例来源:origin: h2oai/h2o-2

/** Record an exception to the log file and store. */
static public <T extends Throwable> T err(Sys t, T exception) {
 return err(t, "", exception);
}
/** Record an exception to the log file and store. */

代码示例来源:origin: h2oai/h2o-2

static int print( String msg, H2ONode h2os[], String msg2 ) {
  Log.debug(msg,Arrays.toString(h2os),msg2);
  return 0;                   // handy flow-coding return
 }
}

代码示例来源:origin: h2oai/h2o-2

@SuppressWarnings("unused")
@Override protected void init() {
 super.init();
 // Initialize local variables
 _mtry = (mtries==-1) ? // classification: mtry=sqrt(_ncols), regression: mtry=_ncols/3
   ( classification ? Math.max((int)Math.sqrt(_ncols),1) : Math.max(_ncols/3,1))  : mtries;
 if (!(1 <= _mtry && _mtry <= _ncols)) throw new IllegalArgumentException("Computed mtry should be in interval <1,#cols> but it is " + _mtry);
 if (!(0.0 < sample_rate && sample_rate <= 1.0)) throw new IllegalArgumentException("Sample rate should be interval (0,1> but it is " + sample_rate);
 if (DEBUG_DETERMINISTIC && seed == -1) _seed = 0x1321e74a0192470cL; // fixed version of seed
 else if (seed == -1) _seed = _seedGenerator.nextLong(); else _seed = seed;
 if (sample_rate==1f && validation!=null)
  Log.warn(Sys.DRF__, "Sample rate is 100% and no validation dataset is specified. There are no OOB data to compute out-of-bag error estimation!");
 if (!classification && do_grpsplit) {
  Log.info(Sys.DRF__, "Group splitting not supported for DRF regression. Forcing group splitting to false.");
  do_grpsplit = false;
 }
}

代码示例来源:origin: h2oai/h2o-2

static public Iced newInstance(int id) {
 if( id >= CLAZZES.length || CLAZZES[id] == null ) loadId(id);
 Iced f = (Iced) GOLD[id];
 if( f == null ) {
  try { GOLD[id] = f = (Iced) Class.forName(CLAZZES[id]).newInstance(); }
  catch( Exception e ) { Log.err("Failed newinstance for class "+className(id)); throw Log.errRTExcept(e); }
 }
 return f.newInstance();
}

代码示例来源:origin: h2oai/h2o-2

static void initializeLicenseManager() {
 licenseManager = new LicenseManager();
 if (OPT_ARGS.license != null) {
  LicenseManager.Result r = licenseManager.readLicenseFile(OPT_ARGS.license);
  if (r == LicenseManager.Result.OK) {
   Log.info("Successfully read license file ("+ OPT_ARGS.license + ")");
   licenseManager.logLicensedFeatures();
  }
  else {
   Log.err("readLicenseFile failed (" + r + ")");
  }
 }
}

代码示例来源:origin: h2oai/h2o-2

/** Log a warning to standard out, the log file and the store. */
static public Throwable warn(Sys t, String msg) {
 return warn(t, msg, null);
}
/** Log a warning to standard out, the log file and the store. */

代码示例来源:origin: h2oai/h2o-2

private boolean canLoadAll(final Frame fr, ChunkAllocInfo cai) {
 int nchks = fr.anyVec().nChunks();
 long localBytes = 0l;
 for (int i = 0; i < nchks; ++i) {
  Key k = fr.anyVec().chunkKey(i);
  if (k.home()) {
   localBytes += fr.anyVec().chunkForChunkIdx(i).byteSize();
  }
 }
 long memForNonLocal = fr.byteSize() - localBytes;
 // Also must add in the RF internal data structure overhead
 memForNonLocal += fr.numRows() * fr.numCols();
 for(int i = 0; i < H2O.CLOUD._memary.length; i++) {
  HeartBeat hb = H2O.CLOUD._memary[i]._heartbeat;
  long nodeFreeMemory = (long)(hb.get_max_mem() * 0.8); // * OVERHEAD_MAGIC;
  Log.debug(Log.Tag.Sys.RANDF, i + ": computed available mem: " + PrettyPrint.bytes(nodeFreeMemory));
  Log.debug(Log.Tag.Sys.RANDF, i + ": remote chunks require: " + PrettyPrint.bytes(memForNonLocal));
  if (nodeFreeMemory - memForNonLocal <= 0 || (nodeFreeMemory <= TWO_HUNDRED_MB && memForNonLocal >= ONE_FIFTY_MB)) {
   Log.info("Node free memory raw: "+nodeFreeMemory);
   cai.node = H2O.CLOUD._memary[i];
   cai.availableMemory = nodeFreeMemory;
   cai.requiredMemory = memForNonLocal;
   return false;
  }
 }
 return true;
}

代码示例来源:origin: h2oai/h2o-3

private boolean loadNextData() {
  // FIXME: just replace data
  byte[] nextChunk = this.din.getChunkData(this.startCidx + chunkCnt + 1);
  if (nextChunk != null && nextChunk.length > 0) {
   this.data = ArrayUtils.append(this.data, nextChunk);
   this.chunkCnt++;
   Log.trace(String.format("Avro stream wrapper - loading another chunk: StartChunkIdx: %d, LoadedChunkCnt: %d",  startCidx, chunkCnt));
   return true;
  } else {
   return false;
  }
 }
}

代码示例来源:origin: h2oai/h2o-3

static private StringBuilder p(StringBuilder sb, String s, int w) {
 return sb.append(Log.fixedLength(s,w));
}
static private StringBuilder p(StringBuilder sb, double d, int w) {

代码示例来源:origin: h2oai/h2o-3

/**
 * Helper to compute the initial value for Bernoulli for offset != 0
 */
private double getInitialValueBernoulliOffset(Frame train) {
 Log.info("Running Newton-Raphson iteration to find the initial value since offsets are specified.");
 double delta;
 int count = 0;
 double tol = 1e-4;
 //From R GBM vignette:
 //For speed, gbm() does only one step of the Newton-Raphson algorithm
 //rather than iterating to convergence. No appreciable loss of accuracy
 //since the next boosting iteration will simply correct for the prior iterations
 //inadequacy.
 int N = 1; //one step is enough - same as R
 double init = 0; //start with initial value of 0 for convergence
 do {
  double newInit = new NewtonRaphson(frameMap, new Distribution(_parms), init).doAll(train).value();
  delta = Math.abs(init - newInit);
  init = newInit;
  Log.info("Iteration " + (++count) + ": initial value: " + init);
 } while (count < N && delta >= tol);
 if (delta > tol) Log.warn("Not fully converged.");
 Log.info("Newton-Raphson iteration ran for " + count + " iteration(s). Final residual: " + delta);
 return init;
}

代码示例来源:origin: h2oai/h2o-2

/** Log a warning to standard out, the log file and the store. */
static public Throwable warn(String msg) {
 return warn(Sys.WATER, msg, null);
}
/** Log an information message to standard out, the log file and the store. */

代码示例来源:origin: h2oai/h2o-3

Log.trace(String.format("Avro: ChunkIdx: %d read %d records, start at %d off, block count: %d, block size: %d", cidx, cnt, din.getChunkDataStart(cidx), dataFileReader.getBlockCount(), dataFileReader.getBlockSize()));

代码示例来源:origin: h2oai/h2o-2

static private StringBuilder p(StringBuilder sb, String s, int w) {
 return sb.append(Log.fixedLength(s,w));
}
static private StringBuilder p(StringBuilder sb, long l, int w) {

代码示例来源:origin: h2oai/h2o-2

public static void setMemLow() {
 if( !CAN_ALLOC ) return;
 synchronized(_lock) { CAN_ALLOC = false; }
 // NO LOGGING UNDER LOCK!
 Log.info(Sys.CLEAN,"Pausing to swap to disk; more memory may help");
}
public static boolean canAlloc() { return CAN_ALLOC; }

代码示例来源:origin: h2oai/h2o-2

/** Record a message to the log file and store. */
static public void err(String msg) {
 err(Sys.WATER, msg);
}
/** Record an exception to the log file and store. */

代码示例来源:origin: h2oai/h2o-3

/**
 * Internal helper to create a native backend, and fill its state
 * @param network user-given network topology
 * @param parameters user-given network state (weights/biases)
 */
private void javaToNative(byte[] network, byte[] parameters) {
 long now = System.currentTimeMillis();
 //existing state is fine
 if (_backend !=null
     // either not overwriting with user-given (new) state, or we already are in sync
     && (network == null || Arrays.equals(network,_network))
     && (parameters == null || Arrays.equals(parameters,_modelparams))) {
  Log.warn("No need to move the state from Java to native.");
  return;
 }
 if (_backend ==null) {
  _backend = createDeepWaterBackend(get_params()._backend.toString()); // new ImageTrain(_width, _height, _channels, _deviceID, (int)parameters.getOrMakeRealSeed(), _gpu);
  if (_backend == null) throw new IllegalArgumentException("No backend found. Cannot build a Deep Water model.");
 }
 if (network==null) network = _network;
 if (parameters==null) parameters= _modelparams;
 if (network==null || parameters==null) return;
 Log.info("Java state -> native backend.");
 initModel(network, parameters);
 long time = System.currentTimeMillis() - now;
 Log.info("Took: " + PrettyPrint.msecs(time, true));
}

代码示例来源:origin: h2oai/h2o-2

public static void ignore(Throwable e, String msg, boolean printException) { Log.debug(Sys.WATER, msg + (printException? e.toString() : "")); }

代码示例来源:origin: h2oai/h2o-3

boolean cleanupBadClusters( LloydsIterationTask task, final Vec[] vecs, final double[][] centers, final double[] means, final double[] mults, final int[] modes ) {
 // Find any bad clusters
 int clu;
 for( clu=0; clu<centers.length; clu++ )
  if( task._size[clu] == 0 ) break;
 if( clu == centers.length ) return false; // No bad clusters
 long row = task._worst_row;
 Log.warn("KMeans: Re-initializing cluster " + clu + " to row " + row);
 data(centers[clu] = task._cMeans[clu], vecs, row, means, mults, modes);
 task._size[clu] = 1; //FIXME: PUBDEV-871 Some other cluster had their membership count reduced by one! (which one?)
 // Find any MORE bad clusters; we only fixed the first one
 for( clu=0; clu<centers.length; clu++ )
  if( task._size[clu] == 0 ) break;
 if( clu == centers.length ) return false; // No MORE bad clusters
 // If we see 2 or more bad rows, just re-run Lloyds to get the
 // next-worst row.  We don't count this as an iteration, because
 // we're not really adjusting the centers, we're trying to get
 // some centers *at-all*.
 Log.warn("KMeans: Re-running Lloyds to re-init another cluster");
 if (_reinit_attempts++ < centers.length) {
  return true;  // Rerun Lloyds, and assign points to centroids
 } else {
  _reinit_attempts = 0;
  return false;
 }
}

代码示例来源:origin: h2oai/h2o-2

@Override protected Response serve() {
  if ((node_idx.value() < 0) || (node_idx.value() >= H2O.CLOUD.size())) {
   throw new IllegalArgumentException("Illegal node_idx for this H2O cluster (must be from 0 to " + H2O.CLOUD.size() + ")");
  }
  H2ONode node = H2O.CLOUD._memary[node_idx.value()];
  GetTicksTask ppt = new GetTicksTask();
  Log.trace("GetTicksTask starting to node " + node_idx.value() + "...");
  // Synchronous RPC call to get ticks from remote (possibly this) node.
  new RPC<GetTicksTask>(node, ppt).call().get();
  Log.trace("GetTicksTask completed to node " + node_idx.value());
  long[][] cpuTicks = ppt._cpuTicks;
  // Stuff tick information into json response.
  JsonArray j = new JsonArray();
  for (long[] arr : cpuTicks) {
   JsonArray j2 = new JsonArray();
   j2.add(new JsonPrimitive(arr[0]));
   j2.add(new JsonPrimitive(arr[1]));
   j2.add(new JsonPrimitive(arr[2]));
   j2.add(new JsonPrimitive(arr[3]));
   j.add(j2);
  }
  JsonObject o = new JsonObject();
  o.add("cpuTicks", j);
  return Response.done(o);
 }
}

相关文章

微信公众号

最新文章

更多