public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            // int overload;
            string exception = null;

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            long messageCount = 0;


            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;

                if (nCache != null)
                {
                    messageCount            = nCache.Cache.GetMessageCount(command.messageCountCommand.topicName);
                    _operationSuccessStatus = true;
                }
                stopwatch.Stop();

                Common.Protobuf.MessageCountResponse messageCountResponse = new Common.Protobuf.MessageCountResponse();
                messageCountResponse.messageCount = messageCount;


                if (clientManager.ClientVersion >= 5000)
                {
                    Common.Util.ResponseHelper.SetResponse(messageCountResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(messageCountResponse, Common.Protobuf.Response.Type.MESSAGE_COUNT));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.messageCountResponse = messageCountResponse;
                    Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.MESSAGE_COUNT);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception e)
            {
                exception = e.ToString();
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(e, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopwatch.Elapsed;
                try
                {
                    if (Management.APILogging.APILogManager.APILogManger != null && Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.MessageCount.ToLower());
                        log.GenerateCacheCountAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), messageCount);
                    }
                }
                catch { }
            }
        }
Beispiel #2
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                _removeQueryResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }

            byte[] data = null;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;

                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                operationContext.Add(OperationContextFieldName.RemoveQueryOperation, true);

                removeRes = nCache.Cache.RemoveQuery(cmdInfo.Query, cmdInfo.Values, operationContext);
                stopWatch.Stop();
                RemoveQueryResponseBuilder.BuildResponse(removeRes, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, nCache.Cache);
            }
            catch (Exception exc)
            {
                _removeQueryResult = OperationResult.Failure;
                exception          = exc.ToString();
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.ExecuteNonQuery.ToLower());
                        log.GenerateDeleteQueryAPILogItem(cmdInfo.Query, cmdInfo.Values, 1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            try
            {
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }

                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                EnumerationDataChunk nextChunk = nCache.Cache.GetNextChunk(cmdInfo.Pointer, cmdInfo.OperationContext);

                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.GetGroupNextChunkResponse getNextChunkResponse = new Alachisoft.NCache.Common.Protobuf.GetGroupNextChunkResponse();
                response.requestId    = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID    = command.commandID;
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_GROUP_NEXT_CHUNK;
                response.getGroupNextChunkResponse = getNextChunkResponse;

                getNextChunkResponse.keys.AddRange(nextChunk.Data);
                getNextChunkResponse.groupEnumerationPointer = EnumerationPointerConversionUtil.ConvertToProtobufGroupEnumerationPointer(nextChunk.Pointer as GroupEnumerationPointer);

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                exception = exception.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetGroupNextChunk.ToLower());
                        log.GenerateGetEnumeratorAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #4
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int    overload;
            string exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            try
            {
                if (clientManager != null)
                {
                    clientManager._leftGracefully = true;
                    NCache nCache = clientManager.CmdExecuter as NCache;
                    if (nCache != null)
                    {
                        nCache.Dispose();
                    }
                    stopWatch.Stop();



                    Alachisoft.NCache.Common.Protobuf.DisposeResponse disposeResponse = new Alachisoft.NCache.Common.Protobuf.DisposeResponse();
                    if (clientManager.ClientVersion >= 5000)
                    {
                        Common.Util.ResponseHelper.SetResponse(disposeResponse, command.requestID, command.commandID);
                        _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(disposeResponse, Common.Protobuf.Response.Type.DISPOSE));
                    }
                    else
                    {
                        //PROTOBUF:RESPONSE
                        Common.Protobuf.Response response = new Common.Protobuf.Response();
                        response.disposeResponse = disposeResponse;
                        Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.DISPOSE);
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                    }
                }
            }
            catch (Exception ex)
            {
                exception = ex.ToString();
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.Dispose.ToLower());
                        log.GenerateDisposeAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());

                        // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #5
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;
            Stopwatch   stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }

                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                nCache.Cache.DisposeReader(cmdInfo.ReaderId, cmdInfo.OperationContext);
                stopWatch.Stop();
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.DisposeReaderResponse disposeReaderResponse = new Alachisoft.NCache.Common.Protobuf.DisposeReaderResponse();
                response.requestId             = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID             = command.commandID;
                response.responseType          = Alachisoft.NCache.Common.Protobuf.Response.Type.DISPOSE_READER;
                response.disposeReaderResponse = disposeReaderResponse;

                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.DisposeReader.ToLower());
                        log.GenerateDisposeReaderAPILogItem(overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

            try
            {
                overload = command.MethodOverload;
                stopWatch.Start();
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc)));
                }
                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                nCache.Cache.UnregisterKeyNotificationCallback(cmdInfo.Keys
                                                               , new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None) // DataFilter not required while unregistration
                                                               , new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, EventDataFilter.None) // DataFilter not required while unregistration
                                                               , new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));
                stopWatch.Stop();
                Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.UnregisterBulkKeyNotifResponse unregResponse = new Common.Protobuf.UnregisterBulkKeyNotifResponse();
                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.UNREGISTER_BULK_KEY_NOTIF;
                response.requestId    = command.requestID;
                response.commandID    = command.commandID;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc)));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.UnRegisterKeyNotificationCallback.ToLower());
                        log.GenerateKeyNotificationCallback(cmdInfo.Keys.Length, cmdInfo.UpdateCallbackId, cmdInfo.RemoveCallbackId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #7
0
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            int    overload         = 1;
            string exceptionMessage = null;
            bool   result           = false;

            try
            {
                NCache nCache           = clientManager.CmdExecuter as NCache;
                var    operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                if (command.commandVersion < 1)
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                }
                else
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture));
                }
                if (nCache != null)
                {
                    _command = command.removeTopicCommand;
                    TopicOperation topicOperation = new TopicOperation(_command.topicName, TopicOperationType.Remove);

                    result = nCache.Cache.TopicOpertion(topicOperation, operationContext);

                    Common.Protobuf.Response            response            = new Common.Protobuf.Response();
                    Common.Protobuf.RemoveTopicResponse removeTopicResponse = new Common.Protobuf.RemoveTopicResponse();
                    response.requestId           = _command.requestId;
                    response.commandID           = command.commandID;
                    removeTopicResponse.success  = result;
                    response.responseType        = Common.Protobuf.Response.Type.REMOVE_TOPIC;
                    response.removeTopicResponse = removeTopicResponse;
                    _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                exceptionMessage = exc.ToString();
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.DeleteTopic);
                        log.GenerateGetCreateOrDeleteTopicAPILogItem(_command.topicName, executionTime, clientManager.ClientID, clientManager.ClientIP, overload, result, exceptionMessage);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #8
