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

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


                       
                        long now = DateUtils.getDate( DateUtils.getGeneralizedTime() ).getTime();
                       
                        long maxIdleTime = log.getMaxIdlePeriod() * 1000L;
                       
                        long lastUpdatedTime = new Csn( lastSentCsn ).getTimestamp();
                       
                        LOG.debug( "checking log idle time now={} lastUpdatedTime={} maxIdleTime={}", now, lastUpdatedTime, maxIdleTime );
                       
                        if( ( now - lastUpdatedTime ) >= maxIdleTime )
                        {
                            //max idle time of the event log reached, delete it
                            removeEventLog( log );
                           
                            // delete the associated entry from DiT, note that ConsumerLogEntryDeleteListener
                            // will get called eventually but removeEventLog() will not be called cause by
                            // that time this log will not be present in replicaLogMap
                            // The reason we don't call this method first is to guard against any rename
                            // operation performed on the log's entry in DiT
                            try
                            {
                                directoryService.getAdminSession().delete( log.getConsumerEntryDn() );
                            }
                            catch( LdapException e )
                            {
                                LOG.warn( "Failed to delete the entry {} of replica event log {}", log.getConsumerEntryDn(), log.getName(), e );
                            }
                           
                            continue;
                        }
                       
                        long thresholdCount = log.getPurgeThresholdCount();
                       
                        if ( log.count() < thresholdCount )
                        {
                            continue;
                        }
                       
                        LOG.debug( "starting to purge the log entries that are older than {} milliseconds",
                            thresholdTime );
                       
                       
                        long deleteCount = 0;
                       
                        ReplicaJournalCursor cursor = log.getCursor( null ); // pass no CSN
                        cursor.skipQualifyingWhileFetching();
                       
                        while ( cursor.next() )
                        {
                            ReplicaEventMessage message = cursor.get();
                            String csnVal = message.getEntry().get( SchemaConstants.ENTRY_CSN_AT ).getString();
                           
                            // skip if we reach the lastSentCsn or got past it
                            if ( csnVal.compareTo( lastSentCsn ) >= 0 )
                            {
                                break;
                            }
                           
                            Csn csn = new Csn( csnVal );
                           
                            if ( ( now - csn.getTimestamp() ) >= thresholdTime )
                            {
                                cursor.delete();
                                deleteCount++;
                            }
                        }
