Package org.apache.directory.shared.ldap.model.csn

Examples of org.apache.directory.shared.ldap.model.csn.Csn


   
    @Test
    public void testDifferentReplicaIdCSNs()
    {
        long t0 = System.currentTimeMillis();
        Csn csn1 = new Csn( t0, 0, 0, 0 );
        Csn csn2 = new Csn( t0, 0, 1, 0 );
       
        assertEquals( -1, comparator.compare( csn1.toString(), csn2.toString() ) );
        assertEquals( 1, comparator.compare( csn2.toString(), csn1.toString() ) );
    }
View Full Code Here


   
    @Test
    public void testDifferentOperationNumberCSNs()
    {
        long t0 = System.currentTimeMillis();
        Csn csn1 = new Csn( t0, 0, 0, 0 );
        Csn csn2 = new Csn( t0, 0, 0, 1 );
       
        assertEquals( -1, comparator.compare( csn1.toString(), csn2.toString() ) );
        assertEquals( 1, comparator.compare( csn2.toString(), csn1.toString() ) );
    }
View Full Code Here

        UUID uuid = UUID.randomUUID();
        entry.add( SchemaConstants.ENTRY_UUID_AT, uuid.toString() );

        CsnFactory csnFac = new CsnFactory( 0 );
        Csn csn = csnFac.newInstance();
        entry.add( SchemaConstants.ENTRY_CSN_AT, csn.toString() );

        con.add( entry );

        // Analyze entry and description attribute
        Entry addedEntry = con.lookup( dn, "*", "+" );
        assertNotNull( addedEntry );

        Attribute attr = addedEntry.get( SchemaConstants.ENTRY_UUID_AT );
        assertNotNull( attr );

        assertEquals( uuid.toString(), attr.getString() );

        attr = addedEntry.get( SchemaConstants.ENTRY_CSN_AT );
        assertNotNull( attr );
        assertEquals( csn.toString(), attr.getString() );

        // Remove entry
        con.delete( dn );
        con.unBind();
    }
View Full Code Here

                        ldifEntry.addAttribute( SchemaConstants.ENTRY_UUID_AT, entryUuid.toString() );
                    }
                    if ( ldifEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
                    {
                        // No CSN, let's create one
                        Csn csn = csnFactory.newInstance();
                        ldifEntry.addAttribute( SchemaConstants.ENTRY_CSN_AT, csn.toString() );
                    }

                    first = false;
                }
                else
View Full Code Here

        UUID uuid = UUID.randomUUID();
        entry.add( SchemaConstants.ENTRY_UUID_AT, uuid.toString() );

        CsnFactory csnFac = new CsnFactory( 0 );
        Csn csn = csnFac.newInstance();
        entry.add( SchemaConstants.ENTRY_CSN_AT, csn.toString() );

        con.add( entry );

        // Analyze entry and description attribute
        Entry addedEntry = con.lookup( dn, "*", "+" );
        assertNotNull( addedEntry );

        Attribute attr = addedEntry.get( SchemaConstants.ENTRY_UUID_AT );
        assertNotNull( attr );

        assertEquals( uuid.toString(), attr.getString() );

        attr = addedEntry.get( SchemaConstants.ENTRY_CSN_AT );
        assertNotNull( attr );
        assertEquals( csn.toString(), attr.getString() );

        // Remove entry
        con.delete( dn );
        con.unBind();
    }
