com.bigdata.service.jini
Class JiniClient<T>

java.lang.Object
  extended by com.bigdata.service.AbstractClient<T>
      extended by com.bigdata.service.AbstractScaleOutClient<T>
          extended by com.bigdata.service.jini.JiniClient<T>
Type Parameters:
T - The generic type of the client or service.
All Implemented Interfaces:
IBigdataClient<T>

public class JiniClient<T>
extends AbstractScaleOutClient<T>

A client capable of connecting to a distributed bigdata federation using JINI.

Clients are configured using a Jini service configuration file. The name of that file is passed to newInstance(String[]). The configuration must be consistent with the configuration of the federation to which you wish to connect.

Version:
$Id$
Author:
Bryan Thompson

Nested Class Summary
static interface JiniClient.Options
          Options understood by the JiniClient.
 
Nested classes/interfaces inherited from class com.bigdata.service.AbstractScaleOutClient
AbstractScaleOutClient.MetadataIndexCachePolicy
 
Field Summary
 JiniClientConfig jiniConfig
          The JiniClient configuration.
 ZookeeperClientConfig zooConfig
          The ZooKeeper client configuration.
 
Fields inherited from class com.bigdata.service.AbstractClient
log
 
Constructor Summary
JiniClient(Class cls, net.jini.config.Configuration config)
          Configures a client.
JiniClient(String[] args)
          Configures a client.
 
Method Summary
 JiniFederation<T> connect()
          Connect to a bigdata federation.
 void disconnect(boolean immediateShutdown)
          Note: Immediate shutdown can cause odd exceptions to be logged.
 net.jini.config.Configuration getConfiguration()
          The Configuration object used to initialize this class.
 JiniFederation<T> getFederation()
          Return the connected federation,
 JiniClientConfig getJiniClientConfig()
          The JiniClient configuration.
 Properties getProperties()
          An object wrapping the properties used to configure the client.
protected static Properties getProperties(File propertyFile)
          Read and return the content of the properties file.
 Properties getProperties(String component)
          Return the Properties for the JiniClient merged with those for the named component in the Configuration.
static Properties getProperties(String className, net.jini.config.Configuration config)
          Read for the optional application or server class identified by [cls].
 ZookeeperClientConfig getZookeeperClientConfig()
          The ZooKeeper client configuration.
 boolean isConnected()
          Return true iff the client is connected to a federation.
static JiniClient newInstance(String[] args)
          Installs a SecurityManager and returns a new client.
protected static void setSecurityManager()
          Conditionally install a suitable security manager if there is none in place.
 
Methods inherited from class com.bigdata.service.AbstractClient
finalize, getBatchApiOnly, getCollectPlatformStatistics, getCollectQueueStatistics, getDefaultRangeQueryCapacity, getDelegate, getHttpdPort, getIndexCacheCapacity, getIndexCacheTimeout, getLocatorCacheCapacity, getLocatorCacheTimeout, getMaxParallelTasksPerRequest, getMaxStaleLocatorRetries, getTaskTimeout, getThreadPoolSize, setDelegate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jiniConfig

public final JiniClientConfig jiniConfig
The JiniClient configuration.


zooConfig

public final ZookeeperClientConfig zooConfig
The ZooKeeper client configuration.

Constructor Detail

JiniClient

public JiniClient(String[] args)
           throws net.jini.config.ConfigurationException
Configures a client.

Parameters:
args - The jini Configuration (you may specify either a file or URL) and optional overrides for that Configuration.
Throws:
net.jini.config.ConfigurationException

JiniClient

public JiniClient(Class cls,
                  net.jini.config.Configuration config)
           throws net.jini.config.ConfigurationException
Configures a client.

Parameters:
cls - The class of the client (optional) determines the component whose configuration will be read in addition to that for the JiniClient itself. Component specific values will override those specified for the JiniClient in the Configuration.
config - The configuration object.
Throws:
net.jini.config.ConfigurationException
Method Detail

isConnected

public boolean isConnected()
Description copied from interface: IBigdataClient
Return true iff the client is connected to a federation.


disconnect