View Full Code Here


                    System.out.println( entryDn.getName() + " exists " );
                }

                Entry providerEntry = providerSession.lookup( entryDn, "*", "+" );
                Entry consumerEntry = consumerSession.lookup( entryDn, "*", "+" );
                Csn providerCSN = new Csn( providerEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
                Csn consumerCSN = new Csn( consumerEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
                if ( consumerCSN.compareTo( providerCSN ) >= 0 )
                {
                    if ( print )
                    {
                        System.out.println( entryDn.getName() + " replicated " );
                    }
View Full Code Here

                return;
            }

            if ( config.isMmrMode() )
            {
                Csn localCsn = new Csn( localEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
                Csn remoteCsn = new Csn( remoteEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );

                if ( localCsn.compareTo( remoteCsn ) >= 0 )
                {
                    // just discard the received modified entry, that is old
                    LOG.debug( "local modification is latest, discarding the modDn operation dn {}",
View Full Code Here

        Entry localEntry = session.getDirectoryService().getOperationManager().lookup( lookupCtx );

        if ( config.isMmrMode() )
        {
            Csn localCsn = new Csn( localEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
            Csn remoteCsn = new Csn( remoteEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );

            if ( localCsn.compareTo( remoteCsn ) >= 0 )
            {
                // just discard the received modified entry, that is old
                LOG.debug( "local modification is latest, discarding the modification of dn {}", remoteEntry.getDn() );
View Full Code Here

                return;
            }

            if ( config.isMmrMode() )
            {
                Csn localCsn = new Csn( localEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
                Csn remoteCsn = new Csn( remoteEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );

                if ( localCsn.compareTo( remoteCsn ) >= 0 )
                {
                    // just discard the received modified entry, that is old
                    LOG.debug( "local modification is latest, discarding the modDn operation dn {}",
View Full Code Here

        Entry localEntry = session.getDirectoryService().getOperationManager().lookup( lookupCtx );

        if ( config.isMmrMode() )
        {
            Csn localCsn = new Csn( localEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
            Csn remoteCsn = new Csn( remoteEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );

            if ( localCsn.compareTo( remoteCsn ) >= 0 )
            {
                // just discard the received modified entry, that is old
                LOG.debug( "local modification is latest, discarding the modification of dn {}", remoteEntry.getDn() );
View Full Code Here

                        long now = DateUtils.getDate( DateUtils.getGeneralizedTime() ).getTime();

                        long maxIdleTime = log.getMaxIdlePeriod() * 1000L;

                        long lastUpdatedTime = new Csn( lastSentCsn ).getTimestamp();

                        LOG.debug( "checking log idle time now={} lastUpdatedTime={} maxIdleTime={}", now,
                            lastUpdatedTime, maxIdleTime );

                        if ( ( now - lastUpdatedTime ) >= maxIdleTime )
                        {
                            //max idle time of the event log reached, delete it
                            removeEventLog( log );

                            // delete the associated entry from DiT, note that ConsumerLogEntryDeleteListener
                            // will get called eventually but removeEventLog() will not be called cause by
                            // that time this log will not be present in replicaLogMap
                            // The reason we don't call this method first is to guard against any rename
                            // operation performed on the log's entry in DiT
                            try
                            {
                                directoryService.getAdminSession().delete( log.getConsumerEntryDn() );
                            }
                            catch ( LdapException e )
                            {
                                LOG.warn( "Failed to delete the entry {} of replica event log {}",
                                    log.getConsumerEntryDn(), log.getName(), e );
                            }

                            continue;
                        }

                        long thresholdCount = log.getPurgeThresholdCount();

                        if ( log.count() < thresholdCount )
                        {
                            continue;
                        }

                        LOG.debug( "starting to purge the log entries that are older than {} milliseconds",
                            thresholdTime );

                        long deleteCount = 0;

                        ReplicaJournalCursor cursor = log.getCursor( null ); // pass no CSN
                        cursor.skipQualifyingWhileFetching();

                        while ( cursor.next() )
                        {
                            ReplicaEventMessage message = cursor.get();
                            String csnVal = message.getEntry().get( SchemaConstants.ENTRY_CSN_AT ).getString();

                            // skip if we reach the lastSentCsn or got past it
                            if ( csnVal.compareTo( lastSentCsn ) >= 0 )
                            {
                                break;
                            }

                            Csn csn = new Csn( csnVal );

                            if ( ( now - csn.getTimestamp() ) >= thresholdTime )
                            {
                                cursor.delete();
                                deleteCount++;
                            }
                        }
View Full Code Here

                    System.out.println( entryDn.getName() + " exists " );
                }

                Entry providerEntry = providerSession.lookup( entryDn, "*", "+" );
                Entry consumerEntry = consumerSession.lookup( entryDn, "*", "+" );
                Csn providerCSN = new Csn( providerEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
                Csn consumerCSN = new Csn( consumerEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );

                if ( consumerCSN.compareTo( providerCSN ) >= 0 )
                {
                    if ( print )
                    {
                        System.out.println( entryDn.getName() + " replicated " );
                    }
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

                            if( csnVal.compareTo( lastSentCsn ) >= 0 )
                            {
                                break;
                            }
                               
                            Csn csn = new Csn( csnVal );
                           
                            if( ( now - csn.getTimestamp() ) >= thresholdTime )
                            {
                                cursor.delete();
                                deleteCount++;
                            }
                        }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.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.