User: d_jencks
  Date: 01/11/12 10:35:18

  Modified:    src/main/org/jboss/pool ObjectPool.java PoolParameters.java
  Log:
  Updated the manual to show mbean refs: simplified the pool configuration.  The pool 
changes are a bit of a hack, but do expose what I think is a better interface.  
Blocking is always on, idle timeout is always on. Idle timeout and CleanupInterval are 
in minutes.
  
  Revision  Changes    Path
  1.7       +17 -14    jbosspool/src/main/org/jboss/pool/ObjectPool.java
  
  Index: ObjectPool.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosspool/src/main/org/jboss/pool/ObjectPool.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ObjectPool.java   2001/09/11 18:39:23     1.6
  +++ ObjectPool.java   2001/11/12 18:35:18     1.7
  @@ -44,22 +44,24 @@
   
      private HashMap  objects = null;
      private HashSet  deadObjects = null;
  +   //settable parameters
      private int      minSize = 0;
      private int      maxSize = 0;
  -   private boolean  idleTimeout = false;
  -   private boolean  GCEnabled = false;
      private float    maxIdleShrinkPercent = 1.0f;
      // don't replace idle connections that timeout
      private long     idleTimeoutMillis = 1800000l;
      // must be idle in pool for 30 minutes
  +   private long      blockingTimeout = -1;
  +   // meaning forever
  +   //non-settable parameters
  +   private boolean  idleTimeout = true;
  +   private boolean  GCEnabled = false;
      private long     gcMinIdleMillis = 1200000l;
      // must be unused by client for 20 minutes
      private long     cleanupIntervalMillis = 120000l;
      // shrink & gc every 2 minutes
      private long     lastCleanup = System.currentTimeMillis();
      private boolean  blocking = true;
  -   private long      blockingTimeout = -1;
  -   // meaning forever
      private boolean  trackLastUsed = false;
      private boolean  invalidateOnError = false;
      private Object   resizeLock = new Object();
  @@ -220,7 +222,7 @@
       *  pooled instances doesn't shrink as rapidly. Also, under no circumstances
       *  will the number of pooled instances fall below the minimum size.</p> <P>
       *
  -    *  The default is disabled.</P>
  +    *  The default is enabled.</P>
       *
       * @param  enableTimeout                     The new IdleTimeoutEnabled value
       * @see                                      #setGCInterval
  @@ -234,7 +236,7 @@
         if ( objects != null ) {
            throw new IllegalStateException( INITIALIZED );
         }
  -      idleTimeout = enableTimeout;
  +      //idleTimeout = enableTimeout;
      }
   
      /**
  @@ -260,7 +262,7 @@
         if ( objects != null ) {
            throw new IllegalStateException( INITIALIZED );
         }
  -      GCEnabled = enabled;
  +      // GCEnabled = enabled;
      }
   
      /**
  @@ -330,7 +332,7 @@
         if ( objects != null ) {
            throw new IllegalStateException( INITIALIZED );
         }
  -      gcMinIdleMillis = millis;
  +      //gcMinIdleMillis = millis;
      }
   
      /**
  @@ -348,7 +350,7 @@
       * @throws  java.lang.IllegalStateException  Occurs when you try to set the
       *      garbage collection interval after the pool has been initialized.
       */
  -   public void setGCInterval( long millis ) {
  +   public void setCleanupInterval( long millis ) {
         if ( objects != null ) {
            throw new IllegalStateException( INITIALIZED );
         }
  @@ -370,7 +372,7 @@
         if ( objects != null ) {
            throw new IllegalStateException( INITIALIZED );
         }
  -      this.blocking = blocking;
  +      //this.blocking = blocking;
      }
   
      /**
  @@ -398,7 +400,7 @@
         if ( objects != null ) {
            throw new IllegalStateException( INITIALIZED );
         }
  -      trackLastUsed = timestamp;
  +      //trackLastUsed = timestamp;
      }
   
      /**
  @@ -418,7 +420,7 @@
         if ( objects != null ) {
            throw new IllegalStateException( INITIALIZED );
         }
  -      invalidateOnError = invalidate;
  +      //invalidateOnError = invalidate;
      }
   
      /**
  @@ -508,7 +510,8 @@
   
   
      public boolean isCleanupEnabled() {
  -      return isGCEnabled() || isIdleTimeoutEnabled();
  +      //return isGCEnabled() || isIdleTimeoutEnabled();
  +      return true;
      }
   
      /**
  @@ -548,7 +551,7 @@
       * @return    The GCInterval value
       * @see       #setGCInterval
       */
  -   public long getGCInterval() {
  +   public long getCleanupInterval() {
         return cleanupIntervalMillis;
      }
   
  
  
  
  1.4       +133 -4    jbosspool/src/main/org/jboss/pool/PoolParameters.java
  
  Index: PoolParameters.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosspool/src/main/org/jboss/pool/PoolParameters.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PoolParameters.java       2001/09/08 19:32:22     1.3
  +++ PoolParameters.java       2001/11/12 18:35:18     1.4
  @@ -4,6 +4,7 @@
   package org.jboss.pool;
   
   import java.io.Serializable;
  +import java.util.Properties;
   
   /**
    *  Convenience wrapper for all ObjectPool parameters. See the ObjectPool
  @@ -23,7 +24,7 @@
      public boolean   idleTimeoutEnabled = false;
      public boolean   invalidateOnError = false;
      public boolean   trackLastUsed = false;
  -   public long      gcIntervalMillis = 120000l;
  +   public long      cleanupIntervalMillis = 120000l;
      public long      gcMinIdleMillis = 1200000l;
      public long      idleTimeoutMillis = 1800000l;
      public float     maxIdleTimeoutPercent = 1.0f;
  @@ -31,15 +32,143 @@
      public final static String MAX_SIZE_KEY = "MaxSize";
      public final static String BLOCKING_KEY = "Blocking";
      public final static String BLOCKING_TIMEOUT_MS_KEY = "BlockingTimeoutMillis";
  -   public final static String GC_ENABLED_KEY = "GCEnabled";
  +   public final static String CLEANUP_ENABLED_KEY = "CleanupEnabled";
      public final static String IDLE_TIMEOUT_ENABLED_KEY = "IdleTimeoutEnabled";
      public final static String INVALIDATE_ON_ERROR_KEY = "InvalidateOnError";
      public final static String TRACK_LAST_USED_KEY = "TimestampUsed";
  -   public final static String GC_INTERVAL_MS_KEY = "GCIntervazlMillis";
  +   public final static String CLEANUP_INTERVAL_MS_KEY = "CleanupIntervalMillis";
      public final static String GC_MIN_IDLE_MS_KEY = "GCMinIdleMillis";
      public final static String IDLE_TIMEOUT_MS_KEY = "IdleTimeoutMillis";
      public final static String MAX_IDLE_TIMEOUT_PERCENT_KEY = 
"MaxIdleTimeoutPercent";
   
  -   public PoolParameters() {
  +   public final static String CLEANUP_INTERVAL_MIN_KEY = "CleanupIntervalMinutes";
  +   public final static String IDLE_TIMEOUT_MIN_KEY = "IdleTimeoutMinutes";
  +
  +   public PoolParameters(Properties props) {
  +
  +      String s = props.getProperty(BLOCKING_TIMEOUT_MS_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            blockingTimeoutMillis = Long.parseLong(s);
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +      }
  +      /*
  +      s = props.getProperty(GC_ENABLED_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            gcEnabled = new Boolean(s).booleanValue();
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +         }*/
  +      s = props.getProperty(CLEANUP_INTERVAL_MIN_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            setCleanupIntervalMinutes(Long.parseLong(s));
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +      }
  +      /*
  +      s = props.getProperty(GC_MIN_IDLE_MS_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            gcMinIdleMillis = Long.parseLong(s);
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +         }*/
  +      /*
  +      s = props.getProperty(IDLE_TIMEOUT_ENABLED_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            idleTimeoutEnabled = new Boolean(s).booleanValue();
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +         }*/
  +      s = props.getProperty(IDLE_TIMEOUT_MIN_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +           setIdleTimeoutMinutes(Long.parseLong(s));
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +      }
  +      /*
  +      s = props.getProperty(INVALIDATE_ON_ERROR_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            invalidateOnError = new Boolean(s).booleanValue();
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +         }*/
  +      s = props.getProperty(MAX_IDLE_TIMEOUT_PERCENT_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            maxIdleTimeoutPercent = new Float(s).floatValue();
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +      }
  +      s = props.getProperty(MAX_SIZE_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            maxSize = Integer.parseInt(s);
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +      }
  +      s = props.getProperty(MIN_SIZE_KEY);
  +      if (s != null)
  +      {
  +         try
  +         {
  +            minSize = Integer.parseInt(s);
  +         }
  +         catch (Exception e)
  +         {
  +         }
  +      }
  +
  +
  +   }
  +   public void setCleanupIntervalMinutes(long min)
  +   {
  +      cleanupIntervalMillis = min * 60 * 1000;
  +   }
  +   public void setIdleTimeoutMinutes(long min)
  +   {
  +      idleTimeoutMillis = min * 60 * 1000;
      }
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to