use of com.brsanthu.googleanalytics.GoogleAnalytics in project h2o-3 by h2oai.
the class H2O method main.
// --------------------------------------------------------------------------
public static void main(String[] args) {
long time0 = System.currentTimeMillis();
if (checkUnsupportedJava())
throw new RuntimeException("Unsupported Java version");
// Record system start-time.
if (!START_TIME_MILLIS.compareAndSet(0L, System.currentTimeMillis()))
// Already started
return;
// Copy all ai.h2o.* system properties to the tail of the command line,
// effectively overwriting the earlier args.
ArrayList<String> args2 = new ArrayList<>(Arrays.asList(args));
for (Object p : System.getProperties().keySet()) {
String s = (String) p;
if (s.startsWith("ai.h2o.")) {
args2.add("-" + s.substring(7));
// hack: Junits expect properties, throw out dummy prop for ga_opt_out
if (!s.substring(7).equals("ga_opt_out"))
args2.add(System.getProperty(s));
}
}
// Parse args
String[] arguments = args2.toArray(args);
parseArguments(arguments);
// Get ice path before loading Log or Persist class
long time1 = System.currentTimeMillis();
String ice = DEFAULT_ICE_ROOT();
if (ARGS.ice_root != null)
ice = ARGS.ice_root.replace("\\", "/");
try {
ICE_ROOT = new URI(ice);
} catch (URISyntaxException ex) {
throw new RuntimeException("Invalid ice_root: " + ice + ", " + ex.getMessage());
}
// Always print version, whether asked-for or not!
long time2 = System.currentTimeMillis();
printAndLogVersion(arguments);
if (ARGS.version) {
Log.flushStdout();
exit(0);
}
// Print help & exit
if (ARGS.help) {
printHelp();
exit(0);
}
// Validate arguments
validateArguments();
Log.info("X-h2o-cluster-id: " + H2O.CLUSTER_ID);
Log.info("User name: '" + H2O.ARGS.user_name + "'");
// Register with GA or not
long time3 = System.currentTimeMillis();
// fetching this list takes ~100ms
List<String> gaidList;
if ((new File(".h2o_no_collect")).exists() || (new File(System.getProperty("user.home") + File.separator + ".h2o_no_collect")).exists() || ARGS.ga_opt_out || (gaidList = JarHash.getResourcesList("gaid")).contains("CRAN") || H2O.ABV.projectVersion().split("\\.")[3].equals("99999")) {
// dev build has minor version 99999
GA = null;
Log.info("Opted out of sending usage metrics.");
} else {
try {
GA = new GoogleAnalytics("UA-56665317-1", "H2O", ABV.projectVersion());
DefaultRequest defReq = GA.getDefaultRequest();
String gaid = null;
if (gaidList.size() > 0) {
if (gaidList.size() > 1)
Log.debug("More than once resource seen in gaid dir.");
for (String str : gaidList) {
if (str.matches("........-....-....-....-............") && !str.equals("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")) {
gaid = str;
break;
}
}
}
if (gaid == null) {
// No UUID, create one
gaid = defReq.clientId();
gaid = gaid.replaceFirst("........-", "ANONYMOU-");
}
defReq.customDimension(CLIENT_ID_GA_CUST_DIM, gaid);
GA.setDefaultRequest(defReq);
} catch (Throwable t) {
Log.POST(11, t.toString());
StackTraceElement[] stes = t.getStackTrace();
for (StackTraceElement ste : stes) Log.POST(11, ste.toString());
}
}
// Epic Hunt for the correct self InetAddress
long time4 = System.currentTimeMillis();
Log.info("IPv6 stack selected: " + IS_IPV6);
SELF_ADDRESS = NetworkInit.findInetAddressForSelf();
// to enable IPv6 preference.
if (!IS_IPV6 && SELF_ADDRESS instanceof Inet6Address) {
Log.err("IPv4 network stack specified but IPv6 address found: " + SELF_ADDRESS + "\n" + "Please specify JVM flags -Djava.net.preferIPv6Addresses=true and -Djava.net.preferIPv4Addresses=false to select IPv6 stack");
H2O.exit(-1);
}
if (IS_IPV6 && SELF_ADDRESS instanceof Inet4Address) {
Log.err("IPv6 network stack specified but IPv4 address found: " + SELF_ADDRESS);
H2O.exit(-1);
}
// Start the local node. Needed before starting logging.
long time5 = System.currentTimeMillis();
startLocalNode();
// Allow extensions to perform initialization that requires the network.
long time6 = System.currentTimeMillis();
for (AbstractH2OExtension ext : extensions) {
ext.onLocalNodeStarted();
}
try {
String logDir = Log.getLogDir();
Log.info("Log dir: '" + logDir + "'");
} catch (Exception e) {
Log.info("Log dir: (Log4j configuration inherited)");
}
Log.info("Cur dir: '" + System.getProperty("user.dir") + "'");
//Print extra debug info now that logs are setup
long time7 = System.currentTimeMillis();
RuntimeMXBean rtBean = ManagementFactory.getRuntimeMXBean();
Log.debug("H2O launch parameters: " + ARGS.toString());
Log.debug("Boot class path: " + rtBean.getBootClassPath());
Log.debug("Java class path: " + rtBean.getClassPath());
Log.debug("Java library path: " + rtBean.getLibraryPath());
// Load up from disk and initialize the persistence layer
long time8 = System.currentTimeMillis();
initializePersistence();
// Initialize NPS
{
String flow_dir;
if (ARGS.flow_dir != null) {
flow_dir = ARGS.flow_dir;
} else {
flow_dir = DEFAULT_FLOW_DIR();
}
if (flow_dir != null) {
flow_dir = flow_dir.replace("\\", "/");
Log.info("Flow dir: '" + flow_dir + "'");
} else {
Log.info("Flow dir is undefined; saving flows not available");
}
NPS = new NodePersistentStorage(flow_dir);
}
// Start network services, including heartbeats
long time9 = System.currentTimeMillis();
// start server services
startNetworkServices();
Log.trace("Network services started");
// The "Cloud of size N formed" message printed out by doHeartbeat is the trigger
// for users of H2O to know that it's OK to start sending REST API requests.
long time10 = System.currentTimeMillis();
Paxos.doHeartbeat(SELF);
assert SELF._heartbeat._cloud_hash != 0 || ARGS.client;
// Start the heartbeat thread, to publish the Clouds' existence to other
// Clouds. This will typically trigger a round of Paxos voting so we can
// join an existing Cloud.
new HeartBeatThread().start();
long time11 = System.currentTimeMillis();
if (GA != null)
startGAStartupReport();
// Log registered parsers
Log.info("Registered parsers: " + Arrays.toString(ParserService.INSTANCE.getAllProviderNames(true)));
long time12 = System.currentTimeMillis();
Log.debug("Timing within H2O.main():");
Log.debug(" Args parsing & validation: " + (time1 - time0) + "ms");
Log.debug(" Get ICE root: " + (time2 - time1) + "ms");
Log.debug(" Print log version: " + (time3 - time2) + "ms");
Log.debug(" Register GA: " + (time4 - time3) + "ms");
Log.debug(" Detect network address: " + (time5 - time4) + "ms");
Log.debug(" Start local node: " + (time6 - time5) + "ms");
Log.debug(" Extensions onLocalNodeStarted(): " + (time7 - time6) + "ms");
Log.debug(" RuntimeMxBean: " + (time8 - time7) + "ms");
Log.debug(" Initialize persistence layer: " + (time9 - time8) + "ms");
Log.debug(" Start network services: " + (time10 - time9) + "ms");
Log.debug(" Cloud up: " + (time11 - time10) + "ms");
Log.debug(" Start GA: " + (time12 - time11) + "ms");
}
Aggregations