/** * Called to increment the number of Instrumentables registered. */ void incrementInstrumentableCount() { int count; synchronized( m_semaphore ) { count = ++m_instrumentableCount; } m_instrumentablesInstrument.setValue( count ); }
/** * Creates a new DefaultInstrumentManagerImpl. */ public DefaultInstrumentManagerImpl() { // Initialize the Instrumentable elements. m_totalMemoryInstrument = new ValueInstrument( "total-memory" ); m_freeMemoryInstrument = new ValueInstrument( "free-memory" ); m_memoryInstrument = new ValueInstrument( "memory" ); m_activeThreadCountInstrument = new ValueInstrument( "active-thread-count" ); m_registrationsInstrument = new CounterInstrument( "instrumentable-registrations" ); m_instrumentablesInstrument = new ValueInstrument( "instrumentables" ); m_instrumentsInstrument = new ValueInstrument( "instruments" ); m_samplesInstrument = new ValueInstrument( "samples" ); m_leasedSamplesInstrument = new ValueInstrument( "leased-samples" ); m_leaseRequestsInstrument = new CounterInstrument( "lease-requests" ); m_stateSavesInstrument = new CounterInstrument( "state-saves" ); m_stateSaveTimeInstrument = new ValueInstrument( "state-save-time" ); }
/** * Updates the Thread based Profile Points published by the InstrumentManager. */ private void threadInstruments() { if( m_activeThreadCountInstrument.isActive() ) { // Get the top level thread group. ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); ThreadGroup parent; while( ( parent = threadGroup.getParent() ) != null ) { threadGroup = parent; } m_activeThreadCountInstrument.setValue( threadGroup.activeCount() ); } }
/** * Sets the current value of the Instrument. This method is optimized * to be extremely light weight when an InstrumentManager is not present * and there are no registered ValueInstrumentListeners. * <p> * Note that in many cases is best to call this method even if the * isActive() method returns false. This is because the InstrumentManager * will remember the last value set and use it if the instrument ever * becomes active. For things like pool sizes which do not change often, * this behavior is critical so that users can begin monitoring the value * and see what it was before they connected. Setting the value is * very light weight, but its calculation may not be. It is up to the * user to weigh the benefits and consequences one way or the other. * * @param value The new value for the Instrument. */ public void setValue( int value ) { InstrumentProxy proxy = getInstrumentProxy(); if( proxy != null ) { proxy.setValue( value ); } } }
/** * Called to increment the number of Instruments registered. */ void incrementInstrumentCount() { int count; synchronized( m_semaphore ) { count = ++m_instrumentCount; } m_instrumentsInstrument.setValue( count ); }
/** * Create a new AbstractComponentManagerServlet. * * @param referenceName A name which does not include any spaces or periods * that will be used to name the logger category and * instrumentable which represents this servlet. */ public AbstractComponentManagerServlet( String referenceName ) { //System.out.println( "AbstractComponentManagerServlet( " + referenceName + " )" ); m_referenceName = referenceName; // Set up Instrumentable like AbstractInstrumentable m_registered = false; m_instrumentList = new ArrayList(); m_childList = new ArrayList(); // Create the instruments setInstrumentableName( referenceName ); addInstrument( m_instrumentRequests = new CounterInstrument( "requests" ) ); addInstrument( m_instrumentTime = new ValueInstrument( "time" ) ); }
/** * Called to increment the number of Permanent Instrument Samples registered. */ void incrementPermanentSampleCount() { int count; synchronized( m_semaphore ) { count = ++m_permanentSampleCount + m_leasedSampleCount; } m_samplesInstrument.setValue( count ); }
/** * Create a new AbstractServiceManagerServlet. * * @param referenceName A name which does not include any spaces or periods * that will be used to name the logger category and * instrumentable which represents this servlet. */ public AbstractServiceManagerServlet( String referenceName ) { //System.out.println( "AbstractServiceManagerServlet( " + referenceName + " )" ); m_referenceName = referenceName; // Set up Instrumentable like AbstractInstrumentable m_registered = false; m_instrumentList = new ArrayList(); m_childList = new ArrayList(); // Create the instruments setInstrumentableName( referenceName ); addInstrument( m_instrumentRequests = new CounterInstrument( "requests" ) ); addInstrument( m_instrumentTime = new ValueInstrument( "time" ) ); }
/** * Called to increment the number of Leased Instrument Samples registered. */ void incrementLeasedSampleCount() { int count; int leasedCount; synchronized( m_semaphore ) { leasedCount = ++m_leasedSampleCount; count = m_permanentSampleCount + m_leasedSampleCount; } m_samplesInstrument.setValue( count ); m_leasedSamplesInstrument.setValue( leasedCount ); }
m_sizeInstrument = new ValueInstrument( INSTRUMENT_SIZE_NAME ); m_readySizeInstrument = new ValueInstrument( INSTRUMENT_READY_SIZE_NAME ); m_getsInstrument = new CounterInstrument( INSTRUMENT_GETS_NAME ); m_putsInstrument = new CounterInstrument( INSTRUMENT_PUTS_NAME );
/** * Called to decrement the number of Leased Instrument Samples registered. */ void decrementLeasedSampleCount() { int count; int leasedCount; synchronized( m_semaphore ) { leasedCount = --m_leasedSampleCount; count = m_permanentSampleCount + m_leasedSampleCount; } m_samplesInstrument.setValue( count ); m_leasedSamplesInstrument.setValue( leasedCount ); }
/** * Creates a new ComponentHandler. */ public ComponentHandler() { // Initialize the Instrumentable elements. setInstrumentableName( ExcaliburComponentManager.INSTRUMENTABLE_NAME + ".unnamed handler" ); addInstrument( m_referencesInstrument = new ValueInstrument( "references" ) ); addInstrument( m_getsInstrument = new CounterInstrument( "gets" ) ); addInstrument( m_putsInstrument = new CounterInstrument( "puts" ) ); }
/** * Clear the Store of all elements */ public synchronized void clear() { Enumeration enumer = m_cache.keys(); while( enumer.hasMoreElements() ) { Object key = enumer.nextElement(); if( key == null ) { continue; } remove( key ); } m_sizeInstrument.setValue( 0 ); }
m_referencesInstrument.setValue( m_references );
/** * Get an instance of the type of component handled by this handler. * <p> * Subclasses should not extend this method but rather the doGet method below otherwise * reference counts will not be supported. * <p> * This method is not final to make the class backwards compatible. * * @return a <code>Component</code> * @exception Exception if an error occurs */ public Component get() throws Exception { Component component = doGet(); synchronized( m_referenceSemaphore ) { m_references++; } // Notify the instrument manager m_getsInstrument.increment(); m_referencesInstrument.setValue( m_references ); return component; }
/** * Create a new poolable instance by by calling the newInstance method * on the pool's ObjectFactory. * <p> * This is the method to override when you need to enforce creational * policies. * <p> * This method is only called by threads that have m_semaphore locked. */ protected Poolable newPoolable() throws Exception { Object obj = m_factory.newInstance(); // Notify the InstrumentManager m_createsInstrument.increment(); // The size is incremented after this call in case an error is thrown. m_sizeInstrument.setValue( getSize() + 1 ); return (Poolable)obj; }