
com.alachisoft.ncache.client.internal.command.CommandResponse Maven / Gradle / Ivy
/*
* CacheItemResult.java
*
* Created on August 31, 2006, 2:54 PM
*
* Copyright 2005 Alachisoft, Inc. All rights reserved.
* ALACHISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.alachisoft.ncache.client.internal.command;
import Alachisoft.NCache.Caching.CompressedValueEntry;
import Alachisoft.NCache.Caching.EventId;
import Alachisoft.NCache.Caching.OpCode;
import Alachisoft.NCache.Caching.Util.HotConfig;
import Alachisoft.NCache.Caching.Util.ProtobufHelper;
import Alachisoft.NCache.Common.BitSet;
import Alachisoft.NCache.Common.DataReader.ReaderResultSet;
import Alachisoft.NCache.Common.DataStructures.EnumerationDataChunk;
import Alachisoft.NCache.Common.DataStructures.EnumerationPointer;
import Alachisoft.NCache.Common.DataStructures.NewHashmap;
import Alachisoft.NCache.Common.DataTypes.Responses.GetCollectionChunkResponse;
import Alachisoft.NCache.Common.DataTypes.Responses.GetPairedCollectionChunkResponse;
import Alachisoft.NCache.Common.Enum.SerializationFormat;
import Alachisoft.NCache.Common.Enum.SubscriptionType;
import Alachisoft.NCache.Common.Event.PollingResult;
import Alachisoft.NCache.Common.Extensibility.ModuleInfo;
import Alachisoft.NCache.Common.JSON.BinaryJsonValue;
import Alachisoft.NCache.Common.JSON.ExtendedJsonValueBase;
import Alachisoft.NCache.Common.Messaging.SubscriptionIdentifier;
import Alachisoft.NCache.Common.Net.Address;
import Alachisoft.NCache.Common.Util.DependencyHelper;
import Alachisoft.NCache.Common.Util.EnumerationPointerConversionUtil;
import Alachisoft.NCache.Common.mapreduce.TaskEnumeratorResult;
import Alachisoft.NCache.Config.Mapping;
import Alachisoft.NCache.Util.MiscUtil;
import Util.ResponseHelper;
import com.alachisoft.ncache.client.*;
import com.alachisoft.ncache.client.ClientInfo;
import com.alachisoft.ncache.client.internal.caching.*;
import com.alachisoft.ncache.client.internal.communication.Connection;
import com.alachisoft.ncache.client.internal.messaging.MessageCollectionEventItem;
import com.alachisoft.ncache.client.internal.messaging.MessageEventItem;
import com.alachisoft.ncache.client.internal.util.DictionaryEntry;
import com.alachisoft.ncache.common.caching.EntryType;
import com.alachisoft.ncache.common.protobuf.BulkEventItemResponseProtocol.BulkEventItemResponse;
import com.alachisoft.ncache.common.protobuf.*;
import com.alachisoft.ncache.common.protobuf.KeyValuePairProtocol.KeyValuePair;
import com.alachisoft.ncache.common.protobuf.QueryResultSetProtocol.QueryResultSet;
import com.alachisoft.ncache.common.protobuf.ResponseProtocol.Response;
import com.alachisoft.ncache.common.protobuf.SearchEntriesResponseProtocol.SearchEntriesResponse;
import com.alachisoft.ncache.common.protobuf.SearchResponseProtocol.SearchResponse;
import com.alachisoft.ncache.common.protobuf.TopicMessagesProtocol.TopicMessages;
import com.alachisoft.ncache.common.protobuf.ValueProtocol.Value;
import Alachisoft.NCache.Common.ErrorHandling.ErrorCodes;
import Alachisoft.NCache.Common.ErrorHandling.ErrorMessages;
import com.alachisoft.ncache.runtime.CacheItemPriority;
import com.alachisoft.ncache.runtime.caching.*;
import com.alachisoft.ncache.runtime.caching.datasource.ResyncOptions;
import com.alachisoft.ncache.runtime.caching.expiration.Expiration;
import com.alachisoft.ncache.runtime.caching.expiration.ExpirationType;
import com.alachisoft.ncache.runtime.events.DataTypeEventDataFilter;
import com.alachisoft.ncache.runtime.events.EventDataFilter;
import com.alachisoft.ncache.runtime.exceptions.SecurityException;
import com.alachisoft.ncache.runtime.exceptions.*;
import com.alachisoft.ncache.runtime.exceptions.runtime.*;
import com.alachisoft.ncache.runtime.util.NCDateTime;
import com.alachisoft.ncache.runtime.util.TimeSpan;
import Alachisoft.NCache.Common.JSON.JsonHelper;
import com.alachisoft.ncache.serialization.standard.CompactBinaryFormatter;
import com.alachisoft.ncache.serialization.util.SerializationUtil;
import Alachisoft.NCache.Common.Caching.UserBinaryObject;
import com.google.protobuf.ByteString;
import javax.cache.processor.EntryProcessorResult;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
/**
* Stores the result send by the NCache Server
*
* @author Administrator
* @version 1.0
*/
public final class CommandResponse {
// region Fields
private Address sourceAddress;
private TaskEnumeratorResult nextRecord = new TaskEnumeratorResult();
private EventTypeInternal _eventTypeInternal;
private int _serverPort = 0;
private HotConfig _hotConfig;
private String key;
private String type;
private long req_id = 0;
private int registeredCallback = 0;
private int reason;
private HashMap KeyValueDic = new HashMap();
private HashMap KeyVersionDic = new HashMap();
private ArrayList resultList = new ArrayList();
private HashMap> messageResponseMap = new HashMap<>();
private Object result = null;
private ExceptionProtocol.Exception.Type expType;
private String expMessage = null;
private int expCode;
private byte[] rawResult = null;
private String _cacheType = "";
private byte[] value;
private CacheItem item;
private com.alachisoft.ncache.serialization.util.TypeInfoMap _typeMap;
private long _compressionThrehold;
private boolean _compressionEnabled;
private Alachisoft.NCache.Caching.CompressedValueEntry _flagValueEntry = new Alachisoft.NCache.Caching.CompressedValueEntry();
//
private String ip = "";
private int port = 0;
private String clusterIp = "";
private int clusterPort = 0;
private boolean reconnectClients = false;
private LockHandle _lockHandle = new LockHandle();
private String cacheId = "";
//
private boolean _brokerReset = false;
private long _version;
private boolean _lockAcquired;
private ResponseProtocol.Response.Type _type;
private long _count = 0;
private boolean _exists = false;
private short _callbackId = -1;
private Object _asyncOpResult = null;
private byte[] _notifId = null;
private boolean _success = false;
private int _bytesRead;
private long _streamLength;
private List _dataList;
private OpCode _operationCode;
private String _bridgeTargetCacheUniqueId;
private Alachisoft.NCache.Caching.Queries.QueryResultSet resultSet = null;
private String _queryId;
private com.alachisoft.ncache.client.internal.caching.QueryChangeType _changeType;
private ArrayList _enumerationDataChunk = new ArrayList();
private java.util.HashMap _runningServers = new HashMap();
private Response _response;
private Alachisoft.NCache.Caching.EventId _eventId;
private boolean _isPersistEnabled = false;
private int _persistenceInterval;
private int _removedKeyCount;
private int cacheManagementPort;
private List _eventList;
private EventDataFilter _dataFilter = EventDataFilter.None;
private HashMap> _messageDic = new LinkedHashMap>();
private Address _resetConnectionIP;//private String _resetConnectionIP = "";
private String _intendedRecipient = "";
private int _sequenceId = 1;
private int _numberOfChunks = 1;
private boolean _isSendFailure;
private boolean isSurrogate = false;
private Address actualTargetNode;
private boolean NeedsDeserialization;
private int _commandId;
private PollingResult _pollingResult = null;
private List readerResultSets = new ArrayList<>();
private ReaderResultSet _readerNextChunk = null;
private List taskEnumerator = new ArrayList<>();
private boolean _enableErrorLogs;
private boolean _enableDetailedLogs;
private InquiryRequestResponseProtocol.InquiryRequestResponse inquiryResponse;
private NewHashmap newHashmap;
private boolean _secureConnectionEnabled;
private ArrayList _serverMappingList;
private DataTypeResponse _dataTypeResponse;
private SerializationFormat _serializationFormat;
private EntryType _entryType;
private String stackTrace;
private long _messageCount;
private int _taskCallbackId;
private String _taskId;
private int _taskStatus;
private String _taskFailureReason;
private boolean _requestInquiryEnabled;
private boolean _pipeliningEnabled;
private String _lockId;
private NCDateTime _lockDate;
private boolean _isLocked;
private int _bucketSize;
private boolean _isAuthorized;
private List _connectedClients;
private List _registeredPatterns;
private int _topicPriority;
private int _pipeliningBatchInterval;
// endregion
// region Constructors
///
/// Creates a new instance of CacheResultItem
/// True if broker is reset due to lost connection, false otherwise
///
public CommandResponse(boolean brokerReset, Address resetConnectionIP) {
key = "";
type = "";
value = null;
_brokerReset = brokerReset;
_resetConnectionIP = resetConnectionIP;
}
// endregion
// region Getter / Setter
public boolean isOperationSuccess() {
return _success;
}
public List getRegisteredPatterns() {
return _registeredPatterns;
}
public int getBucketSize() {
return _bucketSize;
}
public String getLockId() {
return _lockId;
}
public NCDateTime getLockDate() {
return _lockDate;
}
public int getServerPort() {
return _serverPort;
}
public SerializationFormat getSerializationFormat() {
return _serializationFormat;
}
public void setSerializationFormat(SerializationFormat _serializationFormat) {
this._serializationFormat = _serializationFormat;
}
public Address getSourceAddress() {
return sourceAddress;
}
public void setSourceAddress(Address sourceAddress) {
this.sourceAddress = sourceAddress;
}
public ArrayList getServerMappingList() {
if (_serverMappingList != null)
return _serverMappingList;
else
return new ArrayList<>();
}
public void setServerMappingList(ArrayList _serverMappingList) {
this._serverMappingList = _serverMappingList;
}
public boolean isRequestLoggingEnabled() {
return _requestInquiryEnabled;
}
public void setRequestLoggingEnabled(boolean requestLoggingEnabled) {
this._requestInquiryEnabled = requestLoggingEnabled;
}
public boolean isSecureConnectionEnabled() {
return _secureConnectionEnabled;
}
public void setSecureConnectionEnabled(boolean _secureConnectionEnabled) {
this._secureConnectionEnabled = _secureConnectionEnabled;
}
public NewHashmap getNewHashmap() {
return newHashmap;
}
public void setNewHashmap(NewHashmap newHashmap) {
this.newHashmap = newHashmap;
}
public InquiryRequestResponseProtocol.InquiryRequestResponse getInquiryResponse() {
return inquiryResponse;
}
public void setInquiryResponse(InquiryRequestResponseProtocol.InquiryRequestResponse inquiryResponse) {
this.inquiryResponse = inquiryResponse;
}
public boolean isEnableErrorLogs() {
return _enableErrorLogs;
}
public void setEnableErrorLogs(boolean _enableErrorLogs) {
this._enableErrorLogs = _enableErrorLogs;
}
public boolean isEnableDetailedLogs() {
return _enableDetailedLogs;
}
public void setEnableDetailedLogs(boolean _enableDetailedLogs) {
this._enableDetailedLogs = _enableDetailedLogs;
}
public HotConfig getHotConfig() {
return _hotConfig;
}
public void setHotConfig(HotConfig _hotConfig) {
this._hotConfig = _hotConfig;
}
public List getTaskEnumerator() {
return taskEnumerator;
}
public void setTaskEnumerator(List taskEnumerator) {
this.taskEnumerator = taskEnumerator;
}
public TaskEnumeratorResult getNextRecord() {
return nextRecord;
}
public void setNextRecord(TaskEnumeratorResult nextRecord) {
this.nextRecord = nextRecord;
}
public ReaderResultSet getReaderNextChunk() {
return _readerNextChunk;
}
public void setReaderNextChunk(ReaderResultSet _readerNextChunk) {
this._readerNextChunk = _readerNextChunk;
}
public List getReaderResultSets() {
return readerResultSets;
}
public void setReaderResultSets(List readerResultSets) {
this.readerResultSets = readerResultSets;
}
public ArrayList getResultList() {
return resultList;
}
public void setResultList(ArrayList resultList) {
this.resultList = resultList;
}
public HashMap getVersionMap() {
return KeyVersionDic;
}
public void setVersionMap(HashMap keyVersionDic) {
KeyVersionDic = keyVersionDic;
}
public PollingResult getPollingResult() {
return _pollingResult;
}
public void setPollingResult(PollingResult pollingResult) {
this._pollingResult = pollingResult;
}
public HashMap getResultMap() {
return KeyValueDic;
}
public void setResultMap(HashMap result) {
this.KeyValueDic = result;
}
public int getCommandId() {
return _commandId;
}
public void setCommandId(int commandId) {
this._commandId = commandId;
}
public Address getActualTargetNode() {
return actualTargetNode;
}
public void setActualTargetNode(Address actualTargetNode) {
this.actualTargetNode = actualTargetNode;
}
public boolean isSurrogate() {
return isSurrogate;
}
public void setSurrogate(boolean surrogate) {
isSurrogate = surrogate;
}
public boolean getIsSendFailure() {
return _isSendFailure;
}
public void setSendFailure(boolean _isSendFailure) {
this._isSendFailure = _isSendFailure;
}
public boolean getIsInternalResponse() {
return isBrokerReset() || getIsSendFailure();
}
public boolean isNeedsDeserialization() {
return NeedsDeserialization;
}
public void setNeedsDeserialization(boolean needsDeserialization) {
NeedsDeserialization = needsDeserialization;
}
public int getCacheManagementPort() {
return cacheManagementPort;
}
public void setCacheManagementPort(int cacheManagementPort) {
this.cacheManagementPort = cacheManagementPort;
}
public EventDataFilter getDataFilter() {
return this._dataFilter;
}
public final List getEventList() {
if (_eventList != null) {
return _eventList;
} else {
return new ArrayList<>();
}
}
public final boolean getIsPersistenceEnabled() {
return _isPersistEnabled;
}
public final boolean getIspipeliningEnabled() {
return _pipeliningEnabled;
}
public int getPipeliningBatchInterval() {
return _pipeliningBatchInterval;
}
public final int getPersistInterval() {
return _persistenceInterval;
}
public final Alachisoft.NCache.Caching.EventId getEventId() {
return _eventId;
}
public final Response getProtobufResponse() {
return _response;
}
public final int getRemovedKeyCount() {
return _removedKeyCount;
}
public final void setRemovedKeyCount(int value) {
_removedKeyCount = value;
}
public ArrayList getNextChunk() {
return _enumerationDataChunk;
}
public void setNextChunk(ArrayList chunks) {
this._enumerationDataChunk = chunks;
}
public Address getResetConnectionIP() {
return _resetConnectionIP;
}
public void setResetConnectionIP(Address ip) {
_resetConnectionIP = ip;
}
public String getIntendedRecipient() {
return _intendedRecipient;
}
public boolean isReconnectClients() {
return reconnectClients;
}
public String getClusterIp() {
return clusterIp;
}
public int getClusterPort() {
return clusterPort;
}
public int getSequenceId() {
return _sequenceId;
}
public int getNumberOfChunks() {
return _numberOfChunks;
}
/**
* @return The String of the result type.
*/
// public String getType() {
// return type;
// }
public java.util.HashMap getRunningServers() {
if (_runningServers != null) {
return _runningServers;
} else {
return new java.util.HashMap();
}
}
public void setType(Response.Type _type) {
this._type = _type;
}
/**
* Get response type
*
* @return
*/
public ResponseProtocol.Response.Type getType() {
return this._type;
}
public long getVersion() {
return this._version;
}
public OpCode getDSOperationCode() {
return _operationCode;
}
public int BytesRead() {
return _bytesRead;
}
public long StreamLegnth() {
return _streamLength;
}
public List DataList() {
return _dataList;
}
/**
* Get cache count
*
* @return
*/
public long getCount() {
return this._count;
}
public com.alachisoft.ncache.client.internal.caching.QueryChangeType getChangeType() {
return _changeType;
}
/**
* Determine whether an item exists in cache or not
*
* @return
*/
public boolean exists() {
return this._exists;
}
/**
* Get callback id
*
* @return
*/
public short getCallbackId() {
return this._callbackId;
}
/**
* Get notif id for custom events
*
* @return
*/
public byte[] getNotifId() {
return this._notifId;
}
/**
* Determine whether operation was successfully performed or not
*
* @return
*/
public boolean success() {
return this._success;
}
/**
* @return
*/
public Object getAsyncOpResult() {
return this._asyncOpResult;
}
public String getQueryId() {
return _queryId;
}
/*
* @return the populated QueryResult received from the NCache Server based on query executed.
*/
public Alachisoft.NCache.Caching.Queries.QueryResultSet getQueryResultSet() {
return this.resultSet;
}
public EntryType getEntryType() {
return _entryType;
}
public void setEntryType(EntryType entryType) {
this._entryType = entryType;
}
public int getTopicPriority(){
return _topicPriority;
}
// endregion
public void parseDataStructuresResponse() {
if (getType() != null && getType().getNumber() == Response.Type.EXCEPTION.getNumber()) {
switch (expType) {
case OPERATIONFAILED:
throw new OperationFailedRuntimeException(getExpCode(), getExpMessage());
case AGGREGATE:
throw new AggregateRuntimeException(getExpCode(), getExpMessage());
case CONFIGURATION:
throw new ConfigurationRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
case SECURITY:
throw new SecurityRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
case GENERALFAILURE:
throw new GeneralFailureRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
case NOTSUPPORTED:
throw new OperationNotSupportedRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
case STREAM_ALREADY_LOCKED:
case STREAM_CLOSED:
case STREAM_EXC:
case STREAM_INVALID_LOCK:
case STREAM_NOT_FOUND:
case TYPE_INDEX_NOT_FOUND:
throw new OperationFailedRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
case ATTRIBUTE_INDEX_NOT_FOUND:
throw new OperationFailedRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
case STATE_TRANSFER_EXCEPTION:
throw new StateTransferInProgressException(getExpMessage(), getStackTrace());
case INVALID_READER_EXCEPTION:
throw new InvalidReaderRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
case LICENSING_EXCEPTION:
throw new LicensingRuntimeException(getExpCode(), getExpMessage(), getStackTrace());
}
}
else if (isBrokerReset()) {
throw new ConnectionRuntimeException("Connection with server lost [" + getResetConnectionIP() + "]");
}
}
public void parseResponse() throws OperationFailedException, GeneralFailureException, AggregateException, SecurityException, ConnectionException, LicensingException, StreamNotFoundException, StreamException, StreamAlreadyLockedException, OperationNotSupportedException, ConfigurationException {
if (getType() != null && getType().getNumber() == Response.Type.EXCEPTION.getNumber()) {
switch (expType) {
case OPERATIONFAILED:
throw new OperationFailedException(getExpCode(), getExpMessage());
case AGGREGATE:
throw new AggregateException(getExpCode(), getExpMessage(), null);
case CONFIGURATION:
throw new ConfigurationException(getExpCode(), getExpMessage(), getStackTrace());
case SECURITY:
throw new SecurityException(getExpCode(), getExpMessage(), getStackTrace());
case GENERALFAILURE:
throw new GeneralFailureException(getExpCode(), getExpMessage(), getStackTrace());
case NOTSUPPORTED:
throw new OperationNotSupportedException(getExpCode(), getExpMessage(), getStackTrace());
case STREAM_ALREADY_LOCKED:
throw new StreamAlreadyLockedException(getExpCode(), getExpMessage(), getStackTrace());
case STREAM_CLOSED:
throw new StreamCloseException(getExpCode(), getExpMessage(), getStackTrace());
case STREAM_EXC:
throw new StreamException(getExpCode(), getExpMessage(), getStackTrace());
case STREAM_INVALID_LOCK:
throw new StreamInvalidLockException(getExpCode(), getExpMessage(), getStackTrace());
case STREAM_NOT_FOUND:
throw new StreamNotFoundException(getExpCode(), getExpMessage(), getStackTrace());
case TYPE_INDEX_NOT_FOUND:
throw new OperationFailedException(getExpCode(), getExpMessage(), getStackTrace());
case ATTRIBUTE_INDEX_NOT_FOUND:
throw new OperationFailedException(getExpCode(), getExpMessage(), getStackTrace());
case STATE_TRANSFER_EXCEPTION:
throw new StateTransferInProgressException(getExpMessage(), getStackTrace());
case INVALID_READER_EXCEPTION:
throw new InvalidReaderException(getExpCode(), getExpMessage(), getStackTrace());
case LICENSING_EXCEPTION:
throw new LicensingException(getExpCode(), getExpMessage(), getStackTrace());
}
}
else if (isBrokerReset()) {
throw new ConnectionException("Connection with server lost [" + getResetConnectionIP() + "]");
}
}
public List getConnectedClients() {
return _connectedClients;
}
public boolean isIsAuthorized() {
return _isAuthorized;
}
public void setResult(Response response) throws OperationFailedException {
List keys = null;
EnumerationPointer enumerationPointer = null;
EnumerationDataChunk enumerationDataChunk = null;
_type = response.getResponseType();
_sequenceId = response.getSequenceId();
_numberOfChunks = response.getNumberOfChuncks();
_commandId = response.getCommandID();
KeyValuePackageResponseProtocol.KeyValuePackageResponse keyValuePackageResponse = null;
switch(response.getResponseType()) {
case ADD:
_version = response.getAddResponse().getItemversion();
req_id = response.getRequestId();
break;
case REMOVE_GROUP:
case REMOVE_TAG:
case DELETE:
case DELETE_BULK:
case REGISTER_NOTIF:
case CLEAR:
case UNREGISTER_CQ:
case RAISE_CUSTOM_EVENT:
case REGISTER_KEY_NOTIF:
case REGISTER_BULK_KEY_NOTIF:
case UNREGISTER_BULK_KEY_NOTIF:
case UNREGISTER_KEY_NOTIF:
case UNLOCK:
case DISPOSE:
case BRIDGE_MAKE_TARGET_CACHE_ACTIVE_PASSIVE:
case DISPOSE_READER:
case REGISTER_POLL_NOTIF:
case TOUCH:
case MESSAGE_PUBLISH:
case MESSAGE_ACKNOWLEDGEMENT:
req_id = response.getRequestId();
_commandId=response.getCommandID();
break;
case HYBRID_BULK:
req_id = response.getRequestId();
HashMap bridgeResult = null;
try {
Object tmpResult = CompactBinaryFormatter.fromByteBuffer(response.getHybridBulkResponse().getBinaryResult().toByteArray(), null);
bridgeResult = tmpResult instanceof HashMap ? (HashMap) tmpResult : null;
} catch (IOException | ClassNotFoundException ignored) {
}
KeyValueDic = bridgeResult;
break;
case COMPACT_TYPE_REGISTER_EVENT:
value = response.getCompactTypeRegisterEvent().getCompactTypes().toByteArray();
break;
case COUNT:
this.req_id = response.getRequestId();
this._count = response.getCount().getCount();
break;
case MESSAGE_COUNT:
this.req_id = response.getRequestId();
_messageCount = response.getMessageCountResponse().getMessageCount();
break;
case ADD_DEPENDENCY:
this.req_id = response.getRequestId();
this._success = response.getAddDep().getSuccess();
break;
case ADD_ATTRIBUTE:
this.req_id = response.getRequestId();
this._success = response.getAddAttributeResponse().getSuccess();
break;
case ADD_SYNC_DEPENDENCY:
this.req_id = response.getRequestId();
this._success = response.getAddSyncDependencyResponse().getSuccess();
break;
case CONTAINS_BULK:
this.req_id = response.getRequestId();
HashMap containsBulkResult = null;
try {
Object tmpResult = CompactBinaryFormatter.fromByteBuffer(response.getContainBulkResponse().getExists().toByteArray(), null);
containsBulkResult = tmpResult instanceof HashMap ? (HashMap) tmpResult : null;
} catch (IOException | ClassNotFoundException ignored) {
}
KeyValueDic = containsBulkResult;
break;
case CONTAINS:
this.req_id = response.getRequestId();
this._exists = response.getContain().getExists();
break;
case CONFIG_MODIFIED_EVENT:
_hotConfig = HotConfig.FromString(response.getConfigModified().getHotConfig());
break;
case POLL_NOTIFY_CALLBACK:
this._callbackId = (short) response.getPollNotifyEventResponse().getCallbackId();
_eventId = new EventId();
_eventId.setEventUniqueID(response.getPollNotifyEventResponse().getEventId().getEventUniqueId());
_eventId.setEventCounter(response.getPollNotifyEventResponse().getEventId().getEventCounter());
_eventId.setOperationCounter(response.getPollNotifyEventResponse().getEventId().getOperationCounter());
_eventId.setEventType(Alachisoft.NCache.Persistence.EventType.POLL_REQUEST_EVENT);
_eventTypeInternal = EventTypeInternal.forValue(response.getPollNotifyEventResponse().getEventType());
break;
case REGISTER_CQ:
this._queryId = response.getRegisterCQResponse().getCqId();
this.req_id = response.getRequestId();
break;
case INVOKE_ENTRY_PROCESSOR:
req_id = response.getRequestId();
_intendedRecipient = response.getIntendedRecipient();
InvokeEPKeyValuePackageResponseProtocol.InvokeEPKeyValuePackageResponse keyValuePair = response.getInvokeEntryProcessorResponse().getKeyValuePackage();
HashMap invokeEPResult = new HashMap();
if (keyValuePair != null)
{
for (int i = 0; i < keyValuePair.getKeysList().size(); i++)
{
String fetchedKey = keyValuePair.getKeysList().get(i);
EntryProcessorResult result = null;
if (keyValuePair.getValues(i).size() > 0)
{
Object tempVar = null;
try {
tempVar = CompactBinaryFormatter.fromByteBuffer(keyValuePair.getValues(i).toByteArray(), cacheId);
} catch (IOException | ClassNotFoundException ignored) {
}
result = (EntryProcessorResult)((tempVar instanceof EntryProcessorResult) ? tempVar : null);
}
if (result != null)
{
invokeEPResult.put(fetchedKey, result);
}
}
KeyValueDic = invokeEPResult;
}
break;
case CACHE_STOPPED_EVENT:
this.cacheId = response.getCacheStopped().getCacheId();
break;
case ITEM_REMOVED_EVENT:
this.key = response.getItemRemoved().getKey();
this._flagValueEntry.setFlag(new Alachisoft.NCache.Common.BitSet((byte) response.getItemRemoved().getFlag()));
this.reason = response.getItemRemoved().getItemRemoveReason();
if (response.getItemRemoved().getValueCount() > 0) {
UserBinaryObject ubObject = UserBinaryObject.createUserBinaryObject(response.getItemRemoved().getValueList());
value = ubObject.getFullObject();
}
_eventId = new Alachisoft.NCache.Caching.EventId();
_eventId.setEventUniqueID(response.getItemRemoved().getEventId().getEventUniqueId());
_eventId.setEventCounter(response.getItemRemoved().getEventId().getEventCounter());
_eventId.setOperationCounter(response.getItemRemoved().getEventId().getOperationCounter());
_eventId.setEventType(Alachisoft.NCache.Persistence.EventType.ITEM_REMOVED_EVENT);
break;
case CACHE_CLEARED_EVENT:
_eventId = new Alachisoft.NCache.Caching.EventId();
_eventId.setEventUniqueID(response.getCacheCleared().getEventId().getEventUniqueId());
_eventId.setEventCounter(response.getCacheCleared().getEventId().getEventCounter());
_eventId.setOperationCounter(response.getCacheCleared().getEventId().getOperationCounter());
_eventId.setEventType(Alachisoft.NCache.Persistence.EventType.CACHE_CLEARED_EVENT);
break;
case DS_UPDATE_CALLBACK:
_callbackId = (short)response.getDsUpdateCallbackRespose().getCallbackId();
int _opCode = response.getDsUpdateCallbackRespose().getOpCode();
_operationCode = OpCode.forValue(_opCode);
com.alachisoft.ncache.runtime.events.EventType eventType = com.alachisoft.ncache.runtime.events.EventType.getEventType(_opCode);
for (DSUpdatedCallbackResultProtocol.DSUpdatedCallbackResult result : response.getDsUpdateCallbackRespose().getResultList())
{
WriteBehindOpResult writeBehindOpResult;
if (result.getSuccess())
{
writeBehindOpResult = new WriteBehindOpResult(eventType,WriteBehindOpStatus.Success,null);
}
else if (result.getException() != null)
{
OperationFailedException exception = new OperationFailedException(result.getException().getErrorCode(),result.getException().getMessage());
writeBehindOpResult = new WriteBehindOpResult(eventType, WriteBehindOpStatus.Failure, exception);
}
else
{
writeBehindOpResult = new WriteBehindOpResult(eventType, WriteBehindOpStatus.Failure, null);
}
KeyValueDic.put(result.getKey(), writeBehindOpResult);
}
break;
case CUSTOM_EVENT:
this._notifId = response.getCustomEvent().getKey().toByteArray();
this.value = response.getCustomEvent().getValue().toByteArray();
break;
case GET_OPTIMAL_SERVER:
this.req_id = response.getRequestId();
this.ip = response.getGetOptimalServer().getServer();
this._serverPort = response.getGetOptimalServer().getPort();
break;
case GET_CACHE_MANAGEMENT_PORT:
this.req_id = response.getRequestId();
this.ip = response.getGetCacheManagementPortResponse().getServer();
setCacheManagementPort(response.getGetCacheManagementPortResponse().getPort());
break;
case GET_CACHE_BINDING:
req_id = response.getRequestId();
ip = response.getGetCacheBindingResponse().getServer();
_serverPort = response.getGetCacheBindingResponse().getPort();
break;
case GET_RUNNING_SERVERS:
this.req_id = response.getRequestId();
if (response.getGetRunningServer().getKeyValuePairCount() > 0) {
for(KeyValuePair pair : response.getGetRunningServer().getKeyValuePairList()) {
_runningServers.put(pair.getKey(), Integer.parseInt(pair.getValue()));
}
}
break;
case GET_SERVER_MAPPING:
req_id = response.getRequestId();
if (response.getGetServerMappingResponse().getServerMappingCount() > 0)
{
_serverMappingList = new java.util.ArrayList();
for (ServerMappingProtocol.ServerMapping mappingObject : response.getGetServerMappingResponse().getServerMappingList())
{
Mapping serverMapping = new Mapping();
serverMapping.setPrivateIP(mappingObject.getPrivateIp());
serverMapping.setPrivatePort(mappingObject.getPrivatePort());
serverMapping.setPublicIP(mappingObject.getPublicIp());
serverMapping.setPublicPort(mappingObject.getPublicPort());
_serverMappingList.add(serverMapping);
}
}
break;
case BULK_EVENT:
if (response.getBulkEventResponse().getEventListCount() > 0) {
_eventList = response.getBulkEventResponse().getEventListList();
}
break;
case NODE_JOINED_EVENT:
this.ip = response.getNodeJoined().getServerIp();
this._serverPort = Integer.parseInt(response.getNodeJoined().getServerPort());
this.clusterIp = response.getNodeJoined().getClusterIp();
this.clusterPort = Integer.parseInt(response.getNodeJoined().getClusterPort());
this.reconnectClients = response.getNodeJoined().getReconnect();
break;
case NODE_LEFT_EVENT:
this.ip = response.getNodeLeft().getServerIp();
this._serverPort = Integer.parseInt(response.getNodeLeft().getServerPort());
this.clusterIp = response.getNodeLeft().getClusterIp();
this.clusterPort = Integer.parseInt(response.getNodeLeft().getClusterPort());
break;
case INSERT:
this.req_id = response.getRequestId();
this._version = response.getInsert().getVersion();
break;
case INIT:
this.req_id = response.getRequestId();
this._cacheType = response.getInitCache().getCacheType();
this._bridgeTargetCacheUniqueId = response.getInitCache().getTargetCacheUniqueID();
_isPersistEnabled = response.getInitCache().getIsPersistenceEnabled();
_persistenceInterval = response.getInitCache().getPersistenceInterval();
_requestInquiryEnabled = response.getInitCache().getRequestLoggingEnabled();
_secureConnectionEnabled = response.getInitCache().getSecureConnectionEnabled();
_pipeliningEnabled = response.getInitCache().getPipeliningEnabled();
_pipeliningBatchInterval=response.getInitCache().getPipeliningBatchInterval();
_response = response;
break;
case GET:
this.req_id = response.getRequestId();
this._flagValueEntry.setFlag(new Alachisoft.NCache.Common.BitSet((byte) response.getGet().getFlag()));
_lockId = response.getGet().getLockId() == "" ? null : response.getGet().getLockId();
if(!setIfDefaultLockDate(response.getGet().getLockTime()))
_lockDate = new NCDateTime(response.getGet().getLockTime());
this._version = response.getGet().getVersion();
this.setEntryType(MiscUtil.protoItemTypeToEntryType(response.getGet().getItemType()));
if (response.getGet().getDataCount() > 0) {
UserBinaryObject ubObject = UserBinaryObject.createUserBinaryObject(response.getGet().getDataList());
value = ubObject.getFullObject();
}
break;
case REMOVE:
this.req_id = response.getRequestId();
this._flagValueEntry.setFlag(new Alachisoft.NCache.Common.BitSet((byte) response.getRemove().getFlag()));
this.setEntryType(MiscUtil.protoItemTypeToEntryType(response.getRemove().getItemType()));
if (response.getRemove().getValueCount() > 0) {
UserBinaryObject ubObject = UserBinaryObject.createUserBinaryObject(response.getRemove().getValueList());
value = ubObject.getFullObject();
}
break;
case LOCK:
this.req_id = response.getRequestId();
this._lockAcquired = response.getLockResponse().getLocked();
_lockId = response.getLockResponse().getLockId() == "" ? null : response.getLockResponse().getLockId();
if(!setIfDefaultLockDate(response.getLockResponse().getLockTime()))
_lockDate = new NCDateTime(response.getLockResponse().getLockTime());
_lockHandle=new LockHandle(_lockId,_lockDate.getDate());
break;
case ISLOCKED:
this.req_id = response.getRequestId();
this._lockAcquired = response.getIsLockedResponse().getIsLocked();
_isLocked = response.getIsLockedResponse().getIsLocked();
_lockId = response.getIsLockedResponse().getLockId() == "" ? null : response.getIsLockedResponse().getLockId();
if(!setIfDefaultLockDate(response.getIsLockedResponse().getLockTime()))
_lockDate = new NCDateTime(response.getIsLockedResponse().getLockTime());
_lockHandle=new LockHandle(_lockId,_lockDate.getDate());
break;
case GET_LOGGING_INFO:
this.req_id = response.getRequestId();
this._enableErrorLogs = response.getGetLoggingInfoResponse().getErrorsEnabled();
this._enableDetailedLogs = response.getGetLoggingInfoResponse().getDetailedErrorsEnabled();
break;
case LOGGING_INFO_MODIFIED_EVENT:
this._enableErrorLogs = response.getLoggingInfoModified().getEnableErrorsLog();
this._enableDetailedLogs = response.getLoggingInfoModified().getEnableDetailedErrorsLog();
break;
case GET_BULK:
this.req_id = response.getRequestId();
this._intendedRecipient = response.getIntendedRecipient();
keyValuePackageResponse = response.getBulkGet().getKeyValuePackage();
if(keyValuePackageResponse == null)
break;
for (int i = 0; i < keyValuePackageResponse.getKeysCount(); i++) {
String fetchedKey = keyValuePackageResponse.getKeys(i);
Value val = keyValuePackageResponse.getValues(i);
UserBinaryObject ubObject = UserBinaryObject.createUserBinaryObject(val.getDataList());
CompressedValueEntry entry = new CompressedValueEntry();
entry.setFlag(new BitSet((byte) keyValuePackageResponse.getFlag(i)));
entry.setType(MiscUtil.protoItemTypeToEntryType(keyValuePackageResponse.getItemType(i)));
entry.setValue(ubObject.getFullObject());
KeyValueDic.put(fetchedKey, entry);
}
break;
case BULK_GET_CACHEITEM:
req_id = response.getRequestId();
BulkGetCacheItemResponseProtocol.BulkGetCacheItemResponse bulkGetCacheItemResponse = response.getBulkGetCacheItem();
if(bulkGetCacheItemResponse == null)
break;
for(KeyCacheItemPairProtocol.KeyCacheItemPair keyCacheItemPair : bulkGetCacheItemResponse.getKeyCacheItemPairsList()) {
KeyValueDic.put(keyCacheItemPair.getKey(), GetCacheItem(keyCacheItemPair.getCacheItem()));
}
break;
case REMOVE_BULK:
this.req_id = response.getRequestId();
this._intendedRecipient = response.getIntendedRecipient();
addKeyValuePackageToResult(response.getBulkRemove().getKeyValuePackage());
break;
case GET_GROUP_DATA:
this.req_id = response.getRequestId();
addKeyValuePackageToResult(response.getGetGroupData().getKeyValuePackage());
break;
case GET_TAG:
this.req_id = response.getRequestId();
addKeyValuePackageToResult(response.getGetTag().getKeyValuePackage());
break;
case EXECUTE_READER:
case EXECUTE_READER_CQ:
case GET_READER_CHUNK:
req_id = response.getRequestId();
_response = response;
break;
case GET_KEYS_TAG:
this.req_id = response.getRequestId();
setResultList(new ArrayList<>(response.getGetKeysByTagResponse().getKeysList()));
break;
case SEARCH_ENTRIES:
this.req_id = response.getRequestId();
SearchEntriesResponse searchEntriesResponse = response.getSearchEntries();
QueryResultSet protoResultSet = searchEntriesResponse.getQueryResultSet();
resultSet = new Alachisoft.NCache.Caching.Queries.QueryResultSet();
switch (protoResultSet.getQueryType()) {
case AGGREGATE_FUNCTIONS:
resultSet.setType(Alachisoft.NCache.Caching.Queries.QueryType.AggregateFunction);
resultSet.setAggregateFunctionType(Alachisoft.NCache.Common.Enum.AggregateFunctionType.forValue(protoResultSet.getAggregateFunctionType().getNumber()));
byte[] bytes = protoResultSet.getAggregateFunctionResult().getValue().toByteArray();
if (bytes.length > 0) {
resultSet.setAggregateFunctionResult(new DictionaryEntry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy