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 JdbmPartition configuration.
28   *
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  public class JdbmPartitionBean extends PartitionBean
32  {
33      /** The Entry cache size for this partition */
34      @ConfigurationElement(attributeType = "ads-partitionCacheSize", isOptional = true, defaultValue = "-1")
35      private int partitionCacheSize = -1;
36  
37      /** Tells if the optimizer is enabled or not */
38      @ConfigurationElement(attributeType = "ads-jdbmPartitionOptimizerEnabled", isOptional = true, defaultValue = "true")
39      private boolean jdbmPartitionOptimizerEnabled = true;
40  
41  
42      /**
43       * Create a new JdbmPartitionBean instance
44       */
45      public JdbmPartitionBean()
46      {
47      }
48  
49  
50      /**
51       * Used to specify the entry cache size for a Partition.  Various Partition
52       * implementations may interpret this value in different ways: i.e. total cache
53       * size limit verses the number of entries to cache.
54       *
55       * @param partitionCacheSize the maximum size of the cache in the number of entries
56       */
57      public void setPartitionCacheSize( int partitionCacheSize )
58      {
59          this.partitionCacheSize = partitionCacheSize;
60      }
61  
62  
63      /**
64       * Gets the entry cache size for this JdbmPartition.
65       *
66       * @return the maximum size of the cache as the number of entries maximum before paging out
67       */
68      public int getPartitionCacheSize()
69      {
70          return partitionCacheSize;
71      }
72  
73  
74      /**
75       * @return <code>true</code> if the optimizer is enabled
76       */
77      public boolean isJdbmPartitionOptimizerEnabled()
78      {
79          return jdbmPartitionOptimizerEnabled;
80      }
81  
82  
83      /**
84       * Enable or disable the optimizer
85       * 
86       * @param jdbmPartitionOptimizerEnabled True or false
87       */
88      public void setJdbmPartitionOptimizerEnabled( boolean jdbmPartitionOptimizerEnabled )
89      {
90          this.jdbmPartitionOptimizerEnabled = jdbmPartitionOptimizerEnabled;
91      }
92  
93  
94      /**
95       * {@inheritDoc}
96       */
97      @Override
98      public String toString( String tabs )
99      {
100         StringBuilder sb = new StringBuilder();
101 
102         sb.append( tabs ).append( "JdbmPartitionBean :\n" );
103         sb.append( super.toString( tabs ) );
104         sb.append( tabs ).append( "  partition cache size : " ).append( partitionCacheSize ).append( '\n' );
105         sb.append( toString( tabs, "  jdbm partition optimizer enabled", jdbmPartitionOptimizerEnabled ) );
106 
107         return sb.toString();
108     }
109 
110 
111     /**
112      * {@inheritDoc}
113      */
114     @Override
115     public String toString()
116     {
117         return toString( "" );
118     }
119 }