public OpenStreamCommand(string key, StreamModes mode, string group, string subgroup, DateTime absolute, TimeSpan sliding, CacheDependency dependency, Runtime.CacheItemPriority priority, int methodOverload) { base.name = "OpenStreamCommand"; _openStreamCommand = new Alachisoft.NCache.Common.Protobuf.OpenStreamCommand(); _openStreamCommand.key = key; _openStreamCommand.streamMode = (int)mode; _openStreamCommand.group = group; _openStreamCommand.subGroup = subgroup; _methodOverlaod = methodOverload; if (absolute != Alachisoft.NCache.Web.Caching.Cache.NoAbsoluteExpiration) { _openStreamCommand.absoluteExpiration = absolute.Ticks; } if (sliding != Alachisoft.NCache.Web.Caching.Cache.NoSlidingExpiration) { _openStreamCommand.slidingExpiration = sliding.Ticks; } _openStreamCommand.priority = (int)priority; _openStreamCommand.requestId = base.RequestId; if (dependency != null) { _openStreamCommand.dependency = Alachisoft.NCache.Common.Util.DependencyHelper.GetProtoBufDependency(dependency); } }
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)); }