fabric.worker
Class Worker

java.lang.Object
  extended by fabric.worker.Worker

public final class Worker
extends java.lang.Object

This is the main interface to the Fabric API. Applications wishing to use Fabric must first initialize it by calling one of the initialize methods, and can then use the singleton Worker instance to access Stores and Objects.


Nested Class Summary
static interface Worker.Code<T>
           
 
Field Summary
protected  FetchManager fetchManager
           
protected static Worker instance
          The singleton Worker instance.
 java.security.Principal javaPrincipal
           
protected  java.security.KeyStore keyStore
           
protected  LocalStore localStore
           
 java.lang.String name
           
 int port
           
protected  NodePrincipal principal
           
static java.util.Random RAND
           
 int retries
           
 javax.net.ssl.SSLSocketFactory sslSocketFactory
           
 NameService storeNameService
           
protected  java.util.Map<java.lang.String,RemoteStore> stores
           
 int timeout
           
 NameService workerNameService
           
 
Method Summary
 void clearCache()
          Clears out the worker cache (but leaves dissemination cache intact).
 FetchManager fetchManager()
          Returns the fetch manager.
 java.security.Principal getJavaPrincipal()
           
 LocalStore getLocalStore()
           
 RemoteWorker getLocalWorker()
           
 NodePrincipal getPrincipal()
           
 RemoteStore getStore(java.lang.String name)
          Returns a Store object representing the given store.
static Worker getWorker()
          Returns the Singleton Worker instance.
 RemoteWorker getWorker(java.lang.String name)
           
static void initialize(java.lang.String name)
           
static void initialize(java.lang.String name, java.lang.String principalURL, java.util.Map<java.lang.String,RemoteStore> initStoreSet)
           
static void main(java.lang.String[] args)
           
 void registerDisseminationCache(Cache cache)
          Registers that a worker has a new dissemination cache.
static
<T> T
runInSubTransaction(Worker.Code<T> code)
          Executes the given code from within a Fabric subtransaction of the current transaction.
static
<T> T
runInTransaction(TransactionID tid, Worker.Code<T> code)
          Executes the given code from within a Fabric transaction.
static
<T> T
runInTransactionUnauthenticated(Worker.Code<T> code)
          Executes the given code from within a top-level Fabric transaction.
 void setStore(java.lang.String name, RemoteStore store)
           
 void shutdown()
          Called to shut down and clean up worker.
 boolean updateCache(RemoteStore store, ObjectGroup group)
          Updates the worker cache with the given object group.
 boolean updateDissemCaches(RemoteStore store, long onum, Glob update)
          Updates the dissemination caches with the given object glob.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public final java.lang.String name

port

public final int port

stores

protected final java.util.Map<java.lang.String,RemoteStore> stores

localStore

protected final LocalStore localStore

keyStore

protected final java.security.KeyStore keyStore

sslSocketFactory

public final javax.net.ssl.SSLSocketFactory sslSocketFactory

principal

protected final NodePrincipal principal

javaPrincipal

public final java.security.Principal javaPrincipal

timeout

public final int timeout

retries

public final int retries

storeNameService

public final NameService storeNameService

workerNameService

public final NameService workerNameService

fetchManager

protected final FetchManager fetchManager

RAND

public static final java.util.Random RAND

instance

protected static Worker instance
The singleton Worker instance.

Method Detail

getWorker

public static Worker getWorker()
                        throws java.lang.IllegalStateException
Returns the Singleton Worker instance.

Returns:
the Worker instance
Throws:
java.lang.IllegalStateException - if the Fabric worker is uninitialized

getStore

public RemoteStore getStore(java.lang.String name)
Returns a Store object representing the given store.

Parameters:
name - The store's host name.
Returns:
The corresponding Store object.

getWorker

public RemoteWorker getWorker(java.lang.String name)
Returns:
a RemoteWorker object

getLocalStore

public LocalStore getLocalStore()

getLocalWorker

public RemoteWorker getLocalWorker()
Returns:
a RemoteWorker object representing the local worker.

fetchManager

public FetchManager fetchManager()
Returns the fetch manager.


registerDisseminationCache

public void registerDisseminationCache(Cache cache)
Registers that a worker has a new dissemination cache.


updateDissemCaches

public boolean updateDissemCaches(RemoteStore store,
                                  long onum,
                                  Glob update)
Updates the dissemination caches with the given object glob.

Returns:
true iff there was a cache entry for the given oid.

updateCache

public boolean updateCache(RemoteStore store,
                           ObjectGroup group)
Updates the worker cache with the given object group.

Returns:
true iff there was a cache entry for any object in the group.

getPrincipal

public NodePrincipal getPrincipal()
Returns:
the Fabric notion of the worker principal.

getJavaPrincipal

public java.security.Principal getJavaPrincipal()
Returns:
the Java notion of the worker principal.

clearCache

public void clearCache()
Clears out the worker cache (but leaves dissemination cache intact). To be used for (performance) testing only.


shutdown

public void shutdown()
Called to shut down and clean up worker.


initialize

public static void initialize(java.lang.String name)
                       throws java.security.UnrecoverableKeyException,
                              java.security.KeyStoreException,
                              java.security.NoSuchAlgorithmException,
                              java.security.cert.CertificateException,
                              java.lang.IllegalStateException,
                              java.io.IOException,
                              InternalError,
                              UsageError
Throws:
java.security.UnrecoverableKeyException
java.security.KeyStoreException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
java.lang.IllegalStateException
java.io.IOException
InternalError
UsageError

initialize

public static void initialize(java.lang.String name,
                              java.lang.String principalURL,
                              java.util.Map<java.lang.String,RemoteStore> initStoreSet)
                       throws java.io.IOException,
                              java.security.KeyStoreException,
                              java.security.NoSuchAlgorithmException,
                              java.security.cert.CertificateException,
                              java.security.UnrecoverableKeyException,
                              java.lang.IllegalStateException,
                              InternalError,
                              UsageError
Throws:
java.io.IOException
java.security.KeyStoreException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
java.security.UnrecoverableKeyException
java.lang.IllegalStateException
InternalError
UsageError

main

public static void main(java.lang.String[] args)
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

setStore

public void setStore(java.lang.String name,
                     RemoteStore store)

runInTransaction

public static <T> T runInTransaction(TransactionID tid,
                                     Worker.Code<T> code)
Executes the given code from within a Fabric transaction. Should not be called by generated code. This is here to abstract away the details of starting and finishing transactions.

Parameters:
tid - The parent transaction for the subtransaction that will be created.

runInTransactionUnauthenticated

public static <T> T runInTransactionUnauthenticated(Worker.Code<T> code)
Executes the given code from within a top-level Fabric transaction. The transaction is committed to the store without authentication. Should not be called by generated code. This is here to abstract away the details of starting and finishing transactions.


runInSubTransaction

public static <T> T runInSubTransaction(Worker.Code<T> code)
Executes the given code from within a Fabric subtransaction of the current transaction. Should not be called by generated code. This is here to abstract away the details of starting and finishing transactions.