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.core.partition.impl.btree.jdbm;
21  
22  
23  import java.io.IOException;
24  import java.util.UUID;
25  
26  import jdbm.RecordManager;
27  import jdbm.helper.Serializer;
28  
29  import org.apache.directory.api.ldap.model.entry.Entry;
30  import org.apache.directory.api.ldap.model.schema.SchemaManager;
31  import org.apache.directory.api.ldap.model.schema.comparators.UuidComparator;
32  import org.apache.directory.server.xdbm.MasterTable;
33  
34  
35  /**
36   * The master table used to store the Attributes of entries.
37   *
38   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
39   */
40  public class JdbmMasterTable extends JdbmTable<String, Entry> implements MasterTable
41  {
42      /**
43       * Creates the master table using JDBM B+Trees for the backing store.
44       *
45       * @param recMan the JDBM record manager
46       * @param schemaManager the schema manager
47       * @throws IOException if there is an error opening the Db file.
48       */
49      public JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager ) throws IOException
50      {
51          super( schemaManager, DBF, recMan, UuidComparator.INSTANCE, UuidSerializer.INSTANCE,
52              new EntrySerializer( schemaManager ) );
53  
54          UuidComparator.INSTANCE.setSchemaManager( schemaManager );
55      }
56  
57  
58      protected JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager, String dbName, Serializer serializer )
59          throws Exception
60      {
61          super( schemaManager, DBF, recMan, UuidComparator.INSTANCE, UuidSerializer.INSTANCE, serializer );
62      }
63  
64  
65      /**
66       * Get's the next value from this SequenceBDb.  This has the side-effect of
67       * changing the current sequence values permanently in memory and on disk.
68       * Master table sequence begins at BigInteger.ONE.  The BigInteger.ZERO is
69       * used for the fictitious parent of the suffix root entry.
70       *
71       * @return the current value incremented by one.
72       */
73      public String getNextId( Entry entry )
74      {
75          return UUID.randomUUID().toString();
76      }
77  }