0
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            short  callbackId;
            string taskId;
            int    overload;
            string exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                stopWatch.Start();
                IEnumerable <ClientInfo> connectedClients = nCache.Cache.GetConnectedClientInfos();
                Common.Protobuf.GetConnectedClientsResponse clientsResponse = new Common.Protobuf.GetConnectedClientsResponse();
                Common.Protobuf.Response response = new Common.Protobuf.Response();
                response.getConnectedClientsResponse = clientsResponse;
                response.requestId    = command.getConnectedClientsCommand.requestId;
                response.commandID    = command.commandID;
                response.responseType = Response.Type.GET_CONNECTED_CLIENTS;
                if (connectedClients != null)
                {
                    foreach (var connectedClient in connectedClients)
                    {
                        clientsResponse.connectedClients.Add(new Common.Protobuf.ClientInfo
                        {
                            clientId    = connectedClient.ClientID,
                            processId   = connectedClient.ProcessID,
                            appName     = connectedClient.AppName,
                            ipAddress   = connectedClient.IPAddress.ToString(),
                            machineName = connectedClient.MachineName
                        });
                    }
                }
                stopWatch.Stop();
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetConnectedClientList.ToLower());
                        log.GenerateGetConnectedClientsAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #9
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                return;
            }
            int resultCount = 0;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation);
                if (cmdInfo.CommandVersion <= 1) //NCache 3.8 SP4 and previous
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                }
                else
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                }

                resultSet = nCache.Cache.Search(cmdInfo.Query, cmdInfo.Values, operationContext);
                stopWatch.Stop();
                SearchResponseBuilder.BuildResponse(resultSet, cmdInfo.RequestId, command.commandID, _serializedResponsePackets, cmdInfo.CommandVersion, out resultCount);
            }
            catch (Exception exc)
            {
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.Search.ToLower());
                        log.GenerateSearchAPILogItem(cmdInfo.Query, cmdInfo.Values, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resultCount);
                    }
                }
                catch
                {
                }
            }
        }
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;
            Stopwatch   stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                return;
            }
            int resultCount = 0;

            try
            {
                NCache cache = clientManager.CmdExecuter as NCache;
                List <ReaderResultSet> resultSetList = null;
                QueryDataFilters       datafilters   = new QueryDataFilters(cmdInfo.addDF, cmdInfo.updateDF, cmdInfo.removeDF);

                Alachisoft.NCache.Caching.OperationContext operationContext = new Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation);
                operationContext.Add(Caching.OperationContextFieldName.ClientId, clientManager.ClientID);
                operationContext.Add(Caching.OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);

                resultSetList = cache.Cache.ExecuteReaderCQ(cmdInfo.Query, cmdInfo.Values, cmdInfo.getData, cmdInfo.chunkSize, cmdInfo.clientUniqueId, clientManager.ClientID, cmdInfo.notifyAdd, cmdInfo.notifyUpdate, cmdInfo.notifyRemove, operationContext, datafilters);
                stopWatch.Stop();
                ReaderResponseBuilder.Cache = cache.Cache;
                ReaderResponseBuilder.BuildExecuteReaderCQResponse(resultSetList, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, clientManager.ClientVersion < 4620, out resultCount);
            }
            catch (Exception exc)
            {
                //PROTOBUF:RESPONSE
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.ExecuteReaderCQ.ToLower());
                        log.GenerateExecuteReaderCQAPILogItem(cmdInfo.Query, cmdInfo.Values, cmdInfo.getData, cmdInfo.chunkSize, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resultCount);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #11
0
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            string    exception = null;
            int       overload;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }
            try
            {
                NCache           nCache           = clientManager.CmdExecuter as NCache;
                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);

                nCache.Cache.Touch(cmdInfo.Keys, operationContext);
                stopWatch.Stop();
                Common.Protobuf.Response      response      = new Common.Protobuf.Response();
                Common.Protobuf.TouchResponse touchResponse = new Common.Protobuf.TouchResponse();
                response.requestId     = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID     = command.commandID;
                response.responseType  = Common.Protobuf.Response.Type.TOUCH;
                response.touchResponse = touchResponse;
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                exception = exc.ToString();
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Management.APILogging.APILogManager.APILogManger != null && Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.Touch.ToLower());
                        log.GenerateTouchCommandAPILogItem(cmdInfo.Keys.Count, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            long   requestId;
            int    overload;
            string exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            requestId = command.requestID;

            try
            {
                ICommandExecuter tmpVar = clientManager.CmdExecuter;
                NCache           nCache = (NCache)((tmpVar is NCache) ? tmpVar : null);

                // the Actual Call.
                ArrayList runningTasks = nCache.Cache.RunningTasks;

                // Build response
                Common.Protobuf.Response reponse = new Common.Protobuf.Response();
                reponse.requestId            = requestId;
                reponse.commandID            = command.commandID;
                reponse.RunningTasksResponse = new Common.Protobuf.GetRunningTasksResponse();
                List <string> list = new List <string>(runningTasks.Count);
                foreach (string inst in runningTasks)
                {
                    list.Add(inst);
                }
                reponse.RunningTasksResponse.runningTasks.AddRange(list);
                reponse.responseType = Common.Protobuf.Response.Type.RUNNING_TASKS;
                _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(reponse));
            }
            catch (Exception ex)
            {
                exception = ex.ToString();
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponse(ex, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetRunningTasks.ToLower());
                        log.GenerateGetRunningTasksAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #13
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            int         count     = 0;
            string      exception = null;
            Stopwatch   stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = 1;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }

                return;
            }

            try
            {
                NCache          nCache = clientManager.CmdExecuter as NCache;
                ReaderResultSet reader = nCache.Cache.GetReaderChunk(cmdInfo.ReaderId, cmdInfo.nextIndex, false, cmdInfo.OperationContext);
                stopWatch.Stop();
                ReaderResponseBuilder.BuildReaderChunkResponse(reader, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, clientManager.ClientVersion < 4620, out count);
            }
            catch (Exception exc)
            {
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetReaderChunkCommand.ToLower());
                        log.GenerateGetReaderChunkCommand(cmdInfo.ReaderId, count, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            int    overload         = 1;
            string exceptionMessage = null;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                if (nCache != null)
                {
                    _command = command.getMessageCommand;
                    var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    if (command.commandVersion < 1)
                    {
                        operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                    }
                    else // NCache 4.1 SP1 or later
                    {
                        operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture));
                    }
                    _clientId = clientManager.ClientID;
                    SubscriptionInfo subInfo = new SubscriptionInfo()
                    {
                        ClientId = clientManager.ClientID
                    };
                    _result = nCache.Cache.GetAssignedMessages(subInfo, operationContext);
                    GetMessageResponseBuilder.BuildResponse(_result, command.commandVersion, _command.requestId.ToString(CultureInfo.InvariantCulture), _serializedResponsePackets, command.commandID, nCache.Cache);
                }
            }
            catch (System.Exception exc)
            {
                exceptionMessage = exc.ToString();
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetTopicMessages);
                        log.GenerateGetTopicMessagesAPILogItem(executionTime, clientManager.ClientID, clientManager.ClientIP, overload, _result, exceptionMessage);
                    }
                }
                catch
                {
                }
            }
        }
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            long   requestId;
            short  callbackId;
            string taskId;
            string exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

            Common.Protobuf.TaskCallbackCommand taskCallbackCommand = command.TaskCallbackCommand;
            requestId  = command.requestID;
            callbackId = (short)taskCallbackCommand.callbackId;
            taskId     = taskCallbackCommand.taskId;
            try
            {
                stopWatch.Start();
                ICommandExecuter tempVar = clientManager.CmdExecuter;
                NCache           nCache  = (NCache)((tempVar is NCache) ? tempVar : null);

                nCache.Cache.RegisterTaskNotificationCallback(taskId, new TaskCallbackInfo(clientManager.ClientID, callbackId), new Caching.OperationContext());
                stopWatch.Stop();
                Common.Protobuf.Response reponse = new Common.Protobuf.Response();
                reponse.requestId = requestId;
                reponse.commandID = command.commandID;
                Common.Protobuf.TaskCallbackResponse taskCallbackResp = new Common.Protobuf.TaskCallbackResponse();

                reponse.responseType         = Alachisoft.NCache.Common.Protobuf.Response.Type.TASK_CALLBACK;
                reponse.TaskCallbackResponse = taskCallbackResp;
                _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(reponse));
            }
            catch (Exception ex)
            {
                exception = exception.ToString();
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponse(ex, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetTaskResult.ToLower());
                        log.GenerateGetTaskResultAPILogItem(taskId.ToString(), 1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #16
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            Alachisoft.NCache.Common.Protobuf.CloseStreamCommand closeStreamCommand = command.closeStreamCommand;
            string    lockHandle = null;
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            overload = command.MethodOverload;

            try
            {
                if (clientManager != null)
                {
                    ((NCache)clientManager.CmdExecuter).Cache.CloseStream(closeStreamCommand.key, closeStreamCommand.lockHandle, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));
                    stopWatch.Stop();
                }
            }
            catch (Exception e)
            {
                //PROTOBUF:RESPONSE
                exception = e.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(e, command.requestID, command.commandID));
                return;
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.CloseStream.ToLower());
                        log.GenerateCloseStreamAPILogItem(closeStreamCommand.key, closeStreamCommand.lockHandle, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }

            Alachisoft.NCache.Common.Protobuf.Response            response            = new Alachisoft.NCache.Common.Protobuf.Response();
            Alachisoft.NCache.Common.Protobuf.CloseStreamResponse closeStreamResponse = new Alachisoft.NCache.Common.Protobuf.CloseStreamResponse();
            response.requestId           = closeStreamCommand.requestId;
            response.commandID           = command.commandID;
            response.responseType        = Alachisoft.NCache.Common.Protobuf.Response.Type.CLOSE_STREAM;
            response.closeStreamResponse = closeStreamResponse;

            _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
        }
