Source:
private static synchronized void addHeartbeat(ClientContext ctx, MasterInquireClient inquireClient) { Preconditions.checkNotNull(ctx); Preconditions.checkNotNull(inquireClient); if (sHeartbeatExecutor == null) { sHeartbeatExecutor = Executors.newSingleThreadScheduledExecutor( ThreadFactoryUtils.build("metrics-master-heartbeat-%d", true)); } if (!sAddedShudownHook) { try { Runtime.getRuntime().addShutdownHook(new MetricsMasterSyncShutDownHook()); sAddedShudownHook = true; } catch (IllegalStateException e) { } catch (SecurityException e) { LOG.info("Not registering metrics shutdown hook due to security exception. Regular " + "heartbeats will still be performed to collect metrics data, but no final " + "heartbeat will be performed on JVM exit. Security exception: {}", e.toString()); } } if (sAppId == null) { sAppId = IdUtils.createOrGetAppIdFromConfig(ctx.getClusterConf()); LOG.info("Created metrics heartbeat with ID {}. This ID will be used for identifying info " + "from the client. It can be set manually through the property", sAppId, PropertyKey.Name.USER_APP_ID); } if (MetricsSystem.getNumSinks() == 0) { MetricsSystem.startSinks(ctx.getClusterConf().get(PropertyKey.METRICS_CONF_FILE)); } MetricsHeartbeatContext heartbeatCtx = MASTER_METRICS_HEARTBEAT.computeIfAbsent( inquireClient.getConnectDetails(), (addr) -> { try { InetSocketAddress masterAddr = inquireClient.getPrimaryRpcAddress(); ctx.loadConf(masterAddr, true, true); } catch (UnavailableException e) { LOG.error("Failed to get master address during initialization", e); } catch (AlluxioStatusException ae) { LOG.error("Failed to load configuration from " + "meta master during initialization", ae); } return new MetricsHeartbeatContext(ctx, inquireClient); }); heartbeatCtx.addContext(); LOG.debug("Registered metrics heartbeat with appId: {}", sAppId); }

Target:
public static synchronized void addHeartbeat(ClientContext ctx, MasterInquireClient inquireClient) { Preconditions.checkNotNull(ctx); Preconditions.checkNotNull(inquireClient); if (sExecutorService == null) { sExecutorService = Executors.newSingleThreadScheduledExecutor( ThreadFactoryUtils.build("metrics-master-heartbeat-%d", true)); } if (!sAddedShudownHook) { try { Runtime.getRuntime().addShutdownHook(new MetricsMasterSyncShutDownHook()); sAddedShudownHook = true; } catch (IllegalStateException e) { } catch (SecurityException e) { LOG.info("Not registering metrics shutdown hook due to security exception. Regular " + "heartbeats will still be performed to collect metrics data, but no final " + "heartbeat will be performed on JVM exit. Security exception: {}", e.toString()); } } if (sAppId == null) { sAppId = IdUtils.createOrGetAppIdFromConfig(ctx.getClusterConf()); LOG.info("Created metrics heartbeat with ID {}. This ID will be used for identifying info " + "from the client. It can be set manually through the property", sAppId, PropertyKey.Name.USER_APP_ID); } MetricsHeartbeatContext heartbeatCtx = MASTER_METRICS_HEARTBEAT.computeIfAbsent( inquireClient.getConnectDetails(), (addr) -> new MetricsHeartbeatContext(ctx, inquireClient)); heartbeatCtx.addContext(); LOG.debug("Registered metrics heartbeat with appId: {}", sAppId); }