@SuppressWarnings("checkstyle:AbbreviationAsWordInName") // Don't wish to break the API public void registerWithJMX() { JMXUtils.registerMBeanCatchAndLogExceptions(this, OBJECT_NAME_STRING); }
/** Creates a new lock server instance with the given options. */ public static LockServiceImpl create(LockServerOptions options) { if (log.isTraceEnabled()) { log.trace("Creating LockService with options={}", options); } final String jmxBeanRegistrationName = "com.palantir.lock:type=LockServer_" + instanceCount.getAndIncrement(); LockServiceImpl lockService = new LockServiceImpl(options, () -> JMXUtils.unregisterMBeanCatchAndLogExceptions(jmxBeanRegistrationName)); JMXUtils.registerMBeanCatchAndLogExceptions(lockService, jmxBeanRegistrationName); return lockService; }
/** * * @param <T> * @param mbeanClazz * @return proxy interfaces to all beans registered to the server implementing the class mbeanClazz. */ public static <T> Iterable<T> getInstanceBeanProxies(final Class<T> mbeanClazz){ return Iterables.transform( ManagementFactory.getPlatformMBeanServer().queryNames(ObjectName.WILDCARD, Query.isInstanceOf(new StringValueExp(mbeanClazz.getName()))) , obj -> JMXUtils.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), obj, mbeanClazz)); } }
/** * Clears/resets all tracked statistics. */ @Override public synchronized void clearAllStats() { for (SqlCallStats stats : statsByName.values()) { JMXUtils.unregisterMBeanCatchAndLogExceptions(getStatsBeanName(stats)); } namesByUnregisteredSql.clear(); statsByName.clear(); }
/** * Clears/resets all tracked statistics. */ @Override public synchronized void clearAllStats() { for (SqlCallStats stats : statsByName.values()) { JMXUtils.unregisterMBeanCatchAndLogExceptions(getStatsBeanName(stats)); } namesByUnregisteredSql.clear(); statsByName.clear(); }
/** * Registers an mbean for this cache with the provided object name. * * @param objectName * the object name for the mbean */ public void registerMBean(String objectName) { if (objectName == null) { throw new IllegalArgumentException("objectName must not be null."); } JMXUtils.registerMBeanCatchAndLogExceptions(mbean, objectName); }
/** * * @param <T> * @param mbeanClazz * @return proxy interfaces to all beans registered to the server implementing the class mbeanClazz. */ public static <T> Iterable<T> getInstanceBeanProxies(final Class<T> mbeanClazz){ return Iterables.transform( ManagementFactory.getPlatformMBeanServer().queryNames(ObjectName.WILDCARD, Query.isInstanceOf(new StringValueExp(mbeanClazz.getName()))) , obj -> JMXUtils.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), obj, mbeanClazz)); } }
/** * Updates tracked statistics after a SQL query has executed. * * @param sqlName the name of the query (the query's registered key), or * null if the query is unregistered (a name will be automatically * assigned in this case). * @param rawSql the raw SQL for the query. * @param timeInNs the total amount of time in nanoseconds spent executing * the query. */ @SuppressWarnings("ParameterAssignment") // I don't want to copy the query key for perf reasons public synchronized void updateStats(String sqlName, String rawSql, long timeInNs) { if (!collectCallStatsEnabled) { return; } if (sqlName == null) { sqlName = getNameForUnregisteredQuery(rawSql); } SqlCallStats stats = statsByName.get(sqlName); if (stats == null) { stats = new SqlCallStats(sqlName, rawSql); JMXUtils.registerMBeanCatchAndLogExceptions(stats, getStatsBeanName(stats)); statsByName.put(sqlName, stats); } stats.collectCallTimeNanos(timeInNs); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") // Don't wish to break the API public void registerWithJMX() { JMXUtils.registerMBeanCatchAndLogExceptions(this, OBJECT_NAME_STRING); }
/** * Registers an mbean for this cache with the provided object name. * * @param objectName * the object name for the mbean */ public void registerMBean(String objectName) { if (objectName == null) { throw new IllegalArgumentException("objectName must not be null."); } JMXUtils.registerMBeanCatchAndLogExceptions(mbean, objectName); }
/** * Updates tracked statistics after a SQL query has executed. * * @param sqlName the name of the query (the query's registered key), or * null if the query is unregistered (a name will be automatically * assigned in this case). * @param rawSql the raw SQL for the query. * @param timeInNs the total amount of time in nanoseconds spent executing * the query. */ @SuppressWarnings("ParameterAssignment") // I don't want to copy the query key for perf reasons public synchronized void updateStats(String sqlName, String rawSql, long timeInNs) { if (!collectCallStatsEnabled) { return; } if (sqlName == null) { sqlName = getNameForUnregisteredQuery(rawSql); } SqlCallStats stats = statsByName.get(sqlName); if (stats == null) { stats = new SqlCallStats(sqlName, rawSql); JMXUtils.registerMBeanCatchAndLogExceptions(stats, getStatsBeanName(stats)); statsByName.put(sqlName, stats); } stats.collectCallTimeNanos(timeInNs); }