org.gcube.data.streams.publishers
Class RsPublisher<E>

java.lang.Object
  extended by org.gcube.data.streams.publishers.RsPublisher<E>
Type Parameters:
E - the type of stream element
All Implemented Interfaces:
StreamPublisher

public class RsPublisher<E>
extends Object
implements StreamPublisher

Publishes Streams as resultsets.

Author:
Fabio Simeoni

Constructor Summary
RsPublisher(Stream<E> stream, Generator<E,String> serialiser)
          Creates an instance for a given Stream and with a given element serialiser.
RsPublisher(Stream<E> stream, RecordFactory<E> factory)
          Creates an instance for a given Stream and with a given RecordFactory.
 
Method Summary
 URI publish()
          Publishes the stream and returns its address.
 void setBufferSize(int size)
          Sets the size of the write buffer.
 void setFaultHandler(FaultHandler handler)
          Sets the FaultHandler for reading and writing failures.
 void setOnDemand(boolean onDemand)
          Sets the production mode of the publiher
 void setThreadProvider(ThreadProvider provider)
          Sets the ThreadProvider used to populate the resultset.
 void setTimeout(long timeout, TimeUnit timeoutUnit)
          Sets the time to wait on a full write buffer.
 void setTransport(RsTransport transport)
          Sets the resultset transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RsPublisher

public RsPublisher(Stream<E> stream,
                   Generator<E,String> serialiser)
Creates an instance for a given Stream and with a given element serialiser.

Parameters:
stream - the stream
serialiser - the serialiser

RsPublisher

public RsPublisher(Stream<E> stream,
                   RecordFactory<E> factory)
Creates an instance for a given Stream and with a given RecordFactory.

Parameters:
stream - the stream
factory - the factory
Method Detail

setBufferSize

public void setBufferSize(int size)
                   throws IllegalArgumentException
Sets the size of the write buffer.

Parameters:
size - the size in bytes.
Throws:
IllegalArgumentException - if the size is not a positive number

setTimeout

public void setTimeout(long timeout,
                       TimeUnit timeoutUnit)
                throws IllegalArgumentException
Sets the time to wait on a full write buffer. After the time has elapsed publication stops.

Parameters:
timeout - the timeout
timeoutUnit - the timeout unit
Throws:
IllegalArgumentException - if the timeout is not a positive number or the timeout unit is null

setTransport

public void setTransport(RsTransport transport)
Sets the resultset transport.

Parameters:
transport - the transport
Throws:
IllegalArgumentException - if the transport is null

setOnDemand

public void setOnDemand(boolean onDemand)
Sets the production mode of the publiher

Parameters:
onDemand - true if the stream ought to be consumed only when clients require it, false if it should be consumed continuously.

setThreadProvider

public void setThreadProvider(ThreadProvider provider)
Sets the ThreadProvider used to populate the resultset.

Parameters:
provider - the provider
Throws:
IllegalArgumentException - if the provider is null.

setFaultHandler

public void setFaultHandler(FaultHandler handler)
Sets the FaultHandler for reading and writing failures.

Parameters:
handler - the handler
Throws:
IllegalArgumentException - if the handler is null

publish

public URI publish()
            throws StreamPublishException
Description copied from interface: StreamPublisher
Publishes the stream and returns its address.

Specified by:
publish in interface StreamPublisher
Returns:
the address
Throws:
StreamPublishException - if the stream cannot be published


Copyright © 2012. All Rights Reserved.