View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.directory.server.config.beans;
21  
22  
23  import org.apache.directory.server.config.ConfigurationElement;
24  
25  
26  /**
27   * A class used to store the JdbmIndex configuration.
28   *
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  public class JdbmIndexBean extends IndexBean
32  {
33      /** The default cache size */
34      private static final int DEFAULT_INDEX_CACHE_SIZE = 100;
35  
36      /** default duplicate limit before duplicate keys switch to using a btree for values */
37      private static final int DEFAULT_DUPLICATE_LIMIT = 512;
38  
39      /** the size (number of index entries) for the cache */
40      @ConfigurationElement(attributeType = "ads-indexCacheSize", isOptional = true, defaultValue = "100")
41      private int indexCacheSize = DEFAULT_INDEX_CACHE_SIZE;
42  
43      /** duplicate limit before duplicate keys switch to using a btree for values */
44      @ConfigurationElement(attributeType = "ads-indexNumDupLimit", isOptional = true, defaultValue = "512")
45      private int indexNumDupLimit = DEFAULT_DUPLICATE_LIMIT;
46  
47      /** The index file name */
48      @ConfigurationElement(attributeType = "ads-indexFileName", isOptional = true)
49      private String indexFileName;
50  
51      /** The index working directory */
52      @ConfigurationElement(attributeType = "ads-indexWorkingDir", isOptional = true)
53      private String indexWorkingDir;
54  
55  
56      /**
57       * Create a new JdbmIndexBean instance
58       */
59      public JdbmIndexBean()
60      {
61      }
62  
63  
64      /**
65       * Gets the size of the index cache in terms of the number of index entries to be cached.
66       *
67       * @return the size of the index cache
68       */
69      public int getIndexCacheSize()
70      {
71          return indexCacheSize;
72      }
73  
74  
75      /**
76       * Sets the size of the index cache in terms of the number of index entries to be cached.
77       *
78       * @param indexCacheSize the size of the index cache
79       */
80      public void setIndexCacheSize( int indexCacheSize )
81      {
82          this.indexCacheSize = indexCacheSize;
83      }
84  
85  
86      /**
87       * Gets the threshold at which point duplicate keys use btree indirection to store
88       * their values.
89       *
90       * @return the threshold for storing a keys values in another btree
91       */
92      public int getIndexNumDupLimit()
93      {
94          return indexNumDupLimit;
95      }
96  
97  
98      /**
99       * Sets the threshold at which point duplicate keys use btree indirection to store
100      * their values.
101      *
102      * @param indexNumDupLimit the threshold for storing a keys values in another btree
103      */
104     public void setIndexNumDupLimit( int indexNumDupLimit )
105     {
106         this.indexNumDupLimit = indexNumDupLimit;
107     }
108 
109 
110     /**
111      * @return the indexFileName
112      */
113     public String getIndexFileName()
114     {
115         return indexFileName;
116     }
117 
118 
119     /**
120      * @param indexFileName the indexFileName to set
121      */
122     public void setIndexFileName( String indexFileName )
123     {
124         this.indexFileName = indexFileName;
125     }
126 
127 
128     /**
129      * @return the indexWorkingDir
130      */
131     public String getIndexWorkingDir()
132     {
133         return indexWorkingDir;
134     }
135 
136 
137     /**
138      * @param indexWorkingDir the indexWorkingDir to set
139      */
140     public void setIndexWorkingDir( String indexWorkingDir )
141     {
142         this.indexWorkingDir = indexWorkingDir;
143     }
144 
145 
146     /**
147      * {@inheritDoc}
148      */
149     @Override
150     public String toString( String tabs )
151     {
152         StringBuilder sb = new StringBuilder();
153 
154         sb.append( tabs ).append( "JdbmIndexBean :\n" );
155         sb.append( super.toString( tabs ) );
156         sb.append( toString( tabs, "  index file name", indexFileName ) );
157         sb.append( toString( tabs, "  index working directory", indexWorkingDir ) );
158         sb.append( toString( tabs, "  index cache size", indexCacheSize ) );
159         sb.append( toString( tabs, "  index num dup limit", indexNumDupLimit ) );
160 
161         return sb.toString();
162     }
163 
164 
165     /**
166      * {@inheritDoc}
167      */
168     @Override
169     public String toString()
170     {
171         return toString( "" );
172     }
173 }