public BuiltInRuntimeProducer(){ mxBean = ManagementFactory.getRuntimeMXBean(); statsList = new ArrayList<IStats>(1); stats = new RuntimeStats(); statsList.add(stats); BuiltinUpdater.addTask(new TimerTask() { @Override public void run() { readMbean(); }}); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this); }
@Override public void initialize() { globalRequestProcessorProducer = new GlobalRequestProcessorProducer(); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(globalRequestProcessorProducer); }
public BuiltInGCProducer() { mxBeans = ManagementFactory.getGarbageCollectorMXBeans(); iStatsList = new ArrayList<>(mxBeans.size()); List<String> beanNames = new ArrayList<>(); for (GarbageCollectorMXBean bean : mxBeans) { iStatsList.add(new GCStats(bean.getName())); beanNames.add(bean.getName()); } BuiltinUpdater.addTask(new TimerTask() { @Override public void run() { readMbean(); } }); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this); Accumulators.createGCAccumulators(beanNames); }
/** * Creates a new BlueprintProducer object with given parameters * @param aProducerId a producer id * @param aCategory the name of the category (for presentation needs) * @param aSubsystem the name of the subsystem (for presentation needs) */ public BlueprintProducer(String aProducerId, String aCategory, String aSubsystem){ producerId = aProducerId; category = aCategory; subsystem = aSubsystem; stats = new ActionStats("execute", getMonitoringIntervals()); statsList = new CopyOnWriteArrayList<IStats>(); statsList.add(stats); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this); }
/** * Package protected constructor. */ BuiltInThreadCountProducer(){ stats = new ThreadCountStats(); statsList = new CopyOnWriteArrayList<ThreadCountStats>(); statsList.add(stats); threadMxBean = ManagementFactory.getThreadMXBean(); IProducerRegistry reg = ProducerRegistryFactory.getProducerRegistryInstance(); reg.registerProducer(this); BuiltinUpdater.addTask(new TimerTask() { @Override public void run() { readThreads(); } }); }
public BuiltInOSProducer() { mxBean = ManagementFactory.getOperatingSystemMXBean(); statsList = new ArrayList<IStats>(1); stats = new OSStats(); statsList.add(stats); try { clazz = Class.forName(clazzname); } catch (ClassNotFoundException e) { log.warn("Couldn't find unix version of os class: " + clazzname + ", osstats won't operate properly - " + e.getMessage()); } if (!isUnixOS) { log.warn("Couldn't find unix version of os class: " + clazzname + ", osstats won't operate properly for all stats. Current type is: " + mxBean.getClass().getName()); } BuiltinUpdater.addTask(new TimerTask() { @Override public void run() { readMbean(); } }); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this); Accumulators.setupCPUAccumulators(); }
/** * Creates a new storage with given wrapper. * @param aName storage name * @param aWrapper wrapper name */ public Storage(String aName, StorageWrapper<K, V> aWrapper){ name = aName + '-' + instanceCount.incrementAndGet(); wrapper = aWrapper; stats = new StorageStats(name); statsList = new ArrayList<StorageStats>(1); statsList.add(stats); category = DEF_CATEGORY; subsystem = DEF_SUBSYSTEM; IProducerRegistry reg = ProducerRegistryFactory.getProducerRegistryInstance(); reg.registerProducer(this); RuntimeException e = new RuntimeException(); e.fillInStackTrace(); creationInfo = new CreationInfo(e.getStackTrace()); }
/** * Initialization. Moved out to be reused in unit-tests. */ private void init(){ statsMap = new ConcurrentHashMap<>(); statsList = new CopyOnWriteArrayList<>(); cumulatedStats = new ErrorStats("cumulated"); statsList.add(cumulatedStats); catchers = new ConcurrentHashMap<>(); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this); //add charts for cumulated errors. AfterStartTasks.submitTask(new Runnable() { @Override public void run() { AccumulatorRepository.getInstance().createAccumulator(createAccumulatorDefinition("Errors.Cumulated.Total", "total", "cumulated")); } }); AfterStartTasks.submitTask(new Runnable() { @Override public void run() { AccumulatorRepository.getInstance().createAccumulator(createAccumulatorDefinition("Errors.Cumulated.Initial", "initial", "cumulated")); } }); errorHandlingConfig = null; }
registry.registerProducer(new BuiltInMemoryProducer(BuiltInMemoryProducer.FREE)); registry.registerProducer(new BuiltInMemoryProducer(BuiltInMemoryProducer.MAX)); registry.registerProducer(new BuiltInMemoryProducer(BuiltInMemoryProducer.TOTAL)); for (MemoryPoolMXBean pool : pools){ BuiltInMemoryPoolProducer p = new BuiltInMemoryPoolProducer(pool); registry.registerProducer(p); List<BuiltInMemoryPoolProducer> pp = producers.get(pool.getType()); if (pp==null){ registry.registerProducer(vp);
/** * Package protected constructor. */ BuiltInThreadStatesProducer(){ cumulated = new ThreadStateStats("cumulated"); statsMap = new EnumMap<>(Thread.State.class); statsList = new CopyOnWriteArrayList<ThreadStateStats>(); statsList.add(cumulated); for (Thread.State state : Thread.State.values()){ ThreadStateStats statsObject = new ThreadStateStats(state.name()); statsMap.put(state, statsObject); statsList.add(statsObject); } threadMxBean = ManagementFactory.getThreadMXBean(); IProducerRegistry reg = ProducerRegistryFactory.getProducerRegistryInstance(); reg.registerProducer(this); BuiltinUpdater.addTask(new TimerTask() { @Override public void run() { readThreads(); } }); }
/** * Builds all mbean producer that required by mbean producers * configuration. */ public static void buildProducers() { // Registering decorator for mbean stats DecoratorRegistryFactory.getDecoratorRegistry().addDecorator( MBeanStats.class, new GeneralMBeanDecorator() ); for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) for (final ObjectInstance mBean : server.queryMBeans(null, null)) if(isMBeanRequired(mBean)) { SimpleStatsProducer<MBeanStats> producer = buildProducer(server, mBean); if (producer != null) { producerRegistry.registerProducer(producer); log.debug("Registered new producer for " + mBean.getObjectName().getCanonicalName() + "mbean"); } } }
category = "filter"; ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this);
/** * Creates a new MoskitoInvocationProxy with given implementation, handler and stats factory, and interfaces to monitor. * @param anImplementation Implementation object for all interfaces, i.e. MyServiceImpl * @param aHandler the call handler, i.e. net.java.dev.moskito.core.predefined.ServiceStatsCallHandler * @param factory the factory for the stats, i.e. net.java.dev.moskito.core.predefined.ServiceStatsFactory * @param producerId the id of the producer (for ui) i.e. MyService or MyService-1 ... * @param category the key/name/id for the monitored category i.e. service,api,controller,persistence * @param subsystem the key/name/id for the monitored i.e. user,shop,messaging * @param interfaces interfaces which can be called from outside, i.e. MyService */ public MoskitoInvokationProxy(Object anImplementation, IOnDemandCallHandler aHandler, IOnDemandStatsFactory<S> factory, String producerId, String category, String subsystem, Class<?>... interfaces ){ if (interfaces.length==0) throw new RuntimeException("No interfaces specified!"); implementation = anImplementation; supportedInterfaces = interfaces; handler = aHandler; producer = new OnDemandStatsProducer<>(producerId, category, subsystem, factory); producer.setTracingSupported(true); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(producer); guessExceptions(); }
/** * Default Constructor, init mbean, mbeanServer, iStats. */ public BuiltinGlobalRequestProcessorProducer() { List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); boolean isAjp = MoskitoConfigurationHolder.getConfiguration().getTomcatRequestProcessorProducerConfig().isAjp(); boolean isHttp = MoskitoConfigurationHolder.getConfiguration().getTomcatRequestProcessorProducerConfig().isHttp(); String key = isAjp && isHttp ? "*" : isHttp ? "http*" : "ajp*"; try { for (MBeanServer server : servers) { Set<ObjectInstance> instances = server.queryMBeans(new ObjectName(String.format(MBEAN_NAME, key)), null); if (instances.size() == 0) { continue; } List<String> beanNames = initFieldsAndCreateStats(server, instances); addUpdaterTask(); ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this); Accumulators.createGlobalRequestProcessorAccumulators(beanNames); break; } } catch (MalformedObjectNameException e) { log.error("Failed to get GlobalRequestProcessor mbeans", e); } }
subsystem = "sampling"; // TODO make configurable producer = new OnDemandStatsProducer(producerId, category, subsystem, mapper.getFactory()); producerRegistry.registerProducer(producer);
return p; ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(producer);
getStatsFactory() ); producerRegistry.registerProducer(producer);