gr.uoa.di.madgik.grs.proxy.mirror
Interface IMirror

All Known Implementing Classes:
HTTPReaderMirror, HTTPWriterMirror, TCPReaderMirror, TCPWriterMirror

public interface IMirror

This interface defines the base operations that must be available for the management of the mirroring implementation instances. The purpose of the IMirror implementations is to provide a means of synchronization between the IBuffer that is authored by a writer and the respective IBuffer available to the reader. The way the synchronization is performed and the technologies employed is entirely up to the implementation to be specified and the respective IProxy, IReaderProxy and IWriterProxy.

Author:
gpapanikos

Nested Class Summary
static class IMirror.MirroringState
          The status of the mirroring procedure
 
Method Summary
 void dispose()
          Dispose the resources employed by the mirroring implementations
 IBuffer getBuffer()
          Retrieves the IBuffer that is managed by the IMirror implementation.
 boolean pollPartial(long recordIndex, int fieldIndex)
           
 long requestPartial(long recordIndex, int fieldIndex, IBuffer.TransportOverride override, java.lang.Object notify)
          This method is used by the reader side mirror to request payload that belongs to an IBuffer item that has been transfered only partially and more data is requested by the reader client
 

Method Detail

dispose

void dispose()
Dispose the resources employed by the mirroring implementations


getBuffer

IBuffer getBuffer()
Retrieves the IBuffer that is managed by the IMirror implementation. Depending on the mirror side, this instance is either the one the writer is authoring, or the one the reader is accessing.

Returns:
the IBuffer that is managed by the IMirror implementation

requestPartial

long requestPartial(long recordIndex,
                    int fieldIndex,
                    IBuffer.TransportOverride override,
                    java.lang.Object notify)
                    throws GRS2ProxyMirrorException
This method is used by the reader side mirror to request payload that belongs to an IBuffer item that has been transfered only partially and more data is requested by the reader client

Parameters:
recordIndex - The index of the record whose payload is requested. As described in Record, this index coincides with the record id.
fieldIndex - The index of the field belonging to the defined record for which additional data is requested
override - whether or not the field's IBuffer.TransportDirective should be overridden as explained in IBuffer
notify - A synchronization object that can be used for the requester to block on until the required data is provided
Returns:
An indicative amount of time that the requester can wait before the data is available. This value is only indicative and it does not imply that after this period the data will be available. For this. the pollPartial(long, int) should be used
Throws:
GRS2ProxyMirrorException - The status of the IMirror does not allow this operation to be completed

pollPartial

boolean pollPartial(long recordIndex,
                    int fieldIndex)
                    throws GRS2ProxyMirrorException
Parameters:
recordIndex - The record index / id, for which the requester has requested data to be delivered
fieldIndex - The field index of the specific record for which data are requested
Returns:
false if the requester needs to wait again until data is returned false otherwise. In case true is returned, the data have either been retrieved, or no more data is expected to be send, possibly because of a closed connection
Throws:
GRS2ProxyMirrorException - The status of the IMirror does not allow this operation to be completed