Beispiel #17
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int    overload;
            string exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            try
            {
                if (clientManager != null)
                {
                    clientManager._leftGracefully = true;
                    NCache nCache = clientManager.CmdExecuter as NCache;
                    if (nCache != null)
                    {
                        nCache.Dispose();
                    }
                    stopWatch.Stop();
                    Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                    response.requestId       = command.requestID;
                    response.commandID       = command.commandID;
                    response.disposeResponse = new Alachisoft.NCache.Common.Protobuf.DisposeResponse();

                    response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.DISPOSE;
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception ex)
            {
                exception = ex.ToString();
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.Dispose.ToLower());
                        log.GenerateDisposeAPILogItem(1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #18
0
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            int    overload         = 1;
            string exceptionMessage = null;

            NCache nCache = clientManager.CmdExecuter as NCache;

            try
            {
                if (nCache != null)
                {
                    _command = command.messagePublishCommand;
                    var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    if (command.commandVersion < 1)
                    {
                        operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                    }
                    else
                    {
                        operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture));
                    }
                    BitSet flag = BitSet.CreateAndMarkInUse(clientManager.CacheFakePool, NCModulesConstants.SocketServer);
                    flag.Data = ((byte)(byte)_command.flag);
                    try
                    {
                        foreach (KeyValuePair pair in _command.keyValuePair)
                        {
                            _metaData.Add(pair.key, pair.value);
                        }

                        ICollection dataList = _command.data as ICollection;
                        if (dataList != null)
                        {
                            _value = UserBinaryObject.CreateUserBinaryObject(dataList);
                        }
                        else
                        {
                            _value = _command.data;
                        }

                        nCache.Cache.PublishMessage(_command.messageId,
                                                    _value,
                                                    _command.creationTime,
                                                    _command.expiration,
                                                    _metaData,
                                                    flag,
                                                    operationContext
                                                    );
                        stopWatch.Stop();
                    }
                    finally
                    {
                        flag?.MarkFree(NCModulesConstants.SocketServer);
                    }
                    //
                    MessagePublishResponse messagePublishResponse = new MessagePublishResponse();
                    //response.requestId = Convert.ToInt64(_command.requestId);
                    //response.commandID = command.commandID;
                    //response.responseType = Response.Type.MESSAGE_PUBLISH;
                    //_serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.MESSAGE_PUBLISH));

                    if (clientManager.ClientVersion >= 5000)
                    {
                        Common.Util.ResponseHelper.SetResponse(messagePublishResponse, command.requestID, command.commandID);
                        _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(messagePublishResponse, Common.Protobuf.Response.Type.MESSAGE_PUBLISH));
                    }
                    else
                    {
                        //PROTOBUF:RESPONSE
                        Response response = new Response();
                        response.messagePublishResponse = messagePublishResponse;
                        Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.MESSAGE_PUBLISH);
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                    }
                }
            }
            catch (System.Exception exc)
            {
                exceptionMessage = exc.ToString();
                _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log          = new APILogItemBuilder(MethodsName.PublishMessageOnTopic);
                        int            size            = _value != null ? ((UserBinaryObject)_value).Size : 0;
                        bool           notifyOnFailure = bool.Parse(_metaData[TopicConstant.NotifyOption] as string);
                        DeliveryOption deliveryOption  = (DeliveryOption)(int.Parse(_metaData[TopicConstant.DeliveryOption] as string));
                        string         topicName       = _metaData[TopicConstant.TopicName] as string;
                        topicName = topicName.Split(TopicConstant.TopicSeperator)[1];

                        log.GeneratePublishTopicMessageAPILogItem(topicName, _command.messageId, size, deliveryOption, notifyOnFailure, _command.expiration, executionTime, clientManager.ClientID, clientManager.ClientIP, overload, exceptionMessage);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #19
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            ClientId = clientManager.ClientID;

            NCache         nCache = clientManager.CmdExecuter as NCache;
            int            overload;
            Hashtable      queryInfo = null;
            ExpirationHint expHint   = null;
            string         exception = null;
            Stopwatch      stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload             = command.MethodOverload;
                serailizationContext = nCache.CacheId;
                cmdInfo = base.ParseCommand(command, clientManager, serailizationContext);
            }
            catch (System.Exception exc)
            {
                _addBulkResult = OperationResult.Failure;
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            try
            {
                //PROTOBUF:RESPONSE
                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);
                CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);

                operationContext.Add(OperationContextFieldName.WriteThru, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteThru));
                operationContext.Add(OperationContextFieldName.WriteBehind, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteBehind));
                operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout);
                operationContext.CancellationToken = CancellationToken;

                if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient))
                {
                    operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient);
                }
                queryInfo = cmdInfo.Entries[0].QueryInfo;
                expHint   = cmdInfo.Entries[0].ExpirationHint;

                IDictionary itemVersions = null;

                Hashtable addResult = (Hashtable)nCache.Cache.Add(cmdInfo.Keys, cmdInfo.Entries, cmdInfo.Flag, cmdInfo.ProviderName, out itemVersions, operationContext);
                stopWatch.Stop();
                BulkAddResponse addResponse = new BulkAddResponse();


                addResponse.keyExceptionPackage = new Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse();
                addResponse.keyVersionPackage   = new Alachisoft.NCache.Common.Protobuf.KeyVersionPackageResponse();
                Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysExceptions(addResult, addResponse.keyExceptionPackage);

                if (cmdInfo.returnVersion)
                {
                    Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysVersion(itemVersions, addResponse.keyVersionPackage);
                }

                if (clientManager.ClientVersion >= 5000)
                {
                    addResponse.intendedRecipient = cmdInfo.IntendedRecipient;
                    ResponseHelper.SetResponse(addResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(addResponse, Response.Type.ADD_BULK));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Response response = new Response();
                    response.intendedRecipient = cmdInfo.IntendedRecipient;
                    response.bulkAdd           = addResponse;
                    ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.ADD_BULK);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (OperationCanceledException ex)
            {
                exception = ex.ToString();
                Dispose();
            }
            catch (System.Exception exc)
            {
                _addBulkResult = OperationResult.Failure;
                exception      = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }

            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log            = new APILogItemBuilder(MethodsName.ADDBULK.ToLower());
                        Hashtable         expirationHint = log.GetDependencyExpirationAndQueryInfo(expHint, queryInfo);
                        log.GenerateADDInsertBulkAPILogItem(cmdInfo.Keys.Length, cmdInfo.Entries.Length, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["sliding-expiration"] != null ? (long)expirationHint["sliding-expiration"] : -1, cmdInfo.Entries[0].Priority, expirationHint["tag-info"] != null ? expirationHint["tag-info"] as Hashtable : null, expirationHint["named-tags"] != null ? expirationHint["named-tags"] as Hashtable : null, cmdInfo.Group != null ? cmdInfo.Group : null, cmdInfo.SubGroup != null ? cmdInfo.SubGroup : null, cmdInfo.Entries[0].Flag, cmdInfo.Entries[0].ProviderName, cmdInfo.Entries[0].ResyncProviderName, false, cmdInfo.Entries[0].HasQueryInfo, (long)cmdInfo.Entries[0].Version, cmdInfo.onUpdateCallbackId, cmdInfo.OnDsItemsAddedCallback, false, false, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
                if (cmdInfo.Entries != null)
                {
                    foreach (var entry in cmdInfo.Entries)
                    {
                        entry.Flag?.MarkFree(NCModulesConstants.SocketServer);
                    }
                }

                if (cmdInfo.Entries != null)
                {
                    cmdInfo.Entries.MarkFree(NCModulesConstants.SocketServer);
                    MiscUtil.ReturnEntriesToPool(cmdInfo.Entries, clientManager.CacheTransactionalPool);
                }
            }
        }
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            Alachisoft.NCache.Common.Protobuf.OpenStreamCommand openStreamCommand = command.openStreamCommand;
            NCache nCache = clientManager.CmdExecuter as NCache;

            Caching.Cache cache = nCache.Cache;

            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            overload = command.MethodOverload;

            string         lockHandle = null;
            ExpirationHint expHint    = null;

            try
            {
                if (clientManager != null)
                {
                    expHint = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetExpirationHintObj(cache.Configuration.ExpirationPolicy, openStreamCommand.dependency, openStreamCommand.absoluteExpiration, openStreamCommand.slidingExpiration, false, ((NCache)clientManager.CmdExecuter).CacheId);
                    int          pr           = (int)openStreamCommand.priority;
                    EvictionHint evictionHint = new PriorityEvictionHint((CacheItemPriority)pr);
                    if (openStreamCommand.group != null)
                    {
                        openStreamCommand.group = openStreamCommand.group.Length == 0 ? null : openStreamCommand.group;
                    }
                    if (openStreamCommand.subGroup != null)
                    {
                        openStreamCommand.subGroup = openStreamCommand.subGroup.Length == 0 ? null : openStreamCommand.subGroup;
                    }
                    lockHandle = ((NCache)clientManager.CmdExecuter).Cache.OpenStream(openStreamCommand.key, (Alachisoft.NCache.Common.Enum.StreamModes)openStreamCommand.streamMode, openStreamCommand.group, openStreamCommand.subGroup, expHint, evictionHint, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));
                    stopWatch.Stop();
                }
            }
            catch (Exception e)
            {
                //PROTOBUF:RESPONSE
                exception = e.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(e, command.requestID, command.commandID));
                return;
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log            = new APILogItemBuilder(MethodsName.GetCacheStream.ToLower());
                        Hashtable         expirationHint = log.GetDependencyExpirationAndQueryInfo(expHint, null);
                        log.GenerateOpenStreamAPILogItem(openStreamCommand.key, openStreamCommand.streamMode, openStreamCommand.group, openStreamCommand.subGroup, openStreamCommand.priority, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["sliding-expiration"] != null ? (long)expirationHint["sliding-expiration"] : -1, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
            Alachisoft.NCache.Common.Protobuf.Response           response           = new Alachisoft.NCache.Common.Protobuf.Response();
            Alachisoft.NCache.Common.Protobuf.OpenStreamResponse openStreamResponse = new Alachisoft.NCache.Common.Protobuf.OpenStreamResponse();
            response.requestId            = openStreamCommand.requestId;
            response.commandID            = command.commandID;
            response.responseType         = Alachisoft.NCache.Common.Protobuf.Response.Type.OPEN_STREAM;
            response.openStreamResponse   = openStreamResponse;
            openStreamResponse.lockHandle = lockHandle;

            _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
        }
