com.apama.correlator.memstore
Class AbstractStore

java.lang.Object
  extended by com.apama.correlator.memstore.AbstractStore

public abstract class AbstractStore
extends java.lang.Object

A named distributed 'store' instance, which is a factory for tables and typically encapsulates a connection to a single distributed cluster.

Not required to be thread-safe (this is handled by the owner object instead).


Constructor Summary
AbstractStore(java.lang.String storeName)
          Create a store.
 
Method Summary
 void addClusterMembershipListener(ClusterMembershipListener listener)
          Adds a new cluster membership listener callback.
 void close()
          Disposes of all resources associated with this store, including shutting down background threads, terminating network connections, etc.
abstract  AbstractTable createTable(java.lang.String tableName, java.lang.String[] schemaTypes, java.lang.String[] schemaNames)
          Creates a new table instance.
 void fireClusterMembersChanged(int newSize, java.lang.String membershipDisplayInfo)
          Notifies listeners that the membership of the cluster has changed.
 java.lang.String getName()
          Returns the unique id representing this store, which is also the name by which it is referenced from EPL.
abstract  int getTotalClusterMembers()
          Returns the total number of cluster members in this store.
abstract  void init()
          Initialization method that is called by distributed MemoryStore just after construction.
 AbstractTable registerCloseHandlerForTable(AbstractTable table)
          Utility method that registers a newly created AbstractTable instance with AbstractStore so that its close method is automatically called during the store's close method.
 void removeClusterMembershipListener(ClusterMembershipListener listener)
          Removes an existing cluster membership listener callback.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractStore

public AbstractStore(java.lang.String storeName)
Create a store.

Parameters:
storeName - the name of the store, as returned from getName
Method Detail

init

public abstract void init()
                   throws java.lang.Exception
Initialization method that is called by distributed MemoryStore just after construction.

This is always called after the createStore method on AbstractStoreFactory has been called.

Any exception thrown from this will cause the AbstractStore.close method to be called, so this is the most convenient place to put code such as registering callbacks that must be disposed of via the close method if an exception is thrown during initialization. Also post-construction operations such as adding callback listeners that reference the store object would not be safe to do from a constructor itself since the store is not fully constructed until after the constructor has returned.

This method is guaranteed to be called by distributed MemoryStore before createTable or any other method on this object.

If an exception is thrown by this method, then close() will be called and then the prepare store operation will fail.

Throws:
java.lang.Exception

createTable

public abstract AbstractTable createTable(java.lang.String tableName,
                                          java.lang.String[] schemaTypes,
                                          java.lang.String[] schemaNames)
                                   throws DistMemStoreProviderException
Creates a new table instance.

Implementors may assume that the specified table name has not been created previously by this store.

Parameters:
tableName - the unique name of the table to create within this store
schemaTypes - the schemaTypes for that tables columns
schemaNames - the column names represented in the table and in sync with the schemaTypes
Returns:
never null
Throws:
DistMemStoreProviderException

registerCloseHandlerForTable

public AbstractTable registerCloseHandlerForTable(AbstractTable table)
Utility method that registers a newly created AbstractTable instance with AbstractStore so that its close method is automatically called during the store's close method.

This method should usually be called at the end of an implementation of createTable(java.lang.String, java.lang.String[], java.lang.String[]).

Parameters:
table - the table whose close method is to be linked to this stores's close method
Returns:
the same table object that was passed in

close

public void close()
Disposes of all resources associated with this store, including shutting down background threads, terminating network connections, etc.

Note that subclasses which override this method must call super.close() in their implementation.


getName

public final java.lang.String getName()
Returns the unique id representing this store, which is also the name by which it is referenced from EPL.

Returns:
the store name provided to the AbstractStore constructor

getTotalClusterMembers

public abstract int getTotalClusterMembers()
Returns the total number of cluster members in this store.

Returns:
total number of cluster members

fireClusterMembersChanged

public final void fireClusterMembersChanged(int newSize,
                                            java.lang.String membershipDisplayInfo)
Notifies listeners that the membership of the cluster has changed.

Subclasses are responsible for invoking this method at least once during startup to ensure an initial message is logged, and should also invoke it on subsequent membership changes.

This method will also write an INFO log message indicating the new size (and optionally, also a provider-specific string with information such as the list of new members).

Parameters:
newSize - number of connected members now in the cluster
membershipDisplayInfo - an optional provider-specific display string with additional information about the old and/or new members, or null

addClusterMembershipListener

public final void addClusterMembershipListener(ClusterMembershipListener listener)
Adds a new cluster membership listener callback.

This method exists for use by distributed MemoryStore, and in most cases does not need to be called by a driver implementation.

Parameters:
listener - Object implementing the ClusterMembershipListener interface.

removeClusterMembershipListener

public final void removeClusterMembershipListener(ClusterMembershipListener listener)
Removes an existing cluster membership listener callback.

This method exists for use by distributed MemoryStore, and in most cases does not need to be called by a driver implementation.

Parameters:
listener - Previously added callback object.


Submit a bug or feature
Copyright (c) 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG