public static boolean isValidNumber(Object value) { if (value == null) { return false; } if (value instanceof Number) { return isValidNumber((Number) value); } if (value instanceof String) { return isNumeric(value); } return false; }
private synchronized boolean shouldFlush() { if (lastFlush + flushPeriodMillisecond < clock.currentTimeMillis()) { lastFlush = clock.currentTimeMillis(); return true; } return false; } }
private boolean isNotValidValue(Object value) { return !(isNumeric(value) || stringsValuesAsKey); }
public void infoOnce(String format, Object... arguments) { if (maxHistorySizeReached()) return; if (!logger.isInfoEnabled()) return; LogEntry logEntry = new LogEntry(format, arguments); if (shouldLog(logEntry)) logger.info(format, arguments); }
/** * <p> * Register for the given signal. Note that the signal name should * <b>not</b> begin with <b>SIG</b>. For example, if you are interested in * <b>SIGTERM</b>, you should call <code>register("TERM")</code>. * </p> * <p> * If the registration fails for any reason, a * <code>SignalInterceptorException</code> will be thrown. This is usually * caused by one of the following conditions: * </p> * <ul> * <li>The <code>sun.misc.Signal*</code> classes are not available (e.g. you * are not using Sun's JVM).</li> * <li><code>signame</code> is not a valid trappable signal name on this OS * (e.g. <b>KILL</b> can't be trapped, <b>HUP</b> does not exist on Windows) * </li> * <li>The JVM refuses to let you trap <code>signame</code> because it is * already being used for some other important purpose (e.g. <b>QUIT</b> * and/or <b>BREAK</b> cause the JVM to print diagnostic output).</li> * </ul> */ protected void register(String signame) throws SignalInterceptorException { try { new SignalInterceptorHelper(signame, this); } catch (Throwable e) { throw new SignalInterceptorException(signame, e); } }
/** * Startup the watchdir service. */ private void startupWatchdir() throws Exception { File dirToWatch; if (this.configuration.getProcessConfigDirOrFile().isFile()) { dirToWatch = new File(FilenameUtils.getFullPath(this.configuration.getProcessConfigDirOrFile().getAbsolutePath())); } else { dirToWatch = this.configuration.getProcessConfigDirOrFile(); } // start the watcher this.watcher = new WatchDir(dirToWatch, this); this.watcher.start(); }
public static void main(String[] args) throws Exception { Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration()); ProcessConfigUtils processConfigUtils = injector.getInstance(ProcessConfigUtils.class); JmxProcess process = processConfigUtils.parseProcess(new File("local.json")); new JsonPrinter(System.out).print(process); JmxTransformer transformer = injector.getInstance(JmxTransformer.class); transformer.executeStandalone(process); } }
public ManualClock() { setTime(0L, MILLISECONDS); }
@Override public TextNode textNode(String text) { return super.textNode(propertyResolver.resolveProps(text)); }
@Override @IgnoreJRERequirement public void handle(Signal sig) { if (interceptor.handle(sig.getName()) && (oldHandler != null)) { oldHandler.handle(sig); } } }
private MetricDatum processResult(Result result) { // Sometimes the attribute name and the key of the value are the same MetricDatum metricDatum = new MetricDatum(); if (result.getValuePath().isEmpty()) { metricDatum.setMetricName(result.getAttributeName()); } else { metricDatum.setMetricName(result.getAttributeName() + "_" + KeyUtils.getValuePathString(result)); } metricDatum.setDimensions(dimensions); // Converts the Objects to Double-values for CloudWatch metricDatum.setValue(toDoubleConverter.apply(result.getValue())); metricDatum.setTimestamp(new Date()); return metricDatum; }
private boolean isNotValidValue(Object value) { return !isNumeric(value); }
public TimeBasedFlush(@Nonnull Clock clock, long flushPeriod, @Nonnull TimeUnit unit) { this.clock = clock; this.lastFlush = clock.currentTimeMillis(); this.flushPeriodMillisecond = MILLISECONDS.convert(flushPeriod, unit); }
public ManualClock(long time, TimeUnit unit) { setTime(time, unit); }
private boolean isNotValidValue(Object value){ return ! (isNumeric(value) || stringsValuesAsKey); }
@Override public String serialize(Server server, Query query, Result result) { return isNumeric(result.getValue()) ? "" : null; } };
private String computeActualValue(Object value) { Object transformedValue = valueTransformer.apply(value); if (isNumeric(transformedValue)) { return ":" + transformedValue.toString(); } else if (transformedValue == null) { return ":"; } return "." + transformedValue.toString() + ":" + stringValueDefaultCount; } }
private String computeActualValue(Object value){ Object transformedValue = valueTransformer.apply(value); if(isNumeric(transformedValue)){ return ":" + transformedValue.toString(); } return "." + transformedValue.toString() + ":" + stringValueDefaultCount.toString(); }
private Number computeActualValue(Object value) { Object transformedValue = valueTransformer.apply(value); if (isNumeric(transformedValue)) { return transformedValue instanceof Number ? (Number) transformedValue : Float.valueOf(transformedValue.toString()); } throw new IllegalArgumentException("Only numeric values are supported, enable debug log level for more details."); }
@Override public String serialize(Server server, Query query, Result result) throws IOException { log.debug("Query result: [{}]", result); Object value = result.getValue(); if (!isNumeric(value)) { log.warn("Unable to submit non-numeric value to Kafka: [{}] from result [{}]", value, result); return null; } return createJsonMessage(server, query, result, result.getValuePath(), value); }