Package org.apache.directory.server.core.partition.impl.btree.jdbm

Examples of org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition


        if ( ( jdbmPartitionBean == null ) || jdbmPartitionBean.isDisabled() )
        {
            return null;
        }

        JdbmPartition jdbmPartition = new JdbmPartition( directoryService.getSchemaManager() );

        jdbmPartition.setCacheSize( jdbmPartitionBean.getPartitionCacheSize() );
        jdbmPartition.setId( jdbmPartitionBean.getPartitionId() );
        jdbmPartition.setOptimizerEnabled( jdbmPartitionBean.isJdbmPartitionOptimizerEnabled() );
        File partitionPath = new File( directoryService.getInstanceLayout().getPartitionsDirectory(),
            jdbmPartitionBean.getPartitionId() );
        jdbmPartition.setPartitionPath( partitionPath.toURI() );

        try
        {
            jdbmPartition.setSuffixDn( jdbmPartitionBean.getPartitionSuffix() );
        }
        catch ( LdapInvalidDnException lide )
        {
            String message = "Cannot set the Dn " + jdbmPartitionBean.getPartitionSuffix() + ", " + lide.getMessage();
            LOG.error( message );
            throw new ConfigurationException( message );
        }

        jdbmPartition.setSyncOnWrite( jdbmPartitionBean.isPartitionSyncOnWrite() );
        jdbmPartition.setIndexedAttributes( createJdbmIndexes( jdbmPartition, jdbmPartitionBean.getIndexes(),
            directoryService ) );

        String contextEntry = jdbmPartitionBean.getContextEntry();

        if ( contextEntry != null )
        {
            try
            {
                // Replace '\n' to real LF
                String entryStr = contextEntry.replaceAll( "\\\\n", "\n" );

                LdifReader ldifReader = new LdifReader();

                List<LdifEntry> entries = ldifReader.parseLdif( entryStr );

                if ( ( entries != null ) && ( entries.size() > 0 ) )
                {
                    LdifEntry entry = entries.get( 0 );
                    jdbmPartition.setContextEntry( entry.getEntry() );
                }
               
                try
                {
                    ldifReader.close();;
View Full Code Here


    {
        /** A structure to hold all the partitions */
        DnNode<Partition> partitionLookupTree = new DnNode<Partition>();

        Dn suffix = new Dn( "dc=example, dc=com" );
        Partition partition = new JdbmPartition();
        partition.setSuffix( suffix );

        partitionLookupTree.add( suffix, partition );

        assertNotNull( partitionLookupTree );
        assertTrue( partitionLookupTree.hasChildren() );
View Full Code Here

    {
        /** A structure to hold all the partitions */
        DnNode<Partition> partitionLookupTree = new DnNode<Partition>();

        Dn suffix1 = new Dn( "dc=example, dc=com" );
        Partition partition1 = new JdbmPartition();
        partition1.setSuffix( suffix1 );

        partitionLookupTree.add( suffix1, partition1 );

        Dn suffix2 = new Dn( "ou=system" );
        Partition partition2 = new JdbmPartition();
        partition2.setSuffix( suffix2 );

        partitionLookupTree.add( suffix2, partition2 );

        assertNotNull( partitionLookupTree );
        assertTrue( partitionLookupTree.hasChildren() );
View Full Code Here

    {
        /** A structure to hold all the partitions */
        DnNode<Partition> partitionLookupTree = new DnNode<Partition>();

        Dn suffix1 = new Dn( "dc=example1, dc=com" );
        Partition partition1 = new JdbmPartition();
        partition1.setSuffix( suffix1 );

        partitionLookupTree.add( suffix1, partition1 );

        Dn suffix2 = new Dn( "dc=example2, dc=com" );
        Partition partition2 = new JdbmPartition();
        partition2.setSuffix( suffix2 );

        partitionLookupTree.add( suffix2, partition2 );

        assertNotNull( partitionLookupTree );

View Full Code Here

        if ( ( jdbmPartitionBean == null ) || jdbmPartitionBean.isDisabled() )
        {
            return null;
        }
       
        JdbmPartition jdbmPartition = new JdbmPartition();
       
        jdbmPartition.setCacheSize( jdbmPartitionBean.getPartitionCacheSize() );
        jdbmPartition.setId( jdbmPartitionBean.getPartitionId() );
        jdbmPartition.setOptimizerEnabled( jdbmPartitionBean.isJdbmPartitionOptimizerEnabled() );
        File partitionPath = new File( directoryService.getInstanceLayout().getPartitionsDirectory(), jdbmPartitionBean.getPartitionId() );
        jdbmPartition.setPartitionPath( partitionPath.toURI() );
       
        try
        {
            jdbmPartition.setSuffix( jdbmPartitionBean.getPartitionSuffix() );
        }
        catch ( LdapInvalidDnException lide )
        {
            String message = "Cannot set the Dn " + jdbmPartitionBean.getPartitionSuffix() + ", " + lide.getMessage();
            LOG.error( message );
            throw new ConfigurationException( message );
        }
       
        jdbmPartition.setSyncOnWrite( jdbmPartitionBean.isPartitionSyncOnWrite() );
        jdbmPartition.setIndexedAttributes( createJdbmIndexes( jdbmPartition, jdbmPartitionBean.getIndexes(), directoryService ) );
       
        String contextEntry = jdbmPartitionBean.getContextEntry();
       
        if ( contextEntry != null )
        {
            try
            {
                // Replace '\n' to real LF
                String entryStr = contextEntry.replaceAll( "\\\\n", "\n" );
               
                LdifReader ldifReader = new LdifReader();
               
                List<LdifEntry> entries = ldifReader.parseLdif( entryStr );
               
                if ( ( entries != null ) && ( entries.size() > 0 ) )
                {
                    LdifEntry entry = entries.get( 0 );
                    jdbmPartition.setContextEntry( entry.getEntry() );
                }
            }
            catch ( LdapLdifException lle )
            {
                String message = "Cannot parse the context entry : " + contextEntry + ", " + lle.getMessage();
View Full Code Here

     * {@inheritDoc}
     */
    public JdbmPartition createPartition( String id, String suffix, int cacheSize, File workingDirectory )
        throws Exception
    {
        JdbmPartition partition = new JdbmPartition();
        partition.setId( id );
        partition.setSuffix( new Dn( suffix ) );
        partition.setCacheSize( 500 );
        partition.setPartitionPath( workingDirectory.toURI() );
        return partition;
    }
View Full Code Here

        if ( !( partition instanceof JdbmPartition ) )
        {
            throw new IllegalArgumentException( "Partition must be a JdbmPartition" );
        }

        JdbmPartition jdbmPartition = ( JdbmPartition ) partition;
        Set<Index<?, Entry, Long>> indexedAttributes = jdbmPartition.getIndexedAttributes();

        JdbmIndex<Object, Entry> index = new JdbmIndex<Object, Entry>( attributeId );
        index.setCacheSize( cacheSize );

        indexedAttributes.add( index );
        jdbmPartition.setIndexedAttributes( indexedAttributes );
    }
View Full Code Here

     * @throws Exception If the partition can't be added
     */
    private Partition addPartition(final String partitionId, final String partitionDn) throws Exception {

        // Create a new partition named 'foo'.
        JdbmPartition partition = new JdbmPartition();
        partition.setId(partitionId);
        partition.setPartitionDir(new File(service.getWorkingDirectory(), partitionId));
        partition.setSuffix(partitionDn);
        service.addPartition(partition);

        return partition;
    }
View Full Code Here

    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(schemaLdifPartition);
    ds.setSchemaPartition(schemaPartition);

    JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
    systemPartition.setId("system");
    systemPartition.setPartitionPath(new File(
            ds.getInstanceLayout().getPartitionsDirectory(),
            systemPartition.getId()).toURI());
    systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
    systemPartition.setSchemaManager(ds.getSchemaManager());
    ds.setSystemPartition(systemPartition);

    ds.getChangeLog().setEnabled(false);
    ds.setDenormalizeOpAttrsEnabled(true);
    ds.addLast(new KeyDerivationInterceptor());

    // create one partition
    String orgName= conf.getProperty(ORG_NAME).toLowerCase();
    String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase();

    JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
    partition.setId(orgName);
    partition.setPartitionPath(new File(
            ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
    partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
    ds.addPartition(partition);
    // indexes
    Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
    indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
    indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
    indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
    partition.setIndexedAttributes(indexedAttributes);

    // And start the ds
    ds.setInstanceId(conf.getProperty(INSTANCE));
    ds.startup();
    // context entry, after ds.startup()
View Full Code Here

    {
        /** A structure to hold all the partitions */
        DnNode<Partition> partitionLookupTree = new DnNode<Partition>();

        Dn suffix = new Dn( schemaManager, "dc=example, dc=com" );
        Partition partition = new JdbmPartition( schemaManager );
        partition.setSuffixDn( suffix );

        partitionLookupTree.add( suffix, partition );

        assertNotNull( partitionLookupTree );
        assertTrue( partitionLookupTree.hasChildren() );
View Full Code Here

TOP

Related Classes of org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.