Beispiel #21
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;
            Stopwatch   stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd parsed");
                }
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error("UnlockCommand", "command: " + command + " Error" + arEx);
                }
                _unlockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }
            catch (Exception exc)
            {
                _unlockResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            try
            {
                NCache nCache           = clientManager.CmdExecuter as NCache;
                var    operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress);
                nCache.Cache.Unlock(cmdInfo.Key, cmdInfo.lockId, cmdInfo.isPreemptive, operationContext);
                stopWatch.Stop();
                //PROTOBUF:RESPONSE
                // Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.UnlockResponse unlockResponse = new Alachisoft.NCache.Common.Protobuf.UnlockResponse();

                if (clientManager.ClientVersion >= 5000)
                {
                    Common.Util.ResponseHelper.SetResponse(unlockResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(unlockResponse, Common.Protobuf.Response.Type.UNLOCK));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.unlockResponse = unlockResponse;
                    Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.UNLOCK);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                exception     = exc.ToString();
                _unlockResult = OperationResult.Failure;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.Unlock.ToLower());
                        log.GeneratUnlockAPILogItem(cmdInfo.Key, cmdInfo.lockId != null?cmdInfo.lockId.ToString() :null, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }

                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("UnlockCmd.Exec", "cmd executed on cache");
                }
            }
        }
