asmuts 02/01/14 22:35:16
Added: src/java/org/apache/stratum/jcs/engine/behavior
IAttributes.java ICache.java ICacheAttributes.java
ICacheElement.java ICacheEventQueue.java
ICacheHub.java ICacheListener.java
ICacheManager.java ICacheObserver.java
ICacheRestore.java ICacheService.java
ICacheServiceAdmin.java ICacheType.java
ICompositeCache.java ICompositeCacheAttributes.java
ICompositeCacheManager.java
Log:
the core interfaces
Revision Changes Path
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/IAttributes.java
Index: IAttributes.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.control.Cache;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.access.exception.*;
public interface IAttributes {
///////////////////////////////////////////
// remove
//static int DISTRIBUTE = 1; // lateral
static int LATERAL = 1; // lateral
//static int NOFLUSH = 2;
//static int REPLY = 3;
//static int SYNCHRONIZE = 4;
static int SPOOL = 5;
//static int GROUP_TTL_DESTROY = 6;
//static int ORIGINAL = 7;
static int REMOTE = 8; // central rmi store
static int ETERNAL = 8; //
/////////////////////////////////////////////////
public void setFlags( long flags );
//public void setLoader( CacheLoader loader );
/////////////////////////////////////////////////
public void setVersion( long version );
/////////////////////////////////////////////////
public void setTimeToLive( long ttl );
/////////////////////////////////////////////////
public void setDefaultTimeToLive( long ttl );
/////////////////////////////////////////////////
public void setIdleTime( long idle );
/////////////////////////////////////////////////
//public void setListener( int event, CacheEventListener listerner) {}
/////////////////////////////////////////////////
/**
* Size in bytes.
*/
public void setSize( int size );
/////////////////////////////////////////
public int getSize( );
/////////////////////////////////////////
public boolean isSet( long flags );
/////////////////////////////////////////
public long getCreateTime( );
/////////////////////////////////////////
//public CacheLoader getLoader( );
/////////////////////////////////////////
public long getVersion( );
/////////////////////////////////////////
public long getIdleTime( );
/////////////////////////////////////////
public long getTimeToLive( );
/////////////////////////////////////////
public long timeToSeconds( int days, int hours, int minutes, int seconds )
throws InvalidArgumentException;
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICache.java
Index: ICache.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import java.io.*;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.control.Cache;
import org.apache.stratum.jcs.access.exception.*;
/** Inteface implemented by a specific cache. */
public interface ICache extends ICacheType {
public static boolean REMOTE_INVOKATION=true;
public static boolean LATERAL_INVOKATION=true;
public static boolean LOCAL_INVOKATION=!REMOTE_INVOKATION;
public static boolean INCLUDE_REMOTE_CACHE=true;
public static boolean EXCLUDE_REMOTE_CACHE=!INCLUDE_REMOTE_CACHE;
public static boolean MULTICAST_ON=true;
public static boolean MULTICAST_OFF=false;
/** Cache alive status. */
public static final int STATUS_ALIVE = 1;
/** Cache disposed status. */
public static final int STATUS_DISPOSED = 2;
/** Cache in error. */
public static final int STATUS_ERROR = 3;
/** Delimiter of a cache name component. */
public static final String NAME_COMPONENT_DELIMITER = ":";
/** used to identify the source of cache modifications, should be unique */
public Serializable getSourceId();
/**
* Puts an item to the cache.
*/
public void update(ICacheElement ce) throws IOException;
// used to identify the soure, if none is present is assumed to be local
// public void update(CacheElement ce, Serializable source_id ) throws IOException;
// may need insert if we want to distinguish b/wn put and replace
public void put(Serializable key, Serializable val) throws IOException;
public void put(Serializable key, Serializable val, Attributes attr ) throws
IOException;
/**
* Gets an item from the cache.
*/
public Serializable get(Serializable key) throws IOException;
public Serializable get(Serializable key, boolean container ) throws IOException;
/** Removes an item from the cache. */
public boolean remove(Serializable key) throws IOException;
// used to identify the soure, if none is present is assumed to be local
// public boolean remove(Serializable key, Serializable source_id) throws
IOException;
/** Removes all cached items from the cache. */
public void removeAll() throws IOException;
/** Prepares for shutdown. */
public void dispose() throws IOException;
/** Returns the cache statistics. */
public String getStats();
/** Returns the current cache size. */
public int getSize();
/** Returns the cache status. */
public int getStatus();
/** Returns the cache name. */
public String getCacheName();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheAttributes.java
Index: ICacheAttributes.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import java.io.*;
import java.net.*;
import java.util.*;
/**
* This interface allows programatic control of a cache.
* Caches described in the cache.properties file will be created
* with ICacheAttributes that correspond to the props entires.
*/
public interface ICacheAttributes extends Serializable, Cloneable {
// WHETHER ELEMENT CAN USE AUXILLIARY CACHES
/**
* SetLocal sets the attribute to indicate the cache is local. Invalidations and
updates will not be propagated to
* other caches in the system.
*/
public void setIsLocal( boolean isLocal );
////////////////////////////////////
public boolean getIsLocal();
////////////////////////////////////
public void setUseDisk( boolean useDisk );
////////////////////////////////////
public boolean getUseDisk( );
////////////////////////////////////
// REMOVE
public void setDist( boolean dist );
public boolean getDist( );
////////////////////////////////////
/** set whether the cache should use a lateral cache */
public void setUseLateral( boolean d );
public boolean getUseLateral( );
/** Sets whether the cache is remote enabled */
public void setUseRemote( boolean isRemote );
/** returns whether the cache is remote enabled */
public boolean getUseRemote( );
/**
* Sets the name of the cache, referenced by the appropriate manager.
*
*/
public void setCacheName( String s );
public String getCacheName( );
///////////////////////////////////////////////////
// ALL POSSIBLE AUXIALLARY CONFIGURATION
// this might become too much if we continue adding attribute
// may need specific attributes. Say the alteral cache doesn't have a servlet,
// then why should we have a deleteServlet property. Also, why
// should the remote get an attribute set so large.
// The problem with breaking the attributes up is that
// it would become impossible to programatically create a cache.
// perhaps it is worth it. If we broke it up then mor proerties could be
// added reflectively. You could set whatever your particular
// lateral cache needs. The ICacheAttributes could then be distilled
// into general properties and each manager would ahve some other
// atribute object that could e set dynamically.
// the problem with the static getInstance methods may necesitate doing this.
/** manages the remote serice name for the remotecache */
public void setRemoteServiceName( String s );
public String getRemoteServiceName( );
/** Sets whether the cache is remote enabled */
public void setAccessSeq( String seq );
public String getAccessSeq( );
/**
* SetMaxObjects is used to set the attribute to determine the maximum number of
objects allowed in the
* memory cache. If the max number of objects or the cache size is set, the default
for the one not set is
* ignored. If both are set, both are used to determine the capacity of the cache,
i.e., object will be removed
* from the cache if either limit is reached.
*/
public void setMaxObjects(int size);
public int getMaxObjects( );
/**SetMemoryCacheSize sets the attribute to indicate the maximum size of the
memory cache. Size is in
* megabytes. If the max number of objects or the cache size is set, the default
for the one not set is ignored. If
* both are set, both are used to determine the capacity of the cache, i.e., object
will be removed from the cache
* if either limit is reached.
*/
public void setMaxBytes(int size);
public int getMaxBytes( );
/** SetDiskCacheSize sets the attribute to indicate the maximum size of the disk
cache. Size is in megabytes. */
public void setDiskCacheSize(int size);
/** SetDiskPath sets the attribute indicating the root location for the disk
cache. */
public void setDiskPath(String path);
public String getDiskPath( );
/**
* SetCleanInterval sets the attribute indicating the how often the cache should
be checked for objects
* invalidated by �time to live� or �idle time� attributes.
*/
public void setCleanInterval(int seconds );
/**
* AddCacheAddr is used to specify the network address and port to be used by the
cache messaging system.
* At least one known address is required by the cache to allow discovery when a
process using the cache is
* first brought on line. If no address is specified, localhost with a default
port is use. If the system of caches is
* across multiple nodes, it is best to have an address specified for each node to
protect against unavailable
* nodes.
*/
public void addLateralCacheAddr( String ipAddr, int port);
public void setLateralDeleteServlet( String name );
public String getLateralDeleteServlet();
public void setLateralReceiveServlet( String name );
public String getLateralReceiveServlet();
public void setLateralCacheAddrs( ArrayList addrs );
/**
* Returns an ArrayList of Strings representing the address for all the cache
address
* configured. If no address were configured the default value is returned. The
address is in the form of
* ipaddress:port (127.0.0.1:12345)
*/
public ArrayList getLateralCacheAddrs();
/** Sets the remote cache address */
public void setRemoteHost( String host );
/** return the remote cache address */
public String getRemoteHost( );
/** Sets the remote cache port */
public void setRemotePort( int port );
/** returns the port of the remote cahe */
public int getRemotePort( );
// add the secondary remote configuration information
/** Sets the remote cache address */
public void setSecondaryRemoteHost( String host );
/** return the remote cache address */
public String getSecondaryRemoteHost( );
/** Sets the remote cache port */
public void setSecondaryRemotePort( int port );
/** returns the port of the remote cahe */
public int getSecondaryRemotePort( );
/////////////////////////////////////////
// soultion to interface cloning
public ICacheAttributes copy();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheElement.java
Index: ICacheElement.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.behavior.ICache;
import java.io.*;
import java.util.*;
public interface ICacheElement extends Serializable//, Cloneable
{
public String getCacheName();
public Serializable getKey();
public Serializable getVal();
public Attributes getAttributes();
public void setAttributes( IAttributes attr );
public long getCreateTime();
// allow thread-safe operations.
// public Object clone();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheEventQueue.java
Index: ICacheEventQueue.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.behavior.ICache;
import java.io.*;
/**
* Interface for a cache event queue.
* An event queue is used to propagate ordered cache events to
* one and only one target listener.
*/
public interface ICacheEventQueue {
public void addPutEvent( ICacheElement ce ) throws IOException;
public void addRemoveEvent(Serializable key) throws IOException;
public void addRemoveAllEvent() throws IOException;
public void addDisposeEvent() throws IOException;
public byte getListenerId();
public void destroy();
public boolean isAlive();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheHub.java
Index: ICacheHub.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import java.io.*;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.control.Cache;
import org.apache.stratum.jcs.access.exception.*;
/**
* For the framework. Insures methods a MemoryCache needs to access.
*/
public interface ICacheHub extends ICacheType {
public void spoolToDisk( ICacheElement ice );
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheListener.java
Index: ICacheListener.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.behavior.ICacheElement;
import org.apache.stratum.jcs.engine.behavior.ICache;
import java.io.*;
/**
* Used to receive a cache event notification.
* <br><br>
* Note: objects which implement this interface are local listeners to cache changes,
* whereas objects which implement IRmiCacheListener are remote listeners to cache
changes.
*/
public interface ICacheListener {
/**
* Notifies the subscribers for a cache entry update.
*/
public void handlePut( ICacheElement item ) throws IOException;
/**
* Notifies the subscribers for a cache entry removal.
*/
public void handleRemove(String cacheName, Serializable key) throws IOException;
/**
* Notifies the subscribers for a cache remove-all.
*/
public void handleRemoveAll(String cacheName) throws IOException;
/**
* Notifies the subscribers for freeing up the named cache.
*/
public void handleDispose(String cacheName) throws IOException;
/**
* Notifies the subscribers for releasing all caches.
*/
// public void handleRelease() throws IOException;
/** sets unique identifier of listener home */
public void setListenerId( byte id ) throws IOException;
public byte getListenerId( ) throws IOException;
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheManager.java
Index: ICacheManager.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.control.Cache;
import java.io.*;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.access.exception.*;
/** Inteface implemented by a specific cache. */
public interface ICacheManager extends ICacheType {
/** methods to get a cache region from a maanger */
public ICache getCache( String cacheName );
} // end interface
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheObserver.java
Index: ICacheObserver.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.behavior.ICacheListener;
import org.apache.stratum.jcs.engine.behavior.ICache;
import java.io.*;
/**
* Used to register interest in receiving cache changes.
* <br><br>
* Note: server which implements this interface provides a local cache
* event notification service, whereas server which implements IRmiCacheWatch
* provides a remote cache event notification service.
*/
public interface ICacheObserver {
/**
* Subscribes to the specified cache.
* @param cacheName the specified cache.
* @param obj object to notify for cache changes.
*/
public void addCacheListener(String cacheName, ICacheListener obj) throws
IOException; //, CacheNotFoundException;
/**
* Subscribes to all caches.
* @param obj object to notify for all cache changes.
*/
public void addCacheListener(ICacheListener obj) throws IOException;
/**
* Unsubscribes from the specified cache.
* @param obj existing subscriber.
*/
public void removeCacheListener(String cacheName, ICacheListener obj) throws
IOException;
/**
* Unsubscribes from all caches.
* @param obj existing subscriber.
*/
public void removeCacheListener(ICacheListener obj) throws IOException;
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheRestore.java
Index: ICacheRestore.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.behavior.ICache;
import org.apache.stratum.jcs.auxiliary.remote.*;
public interface ICacheRestore {
public boolean canFix();
public void fix();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheService.java
Index: ICacheService.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.control.Cache;
import org.apache.stratum.jcs.access.exception.*;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.behavior.ICacheElement;
import org.apache.stratum.jcs.engine.behavior.ICache;
import java.io.*;
/**
* Used to retrieve and update the cache.
* <br><br>
* Note: server which implements this interface provides a local cache service,
* whereas server which implements IRmiCacheService provides a remote cache service.
*/
public interface ICacheService {
/**
* Puts a cache item to the cache.
*/
public void update(ICacheElement item) throws ObjectExistsException, IOException;
/**
* Returns a cache bean from the specified cache;
* or null if the key does not exist.
*/
public Serializable get(String cacheName, Serializable key) throws
ObjectNotFoundException, IOException;
public Serializable get(String cacheName, Serializable key, boolean container )
throws ObjectNotFoundException, IOException;
/**
* Removes the given key from the specified cache.
*/
public void remove(String cacheName, Serializable key) throws IOException;
/**
* Remove all keys from the sepcified cache.
*/
public void removeAll(String cacheName) throws IOException;
/**
* Frees the specified cache.
*/
public void dispose(String cacheName) throws IOException;
/**
* Frees all caches.
*/
public void release() throws IOException;
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheServiceAdmin.java
Index: ICacheServiceAdmin.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.behavior.ICacheService;
import org.apache.stratum.jcs.engine.behavior.ICache;
import java.io.*;
public interface ICacheServiceAdmin {
public String getStats() throws IOException;
public void shutdown() throws IOException;
public void shutdown(String host, int port) throws IOException;
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICacheType.java
Index: ICacheType.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import org.apache.stratum.jcs.engine.control.Cache;
import java.io.*;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.access.exception.*;
/** Inteface implemented by a specific cache. */
public interface ICacheType extends Serializable {
/** Composite/ memory cache type, cetral hub. */
public static final int COMPOSITE_CACHE = 1;
public static final int CACHE_HUB = 1;
public static final int MEMORY_CACHE = 1;
/** Disk cache type. */
public static final int DISK_CACHE = 2;
/** Lateral cache type. */
public static final int LATERAL_CACHE = 3;
/** Remote cache type. */
public static final int REMOTE_CACHE = 4;
/** Returns the cache type. */
public int getCacheType();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICompositeCache.java
Index: ICompositeCache.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
import java.io.Serializable;
import java.io.*;
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.engine.control.Cache;
import org.apache.stratum.jcs.access.exception.*;
/**
* Much like the ICache interface, but htis is specifically designed for the
* CompositeCaches. This interface guarantees a simple set of methods for use
* by auxiliary cache implementations.
*/
public interface ICompositeCache extends ICache {
/**
* Puts an item to the cache.
*/
public void update(ICacheElement ce) throws IOException;
public void update(ICacheElement ce, boolean localInvocation) throws IOException;
public boolean remove(Serializable key) throws IOException;
public boolean remove(Serializable key, boolean localInvocation) throws
IOException;
/** allows a get request to stay local **/
public Serializable get(Serializable key, boolean container, boolean
localInvocation) throws IOException;
/** Returns the cache statistics. */
public String getStats();
/** Returns the current cache size. */
public int getSize();
/** Returns the cache status. */
public int getStatus();
/** Returns the cache name. */
public String getCacheName();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICompositeCacheAttributes.java
Index: ICompositeCacheAttributes.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
import java.io.*;
//////////////////////////////////////////////////////
public interface ICompositeCacheAttributes extends Serializable {
/**
* SetMaxObjects is used to set the attribute to determine the maximum number of
objects allowed in the
* memory cache. If the max number of objects or the cache size is set, the default
for the one not set is
* ignored. If both are set, both are used to determine the capacity of the cache,
i.e., object will be removed
* from the cache if either limit is reached.
*
* TODO: move to MemoryCache config file.
*/
public void setMaxObjects(int size);
public int getMaxObjects( );
////////////////////////////////////
public void setUseDisk( boolean useDisk );
public boolean getUseDisk( );
////////////////////////////////////
/** set whether the cache should use a lateral cache */
public void setUseLateral( boolean d );
public boolean getUseLateral( );
/** Sets whether the cache is remote enabled */
public void setUseRemote( boolean isRemote );
/** returns whether the cache is remote enabled */
public boolean getUseRemote( );
/**
* Sets the name of the cache, referenced by the appropriate manager.
*
*/
public void setCacheName( String s );
public String getCacheName( );
/**
* Sets the name of the MemoryCache, referenced by the appropriate manager.
* TODO: create a separate memory cache attribute class.
*/
public void setMemoryCacheName( String s );
public String getMemoryCacheName( );
/////////////////////////////////////////
// soultion to interface cloning
public ICompositeCacheAttributes copy();
}
1.1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICompositeCacheManager.java
Index: ICompositeCacheManager.java
===================================================================
package org.apache.stratum.jcs.engine.behavior;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
import org.apache.stratum.jcs.engine.*;
import org.apache.stratum.jcs.access.exception.*;
public interface ICompositeCacheManager extends ICacheManager {
public ICache getCache( ICompositeCacheAttributes cattr );
public ICompositeCacheAttributes getDefaultCattr();
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>