public void disconnect(boolean immediateShutdown)
Note: Immediate shutdown can cause odd exceptions to be logged. Normal shutdown is recommended unless there is a reason to force immediate shutdown.

Parameters:
immediateShutdown - When true the shutdown is abrubt. You can expect to see messages about interrupted IO such as
 java.rmi.MarshalException: error marshalling arguments; nested exception is: 
     java.io.IOException: request I/O interrupted
     at net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce(BasicInvocationHandler.java:785)
     at net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(BasicInvocationHandler.java:659)
     at net.jini.jeri.BasicInvocationHandler.invoke(BasicInvocationHandler.java:528)
     at $Proxy5.notify(Ljava.lang.String;Ljava.util.UUID;Ljava.lang.String;[B)V(Unknown Source)
 
These messages may be safely ignored if they occur during immediate shutdown.

getFederation

public JiniFederation<T> getFederation()
Description copied from interface: IBigdataClient
Return the connected federation,


connect

public JiniFederation<T> connect()
Description copied from interface: IBigdataClient
Connect to a bigdata federation. If the client is already connected, then the existing connection is returned.

Returns:
The object used to access the federation services.

getJiniClientConfig

public JiniClientConfig getJiniClientConfig()
The JiniClient configuration.


getZookeeperClientConfig

public final ZookeeperClientConfig getZookeeperClientConfig()
The ZooKeeper client configuration.


getConfiguration

public final net.jini.config.Configuration getConfiguration()
The Configuration object used to initialize this class.


getProperties

public Properties getProperties()
An object wrapping the properties used to configure the client.

Specified by:
getProperties in interface IBigdataClient<T>
Overrides:
getProperties in class AbstractClient<T>
See Also:
getProperties(String component)

getProperties

public Properties getProperties(String component)
                         throws net.jini.config.ConfigurationException
Return the Properties for the JiniClient merged with those for the named component in the Configuration. Any properties found for the JiniClient "component" will be read first. Properties for the named component are next, and therefore will override those given for the JiniClient. You can specify properties for either the JiniClient or the component using:
 properties = NV[]{...};
 
in the appropriate section of the Configuration. For example:
 
 // Jini client configuration
 com.bigdata.service.jini.JiniClient {
 
     // ...
 
     // optional JiniClient properties.
     properties = new NV[] {
        
        new NV("foo","bar")
        
     };
 
 }
 
And overrides for a named component as:
 
 com.bigdata.service.FooBaz {
 
    properties = new NV[] {
    
        new NV("foo","baz"),
        new NV("goo","12"),
    
    };
 
 }
 

Parameters:
component - The name of the component.
Returns:
The properties specified for that component.
Throws:
net.jini.config.ConfigurationException
See Also:
getConfiguration()

getProperties

public static Properties getProperties(String className,
                                       net.jini.config.Configuration config)
                                throws net.jini.config.ConfigurationException
Read for the optional application or server class identified by [cls].

Note: Anything read for the specific class will overwrite any value for the same properties specified for JiniClient.

Parameters:
className - The class name of the client or service (optional). When specified, properties defined for that class in the configuration will be used and will override those specified for the .
config - The Configuration.
Throws:
net.jini.config.ConfigurationException
TODO:
this could be replaced by explicit use of the java identifier corresponding to the Option and simply collecting all such properties into a Properties object using their native type (as reported by the ConfigurationFile).

newInstance

public static JiniClient newInstance(String[] args)
Installs a SecurityManager and returns a new client.

Parameters:
args - Either the command line arguments or the arguments from the ServiceDescriptor. Either way they identify the jini Configuration (you may specify either a file or URL) and optional overrides for that Configuration.
Returns:
The new client.
Throws:
RuntimeException - if there is a problem reading the jini configuration for the client, reading the properties for the client, etc.

setSecurityManager

protected static void setSecurityManager()
Conditionally install a suitable security manager if there is none in place. This is required before the client can download code. The code will be downloaded from the HTTP server identified by the java.rmi.server.codebase property specified for the VM running the service.


getProperties

protected static Properties getProperties(File propertyFile)
                                   throws IOException
Read and return the content of the properties file.

Parameters:
propertyFile - The properties file.
Throws:
IOException


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.