Beispiel #22
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                try
                {
                    overload = command.MethodOverload;
                    cmdInfo  = ParseCommand(command, clientManager);
                }
                catch (Exception exc)
                {
                    _removeBulkResult = OperationResult.Failure;
                    if (!base.immatureId.Equals("-2"))
                    {
                        //PROTOBUF:RESPONSE
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                        //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc));
                    }
                    return;
                }

                //TODO
                byte[] data = null;

                try
                {
                    NCache        nCache  = clientManager.CmdExecuter as NCache;
                    Notifications cbEnrty = null;
                    if (cmdInfo.DsItemsRemovedId != -1)
                    {
                        cbEnrty = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsItemsRemovedId,
                                                    Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required
                    }
                    OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                    CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress);
                    if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient))
                    {
                        operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient);
                    }
                    operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID);
                    operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout);
                    operationContext.CancellationToken = CancellationToken;

                    nCache.Cache.Delete(cmdInfo.Keys, cmdInfo.FlagMap, cbEnrty, cmdInfo.ProviderName, operationContext);
                    stopWatch.Stop();

                    Alachisoft.NCache.Common.Protobuf.Response           response           = new Alachisoft.NCache.Common.Protobuf.Response();
                    Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse bulkDeleteResponse = new Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse();
                    //response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                    //response.commandID = command.commandID;
                    //response.intendedRecipient = cmdInfo.IntendedRecipient;

                    //response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.DELETE_BULK;
                    //response.bulkDeleteResponse = bulkDeleteResponse;
                    //_serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.DELETE_BULK));

                    if (clientManager.ClientVersion >= 5000)
                    {
                        bulkDeleteResponse.intendedRecipient = cmdInfo.IntendedRecipient;
                        Common.Util.ResponseHelper.SetResponse(bulkDeleteResponse, command.requestID, command.commandID);
                        _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(bulkDeleteResponse, Common.Protobuf.Response.Type.DELETE_BULK));
                    }
                    else
                    {
                        //PROTOBUF:RESPONSE
                        response.intendedRecipient  = cmdInfo.IntendedRecipient;
                        response.bulkDeleteResponse = bulkDeleteResponse;
                        Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.DELETE_BULK);
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                    }
                }

                catch (OperationCanceledException ex)
                {
                    exception = ex.ToString();
                    Dispose();
                }
                catch (Exception exc)
                {
                    _removeBulkResult = OperationResult.Failure;
                    exception         = exc.ToString();
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                    //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc));
                }
                finally
                {
                    try
                    {
                        TimeSpan executionTime = stopWatch.Elapsed;
                        if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                        {
                            APILogItemBuilder log = new APILogItemBuilder(MethodsName.DELETEBULK.ToLower());
                            // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo);
                            log.GenerateBulkDeleteAPILogItem(cmdInfo.Keys.Length, cmdInfo.FlagMap, cmdInfo.ProviderName, cmdInfo.DsItemsRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                        }
                    }
                    catch
                    {
                    }
                }
            }
            finally
            {
                cmdInfo.FlagMap.MarkFree(NCModulesConstants.SocketServer);
            }
        }
