001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.server.config.beans; 021 022 023import org.apache.directory.server.config.ConfigurationElement; 024 025 026/** 027 * A class used to store the JdbmPartition configuration. 028 * 029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 030 */ 031public class JdbmPartitionBean extends PartitionBean 032{ 033 /** The Entry cache size for this partition */ 034 @ConfigurationElement(attributeType = "ads-partitionCacheSize", isOptional = true, defaultValue = "-1") 035 private int partitionCacheSize = -1; 036 037 /** Tells if the optimizer is enabled or not */ 038 @ConfigurationElement(attributeType = "ads-jdbmPartitionOptimizerEnabled", isOptional = true, defaultValue = "true") 039 private boolean jdbmPartitionOptimizerEnabled = true; 040 041 042 /** 043 * Create a new JdbmPartitionBean instance 044 */ 045 public JdbmPartitionBean() 046 { 047 } 048 049 050 /** 051 * Used to specify the entry cache size for a Partition. Various Partition 052 * implementations may interpret this value in different ways: i.e. total cache 053 * size limit verses the number of entries to cache. 054 * 055 * @param partitionCacheSize the maximum size of the cache in the number of entries 056 */ 057 public void setPartitionCacheSize( int partitionCacheSize ) 058 { 059 this.partitionCacheSize = partitionCacheSize; 060 } 061 062 063 /** 064 * Gets the entry cache size for this JdbmPartition. 065 * 066 * @return the maximum size of the cache as the number of entries maximum before paging out 067 */ 068 public int getPartitionCacheSize() 069 { 070 return partitionCacheSize; 071 } 072 073 074 /** 075 * @return <code>true</code> if the optimizer is enabled 076 */ 077 public boolean isJdbmPartitionOptimizerEnabled() 078 { 079 return jdbmPartitionOptimizerEnabled; 080 } 081 082 083 /** 084 * Enable or disable the optimizer 085 * 086 * @param jdbmPartitionOptimizerEnabled True or false 087 */ 088 public void setJdbmPartitionOptimizerEnabled( boolean jdbmPartitionOptimizerEnabled ) 089 { 090 this.jdbmPartitionOptimizerEnabled = jdbmPartitionOptimizerEnabled; 091 } 092 093 094 /** 095 * {@inheritDoc} 096 */ 097 public String toString( String tabs ) 098 { 099 StringBuilder sb = new StringBuilder(); 100 101 sb.append( tabs ).append( "JdbmPartitionBean :\n" ); 102 sb.append( super.toString( tabs ) ); 103 sb.append( tabs ).append( " partition cache size : " ).append( partitionCacheSize ).append( '\n' ); 104 sb.append( toString( tabs, " jdbm partition optimizer enabled", jdbmPartitionOptimizerEnabled ) ); 105 106 return sb.toString(); 107 } 108 109 110 /** 111 * {@inheritDoc} 112 */ 113 public String toString() 114 { 115 return toString( "" ); 116 } 117}