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 JdbmIndex configuration. 028 * 029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 030 */ 031public class JdbmIndexBean extends IndexBean 032{ 033 /** The default cache size */ 034 private static final int DEFAULT_INDEX_CACHE_SIZE = 100; 035 036 /** default duplicate limit before duplicate keys switch to using a btree for values */ 037 private static final int DEFAULT_DUPLICATE_LIMIT = 512; 038 039 /** the size (number of index entries) for the cache */ 040 @ConfigurationElement(attributeType = "ads-indexCacheSize", isOptional = true, defaultValue = "100") 041 private int indexCacheSize = DEFAULT_INDEX_CACHE_SIZE; 042 043 /** duplicate limit before duplicate keys switch to using a btree for values */ 044 @ConfigurationElement(attributeType = "ads-indexNumDupLimit", isOptional = true, defaultValue = "512") 045 private int indexNumDupLimit = DEFAULT_DUPLICATE_LIMIT; 046 047 /** The index file name */ 048 @ConfigurationElement(attributeType = "ads-indexFileName", isOptional = true) 049 private String indexFileName; 050 051 /** The index working directory */ 052 @ConfigurationElement(attributeType = "ads-indexWorkingDir", isOptional = true) 053 private String indexWorkingDir; 054 055 056 /** 057 * Create a new JdbmIndexBean instance 058 */ 059 public JdbmIndexBean() 060 { 061 } 062 063 064 /** 065 * Gets the size of the index cache in terms of the number of index entries to be cached. 066 * 067 * @return the size of the index cache 068 */ 069 public int getIndexCacheSize() 070 { 071 return indexCacheSize; 072 } 073 074 075 /** 076 * Sets the size of the index cache in terms of the number of index entries to be cached. 077 * 078 * @param indexCacheSize the size of the index cache 079 */ 080 public void setIndexCacheSize( int indexCacheSize ) 081 { 082 this.indexCacheSize = indexCacheSize; 083 } 084 085 086 /** 087 * Gets the threshold at which point duplicate keys use btree indirection to store 088 * their values. 089 * 090 * @return the threshold for storing a keys values in another btree 091 */ 092 public int getIndexNumDupLimit() 093 { 094 return indexNumDupLimit; 095 } 096 097 098 /** 099 * 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}