Beispiel #23
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            int result = 0;

            try
            {
                overload = command.MethodOverload;
                cmdInfo  = base.ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }

            byte[] data = null;

            try
            {
                NCache           nCache           = clientManager.CmdExecuter as NCache;
                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                if (cmdInfo.CommandVersion < 1)
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                }
                else // NCache 4.1 or later
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                }
                operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout);
                operationContext.CancellationToken = CancellationToken;

                HashVector groupResult = nCache.Cache.GetGroupData(cmdInfo.Group, cmdInfo.SubGroup, operationContext);
                stopWatch.Stop();
                result = groupResult.Count;
                GetGroupDataResponseBuilder.BuildResponse(groupResult, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, nCache.Cache);
            }
            catch (OperationCanceledException ex)
            {
                exception = ex.ToString();
                Dispose();
            }
            catch (Exception exc)
            {
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetGroupData.ToLower());
                        log.GenerateGetGroupDataAPILogItem(cmdInfo.Group, cmdInfo.SubGroup, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), result);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #24
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int    dataLength = 0;
            int    overload;
            string exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error("GetCommand", "command: " + command + " Error" + arEx);
                }
                _getResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(arEx, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }
            catch (Exception exc)
            {
                _getResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }
            Alachisoft.NCache.Common.Protobuf.GetResponse getResponse = null;
            CompressedValueEntry flagValueEntry   = null;
            OperationContext     operationContext = null;
            NCache nCache = clientManager.CmdExecuter as NCache;

            try
            {
                object   lockId   = cmdInfo.LockId;
                ulong    version  = cmdInfo.CacheItemVersion;
                DateTime lockDate = new DateTime();

                operationContext = _operationContext;
                operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);

                if (cmdInfo.LockAccessType == LockAccessType.ACQUIRE)
                {
                    operationContext.Add(OperationContextFieldName.ClientThreadId, clientManager.ClientID);
                    operationContext.Add(OperationContextFieldName.ClientThreadId, cmdInfo.ThreadId);
                    operationContext.Add(OperationContextFieldName.IsRetryOperation, command.isRetryCommand);
                }

                flagValueEntry = nCache.Cache.GetGroup(cmdInfo.Key, cmdInfo.FlagMap, null, null, ref version, ref lockId, ref lockDate, cmdInfo.LockTimeout, cmdInfo.LockAccessType, operationContext);

                stopWatch.Stop();
                UserBinaryObject ubObj = null;

                getResponse = _getResponse;

                if (flagValueEntry != null)
                {
                    if (flagValueEntry.Value is UserBinaryObject)
                    {
                        ubObj = (UserBinaryObject)flagValueEntry.Value;
                    }
                    else
                    {
                        var flag = flagValueEntry.Flag;
                        ubObj = (UserBinaryObject)nCache.Cache.SocketServerDataService.GetClientData(flagValueEntry.Value, ref flag, LanguageContext.DOTNET);
                    }
                    if (flagValueEntry.Value != null)
                    {
                        getResponse.itemType = MiscUtil.EntryTypeToProtoItemType(flagValueEntry.Type);// (Alachisoft.NCache.Common.Protobuf.CacheItemType.ItemType)flagValueEntry.Type;
                    }
                }
                if (ubObj != null)
                {
                    dataLength = ubObj.Length;
                }

                if (clientManager.ClientVersion >= 5000)
                {
                    if (lockId != null)
                    {
                        getResponse.lockId = lockId.ToString();
                    }
                    getResponse.requestId = cmdInfo.RequestId;
                    getResponse.commandID = command.commandID;
                    getResponse.lockTime  = lockDate.Ticks;
                    getResponse.version   = version;
                    if (ubObj == null)
                    {
                        //  response.get = getResponse;
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getResponse, Common.Protobuf.Response.Type.GET));
                    }
                    else
                    {
                        //_dataPackageArray = ubObj.Data;
                        getResponse.flag = flagValueEntry.Flag.Data;
                        getResponse.data.AddRange(ubObj.DataList);
                        //  response.get = getResponse;
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(getResponse, Common.Protobuf.Response.Type.GET));
                    }
                }
                else
                {
                    Alachisoft.NCache.Common.Protobuf.Response response = Stash.ProtobufResponse;

                    response.requestId    = Convert.ToInt64(cmdInfo.RequestId);
                    response.commandID    = command.commandID;
                    response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET;
                    if (lockId != null)
                    {
                        getResponse.lockId = lockId.ToString();
                    }
                    getResponse.lockTime = lockDate.Ticks;
                    getResponse.version  = version;
                    if (ubObj == null)
                    {
                        response.get = getResponse;
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                    }
                    else
                    {
                        getResponse.flag = flagValueEntry.Flag.Data;
                        getResponse.data.AddRange(ubObj.DataList);
                        response.get = getResponse;
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                    }
                }
            }
            catch (Exception exc)
            {
                exception  = exc.ToString();
                _getResult = OperationResult.Failure;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                operationContext?.MarkFree(NCModulesConstants.SocketServer);

                TimeSpan executionTime = stopWatch.Elapsed;


                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        int resutlt = 0;
                        if (getResponse != null)
                        {
                            resutlt = dataLength;
                        }
                        string methodName = null;
                        if (cmdInfo.LockAccessType == LockAccessType.ACQUIRE)
                        {
                            methodName = MethodsName.GET.ToLower();
                        }

                        else
                        {
                            methodName = MethodsName.GET.ToLower();
                        }
                        APILogItemBuilder log = new APILogItemBuilder(methodName);
                        log.GenerateGetCommandAPILogItem(cmdInfo.Key, null, null, (long)cmdInfo.CacheItemVersion, cmdInfo.LockAccessType, cmdInfo.LockTimeout, cmdInfo.LockId, cmdInfo.ProviderName, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resutlt);
                    }
                }
                catch
                {
                }
                if (flagValueEntry != null)
                {
                    MiscUtil.ReturnCompressedEntryToPool(flagValueEntry, clientManager.CacheTransactionalPool);
                    MiscUtil.ReturnEntryToPool(flagValueEntry.Entry, clientManager.CacheTransactionalPool);
                }
            }
            //}
            //if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("GetCmd.Exec", "cmd executed on cache");
        }
