@Nullable static OperationalExtensionId getOperationalExtensionId(OperationalStats operationalStats) { String serviceName = operationalStats.getServiceName(); String statType = operationalStats.getStatType(); if (Strings.isNullOrEmpty(serviceName) && Strings.isNullOrEmpty(statType)) { return null; } if (!Strings.isNullOrEmpty(serviceName)) { serviceName = serviceName.toLowerCase(); } else { LOG.warn("Found operational stat without service name - {}. This stat will not be discovered by service name.", operationalStats.getClass().getName()); } if (!Strings.isNullOrEmpty(statType)) { statType = statType.toLowerCase(); } else { LOG.warn("Found operational stat without stat type - {}. This stat will not be discovered by stat type.", operationalStats.getClass().getName()); } return new OperationalExtensionId(serviceName, statType); }
@Nullable static OperationalExtensionId getOperationalExtensionId(OperationalStats operationalStats) { String serviceName = operationalStats.getServiceName(); String statType = operationalStats.getStatType(); if (Strings.isNullOrEmpty(serviceName) && Strings.isNullOrEmpty(statType)) { return null; } if (!Strings.isNullOrEmpty(serviceName)) { serviceName = serviceName.toLowerCase(); } else { LOG.warn("Found operational stat without service name - {}. This stat will not be discovered by service name.", operationalStats.getClass().getName()); } if (!Strings.isNullOrEmpty(statType)) { statType = statType.toLowerCase(); } else { LOG.warn("Found operational stat without stat type - {}. This stat will not be discovered by stat type.", operationalStats.getClass().getName()); } return new OperationalExtensionId(serviceName, statType); }
/** * Collects stats from all {@link OperationalStats}. */ private void collectOperationalStats() throws InterruptedException { LOG.trace("Running operational stats extension service iteration"); for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) { if (!isRunning()) { return; } OperationalStats stats = entry.getValue(); LOG.trace("Collecting stats for service {} of type {}", stats.getServiceName(), stats.getStatType()); try { stats.collect(); } catch (Throwable t) { Throwables.propagateIfInstanceOf(t, InterruptedException.class); Throwable rootCause = Throwables.getRootCause(t); if (rootCause instanceof ServiceUnavailableException || rootCause instanceof TException) { // Required service (for example DatasetService in case of ServiceUnavailableException // or Transaction Service in case of TException) is not running yet. // Return without logging. return; } if (rootCause instanceof InterruptedException) { throw (InterruptedException) rootCause; } READ_FAILURE_LOG.warn("Failed to collect stats for service {} of type {} due to {}", stats.getServiceName(), stats.getStatType(), rootCause.getMessage()); } } }
/** * Collects stats from all {@link OperationalStats}. */ private void collectOperationalStats() throws InterruptedException { LOG.trace("Running operational stats extension service iteration"); for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) { if (!isRunning()) { return; } OperationalStats stats = entry.getValue(); LOG.trace("Collecting stats for service {} of type {}", stats.getServiceName(), stats.getStatType()); try { stats.collect(); } catch (Throwable t) { Throwables.propagateIfInstanceOf(t, InterruptedException.class); Throwable rootCause = Throwables.getRootCause(t); if (rootCause instanceof ServiceUnavailableException || rootCause instanceof TException) { // Required service (for example DatasetService in case of ServiceUnavailableException // or Transaction Service in case of TException) is not running yet. // Return without logging. return; } if (rootCause instanceof InterruptedException) { throw (InterruptedException) rootCause; } READ_FAILURE_LOG.warn("Failed to collect stats for service {} of type {} due to {}", stats.getServiceName(), stats.getStatType(), rootCause.getMessage()); } } }