org.openstreetmap.osmosis.core.buffer.v0_6
Class EntityBuffer

java.lang.Object
  extended by org.openstreetmap.osmosis.core.buffer.v0_6.EntityBuffer
All Implemented Interfaces:
java.lang.Runnable, Completable, Releasable, Task, RunnableSource, Sink, SinkRunnableSource, Source

public class EntityBuffer
extends java.lang.Object
implements SinkRunnableSource

Splits the pipeline so that it can be processed on multiple threads. The input thread to this task stores data in a buffer which blocks if it fills up. This task runs on a new thread which reads data from the buffer and writes it to the destination.

Author:
Brett Henderson

Constructor Summary
EntityBuffer(int bufferCapacity)
          Creates a new instance.
 
Method Summary
 void complete()
          Ensures that all information is fully persisted.
 void process(EntityContainer entityContainer)
          Process the entity.
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 void run()
          Sends all input data to the sink.
 void setSink(Sink sink)
          Sets the osm sink to send data to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityBuffer

public EntityBuffer(int bufferCapacity)
Creates a new instance.

Parameters:
bufferCapacity - The size of the buffer to use.
Method Detail

process

public void process(EntityContainer entityContainer)
Process the entity.

Specified by:
process in interface Sink
Parameters:
entityContainer - The entity to be processed.

complete

public void complete()
Ensures that all information is fully persisted. This includes database commits, file buffer flushes, etc. Implementations must call complete on any nested Completable objects. Where the releasable method of a Releasable class should be called within a finally block, this method should typically be the final statement within the try block.

Specified by:
complete in interface Completable

release

public void release()
Performs resource cleanup tasks such as closing files, or database connections. This must be called after all processing is complete and may be called multiple times. Implementations must call release on any nested Releasable objects. It should be called within a finally block to ensure it is called in exception scenarios.

Specified by:
release in interface Releasable

setSink

public void setSink(Sink sink)
Sets the osm sink to send data to.

Specified by:
setSink in interface Source
Parameters:
sink - The sink for receiving all produced data.

run

public void run()
Sends all input data to the sink.

Specified by:
run in interface java.lang.Runnable