org.garret.perst
Class StorageFactory

java.lang.Object
  extended byorg.garret.perst.StorageFactory

public class StorageFactory
extends java.lang.Object

Storage factory


Constructor Summary
StorageFactory()
           
 
Method Summary
 ReplicationMasterStorage createReplicationMasterStorage(java.lang.String[] replicationSlaveNodes, int asyncBufSize)
          Create new instance of the master node of replicated storage
 ReplicationSlaveStorage createReplicationSlaveStorage(int port)
          Create new instance of the slave node of replicated storage
 Storage createStorage()
          Create new instance of the storage
static StorageFactory getInstance()
          Get instance of storage factory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StorageFactory

public StorageFactory()
Method Detail

createReplicationMasterStorage

public ReplicationMasterStorage createReplicationMasterStorage(java.lang.String[] replicationSlaveNodes,
                                                               int asyncBufSize)
Create new instance of the master node of replicated storage

Parameters:
replicationSlaveNodes - addresses of hosts to which replication will be performed. Address as specified as NAME:PORT
asyncBufSize - if value of this parameter is greater than zero then replication will be asynchronous, done by separate thread and not blocking main application. Otherwise data is send to the slave nodes by the same thread which updates the database. If space asynchronous buffer is exhausted, then main thread willbe also blocked until the data is send.
Returns:
new instance of the master storage (unopened, you should explicitely invoke open method)

createReplicationSlaveStorage

public ReplicationSlaveStorage createReplicationSlaveStorage(int port)
Create new instance of the slave node of replicated storage

Parameters:
port - socket port at which connection from master will be established
Returns:
new instance of the slave storage (unopened, you should explicitely invoke open method)

createStorage

public Storage createStorage()
Create new instance of the storage

Returns:
new instance of the storage (unopened, you should explicitely invoke open method)

getInstance

public static StorageFactory getInstance()
Get instance of storage factory. So new storages should be create in application in the following way: StorageFactory.getInstance().createStorage()

Returns:
instance of the storage factory