/** * Called to increment the number of Instrumentables registered. */ void incrementInstrumentableCount() { int count; synchronized( m_semaphore ) { count = ++m_instrumentableCount; } m_instrumentablesInstrument.setValue( count ); }
/** * 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 ); }
/** * Called to increment the number of Instruments registered. */ void incrementInstrumentCount() { int count; synchronized( m_semaphore ) { count = ++m_instrumentCount; } m_instrumentsInstrument.setValue( count ); }
/** * 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 ); }
/** * 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 ); }
/** * 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() ); } }
/** * 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 );
m_instrumentTime.setValue( (int)( System.currentTimeMillis() - start ) );
/** * 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; }
/** * This method holds the requested object in a HashMap combined * with a LinkedList to create the MRU. * It also stores objects onto the filesystem if configured. * * @param key The key of the object to be stored * @param value The object to be stored */ public synchronized void hold( Object key, Object value ) { if( getLogger().isDebugEnabled() ) { getLogger().debug( "Holding object in memory:" ); getLogger().debug( " key: " + key ); getLogger().debug( " value: " + value ); } /** ...first test if the max. objects in cache is reached... */ while( m_mrulist.size() >= m_maxobjects ) { /** ...ok, heapsize is reached, remove the last element... */ free(); } /** ..put the new object in the cache, on the top of course ... */ m_cache.put( key, value ); m_mrulist.remove( key ); m_mrulist.addFirst( key ); m_sizeInstrument.setValue( m_mrulist.size() ); }
/** * Remove the object associated to the given key. * * @param key The key of to be removed object */ public synchronized void remove( Object key ) { if( getLogger().isDebugEnabled() ) { getLogger().debug( "Removing object from store" ); getLogger().debug( " key: " + key ); } m_cache.remove( key ); m_mrulist.remove( key ); m_sizeInstrument.setValue( m_mrulist.size() ); if( m_persistent && key != null ) { m_persistentStore.remove( key ); } }
m_stateSaveTimeInstrument.setValue( (int)( System.currentTimeMillis() - now ) );
/** * Frees some values of the data file.<br> */ public void free() { Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doFree(); m_sizeInstrument.setValue( doGetSize() ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }
/** * Store the given object in the indexed data file. * * @param key the key object * @param value the value object * @exception IOException */ public void store(Object key, Object value) throws IOException { Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doStore(key, value); m_sizeInstrument.setValue( doGetSize() ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }
/** * Removes a value from the data file with the given key. * * @param key the key object */ public void remove(Object key) { Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doRemove(key); m_sizeInstrument.setValue( doGetSize() ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }
/** * Called when an object is being removed permanently from the pool. * This is the method to override when you need to enforce destructional * policies. * <p> * This method is only called by threads that have m_semaphore locked. * * @param poolable Poolable to be completely removed from the pool. */ protected void removePoolable( Poolable poolable ) { try { m_factory.decommission( poolable ); // Notify the InstrumentManager m_decommissionsInstrument.increment(); m_sizeInstrument.setValue( getSize() ); } catch( Exception e ) { if( getLogger().isDebugEnabled() ) { getLogger().debug( "Error decommissioning object", e ); } } }
/** * Clear the Store of all elements */ public void clear() { if (getLogger().isDebugEnabled()) { getLogger().debug("clear(): Clearing the database "); } Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doClear(); m_sizeInstrument.setValue( 0 ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }
m_sizeInstrument.setValue( m_mrulist.size() );