gr.uoa.di.madgik.grs.proxy.tcp
Class TCPWriterProxy

java.lang.Object
  extended by gr.uoa.di.madgik.grs.proxy.tcp.TCPWriterProxy
All Implemented Interfaces:
IProxy, IWriterProxy

public class TCPWriterProxy
extends java.lang.Object
implements IWriterProxy

This proxy is an implementation of the IWriterProxy interface available to be used by writers that want to make available their authored IBuffer to readers that can connect to a raw TCP socket that can serve it regardless of their location

Author:
gpapanikos

Nested Class Summary
 
Nested classes/interfaces inherited from interface gr.uoa.di.madgik.grs.proxy.IProxy
IProxy.ProxyType
 
Field Summary
 
Fields inherited from interface gr.uoa.di.madgik.grs.proxy.IProxy
ProxyScheme, ProxyStoreScheme
 
Constructor Summary
TCPWriterProxy()
          Creates a new instance
 
Method Summary
 IMirror bind()
          After setting the registry key, this method is used to retrieve the IMirror that can serve the mirroring procedure for a reader
 java.lang.String getHostname()
          The name of the host this TCPWriterProxy is used.
 java.net.URI getLocator()
          Retrieves a locator through which a reader proxy can contact the IMirror serving the registered IBuffer
 int getPort()
          The port the connection manager used.
static boolean isOfType(java.net.URI locator)
          Checks if the provided URI is of a type that can be managed by an instance of this class.
 void setKey(java.lang.String key)
          Sets the key that was assigned to the serving IBuffer through the buffer registry
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPWriterProxy

public TCPWriterProxy()
Creates a new instance

Method Detail

getHostname

public java.lang.String getHostname()
The name of the host this TCPWriterProxy is used. The hostname is retrieved by TCPConnectionManager.GetConnectionManagerHostName()

Returns:
the host name

getPort

public int getPort()
The port the connection manager used. The port is retrieved by TCPConnectionManager.GetConnectionManagerPort()

Returns:
the port

setKey

public void setKey(java.lang.String key)
            throws GRS2ProxyInvalidOperationException
Sets the key that was assigned to the serving IBuffer through the buffer registry

Specified by:
setKey in interface IWriterProxy
Parameters:
key - the registry key
Throws:
GRS2ProxyInvalidOperationException - if the key is already set for this instance
See Also:
IWriterProxy.setKey(java.lang.String)

bind

public IMirror bind()
             throws GRS2ProxyInvalidOperationException
After setting the registry key, this method is used to retrieve the IMirror that can serve the mirroring procedure for a reader

An instance of the TCPWriterMirror that can serve in publishing the IBuffer is created if not already available and returned

Specified by:
bind in interface IWriterProxy
Returns:
the associated IMirror
Throws:
GRS2ProxyInvalidOperationException - if the key i not set for this instance
See Also:
IWriterProxy.bind()

getLocator

public java.net.URI getLocator()
                        throws GRS2ProxyInvalidOperationException,
                               GRS2ProxyInvalidArgumentException
Retrieves a locator through which a reader proxy can contact the IMirror serving the registered IBuffer

The created uri uses the scheme of IProxy.ProxyScheme, the host name and port returned from getHostname() and getPort() and sets the fragment to IProxy.ProxyType.TCP.
An example of the created locator is grs2-proxy://foo.bar.gr:53361?key=272b934d-e796-4c30-944c-44ec2aec7eb7#TCP

Specified by:
getLocator in interface IWriterProxy
Returns:
the URI locator
Throws:
GRS2ProxyInvalidOperationException - if the set key is null or empty
GRS2ProxyInvalidArgumentException - if there was a problem creating the locator URI
See Also:
IWriterProxy.getLocator()

isOfType

public static boolean isOfType(java.net.URI locator)
Checks if the provided URI is of a type that can be managed by an instance of this class. It bases its checks on the URI scheme and the fragment type. An example of the URI this proxy can manage is grs2-proxy://foo.bar.gr:53361?key=272b934d-e796-4c30-944c-44ec2aec7eb7#TCP

Parameters:
locator - the locator URI that needs to be checked
Returns:
true is this proxy class can handle the locator, false otherwise