Pepper  3.6.0
A highly extensible plattform for conversion and manipulationoflinguisticdata.
org.corpus_tools.pepper.core.DocumentBus Class Reference

This object is an implementation of a threadsafe queue to store DocumentController objects. More...

Inherited by org.corpus_tools.pepper.core.InitialDocumentBus, and org.corpus_tools.pepper.core.TerminalDocumentBus.

Public Member Functions

 DocumentBus (String inputModuleControllerId, String outputModuleControllerId)
 Creates an object of this type and sets the passes the given input controller and output controller. More...
 
 DocumentBus (String inputModuleControllerId, List< String > outputModuleControllerIds)
 Creates an object of this type and sets the passes the given input controller and output controller. More...
 
 DocumentBus (List< String > inputModuleControllerIds, String outputModuleControllerId)
 Creates an object of this type and sets the passes the given input controller and output controller. More...
 
 DocumentBus (List< String > inputModuleControllerIds, List< String > outputModuleControllerIds)
 Creates an object of this type and sets all passed in- and output ModuleController objects. More...
 
List< String > getOutputControllerIds ()
 Returns a list of Ids belonging to ModuleController objects, which are on the output side of this queue. More...
 
List< String > getInputControllerIds ()
 Returns a list of Ids belonging to ModuleController objects on the input side. More...
 
String getId ()
 Creates an id for this object. More...
 
PepperJobImpl getPepperJob ()
 Returns the PepperJob object containing this object. More...
 
void setPepperJob (PepperJobImpl pepperJob)
 Sets the PepperJob object containing this object. More...
 
Hashtable< String, ConcurrentLinkedQueue< DocumentController > > getDocumentBus ()
 Returns the table, which is the central management object of the DocumentBus. More...
 
MEMORY_POLICY getMemPolicy ()
 Returns the set memory policy. More...
 
void setMemPolicy (MEMORY_POLICY memPolicy)
 Sets the memory policy. More...
 
void finish (String inputControllerId)
 Sets the entry corresponding to given id to status finished, which means, that when all listed ModuleController objects on input side, are set to status finish, this queue is finished and no further documents are passed to ModuleController objects on output side. More...
 
boolean isFinished ()
 Returns true, whether all input ModuleController objects called the finish(String) method and set this object to status finish. More...
 
void put (DocumentController documentController)
 Adds the given DocumentController object to the queue. More...
 
DocumentController pop (String outputControllerId)
 Returns a DocumentController object, which is on first place of the internal queue (regarding the FIFO principle). More...
 
DocumentController pop (String outputControllerId, boolean ignorePermissionForDocument)
 Returns a DocumentController object, which is on first place of the internal queue (regarding the FIFO principle). More...
 
String toString ()
 returns a String representation of this object. More...
 

Protected Member Functions

void init (List< String > inputModuleControllerIds, List< String > outputModuleControllerIds)
 Creates an object of this type and passes all output ModuleController objects. More...
 
void initDocumentBus (List< String > outputModuleControllerIds)
 Initializes the table, which is the central management object of the DocumentBus. More...
 

Protected Attributes

List< String > outputModuleControllerIds = null
 A list of Ids belonging to ModuleController objects, which are on the output side of this queue. More...
 
List< String > inputModuleControllerIds = null
 A list of Ids belonging to ModuleController objects on the input side. More...
 
String id = null
 Id of this object.
 
volatile Hashtable< String, ConcurrentLinkedQueue< DocumentController > > documentBus = null
 This table is the central management object of the DocumentBus. More...
 
volatile MEMORY_POLICY memPolicy = MEMORY_POLICY.MODERATE
 
ReentrantLock lock = new ReentrantLock(true)
 This lock is used for creating the condition waitUntilAllDocumentsArePut to let the pop(String) method wait until all documents have been put.
 
Condition waitUntilAllDocumentsArePut = lock.newCondition()
 Used to let the pop(String) method wait until all documents have been put.
 

Detailed Description

This object is an implementation of a threadsafe queue to store DocumentController objects.

Such an object is used to connect multiple ModuleController objects. An DocumentController can only be removed from queue, when all output ModuleController objects requested the DocumentController object.

This object has a list of Ids belonging to ModuleController objects, which are on the output side of this queue. All these objects have to request a document, before this queue can get the status finished. The same goes for ModuleController objects on the input side. All these controllers have to notify this queue to be finished, before the queue can notify the controllers on the output side, that this queue is finished.

