com.atlassian.confluence.search.lucene.queue
Class DatabaseIndexTaskQueue

java.lang.Object
  extended by com.atlassian.confluence.search.lucene.queue.DatabaseIndexTaskQueue
All Implemented Interfaces:
IndexTaskQueue, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

public class DatabaseIndexTaskQueue
extends java.lang.Object
implements IndexTaskQueue, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

An implementation of the IndexTaskQueue backed by the database.


Field Summary
static org.apache.log4j.Logger log
          Deprecated. since 3.1 do not use this class's logger externally. Create one in the class doing the logging.
 
Constructor Summary
DatabaseIndexTaskQueue()
           
 
Method Summary
 void afterPropertiesSet()
           
 java.util.Date calculateLastFlushTime()
          Returns the time of last flush as stored in memory (or in the timestampFile if value has not yet been initialised in memory), minus an arbitrary amount by which the time stamps could differ on the nodes in a cluster.
 void deleteOldEntries()
          Delete all entries older then 2 days from the database.
 void destroy()
           
 void enqueue(IndexTask task)
          Add a new index task to the queue.
 void enqueueAll(java.util.Collection<IndexTask> tasks)
          Add a collection of index tasks to the queue.
 void flushIndexTaskQueue(com.atlassian.config.lifecycle.events.ApplicationStartedEvent event)
          Set the initial entry on the IndexQueueTracker.
 java.util.List<IndexTask> flushQueue()
          Flush the contents of the queue, returning those elements currently queued as the result.
 java.util.List<IndexTask> flushQueue(int maxEntries)
          Flush the contents of the queue, returning those elements currently queued as the result.
 java.util.List<IndexTask> getQueuedEntries()
          Retrieve the list of index tasks currently queued.
 int getSize()
          Retrieve the number of tasks currently queued.
 void reset()
          Reseting the queue removes all queued index tasks from the queue without flushing.
 void setAnyTypeDao(AnyTypeDao anyTypeDao)
           
 void setBootstrapManager(BootstrapManager bootstrapManager)
           
 void setEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher)
           
 void setIndexQueueTracker(IndexQueueTracker indexQueueTracker)
           
 void setIndexTaskFactory(IndexTaskFactory indexTaskFactory)
           
 void setQueueEntryDao(IndexQueueEntryDao queueEntryDao)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

@Deprecated
public static final org.apache.log4j.Logger log
Deprecated. since 3.1 do not use this class's logger externally. Create one in the class doing the logging.
Constructor Detail

DatabaseIndexTaskQueue

public DatabaseIndexTaskQueue()
Method Detail

flushIndexTaskQueue

@EventListener
public void flushIndexTaskQueue(com.atlassian.config.lifecycle.events.ApplicationStartedEvent event)
Set the initial entry on the IndexQueueTracker. This must be done after the Spring application context has started (so that we know that necessary database tables exist).


afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

enqueue

public void enqueue(IndexTask task)
Add a new index task to the queue.

Specified by:
enqueue in interface IndexTaskQueue

enqueueAll

public void enqueueAll(java.util.Collection<IndexTask> tasks)
Add a collection of index tasks to the queue.

Specified by:
enqueueAll in interface IndexTaskQueue

getSize

public int getSize()
Retrieve the number of tasks currently queued.

Specified by:
getSize in interface IndexTaskQueue
Returns:
an int count of the number of index tasks in the queue.

getQueuedEntries

public java.util.List<IndexTask> getQueuedEntries()
Retrieve the list of index tasks currently queued.

Specified by:
getQueuedEntries in interface IndexTaskQueue
Returns:
a list of IndexTask objects.

flushQueue

public java.util.List<IndexTask> flushQueue()
Description copied from interface: IndexTaskQueue
Flush the contents of the queue, returning those elements currently queued as the result.

Specified by:
flushQueue in interface IndexTaskQueue
Returns:
the list of entries on the queue when it was flushed.

flushQueue

public java.util.List<IndexTask> flushQueue(int maxEntries)
Description copied from interface: IndexTaskQueue
Flush the contents of the queue, returning those elements currently queued as the result.

Specified by:
flushQueue in interface IndexTaskQueue
Parameters:
maxEntries - the maximum number of entries to return. This should return the n first entries in the queue.
Returns:
the list of entries on the queue when it was flushed.

calculateLastFlushTime

public java.util.Date calculateLastFlushTime()
Returns the time of last flush as stored in memory (or in the timestampFile if value has not yet been initialised in memory), minus an arbitrary amount by which the time stamps could differ on the nodes in a cluster.

Returns:
time of last index queue flush, minus a 'fudge factor'

deleteOldEntries

public void deleteOldEntries()
Delete all entries older then 2 days from the database. This should be triggered by a regularly scheduled maintenance task.


reset

public void reset()
Reseting the queue removes all queued index tasks from the queue without flushing.

Specified by:
reset in interface IndexTaskQueue

setQueueEntryDao

public void setQueueEntryDao(IndexQueueEntryDao queueEntryDao)

setBootstrapManager

public void setBootstrapManager(BootstrapManager bootstrapManager)

setAnyTypeDao

public void setAnyTypeDao(AnyTypeDao anyTypeDao)

setIndexQueueTracker

public void setIndexQueueTracker(IndexQueueTracker indexQueueTracker)

setIndexTaskFactory

public void setIndexTaskFactory(IndexTaskFactory indexTaskFactory)

setEventPublisher

public void setEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher)


Copyright © 2003-2014 Atlassian. All Rights Reserved.