View Full Code Here

     * starting in the middle.
     */
    @Test
    public void testJournalWriting() throws Exception
    {
        Csn entryCsn = csnFactory.newInstance();
        Csn firstCsn = entryCsn;
        Csn csn100 = null;

        for ( int i = 0; i < 1000; i++ )
        {
            if ( i == 100 )
            {
                csn100 = entryCsn;
            }

            Entry entry = new DefaultEntry( schemaManager, "ou=test" + i + ",ou=system",
                "ObjectClass: top",
                "ObjectClass: organizationalUnit",
                "ou", "test" + i,
                "entryCsn", entryCsn.toString()
                );

            ReplicaEventMessage replicaEventMessage = new ReplicaEventMessage( ChangeType.ADD, entry );
            journal.put( entryCsn.toString(), replicaEventMessage );
            journal.sync();

            entryCsn = csnFactory.newInstance();
        }

        // Now check that the ReplicaEventMessages has been written
        ReplicaEventMessage firstMessage = journal.get( firstCsn.toString() );

        assertEquals( ChangeType.ADD, firstMessage.getChangeType() );
        assertEquals( "test0", firstMessage.getEntry().get( "ou" ).getString() );

        // Read entry from the 100th element
        Cursor<Tuple<String, ReplicaEventMessage>> cursor = journal.cursor( csn100.toString() );
        int pos = 100;

        while ( cursor.next() )
        {
            Tuple<String, ReplicaEventMessage> tuple = cursor.get();
View Full Code Here

     * remaining ones.
     */
    @Test
    public void testJournalTruncate() throws Exception
    {
        Csn entryCsn = csnFactory.newInstance();

        for ( int i = 0; i < 1000; i++ )
        {
            Entry entry = new DefaultEntry( schemaManager, "ou=test" + i + ",ou=system",
                "ObjectClass: top",
                "ObjectClass: organizationalUnit",
                "ou", "test" + i,
                "entryCsn", entryCsn.toString()
                );

            ReplicaEventMessage replicaEventMessage = new ReplicaEventMessage( ChangeType.ADD, entry );
            journal.put( entryCsn.toString(), replicaEventMessage );
            journal.sync();

            entryCsn = csnFactory.newInstance();
        }

View Full Code Here

     */
    @Test
    @Ignore("Performance test")
    public void testJournalPerf() throws Exception
    {
        Csn entryCsn = csnFactory.newInstance();

        // The write perf
        long t0 = System.currentTimeMillis();

        for ( int i = 0; i < 100000; i++ )
        {
            Entry entry = new DefaultEntry( schemaManager, "ou=test" + i + ",ou=system",
                "ObjectClass: top",
                "ObjectClass: organizationalUnit",
                "ou", "test" + i,
                "entryCsn", entryCsn.toString()
                );

            ReplicaEventMessage replicaEventMessage = new ReplicaEventMessage( ChangeType.ADD, entry );
            journal.put( entryCsn.toString(), replicaEventMessage );
            journal.sync();
            recman.commit();

            entryCsn = csnFactory.newInstance();
        }
View Full Code Here

                        ldifEntry.addAttribute( SchemaConstants.ENTRY_UUID_AT, entryUuid.toString() );
                    }
                    if ( ldifEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
                    {
                        // No CSN, let's create one
                        Csn csn = csnFactory.newInstance();
                        ldifEntry.addAttribute( SchemaConstants.ENTRY_CSN_AT, csn.toString() );
                    }

                    first = false;
                }
                else
View Full Code Here

        UUID uuid = UUID.randomUUID();
        entry.add( SchemaConstants.ENTRY_UUID_AT, uuid.toString() );

        CsnFactory csnFac = new CsnFactory( 0 );
        Csn csn = csnFac.newInstance();
        entry.add( SchemaConstants.ENTRY_CSN_AT, csn.toString() );

        con.add( entry );

        // Analyze entry and description attribute
        Entry addedEntry = con.lookup( dn, "*", "+" );
        assertNotNull( addedEntry );

        Attribute attr = addedEntry.get( SchemaConstants.ENTRY_UUID_AT );
        assertNotNull( attr );

        assertEquals( uuid.toString(), attr.getString() );

        attr = addedEntry.get( SchemaConstants.ENTRY_CSN_AT );
        assertNotNull( attr );
        assertEquals( csn.toString(), attr.getString() );

        // Remove entry
        con.delete( dn );
        con.unBind();
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.csn.Csn

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.