Author
Florian Zipser

Constructor & Destructor Documentation

◆ DocumentBus() [1/4]

org.corpus_tools.pepper.core.DocumentBus.DocumentBus ( String  inputModuleControllerId,
String  outputModuleControllerId 
)

Creates an object of this type and sets the passes the given input controller and output controller.

Parameters
inputModuleControllerIdidentifier of controller, which produces documents for this bus
outputModuleControllerIdidentifier of controller, which consumes documents for this bus

◆ DocumentBus() [2/4]

org.corpus_tools.pepper.core.DocumentBus.DocumentBus ( String  inputModuleControllerId,
List< String >  outputModuleControllerIds 
)

Creates an object of this type and sets the passes the given input controller and output controller.

Parameters
inputModuleControllerIdidentifier of controller, which produces documents for this bus
outputModuleControllerIdslist of identifier of controller, which consumes documents for this bus

◆ DocumentBus() [3/4]

org.corpus_tools.pepper.core.DocumentBus.DocumentBus ( List< String >  inputModuleControllerIds,
String  outputModuleControllerId 
)

Creates an object of this type and sets the passes the given input controller and output controller.

Parameters
inputModuleControllerIdslist of identifier of controller, which produces documents for this bus
outputModuleControllerIdidentifier of controller, which consumes documents for this bus

◆ DocumentBus() [4/4]

org.corpus_tools.pepper.core.DocumentBus.DocumentBus ( List< String >  inputModuleControllerIds,
List< String >  outputModuleControllerIds 
)

Creates an object of this type and sets all passed in- and output ModuleController objects.

This is important, because an DocumentController can only be removed from queue, when all output ModuleController objects requested the DocumentController object.

Parameters
inputModuleControllerIdslist of identifier of controller, which produces documents for this bus
outputModuleControllerIdslist of identifier of controller, which consumes documents for this bus

Member Function Documentation

◆ finish()

void org.corpus_tools.pepper.core.DocumentBus.finish ( String  inputControllerId)

Sets the entry corresponding to given id to status finished, which means, that when all listed ModuleController objects on input side, are set to status finish, this queue is finished and no further documents are passed to ModuleController objects on output side.

Parameters
inputControllerIdid of controller to be set to finish.

◆ getDocumentBus()

Hashtable<String, ConcurrentLinkedQueue<DocumentController> > org.corpus_tools.pepper.core.DocumentBus.getDocumentBus ( )

Returns the table, which is the central management object of the DocumentBus.

This table relates a queue containing document controllers to a identifier of a ModuleController object. Key= identifier, value= queue

Returns

◆ getId()

String org.corpus_tools.pepper.core.DocumentBus.getId ( )

Creates an id for this object.

the id consists of the in- and output DocumentController objects.

Returns

◆ getInputControllerIds()

List<String> org.corpus_tools.pepper.core.DocumentBus.getInputControllerIds ( )

Returns a list of Ids belonging to ModuleController objects on the input side.

All these controllers have to notify this queue to be finished, before the queue can notify the controllers on the output side, that this queue is finished.

Returns
list of all ids

◆ getMemPolicy()

MEMORY_POLICY org.corpus_tools.pepper.core.DocumentBus.getMemPolicy ( )

Returns the set memory policy.

Returns

◆ getOutputControllerIds()

List<String> org.corpus_tools.pepper.core.DocumentBus.getOutputControllerIds ( )

Returns a list of Ids belonging to ModuleController objects, which are on the output side of this queue.

All these objects have to request a document, before this queue can get the status finished.

Returns
list of all ids

◆ getPepperJob()

PepperJobImpl org.corpus_tools.pepper.core.DocumentBus.getPepperJob ( )

Returns the PepperJob object containing this object.

Returns
PepperJob object containing this

◆ init()

void org.corpus_tools.pepper.core.DocumentBus.init ( List< String >  inputModuleControllerIds,
List< String >  outputModuleControllerIds 
)
protected

Creates an object of this type and passes all output ModuleController objects.

This is important, because an DocumentController can only be removed from queue, when all output ModuleController objects requested the DocumentController object.

Parameters
outputs

◆ initDocumentBus()

void org.corpus_tools.pepper.core.DocumentBus.initDocumentBus ( List< String >  outputModuleControllerIds)
protected

Initializes the table, which is the central management object of the DocumentBus.

This table relates a queue containing document controllers to a identifier of a ModuleController object. Key= identifier, value= queue.
Please take care not to call this method, when this object is already started, since this will confuse the started process.

