SMILA (incubation) API documentation

org.eclipse.smila.objectstore.util
Class ObjectStoreRetryUtil

java.lang.Object
  extended by org.eclipse.smila.objectstore.util.ObjectStoreRetryUtil

public final class ObjectStoreRetryUtil
extends java.lang.Object

Utility class to retry objectstore operations.


Method Summary
static void retryClose(StoreOutputStream storeOutputStream)
          calls StoreOutputStream.close(), retries in case of IOException.
static void retryCreateStore(ObjectStoreService objectStore, java.lang.String storeName, AnyMap storeProperties, boolean storeExistsException)
          Prepares a store and retries on ServiceUnavailableException.
static void retryEnsureStore(ObjectStoreService objectStore, java.lang.String storeName)
          Ensures that a store exists.
static boolean retryExistsObject(ObjectStoreService objectStore, java.lang.String storeName, java.lang.String objectId)
          Checks if an object in a store exists.
static boolean retryExistsStore(ObjectStoreService objectStore, java.lang.String storeName)
          Checks if a store exists.
static java.util.Collection<StoreObject> retryGetStoreObjectInfos(ObjectStoreService objectStore, java.lang.String storeName, java.lang.String objectIdPrefix)
          Retries listing object infos from a store.
static void retryPutObject(ObjectStoreService objectStore, java.lang.String storeName, java.lang.String objectId, byte[] data)
          Open a store and puts data to an object.
static java.io.InputStream retryReadObject(ObjectStoreService objectStore, java.lang.String storeName, java.lang.String objectId)
          Open a store and open an object for read.
static StoreOutputStream retryWriteObject(ObjectStoreService objectStore, java.lang.String storeName, java.lang.String objectId)
          Open a store and open an object for write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

retryReadObject

public static java.io.InputStream retryReadObject(ObjectStoreService objectStore,
                                                  java.lang.String storeName,
                                                  java.lang.String objectId)
                                           throws ObjectStoreException
Open a store and open an object for read. Retry on ServiceUnavailableException.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
objectId - name of object to read.
Returns:
an InputStream to read from the store.
Throws:
ObjectStoreException - error reading object.

retryWriteObject

public static StoreOutputStream retryWriteObject(ObjectStoreService objectStore,
                                                 java.lang.String storeName,
                                                 java.lang.String objectId)
                                          throws ObjectStoreException
Open a store and open an object for write. Retry on ServiceUnavailableException.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
objectId - name of object to read.
Returns:
a StoreOutputStream to the object
Throws:
ObjectStoreException - error opening object in the ObjectStoreService.

retryPutObject

public static void retryPutObject(ObjectStoreService objectStore,
                                  java.lang.String storeName,
                                  java.lang.String objectId,
                                  byte[] data)
                           throws ObjectStoreException
Open a store and puts data to an object. Retry on ServiceUnavailableException.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
objectId - name of object to read.
data - the data to write to the object
Throws:
ObjectStoreException - error opening object in the ObjectStoreService.

retryCreateStore

public static void retryCreateStore(ObjectStoreService objectStore,
                                    java.lang.String storeName,
                                    AnyMap storeProperties,
                                    boolean storeExistsException)
                             throws ObjectStoreException
Prepares a store and retries on ServiceUnavailableException.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
storeProperties - the properties of the store
storeExistsException - 'true': throw exception if store exists
Throws:
ObjectStoreException - error preparing store (even after retrying if it is an ServiceUnavailableException).

retryEnsureStore

public static void retryEnsureStore(ObjectStoreService objectStore,
                                    java.lang.String storeName)
                             throws ObjectStoreException
Ensures that a store exists. If it does not exist, it will be created with default properties.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
Throws:
ObjectStoreException - error preparing store (even after retrying if it is an ServiceUnavailableException).

retryExistsStore

public static boolean retryExistsStore(ObjectStoreService objectStore,
                                       java.lang.String storeName)
                                throws ObjectStoreException
Checks if a store exists.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
Returns:
'true' if the store exists, 'false' if not.
Throws:
ObjectStoreException - error checking store existence (even after retrying if it is an ServiceUnavailableException).

retryGetStoreObjectInfos

public static java.util.Collection<StoreObject> retryGetStoreObjectInfos(ObjectStoreService objectStore,
                                                                         java.lang.String storeName,
                                                                         java.lang.String objectIdPrefix)
                                                                  throws ObjectStoreException
Retries listing object infos from a store.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
objectIdPrefix - the prefix for the ids of the objects to list.
Returns:
the list of object infos for the given prefix and the given store.
Throws:
ObjectStoreException - error reading info (even after retrying if it is an ServiceUnavailableException).

retryExistsObject

public static boolean retryExistsObject(ObjectStoreService objectStore,
                                        java.lang.String storeName,
                                        java.lang.String objectId)
                                 throws ObjectStoreException
Checks if an object in a store exists.

Parameters:
objectStore - ObjectStoreService reference to use.
storeName - the name of the store
objectId - the id of the object
Returns:
'true' if the store exists, 'false' if not.
Throws:
ObjectStoreException - error checking store existence (even after retrying if it is an ServiceUnavailableException).

retryClose

public static void retryClose(StoreOutputStream storeOutputStream)
                       throws java.io.IOException
calls StoreOutputStream.close(), retries in case of IOException.

Throws:
java.io.IOException - could not successfully close StoreOutputStream even after retrying.

SMILA (incubation) API documentation