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.core.partition.impl.btree.jdbm; 021 022 023import java.io.IOException; 024import java.util.UUID; 025 026import jdbm.RecordManager; 027import jdbm.helper.Serializer; 028 029import org.apache.directory.api.ldap.model.entry.Entry; 030import org.apache.directory.api.ldap.model.schema.SchemaManager; 031import org.apache.directory.api.ldap.model.schema.comparators.UuidComparator; 032import org.apache.directory.server.xdbm.MasterTable; 033 034 035/** 036 * The master table used to store the Attributes of entries. 037 * 038 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 039 */ 040public class JdbmMasterTable extends JdbmTable<String, Entry> implements MasterTable 041{ 042 /** 043 * Creates the master table using JDBM B+Trees for the backing store. 044 * 045 * @param recMan the JDBM record manager 046 * @param schemaManager the schema manager 047 * @throws IOException if there is an error opening the Db file. 048 */ 049 public JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager ) throws IOException 050 { 051 super( schemaManager, DBF, recMan, UuidComparator.INSTANCE, UuidSerializer.INSTANCE, 052 new EntrySerializer( schemaManager ) ); 053 054 UuidComparator.INSTANCE.setSchemaManager( schemaManager ); 055 } 056 057 058 protected JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager, String dbName, Serializer serializer ) 059 throws Exception 060 { 061 super( schemaManager, DBF, recMan, UuidComparator.INSTANCE, UuidSerializer.INSTANCE, serializer ); 062 } 063 064 065 /** 066 * Get's the next value from this SequenceBDb. This has the side-effect of 067 * changing the current sequence values permanently in memory and on disk. 068 * Master table sequence begins at BigInteger.ONE. The BigInteger.ZERO is 069 * used for the fictitious parent of the suffix root entry. 070 * 071 * @return the current value incremented by one. 072 */ 073 public String getNextId( Entry entry ) 074 { 075 return UUID.randomUUID().toString(); 076 } 077}