Beispiel #25
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            int responseResult = 0;

            byte[] data = null;

            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (ArgumentOutOfRangeException arEx)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error("GetCommand", "command: " + command + " Error" + arEx);
                }
                _getResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(arEx, command.requestID, command.commandID));
                }
                return;
            }
            catch (Exception exc)
            {
                _getResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }

            try
            {
                NCache           nCache           = clientManager.CmdExecuter as NCache;
                HashVector       result           = null;
                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);

                if (cmdInfo.CommandVersion < 1)
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                }
                else // NCache 4.1 or later
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                }

                result = (HashVector)nCache.Cache.GetByTag(cmdInfo.Tags, cmdInfo.ComparisonType, operationContext);
                stopWatch.Stop();
                resultCount    = result.Count;
                responseResult = result.Count;
                GetTagResponseBuilder.BuildResponse(result, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, nCache.Cache);
            }
            catch (Exception exc)
            {
                exception  = exc.ToString();
                _getResult = OperationResult.Failure;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        if (cmdInfo.ComparisonType == TagComparisonType.ALL_MATCHING_TAGS)
                        {
                            APILogItemBuilder log  = new APILogItemBuilder(MethodsName.GetByAllTags.ToLower());
                            Hashtable         tags = new Hashtable();
                            foreach (string tag in cmdInfo.Tags)
                            {
                                tags.Add(tag, tag);
                            }
                            log.GenerateGetByAllTagsAPILogItem(tags, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), responseResult);
                        }
                        else if (cmdInfo.ComparisonType == TagComparisonType.BY_TAG)
                        {
                            APILogItemBuilder log  = new APILogItemBuilder(MethodsName.GetByTag.ToLower());
                            Hashtable         tags = new Hashtable();
                            foreach (string tag in cmdInfo.Tags)
                            {
                                tags.Add(tag, tag);
                            }
                            log.GenerateGetByTagAPILogItem(tags, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), responseResult);
                        }
                        else if (cmdInfo.ComparisonType == TagComparisonType.ANY_MATCHING_TAG)
                        {
                            APILogItemBuilder log  = new APILogItemBuilder(MethodsName.GetByAnyTag.ToLower());
                            Hashtable         tags = new Hashtable();
                            foreach (string tag in cmdInfo.Tags)
                            {
                                tags.Add(tag, tag);
                            }
                            log.GenerateGetByAnyTagAPILogItem(tags, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), responseResult);
                        }
                    }
                }
                catch
                {
                }
            }
        }
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

            try
            {
                overload = command.MethodOverload;
                stopWatch.Start();

                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc));
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            try
            {
                CallbackInfo cbUpdate = null;
                CallbackInfo cbRemove = null;

                CallbackType callbackType = (CallbackType)cmdInfo.callbackType;

                if (cmdInfo.dataFilter != -1) //Default value in protbuf set to -1
                {
                    EventDataFilter datafilter = (EventDataFilter)cmdInfo.dataFilter;

                    cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, datafilter, callbackType);
                    cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, datafilter, cmdInfo.NotifyOnExpiration, callbackType);
                }
                else
                {
                    cbUpdate = new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None, callbackType);
                    cbRemove = new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, EventDataFilter.None, cmdInfo.NotifyOnExpiration, callbackType);
                }


                NCache           nCache  = clientManager.CmdExecuter as NCache;
                OperationContext context = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                context.Add(OperationContextFieldName.ClientId, clientManager.ClientID);

                if (command.commandVersion < 1)
                {
                    context.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                }
                else //NCache 4.1 SP1 or later
                {
                    context.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.clientLastViewId.ToString(CultureInfo.InvariantCulture));
                }

                nCache.Cache.RegisterKeyNotificationCallback(cmdInfo.Key, cbUpdate, cbRemove
                                                             , context);
                stopWatch.Stop();
                if (clientManager.ClientVersion < 5000 && !clientManager.CreateEventSubscription)
                {
                    Util.EventHelper.SubscribeEvents(clientManager.ClientID, TopicConstant.ItemLevelEventsTopic, nCache, context);
                    clientManager.CreateEventSubscription = true;
                }

                //PROTOBUF:RESPONSE
                // Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse registerKeyNotifResponse = new Alachisoft.NCache.Common.Protobuf.RegisterKeyNotifResponse();
                //response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF;
                //response.registerKeyNotifResponse = registerKeyNotifResponse;
                //response.requestId = command.registerKeyNotifCommand.requestId;
                //response.commandID = command.commandID;
                //_serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF));

                if (clientManager.ClientVersion >= 5000)
                {
                    Common.Util.ResponseHelper.SetResponse(registerKeyNotifResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(registerKeyNotifResponse, Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.registerKeyNotifResponse = registerKeyNotifResponse;
                    Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.REGISTER_KEY_NOTIF);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }

                //_commandBytes = clientManager.ReplyPacket("REGKEYNOTIFRESULT \"" + cmdInfo.RequestId + "\"", new byte[0]);
            }
            catch (Exception exc)
            {
                exception = exc.ToString();

                //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc));
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.RegisterKeyNotificationCallback.ToLower());
                        log.GenerateKeyNotificationCallback(1, cmdInfo.UpdateCallbackId, cmdInfo.RemoveCallbackId, 1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());



                        // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #27
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();
            int       count     = 0;

            stopWatch.Start();

            try
            {
                try
                {
                    overload = command.MethodOverload;
                    cmdInfo  = ParseCommand(command, clientManager);
                    if (ServerMonitor.MonitorActivity)
                    {
                        ServerMonitor.LogClientActivity("BulkGetCmd.Exec", "cmd parsed");
                    }
                }
                catch (Exception exc)
                {
                    _getBulkResult = OperationResult.Failure;
                    if (!base.immatureId.Equals("-2"))
                    {
                        //PROTOBUF:RESPONSE
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                    }
                    return;
                }

                byte[] data = null;

                NCache     nCache    = clientManager.CmdExecuter as NCache;
                HashVector getResult = null;

                try
                {
                    OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                    if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient))
                    {
                        operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient);
                    }

                    operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout);
                    operationContext.CancellationToken = CancellationToken;
                    getResult = (HashVector)nCache.Cache.GetBulk(cmdInfo.Keys, cmdInfo.FlagMap, operationContext);
                    stopWatch.Stop();

                    count = getResult.Count;
                    BulkGetResponseBuilder.BuildResponse(getResult, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, cmdInfo.IntendedRecipient, command.commandID, clientManager, nCache.Cache);
                }
                catch (OperationCanceledException ex)
                {
                    exception = ex.ToString();
                    Dispose();
                }
                catch (Exception exc)
                {
                    _getBulkResult = OperationResult.Failure;
                    exception      = exc.ToString();
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                finally
                {
                    TimeSpan executionTime = stopWatch.Elapsed;
                    if (getResult != null)
                    {
                        foreach (CompressedValueEntry compressedValueEntry in getResult.Values)
                        {
                            MiscUtil.ReturnEntryToPool(compressedValueEntry.Entry, clientManager.CacheTransactionalPool);
                            MiscUtil.ReturnCompressedEntryToPool(compressedValueEntry, clientManager.CacheTransactionalPool);
                        }
                    }
                    try
                    {
                        if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                        {
                            APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetBulk.ToLower());
                            log.GenerateBulkGetAPILogItem(cmdInfo.Keys.Length, cmdInfo.providerName, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString(), count);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            finally
            {
                cmdInfo.FlagMap.MarkFree(NCModulesConstants.SocketServer);
            }
            if (ServerMonitor.MonitorActivity)
            {
                ServerMonitor.LogClientActivity("BulkGetCmd.Exec", "cmd executed on cache");
            }
        }
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;
            int         overload;
            string      exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

            try
            {
                overload = command.MethodOverload;
                stopWatch.Start();

                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc));
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                nCache.Cache.UnregisterKeyNotificationCallback(cmdInfo.Key
                                                               , new CallbackInfo(clientManager.ClientID, cmdInfo.UpdateCallbackId, EventDataFilter.None) //DataFilter not required while unregistration
                                                               , new CallbackInfo(clientManager.ClientID, cmdInfo.RemoveCallbackId, EventDataFilter.None) //DataFilter not required while unregistration
                                                               , new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));
                stopWatch.Stop();

                //Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.UnregisterKeyNotifResponse unregisterKeyNotifResponse = new Alachisoft.NCache.Common.Protobuf.UnregisterKeyNotifResponse();
                //            response.requestId = Convert.ToInt64(cmdInfo.RequestId);
                //            response.commandID = command.commandID;
                //            response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF;
                //response.unregisterKeyNotifResponse = unregisterKeyNotifResponse;

                //            _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response,Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF));

                //_commandBytes = clientManager.ReplyPacket("UNREGKEYNOTIFRESULT \"" + cmdInfo.RequestId + "\"", new byte[0]);

                if (clientManager.ClientVersion >= 5000)
                {
                    Common.Util.ResponseHelper.SetResponse(unregisterKeyNotifResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(unregisterKeyNotifResponse, Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF));
                }
                else
                {
                    //PROTOBUF:RESPONSE
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.unregisterKeyNotifResponse = unregisterKeyNotifResponse;
                    Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.UNREGISTER_KEY_NOTIF);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                exception = exc.ToString();

                //_commandBytes = clientManager.ReplyPacket(base.ExceptionPacket(exc, cmdInfo.RequestId), base.ExceptionMessage(exc));
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.UnRegisterKeyNotificationCallback.ToLower());
                        log.GenerateKeyNotificationCallback(1, cmdInfo.UpdateCallbackId, cmdInfo.RemoveCallbackId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());



                        // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #29
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            ClientId = clientManager.ClientID;

            NCache         nCache = clientManager.CmdExecuter as NCache;
            int            overload;
            Hashtable      queryInfo = null;
            ExpirationHint expHint   = null;
            string         exception = null;
            Stopwatch      stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload             = command.MethodOverload;
                serailizationContext = nCache.CacheId;
                cmdInfo = base.ParseCommand(command, clientManager, serailizationContext);
                if (ServerMonitor.MonitorActivity)
                {
                    ServerMonitor.LogClientActivity("BulkAddCmd.Exec", "cmd parsed");
                }
            }
            catch (Exception exc)
            {
                _addBulkResult = OperationResult.Failure;
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                }
                return;
            }

            try
            {
                //PROTOBUF:RESPONSE
                OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);

                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);

                operationContext.Add(OperationContextFieldName.WriteThru, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteThru));
                operationContext.Add(OperationContextFieldName.WriteBehind, cmdInfo.Flag.IsBitSet(BitSetConstants.WriteBehind));

                if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient))
                {
                    operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient);
                }
                queryInfo = cmdInfo.Entries[0].QueryInfo;
                expHint   = cmdInfo.Entries[0].ExpirationHint;

                IDictionary itemVersions = null;

                Hashtable addResult = (Hashtable)nCache.Cache.Add(cmdInfo.Keys, cmdInfo.Entries, cmdInfo.Flag, cmdInfo.ProviderName, out itemVersions, operationContext);
                stopWatch.Stop();

                Alachisoft.NCache.Common.Protobuf.Response        response        = new Alachisoft.NCache.Common.Protobuf.Response();
                Alachisoft.NCache.Common.Protobuf.BulkAddResponse bulkAddResponse = new Alachisoft.NCache.Common.Protobuf.BulkAddResponse();
                response.requestId         = Convert.ToInt64(cmdInfo.RequestId);
                response.commandID         = command.commandID;
                response.intendedRecipient = cmdInfo.IntendedRecipient;

                bulkAddResponse.keyExceptionPackage = new Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse();
                bulkAddResponse.keyVersionPackage   = new Alachisoft.NCache.Common.Protobuf.KeyVersionPackageResponse();

                Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysExceptions(addResult, bulkAddResponse.keyExceptionPackage);

                if (cmdInfo.returnVersion)
                {
                    Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysVersion(itemVersions, bulkAddResponse.keyVersionPackage);
                }

                response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.ADD_BULK;
                response.bulkAdd      = bulkAddResponse;
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            catch (Exception exc)
            {
                _addBulkResult = OperationResult.Failure;
                exception      = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log            = new APILogItemBuilder(MethodsName.ADDBULK.ToLower());
                        Hashtable         expirationHint = log.GetDependencyExpirationAndQueryInfo(expHint, queryInfo);
                        log.GenerateADDInsertBulkAPILogItem(cmdInfo.Keys.Length, cmdInfo.Entries.Length, expirationHint["dependency"] != null ? expirationHint["dependency"] as ArrayList : null, expirationHint["absolute-expiration"] != null ? (long)expirationHint["absolute-expiration"] : -1, expirationHint["sliding-expiration"] != null ? (long)expirationHint["sliding-expiration"] : -1, cmdInfo.Entries[0].Priority, cmdInfo.Entries[0].SyncDependency, expirationHint["tag-info"] != null ? expirationHint["tag-info"] as Hashtable : null, expirationHint["named-tags"] != null ? expirationHint["named-tags"] as Hashtable : null, cmdInfo.Group != null ? cmdInfo.Group : null, cmdInfo.SubGroup != null ? cmdInfo.SubGroup : null, cmdInfo.Entries[0].Flag, cmdInfo.Entries[0].ProviderName, cmdInfo.Entries[0].ResyncProviderName, false, cmdInfo.Entries[0].HasQueryInfo, (long)cmdInfo.Entries[0].Version, cmdInfo.onUpdateCallbackId, cmdInfo.OnDsItemsAddedCallback, false, false, overload, exception, executionTime, clientManager.ClientID, clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
            if (ServerMonitor.MonitorActivity)
            {
                ServerMonitor.LogClientActivity("BulkAddCmd.Exec", "cmd executed on cache");
            }
        }
Beispiel #30
0
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            int    overload         = 1;
            bool   isTopicCreated   = false;
            string exceptionMessage = null;

            try
            {
                NCache nCache           = clientManager.CmdExecuter as NCache;
                var    operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                if (command.commandVersion < 1)
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId);
                }
                else //NCache 4.1 SP1 or later
                {
                    operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture));
                }
                if (nCache != null)
                {
                    Common.Protobuf.GetTopicCommand getTopicCommand = command.getTopicCommand;
                    _command = getTopicCommand;



                    TopicOperation topicOperation = new TopicOperation(getTopicCommand.topicName, (TopicOperationType)getTopicCommand.type);
                    isTopicCreated = nCache.Cache.TopicOpertion(topicOperation, operationContext);
                    stopWatch.Stop();
                    Common.Protobuf.Response         response         = new Common.Protobuf.Response();
                    Common.Protobuf.GetTopicResponse getTopicResponse = new Common.Protobuf.GetTopicResponse();
                    getTopicResponse.success = isTopicCreated;

                    if (clientManager.ClientVersion >= 5000)
                    {
                        Common.Util.ResponseHelper.SetResponse(getTopicResponse, command.requestID, command.commandID);
                        _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(getTopicResponse, Common.Protobuf.Response.Type.GET_TOPIC));
                    }
                    else
                    {
                        //PROTOBUF:RESPONSE
                        response.getTopicResponse = getTopicResponse;
                        Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.GET_TOPIC);
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                    }
                }
            }
            catch (Exception exc)
            {
                exceptionMessage = exc.ToString();
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        string methodName = null;

                        if ((TopicOperationType)_command.type == TopicOperationType.Get)
                        {
                            methodName = MethodsName.GetTopic;
                        }
                        else
                        {
                            methodName = MethodsName.CreateTopic;
                        }

                        APILogItemBuilder log = new APILogItemBuilder(methodName);
                        log.GenerateGetCreateOrDeleteTopicAPILogItem(_command.topicName, executionTime, clientManager.ClientID, clientManager.ClientIP, overload, isTopicCreated, exceptionMessage);

                        // Hashtable expirationHint = log.GetDependencyExpirationAndQueryInfo(cmdInfo.ExpirationHint, cmdInfo.queryInfo);
                    }
                }
                catch
                {
                }
            }
        }