luetzkendorf    2004/11/08 01:30:16

  Modified:    src/share/org/apache/slide/store ResourceId.java
  Log:
  trial with structures UURIs to avoid very large directories with FileStore
  
  Revision  Changes    Path
  1.6       +33 -19    
jakarta-slide/src/share/org/apache/slide/store/ResourceId.java
  
  Index: ResourceId.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/ResourceId.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ResourceId.java   22 Sep 2004 15:20:23 -0000      1.5
  +++ ResourceId.java   8 Nov 2004 09:30:16 -0000       1.6
  @@ -30,6 +30,7 @@
   import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.common.ServiceConnectionFailedException;
   import org.apache.slide.common.ServiceMissingOnRootNodeException;
  +import org.apache.slide.common.SlideRuntimeException;
   import org.apache.slide.common.SlideToken;
   import org.apache.slide.common.Uri;
   import org.apache.slide.common.UriPath;
  @@ -63,7 +64,8 @@
       /**
        ** Number of uuri created in this JVM session
        **/
  -    private static int counter = 0;
  +    private static int counter1 = 0;
  +    private static int counter2 = 0;
       
       /**
        * @pre  uriStr has to contain store prefix, i.e. extractStoreUri has to 
succeed
  @@ -73,15 +75,21 @@
           boolean useBinding = Configuration.useBinding(uri.getStore());
           
           if (useBinding) {
  -            String scopeSlash = uri.getScope().toString();
  -            if (!"/".equals(scopeSlash)) {
  -                scopeSlash += "/";
  -            }
  -            synchronized (ResourceId.class) {
  -                newUuri = uri.isStoreRoot()
  -                    ? scopeSlash
  -                    : scopeSlash+TIMESTAMP+"."+counter++;
  +            StringBuffer b = new StringBuffer();
  +            b.append(uri.getScope().toString());
  +            if (b.length() > 1) b.append("/");
  +            
  +            if (!uri.isStoreRoot()) {
  +                synchronized (ResourceId.class) { 
  +                    b.append(TIMESTAMP).append("/").append(counter2)
  +                        .append("/") .append(counter1++);
  +                    if (counter1 > 500) {
  +                        counter1 = 0;
  +                        counter2++;
  +                    }
  +                }
               }
  +            newUuri = b.toString();
           } else {
               newUuri = uri.toString();
           }
  @@ -233,7 +241,7 @@
        *
        * @param uri Uri to parse
        */
  -    private void parseUuri(String uuri) {
  +    protected void parseUuri(String uuri) {
           // We first try to tokenize the uri string.
           scopes = new ScopeTokenizer(token, namespace, uuri);
           
  @@ -255,12 +263,10 @@
                   }
               }
               catch (ServiceConnectionFailedException e) {
  -                // Problem ...
  -                // FIXME : Throw a RuntimeException ??
  +                throw new SlideRuntimeException(e.toString(), true);
               }
               catch (ServiceAccessException e) {
  -                // Problem ...
  -                // FIXME : Throw a RuntimeException ??
  +                throw new SlideRuntimeException(e.toString(), true);
               }
           }
           
  @@ -269,7 +275,15 @@
           if (store == null) {
               throw new ServiceMissingOnRootNodeException();
           }
  -        
       }
  +    
  +    /**
  +     * Does nothing, overwrited the [EMAIL PROTECTED] Uri#parseUri(String)} 
method to
  +     * avoid its unrequired overhead.
  +     */
  +    protected void parseUri(String uri) {
  +       
  +    }
  +    
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to