com.alachisoft.ncache.client.internal.caching.CacheImplBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
package com.alachisoft.ncache.client.internal.caching;
//import Alachisoft.NCache.Common.Util.*;
import Alachisoft.NCache.Caching.CompressedValueEntry;
import Alachisoft.NCache.Caching.Queries.QueryResultSet;
import Alachisoft.NCache.Common.BitSet;
import Alachisoft.NCache.Common.DataReader.RecordSetEnumerator;
import Alachisoft.NCache.Common.DataStructures.EnumerationDataChunk;
import Alachisoft.NCache.Common.DataStructures.EnumerationPointer;
import Alachisoft.NCache.Common.Enum.SubscriptionType;
import Alachisoft.NCache.Common.Enum.TopicOperationType;
import Alachisoft.NCache.Common.Enum.UserObjectType;
import Alachisoft.NCache.Common.Extensibility.Client.RPC.PartitioningStrategy;
import Alachisoft.NCache.Common.Locking.LockAccessType;
import Alachisoft.NCache.Common.Logger.ILogger;
import com.alachisoft.ncache.client.*;
import com.alachisoft.ncache.client.ClientInfo;
import com.alachisoft.ncache.client.internal.communication.Connection;
import com.alachisoft.ncache.client.internal.communication.ModuleOperation;
import com.alachisoft.ncache.client.internal.messaging.ReceivedMessages;
import com.alachisoft.ncache.common.caching.statistics.monitoring.PublisherContextMetaPublisher;
import com.alachisoft.ncache.runtime.CacheItemPriority;
import com.alachisoft.ncache.runtime.caching.*;
import com.alachisoft.ncache.runtime.dependencies.CacheDependency;
import com.alachisoft.ncache.runtime.events.EventDataFilter;
import com.alachisoft.ncache.runtime.events.ListenerType;
import com.alachisoft.ncache.runtime.exceptions.SecurityException;
import com.alachisoft.ncache.runtime.exceptions.*;
import com.alachisoft.ncache.runtime.util.TimeSpan;
import com.alachisoft.ncache.serialization.util.TypeInfoMap;
import tangible.RefObject;
import java.net.InetAddress;
import java.util.*;
public abstract class CacheImplBase implements PublisherContextMetaPublisher {
private String _clientID;
private boolean _encryptionEnabled;
private ClientInfo _clientInfo;
public CacheImplBase() {
try {
_clientInfo = new ClientInfo();
_clientInfo.setProcessID((int) ProcessHandle.current().pid());
_clientInfo.setClientID(UUID.randomUUID().toString() );
_clientInfo.setMachineName(InetAddress.getLocalHost().getHostName().toString());
//Taimoor: from NCache 4.1 SP2 private patch 2 ownward client version will also be sent
//Client version has following format :
//[2 digits for major version][1 digit for service paack][1 digit for private patch]
//e.g. 4122 means 4.1 major , 2 for service pack 2 and last 4 for private patch 4
_clientInfo.setClientVersion(5000); //changed for 5.0
_clientID = ClientInfo.getLegacyClientID(_clientInfo);
} catch (Exception e) {
}
}
public boolean getEncryptionEnabled() {
return _encryptionEnabled;
}
public void setEncryptionEnabled(boolean value) {
_encryptionEnabled = value;
}
public ClientInfo getLocalClientInfo() {
return _clientInfo;
}
abstract public ILogger getNCacheLog();
abstract protected void registerCustomEventListener(CustomListener listener) throws GeneralFailureException, OperationFailedException, AggregateException, SecurityException, ConfigurationException, ConnectionException, Exception;
abstract protected void registerCacheEventlistener(CacheListener listener, EnumSet registerAgainst) throws GeneralFailureException, OperationFailedException, AggregateException, SecurityException, ConfigurationException, ConnectionException, StreamNotFoundException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, CommandException;
abstract protected void registerCacheStatusEventlistener(CacheStatusEventListener listener, EnumSet registerAgainst) throws GeneralFailureException, OperationFailedException, AggregateException, SecurityException, ConfigurationException, ConnectionException, StreamNotFoundException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, CommandException;
abstract protected void unregisterCacheEventlistener(CacheListener listener, EnumSet unregisterAgainst) throws GeneralFailureException, OperationFailedException, AggregateException, SecurityException, ConfigurationException, ConnectionException, StreamNotFoundException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, CommandException;
abstract protected void unregisterCacheStatusEventlistener(CacheStatusEventListener listener, EnumSet unregisterAgainst) throws GeneralFailureException, OperationFailedException, AggregateException, SecurityException, ConfigurationException, ConnectionException, StreamNotFoundException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, CommandException;
abstract protected void unregisterCustomEventListener(CustomListener listener) throws GeneralFailureException, OperationFailedException, AggregateException, SecurityException, ConfigurationException, ConnectionException, Exception;
boolean isInproc() {
return false;
}
boolean getSerializationEnabled() {
return true;
}
abstract protected TypeInfoMap getTypeMap();
abstract protected void setTypeMap(TypeInfoMap value);
abstract public long getCompressionThreshold();
abstract protected void setCompressionThreshold(long value);
abstract public boolean getCompressionEnabled();
abstract protected void setCompressionEnabled(boolean value);
protected abstract void registerCacheClientConnectivityEvent() throws CacheException;
protected abstract void unregisterCacheClientConnectivityEvent() throws CacheException;
abstract void registerCacheStoppedEvent() throws CacheException;
abstract void unregisterCacheStoppedEvent() throws CacheException;
abstract void registerClearEvent() throws CacheException;
abstract void unregisterClearEvent() throws CacheException;
abstract public long getCount() throws CacheException;
public final String getClientID() {
return _clientID;
}
public void unregisterHashmapChangedNotification() throws GeneralFailureException, OperationFailedException, AggregateException, SecurityException, ConfigurationException, ConnectionException, Exception {
}
abstract public void makeTargetCacheActivePassive(boolean makeActive) throws GeneralFailureException, SecurityException, OperationFailedException, AggregateException, ConnectionException, Exception;
abstract public String getName();
abstract protected String getBridgeTargetCacheUniqueID();
abstract protected void setBridgeTargetCacheUniqueID(String value);
abstract public void dispose(boolean disposing) throws GeneralFailureException, OperationFailedException, ConfigurationException;
abstract public Object getItem(String key) throws Exception;
abstract Vector getCallbackQueue();
abstract public void setItem(String key, Object value);
abstract public CacheItemVersion add(String key, Object value, CacheDependency dependency, CacheSyncDependency syncDependency,
java.util.Date absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short onRemoveCallback,
short onUpdateCallback, short onDsItemAddedCallback, boolean isResyncExpiredItems,
String group, java.util.HashMap queryInfo, BitSet flagMap,
String providerName,
EventDataFilter itemUpdateDataFilter, EventDataFilter itemRemovedDataFilter,
long size,boolean encryptionEnabled ,String clientId,String typeName)
throws OperationFailedException, AggregateException, SecurityException, GeneralFailureException, ConnectionException, ConfigurationException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, StreamNotFoundException, CommandException;
abstract public java.util.HashMap add(String[] keys, com.alachisoft.ncache.client.CacheItem[] items, String providerName, long[] sizes, boolean encryptionEnabled ,String clientID , short updateCallbackId , short removeCallbackId , EventDataFilter updateCallbackFilter , EventDataFilter removeCallbackFilter ,boolean returnVersions , Map itemVersions , ListenerType listenerType) throws OperationFailedException, SecurityException, AggregateException, GeneralFailureException, ConfigurationException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, StreamNotFoundException, CommandException;
/**
* Function that choose the appropriate function of NCache's Cache, that need to be called according to the data provided to it.
*/
abstract public Object addAsync(String key, Object value, CacheDependency dependency, CacheSyncDependency syncDependency, java.util.Date absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority,
short onRemoveCallback, short onUpdateCallback, short onAsyncItemAddCallback, short dsItemAddedCallback, boolean isResyncExpiredItems, String group,
java.util.HashMap queryInfo, BitSet flagMap, String providerName, String resyncProviderName, EventDataFilter itemUpdateDataFilter, EventDataFilter itemRemovedDataFilter, long size,
String clientId, short updateCallbackId, short removeCallbackId, short dsItemAddedCallbackId) throws Exception;
/**
* Add dependency to the cache item.
*
* @param key key used to reference the required object
* @param dependency CacheDependency to be added
* @param isResyncRequired Boolean value indicating wether Resync is required or not
* @return True if operations successeded else false
*/
// abstract public boolean addDependency(String key, CacheDependency dependency, boolean isResyncRequired) throws Exception;
//
// abstract public boolean addDependency(String key, CacheSyncDependency syncDependency) throws Exception;
//#endif
public void clear(BitSet flagMap, short onDsClearedCallback, String providerName) throws CacheException {
}
public abstract boolean contains(String key) throws CacheException;
public abstract Map containsBulk(String[] keys) throws CacheException;
public abstract CompressedValueEntry get(String key, BitSet flagMap, String group, CacheItemVersion version, LockHandle lockHandle, TimeSpan lockTimeout, LockAccessType accessType) throws OperationFailedException, GeneralFailureException, AggregateException, SecurityException, ConfigurationException, CommandException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, StreamNotFoundException;
abstract public Collection getGroupKeys(String group) throws OperationFailedException, GeneralFailureException, AggregateException, com.alachisoft.ncache.runtime.exceptions.SecurityException, ConnectionException, Exception;
abstract public java.util.HashMap getGroupData(String group) throws OperationFailedException, GeneralFailureException, AggregateException, com.alachisoft.ncache.runtime.exceptions.SecurityException, ConnectionException, Exception;
abstract public java.util.Map get(String[] keys, BitSet flagMap) throws OperationFailedException, GeneralFailureException, AggregateException, SecurityException, ConfigurationException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, StreamNotFoundException;
public abstract Object getCacheItem(String key, BitSet flagMap, String group, CacheItemVersion version, LockHandle lockHandle, TimeSpan lockTimeout, LockAccessType accessType) throws OperationFailedException, SecurityException, AggregateException, GeneralFailureException, ConfigurationException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, StreamNotFoundException, CommandException;
public List GetConnectedClientList() throws OperationFailedException, AggregateException, GeneralFailureException, CommandException, StreamNotFoundException, StreamException, OperationNotSupportedException, StreamAlreadyLockedException, ConfigurationException, LicensingException, SecurityException {
return null;
}
abstract public java.util.HashMap insert(String[] keys, com.alachisoft.ncache.client.CacheItem[] items,
long[] sizes, boolean encryptionEnabled, String clientId,
short updateCallbackId, short removeCallbackId,
EventDataFilter updateCallbackFilter, EventDataFilter removeCallbackFilter, boolean returnVersions,
Map itemVersions, ListenerType listenerType) throws OperationFailedException, AggregateException, SecurityException, GeneralFailureException, ConfigurationException, CacheException;
//#endif
public abstract CacheItemVersion insert(String key, Object value, CacheDependency dependency, CacheSyncDependency syncDependency,
java.util.Date absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority,
short onRemoveCallback, short onUpdateCallback,
boolean isResyncExpiredItems, String group, java.util.HashMap queryInfo,
BitSet flagMap, String lockId, CacheItemVersion version, LockAccessType accessType,
EventDataFilter updateCallbackFilter,
EventDataFilter removeCallabackFilter, long size, boolean encryptionEnabled, String clientId,
String typeName, ListenerType listenerType)
throws CacheException;
abstract public CompressedValueEntry remove(String key, BitSet flagMap, short dsItemRemovedCallbackId, String lockId, CacheItemVersion version, LockAccessType accessType, String ProviderName) throws CacheException;
abstract public void delete(String key, BitSet flagMap, short dsItemRemovedCallbackId, String lockId, CacheItemVersion version, LockAccessType accessType, String providerName) throws CacheException;
abstract public java.util.HashMap remove(String[] keys, BitSet flagMap, String providerName, short onDsItemsRemovedCallback) throws CacheException, Exception;
abstract public void delete(String[] keys, BitSet flagMap, String providerName, short onDsItemsRemovedCallback) throws CacheException;
abstract public void remove(String group) throws OperationFailedException, GeneralFailureException, AggregateException, com.alachisoft.ncache.runtime.exceptions.SecurityException, ConnectionException;
public Object safeSerialize(Object serializableObject, String serializationContext, BitSet flag, CacheImplBase cacheImpl,RefObject size, UserObjectType userObjectType) throws GeneralFailureException, OperationFailedException {
return safeSerialize(serializableObject, serializationContext, flag, cacheImpl,size, userObjectType, false);
}
abstract public Object safeSerialize(Object serializableObject, String serializationContext, BitSet flag, CacheImplBase cacheImpl, RefObject size, UserObjectType userObjectType, boolean isCustomerAtributeBaseSerialized) throws GeneralFailureException, OperationFailedException;
public abstract T safeDeserialize(Object serializedObject, String serializationContext, BitSet flag, CacheImplBase cacheImpl, UserObjectType userObjectType, Class> cls) throws OperationFailedException;
abstract public Enumeration getEnumerator();
abstract public java.util.ArrayList getNextChunk(java.util.ArrayList pointers) throws SecurityException, GeneralFailureException, OperationFailedException, AggregateException, ConnectionException, java.net.UnknownHostException, ConfigurationException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, StreamNotFoundException, CommandException;
abstract public java.util.HashMap getCompactTypes();
abstract public void unlock(String key) throws Exception;
abstract public void unlock(String key, String lockId) throws Exception;
abstract public boolean lock(String key, TimeSpan lockTimeout, LockHandle lockHandle) throws OperationFailedException, GeneralFailureException, AggregateException, SecurityException, ConnectionException, Exception;
abstract public boolean isLocked(String key, LockHandle lockHandle) throws OperationFailedException, GeneralFailureException, AggregateException, SecurityException, ConnectionException, Exception;
abstract public boolean setAttributes(String key, CacheItemAttributes attribute) throws CacheException;
abstract public boolean getOrCreate(String topicName, TopicOperationType type) throws CacheException;
abstract public void acknowledgeMessageReceipt(java.util.Map> topicWiseMessageIds) throws Exception;
abstract public boolean removeTopic(String topicName, boolean b) throws CacheException;
abstract public void publishMessage(String messageId, Object value, long time, long expiration, Hashtable metaInfo, BitSet flagMap) throws Exception;
abstract public boolean unSubscribe(String topicName, String recepientId,SubscriptionPolicyType subscriptionPolicyType, SubscriptionType pubSubType, boolean dispose) throws Exception;
abstract public ReceivedMessages getMessageData(BitSet flagMap) throws CacheException;
// region SearchService methods
abstract public QueryResultSet search(String query, java.util.HashMap values) throws OperationFailedException, GeneralFailureException, AggregateException, SecurityException;
abstract public int executeNonQuery(String query, java.util.HashMap values)
throws Exception;
abstract RecordSetEnumerator executeReader(String query, Map values, boolean getData, int chunkSize) throws OperationFailedException;
// endregion
//region MessagingService
public abstract void registerKeyNotificationListener(String key, short update, short remove, EventDataFilter datafilter, boolean notifyOnItemExpiration, ListenerType listenerType) throws OperationFailedException, CommandException, StreamNotFoundException, StreamException, OperationNotSupportedException, StreamAlreadyLockedException, AggregateException, GeneralFailureException, ConfigurationException, LicensingException, SecurityException;
public abstract void registerKeyNotificationListener(String[] key, short update, short remove, EventDataFilter datafilter, boolean notifyOnItemExpiration, ListenerType listenerType) throws OperationFailedException, CommandException, StreamNotFoundException, StreamException, OperationNotSupportedException, StreamAlreadyLockedException, AggregateException, GeneralFailureException, ConfigurationException, LicensingException, SecurityException;
public abstract void registerKeyNotificationListener(String[] keys, short updateCallbackid, short removeCallbackid) throws CacheException;
public abstract void unRegisterKeyNotificationListener(String key, short updateCallbackid, short removeCallbackid) throws CacheException;
public abstract void unRegisterKeyNotificationListener(String[] key, short update, short remove) throws CacheException;
public abstract void unRegisterGeneralNotificationListener(EventTypeInternal unregister, short sequenceNumber) throws CacheException;
public abstract void registerGeneralNotification(EventTypeInternal eventType, EventDataFilter datafilter, short sequenceNumber) throws CacheException;
public abstract void registerKeyNotificationListener(String[] keys, short updateCallbackid, short removeCallbackid, String clientId, ListenerType listenerType);
public abstract void raiseCustomEvent(Object notifId, Object data) throws CacheException;
public abstract void registerKeyNotificationListener(String key, short updateCallbackid, short removeCallbackid, boolean notifyOnItemExpiration) throws CacheException;
public abstract boolean subscribe(String topicName, String subscriptionName, SubscriptionType subscriptionType, long creationTime, long expiration, SubscriptionPolicyType subscriptionPolicyType)throws CacheException;
public abstract long getMessageCount(String topicName) throws OperationFailedException, CommandException, StreamNotFoundException, StreamException, OperationNotSupportedException, StreamAlreadyLockedException, AggregateException, GeneralFailureException, ConfigurationException, LicensingException, SecurityException;
public abstract void registerKeyNotificationListener(String key, short callbackRef, short callbackRef1, EventDataFilter dataFilter, boolean notifyOnItemExpiration) throws CacheException;
public abstract void registerKeyNotificationListener(String[] keys, short callbackRef, short callbackRef1, EventDataFilter dataFilter, boolean notifyOnItemExpiration) throws CacheException;
public abstract Map getCacheItemBulk(String[] keysList, BitSet flagMap) throws OperationFailedException, SecurityException, AggregateException, GeneralFailureException, StreamNotFoundException, OperationNotSupportedException, StreamException, ConfigurationException, LicensingException, StreamAlreadyLockedException;
public abstract void InvalidateReaders(String toString);
public abstract void setCompressionThresholdSize(long compressionThreshold);
public abstract void registerHashmapChangedEvent(Connection connection) throws AggregateException, SecurityException, GeneralFailureException, OperationFailedException, ConfigurationException, StreamNotFoundException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, CommandException;
public abstract void getTypeInfoMap(Connection connection) throws AggregateException, InternalCommandException, GeneralFailureException, OperationFailedException, SecurityException, OperationNotSupportedException, StreamException, ConfigurationException, LicensingException, StreamNotFoundException, StreamAlreadyLockedException, CommandException;
public abstract void getThresholdSize(Connection connection) throws AggregateException, InternalCommandException, GeneralFailureException, OperationFailedException, OperationNotSupportedException, StreamException, SecurityException, LicensingException, ConfigurationException, StreamNotFoundException, StreamAlreadyLockedException, CacheException;
public abstract void getExpirationFromServer(Connection connection) throws AggregateException, InternalCommandException, GeneralFailureException, OperationFailedException, OperationNotSupportedException, StreamException, SecurityException, LicensingException, ConfigurationException, StreamNotFoundException, StreamAlreadyLockedException, CommandException;
public abstract void getSerializationFormat(Connection connection) throws AggregateException, InternalCommandException, GeneralFailureException, OperationFailedException, SecurityException, OperationNotSupportedException, StreamException, ConfigurationException, LicensingException, StreamNotFoundException, StreamAlreadyLockedException, CommandException;
public abstract void getCompactTypesFromServer(Connection connection) throws AggregateException, InternalCommandException, GeneralFailureException, OperationFailedException, SecurityException, OperationNotSupportedException, StreamException, ConfigurationException, LicensingException, StreamNotFoundException, StreamAlreadyLockedException, CommandException;
public abstract void getEncryptionKeyFromServer(Connection connection) throws AggregateException, InternalCommandException, GeneralFailureException, OperationFailedException, OperationNotSupportedException, StreamException, SecurityException, LicensingException, ConfigurationException, StreamNotFoundException, StreamAlreadyLockedException, CommandException;
public abstract void reRegisterGeneralNotification(Connection connection) throws AggregateException, SecurityException, GeneralFailureException, OperationFailedException, ConfigurationException, StreamNotFoundException, StreamException, StreamAlreadyLockedException, LicensingException, OperationNotSupportedException, CommandException;
public abstract void ExecuteModuleOperation(ModuleOperation operation) throws OperationFailedException, CommandException, LicensingException;
public abstract PartitioningStrategy getPartitioningStrategy();
public abstract boolean checkSecurityAuthorization(String cacheId, byte[] password, String userId) throws OperationFailedException, SecurityException, AggregateException, GeneralFailureException, CommandException, StreamNotFoundException, OperationNotSupportedException, StreamException, ConfigurationException, LicensingException, StreamAlreadyLockedException;
//endregion
public List getConnectedClientList()throws OperationFailedException, CommandException, StreamNotFoundException, StreamException, OperationNotSupportedException, StreamAlreadyLockedException, AggregateException, GeneralFailureException, ConfigurationException, LicensingException, SecurityException{
return null;
}
public abstract Map publishMessage(String topicName, Map keyMessageBulk, boolean notifyDeliveryFailure) throws OperationFailedException, LicensingException, CommandException, StreamAlreadyLockedException, GeneralFailureException, OperationNotSupportedException, SecurityException, StreamException, ConfigurationException, StreamNotFoundException, AggregateException;
public abstract HashMap getEncryptionInfo();
public abstract void touch(ArrayList keys) throws OperationFailedException, LicensingException, CommandException, StreamAlreadyLockedException, GeneralFailureException, OperationNotSupportedException, SecurityException, StreamException, ConfigurationException, StreamNotFoundException, AggregateException;
public abstract String getMonitoringSessionId();
public abstract String getCacheConfigId();
}