Parameters
outputModuleControllerIdsa list of ids of the ModuleController objects on the output side.

◆ isFinished()

boolean org.corpus_tools.pepper.core.DocumentBus.isFinished ( )

Returns true, whether all input ModuleController objects called the finish(String) method and set this object to status finish.

Returns
if all input controllers called finished

◆ pop() [1/2]

DocumentController org.corpus_tools.pepper.core.DocumentBus.pop ( String  outputControllerId)

Returns a DocumentController object, which is on first place of the internal queue (regarding the FIFO principle).

When all registered ModuleController objects popped the DocumentController object, it will be removed from internal queue.
If the document, which is the one to be taken in queue is in sleep mode, it will be woken up, if the PepperJobImpl gives the permission. Otherwise, this method waits for the permission.
Caution, call this method can take some time, since it waits for two conditions:

  1. a document is waiting in the queue, and the preceding PepperModule has not finished all documents
  2. the Pepper framework (more precisely the PepperJobImpl) gives the permission to wake up the document, if it was in sleep mode
Parameters
moduleControllerobject requesting the DocumentController object
Returns
head of the queue.

Reimplemented in org.corpus_tools.pepper.core.TerminalDocumentBus.

◆ pop() [2/2]

DocumentController org.corpus_tools.pepper.core.DocumentBus.pop ( String  outputControllerId,
boolean  ignorePermissionForDocument 
)

Returns a DocumentController object, which is on first place of the internal queue (regarding the FIFO principle).

When all registered ModuleController objects popped the DocumentController object, it will be removed from internal queue.
If the document, which is the one to be taken in queue is in sleep mode, it will be woken up, if the PepperJobImpl gives the permission. Otherwise, this method waits for the permission.
Caution, call this method can take some time, since it waits for two conditions:

  1. a document is waiting in the queue, and the preceding PepperModule has not finished all documents
  2. the Pepper framework (more precisely the PepperJobImpl) gives the permission to wake up the document, if it was in sleep mode

In contrast to pop(String), if ignorePermissionForDocument is set to true this method returns a DocumentController object even if the PepperJob permission does not allow to process a further document. This mechanism can be used, if a PepperModule has an own control mechanism of sending SDocuments to sleep.

Parameters
outputControllerIdobject requesting the DocumentController object
ignorePermissionForDocumentif set, a document will be returned even if the Pepper job gives no permission
Returns
head of the queue.

Reimplemented in org.corpus_tools.pepper.core.TerminalDocumentBus.

◆ put()

void org.corpus_tools.pepper.core.DocumentBus.put ( DocumentController  documentController)

Adds the given DocumentController object to the queue.

Parameters
documentControllerthe DocumentController object to be added to the queue.

Reimplemented in org.corpus_tools.pepper.core.InitialDocumentBus.

◆ setMemPolicy()

void org.corpus_tools.pepper.core.DocumentBus.setMemPolicy ( MEMORY_POLICY  memPolicy)

Sets the memory policy.

Don't change the memory policy, when job was started.

Parameters
memPolicy

◆ setPepperJob()

void org.corpus_tools.pepper.core.DocumentBus.setPepperJob ( PepperJobImpl  pepperJob)

Sets the PepperJob object containing this object.

Parameters
pepperJobPepperJob object containing this

◆ toString()

String org.corpus_tools.pepper.core.DocumentBus.toString ( )

returns a String representation of this object.

Note, that this String cannot be used for serialization/deserialization purposes.

Member Data Documentation

◆ documentBus

volatile Hashtable<String, ConcurrentLinkedQueue<DocumentController> > org.corpus_tools.pepper.core.DocumentBus.documentBus = null
protected

This table is the central management object of the DocumentBus.

This table relates a queue containing document controllers to a identifier of a ModuleController object. Key= identifier, value= queue

◆ inputModuleControllerIds

List<String> org.corpus_tools.pepper.core.DocumentBus.inputModuleControllerIds = null
protected

A list of Ids belonging to ModuleController objects on the input side.

All these controllers have to notify this queue to be finished, before the queue can notify the controllers on the output side, that this queue is finished.

◆ outputModuleControllerIds

List<String> org.corpus_tools.pepper.core.DocumentBus.outputModuleControllerIds = null
protected

A list of Ids belonging to ModuleController objects, which are on the output side of this queue.

All these objects have to request a document, before this queue can get the status finished.