コード例 #1
0
        public MessagePublishCommand(string messageId, byte[] payLoad, long creationTime, long expirationTime,
                                     Hashtable metadata, BitSet flagMap)
        {
            name = "PublishMessageCommand";

            _publishMessageCommand           = new Common.Protobuf.MessagePublishCommand();
            _publishMessageCommand.messageId = messageId;
            key = messageId;
            UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(payLoad);

            _publishMessageCommand.data.AddRange(ubObject.DataList);

            _publishMessageCommand.flag         = flagMap.Data;
            _publishMessageCommand.expiration   = expirationTime;
            _publishMessageCommand.creationTime = creationTime;
            _publishMessageCommand.requestId    = RequestId;
            _publishMessageCommand.isAsync      = isAsync;

            foreach (DictionaryEntry entry in metadata)
            {
                KeyValuePair keyValue = new KeyValuePair();
                keyValue.key   = entry.Key.ToString();
                keyValue.value = entry.Value.ToString();

                _publishMessageCommand.keyValuePair.Add(keyValue);
            }
        }
コード例 #2
0
        /// <summary>
        /// For Inproc only
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        internal static EventCacheItem ConvertToItem(EventCacheEntry entry)
        {
            Byte[] objectValue = null;
            if (entry != null)
            {
                EventCacheItem item = new EventCacheItem();
                item.CacheItemPriority = (CacheItemPriority)entry.Priority;
                item.CacheItemVersion  = new CacheItemVersion(entry.Version);
                item.Group             = entry.Group;
                item.SubGroup          = entry.SubGroup;

                if (entry.Value != null)
                {
                    UserBinaryObject ubObject = entry.Value as UserBinaryObject;
                    if (ubObject != null)
                    {
                        objectValue = ubObject.GetFullObject();
                        item.SetValue(objectValue);
                    }
                    else
                    {
                        item.SetValue(entry.Value);
                    }
                }
                item.EntryType = entry.EntryType;

                return(item);
            }

            return(null);
        }
コード例 #3
0
        internal static EventCacheItem ConvertToEventEntry(Alachisoft.NCache.Common.Protobuf.EventCacheItem cacheItem)
        {
            Byte[] objectValue = null;

            if (cacheItem == null)
            {
                return(null);
            }

            EventCacheItem item = new EventCacheItem();

            item.CacheItemPriority = (CacheItemPriority)cacheItem.priority;
            item.CacheItemVersion  = new CacheItemVersion(cacheItem.itemVersion);
            item.Group             = String.IsNullOrEmpty(cacheItem.group) ? null : cacheItem.group;
            item.SubGroup          = String.IsNullOrEmpty(cacheItem.subGroup) ? null : cacheItem.subGroup;
            item.Flagmap           = new Common.BitSet((byte)cacheItem.flagMap);
            if (cacheItem.value != null && cacheItem.value.Count > 0)
            {
                UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(cacheItem.value.ToArray());
                objectValue = ubObject.GetFullObject();
                item.SetValue(objectValue);
            }

            item.EntryType = NCache.Util.MiscUtil.ProtoItemTypeToEntryType(cacheItem.itemType);

            return(item);
        }
コード例 #4
0
        internal static EventCacheItem ConvertToEventEntry(Alachisoft.NCache.Common.Protobuf.EventCacheItem cacheItem)
        {
            Byte[] objectValue = null;

            if (cacheItem == null)
            {
                return(null);
            }

            EventCacheItem item = new EventCacheItem();

            item.CacheItemPriority  = (CacheItemPriority)cacheItem.priority;
            item.CacheItemVersion   = new Caching.CacheItemVersion(cacheItem.itemVersion);
            item.Group              = String.IsNullOrEmpty(cacheItem.group) ? null : cacheItem.group;
            item.ResyncExpiredItems = cacheItem.resyncExpiredItems;
            item.ResyncProviderName =
                String.IsNullOrEmpty(cacheItem.resyncProviderName) ? null : cacheItem.resyncProviderName;
            item.SubGroup = String.IsNullOrEmpty(cacheItem.subGroup) ? null : cacheItem.subGroup;
            if (cacheItem.value != null && cacheItem.value.Count > 0)
            {
                UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(cacheItem.value.ToArray());
                objectValue = ubObject.GetFullObject();
                item.Value  = objectValue;
            }

            return(item);
        }
コード例 #5
0
        /// <summary>
        /// Makes a key and data package form the keys and values of hashtable
        /// </summary>
        /// <param name="dic">Hashtable containing the keys and values to be packaged</param>
        /// <param name="keys">Contains packaged keys after execution</param>
        /// <param name="data">Contains packaged data after execution</param>
        /// <param name="currentContext">Current cache</param>
        internal static Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse PackageKeysValues(IDictionary dic, Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse keyPackageResponse)
        {
            if (dic != null && dic.Count > 0)
            {
                if (keyPackageResponse == null)
                {
                    keyPackageResponse = new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse();
                }
                ;

                IDictionaryEnumerator enu = dic.GetEnumerator();
                while (enu.MoveNext())
                {
                    keyPackageResponse.keys.Add((string)enu.Key);
                    CompressedValueEntry cmpEntry = (CompressedValueEntry)enu.Value;
                    BitSet           flag         = cmpEntry.Flag;
                    UserBinaryObject ubObject     = Cache.SocketServerDataService.GetClientData(cmpEntry.Value, ref flag, LanguageContext.DOTNET) as UserBinaryObject;
                    Alachisoft.NCache.Common.Protobuf.Value value = new Alachisoft.NCache.Common.Protobuf.Value();
                    value.data.AddRange(ubObject.DataList);
                    keyPackageResponse.flag.Add(cmpEntry.Flag.Data);

                    keyPackageResponse.values.Add(value);
                    keyPackageResponse.itemType.Add(MiscUtil.EntryTypeToProtoItemType(cmpEntry.Type));
                }
            }

            return(keyPackageResponse);
        }
コード例 #6
0
ファイル: DatasourceMgr.cs プロジェクト: fabrimaciel/colosoft
        /// <summary>
        /// Ressincroniza a entrada do cache.
        /// </summary>
        /// <param name="key">Chave do item.</param>
        /// <param name="entry">Instancia da entrada.</param>
        /// <param name="flag">Conjunto associado.</param>
        /// <param name="group">Grupo onde a entrada está inserida.</param>
        /// <param name="subGroup">Subgrupo da entrada.</param>
        /// <param name="providerName">Nome do provedor.</param>
        /// <param name="operationContext">Contexto da operação.</param>
        /// <returns></returns>
        public object ResyncCacheItem(string key, out CacheEntry entry, ref BitSet flag, string group, string subGroup, string providerName, OperationContext operationContext)
        {
            ProviderCacheItem item = null;

            this.ReadThru(key, out item, providerName);
            UserBinaryObject obj2 = null;

            try
            {
                obj2 = this.GetCacheEntry(key, item, ref flag, group, subGroup, out entry);
                if (obj2 == null)
                {
                    return(obj2);
                }
                CacheInsResultWithEntry entry2 = _context.CacheImpl.Insert(key, entry, false, null, 0, LockAccessType.IGNORE_LOCK, operationContext);
                if (entry2.Result == CacheInsResult.Failure)
                {
                    throw new OperationFailedException("Operation failed to synchronize with data source");
                }
                if (entry2.Result == CacheInsResult.NeedsEviction)
                {
                    throw new OperationFailedException("The cache is full and not enough items could be evicted.");
                }
            }
            catch (Exception exception)
            {
                throw new OperationFailedException("Error occurred while synchronization with data source. Error: " + exception.Message, exception);
            }
            return(obj2);
        }
コード例 #7
0
        /// <summary>
        /// For Inproc only
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        internal static EventCacheItem ConvertToItem(EventCacheEntry entry)
        {
            Byte[] objectValue = null;
            if (entry != null)
            {
                EventCacheItem item = new EventCacheItem();
                item.CacheItemPriority  = (CacheItemPriority)entry.Priority;
                item.CacheItemVersion   = new Caching.CacheItemVersion(entry.Version);
                item.Group              = entry.Group;
                item.ResyncExpiredItems = entry.ReSyncExpiredItems;
                item.ResyncProviderName = entry.ReSyncProviderCacheItem;
                item.SubGroup           = entry.SubGroup;
                if (entry.Value != null)
                {
                    UserBinaryObject ubObject = entry.Value as UserBinaryObject;
                    if (ubObject != null)
                    {
                        objectValue = ubObject.GetFullObject();
                        item.Value  = objectValue;
                    }
                    else
                    {
                        item.Value = entry.Value;
                    }
                }


                return(item);
            }

            return(null);
        }
コード例 #8
0
        internal static ItemRemoveCallbackResponse GetItemRemovedCallbackResponse(EventContext eventContext, short id, string key, UserBinaryObject value, BitSet flag, ItemRemoveReason reason, EventDataFilter dataFilter)
        {
            Alachisoft.NCache.Common.Protobuf.ItemRemoveCallbackResponse itemRemovedCallback = new Alachisoft.NCache.Common.Protobuf.ItemRemoveCallbackResponse();

            itemRemovedCallback.key              = key;
            itemRemovedCallback.callbackId       = id;
            itemRemovedCallback.itemRemoveReason = (int)reason;
            itemRemovedCallback.flag             = flag != null? (int)flag.Data : 0;
            itemRemovedCallback.dataFilter       = (short)dataFilter;
            itemRemovedCallback.eventId          = new Common.Protobuf.EventId();
            UserBinaryObject binaryObject = eventContext.Item != null ?(UserBinaryObject)eventContext.Item.Value : null;

            if (binaryObject != null)
            {
                itemRemovedCallback.value.AddRange(binaryObject.DataList);
            }

            if (eventContext != null)
            {
                itemRemovedCallback.eventId.eventUniqueId    = eventContext.EventID.EventUniqueID;
                itemRemovedCallback.eventId.operationCounter = eventContext.EventID.OperationCounter;
                itemRemovedCallback.eventId.eventCounter     = eventContext.EventID.EventCounter;
                if (eventContext.Item != null)
                {
                    itemRemovedCallback.flag = eventContext.Item.Flags.Data;
                }
                itemRemovedCallback.eventId.item = ConvertToEventItem(eventContext.Item, null);
                if (itemRemovedCallback.eventId.item != null && itemRemovedCallback.eventId.item.value != null)
                {
                    itemRemovedCallback.eventId.item.value.Clear();//data will be travalling in old fashion due to old callbacks
                }
            }

            return(itemRemovedCallback);
        }
コード例 #9
0
        /// <summary>
        /// For Inproc only
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        internal static EventCacheItem ConvertToItem(EventCacheEntry entry)
        {
            Byte[] objectValue = null;
            if (entry != null)
            {
                EventCacheItem item = new EventCacheItem();
                item.CacheItemPriority = (CacheItemPriority)entry.Priority;
                if (entry.Value != null)
                {
                    UserBinaryObject ubObject = entry.Value as UserBinaryObject;
                    if (ubObject != null)
                    {
                        objectValue = ubObject.GetFullObject();
                        item.Value  = objectValue;
                    }
                    else
                    {
                        item.Value = entry.Value;
                    }
                }


                return(item);
            }

            return(null);
        }
コード例 #10
0
ファイル: MessageEventItem.cs プロジェクト: yongwuhou/NCache
        internal EventCacheItem ConvertToEventCacheItem(Common.Protobuf.EventCacheItem entry)
        {
            EventCacheItem cacheItem = new EventCacheItem();

            try
            {
                cacheItem.Group                    = entry.group;
                cacheItem.SubGroup                 = entry.subGroup;
                cacheItem.CacheItemVersion         = new CacheItemVersion();
                cacheItem.CacheItemVersion.Version = entry.itemVersion;
                cacheItem.CacheItemPriority        = (CacheItemPriority)entry.priority;
                //cacheItem.ResyncOptions = new Runtime.Caching.ResyncOptions(false, "");
                cacheItem.Flagmap = new Common.BitSet((byte)entry.flagMap);

                if (entry.value.Count > 0)
                {
                    List <byte[]>    val      = entry.value;
                    UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(entry.value.ToArray());
                    if (ubObject != null)
                    {
                        cacheItem.SetValue(ubObject.GetFullObject());
                    }
                }

                cacheItem.EntryType = Util.MiscUtil.ProtoItemTypeToEntryType(entry.itemType);
            }
            catch (System.Exception e)
            {
                throw e;
            }

            return(cacheItem);
        }
コード例 #11
0
ファイル: Request.cs プロジェクト: wangchengqun/NCache
        private void PopulateRows(Common.DataReader.RecordSet recordSet, List <RecordRow> rows)
        {
            try
            {
                if (recordSet != null && rows != null)
                {
                    foreach (RecordRow rowProto in rows)
                    {
                        Common.DataReader.RecordRow row = recordSet.CreateRow();
                        if (recordSet.Columns != null)
                        {
                            for (int i = 0; i < recordSet.Columns.Count; i++)
                            {
                                if (rowProto.values[i] != null)
                                {
                                    if (recordSet.Columns[i].DataType != null)
                                    {
                                        switch (recordSet.Columns[i].DataType)
                                        {
                                        case Common.Enum.ColumnDataType.AverageResult:

                                            Common.Queries.AverageResult avgResult =
                                                new Common.Queries.AverageResult();
                                            avgResult.Sum   = Convert.ToDecimal(rowProto.values[i].avgResult.sum);
                                            avgResult.Count = Convert.ToDecimal(rowProto.values[i].avgResult.count);
                                            row[i]          = avgResult;
                                            break;

                                        case Common.Enum.ColumnDataType.CompressedValueEntry:
                                            Value            val      = rowProto.values[i].binaryObject;
                                            UserBinaryObject ubObject =
                                                UserBinaryObject.CreateUserBinaryObject(val.data.ToArray());
                                            byte[] bytes = ubObject.GetFullObject();
                                            CompressedValueEntry cmpEntry = new CompressedValueEntry();
                                            cmpEntry.Flag  = new BitSet((byte)rowProto.values[i].flag);
                                            cmpEntry.Value = bytes;
                                            row[i]         = ConvertToUserObject(cmpEntry);
                                            break;

                                        default:
                                            row[i] = Common.DataReader.RecordSet.ToObject(
                                                rowProto.values[i].stringValue, recordSet.Columns[i].DataType);
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        recordSet.AddRow(row);
                    }
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
                throw new InvalidReaderException("Reader state has been lost.: ", ex);
            }
        }
コード例 #12
0
        /// <summary>
        /// Makes a key and data package form the keys and values of hashtable
        /// </summary>
        /// <param name="dic">Hashtable containing the keys and values to be packaged</param>
        /// <param name="keys">Contains packaged keys after execution</param>
        /// <param name="data">Contains packaged data after execution</param>
        /// <param name="currentContext">Current cache</param>
        internal static IList PackageKeysValues(IDictionary dic)
        {
            int   estimatedSize            = 0;
            IList ListOfKeyPackageResponse = new ClusteredArrayList();

            if (dic != null && dic.Count > 0)
            {
                Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse keyPackageResponse = new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse();

                IDictionaryEnumerator enu = dic.GetEnumerator();
                while (enu.MoveNext())
                {
                    Alachisoft.NCache.Common.Protobuf.Value value = new Alachisoft.NCache.Common.Protobuf.Value();
                    CompressedValueEntry cmpEntry = (CompressedValueEntry)enu.Value;

                    UserBinaryObject ubObject = null;
                    if (cmpEntry != null)
                    {
                        if (cmpEntry.Value is UserBinaryObject)
                        {
                            ubObject = (UserBinaryObject)cmpEntry.Value;
                        }
                        else
                        {
                            var flag = cmpEntry.Flag;
                            ubObject = (UserBinaryObject)Cache.SocketServerDataService.GetClientData(cmpEntry.Value, ref flag, LanguageContext.DOTNET);
                        }
                    }

                    //UserBinaryObject ubObject = Cache.SocketServerDataService.GetClientData(cmpEntry.Value, ref cmpEntry.Flag, LanguageContext.DOTNET) as UserBinaryObject;
                    value.data.AddRange(ubObject.DataList);
                    keyPackageResponse.keys.Add((string)enu.Key);
                    keyPackageResponse.flag.Add(cmpEntry.Flag.Data);
                    keyPackageResponse.values.Add(value);
                    keyPackageResponse.itemType.Add(MiscUtil.EntryTypeToProtoItemType(cmpEntry.Type)); // (Alachisoft.NCache.Common.Protobuf.CacheItemType.ItemType));

                    estimatedSize = estimatedSize + ubObject.Size + (((string)enu.Key).Length * sizeof(Char));

                    if (estimatedSize >= ServiceConfiguration.ResponseDataSize) //If size is greater than specified size then add it and create new chunck
                    {
                        ListOfKeyPackageResponse.Add(keyPackageResponse);
                        keyPackageResponse = new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse();
                        estimatedSize      = 0;
                    }
                }

                if (estimatedSize != 0)
                {
                    ListOfKeyPackageResponse.Add(keyPackageResponse);
                }
            }
            else
            {
                ListOfKeyPackageResponse.Add(new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse());
            }

            return(ListOfKeyPackageResponse);
        }
コード例 #13
0
        internal AddCommand(string key, byte[] value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short removeCallback, short updateCallback, short dsItemAddedCallback, bool isResyncExpiredItems, short itemAdded, bool isAsync, Hashtable queryInfo, BitSet flagMap, string providerName, string resyncProviderName, bool encryption, string cacheId, EventDataFilter updateDataFilter, EventDataFilter removeDataFilter, int methodOverload, string clientId, string typeName)
        {
            base.name = "AddCommand";
            base.asyncCallbackSpecified = isAsync && itemAdded != -1 ? true : false;
            base.isAsync = isAsync;
            base.key     = key;

            _itemAdded = itemAdded;

            _addCommand = new Alachisoft.NCache.Common.Protobuf.AddCommand();

            if (absoluteExpiration.Equals(Cache.DefaultAbsolute.ToUniversalTime()))
            {
                _addCommand.absExpiration = 1;
            }
            else if (absoluteExpiration.Equals(Cache.DefaultAbsoluteLonger.ToUniversalTime()))
            {
                _addCommand.absExpiration = 2;
            }
            else if (absoluteExpiration != Cache.NoAbsoluteExpiration)
            {
                _addCommand.absExpiration = absoluteExpiration.Ticks;
            }

            if (slidingExpiration.Equals(Cache.DefaultSliding))
            {
                _addCommand.sldExpiration = 1;
            }
            else if (slidingExpiration.Equals(Cache.DefaultSlidingLonger))
            {
                _addCommand.sldExpiration = 2;
            }
            else if (slidingExpiration != Cache.NoSlidingExpiration)
            {
                _addCommand.sldExpiration = slidingExpiration.Ticks;
            }

            UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(value);

            _addCommand.key = key;
            _addCommand.data.AddRange(ubObject.DataList);
            _addCommand.requestId        = base.RequestId;
            _addCommand.updateCallbackId = updateCallback;
            _addCommand.removeCallbackId = removeCallback;
            _addCommand.datasourceItemAddedCallbackId = dsItemAddedCallback;
            _addCommand.isAsync            = isAsync;
            _addCommand.priority           = (int)priority;
            _addCommand.isResync           = isResyncExpiredItems;
            _addCommand.flag               = flagMap.Data;
            _addCommand.providerName       = providerName;
            _addCommand.resyncProviderName = resyncProviderName;
            _addCommand.updateDataFilter   = (short)updateDataFilter;
            _addCommand.removeDataFilter   = (short)removeDataFilter;

            // Client ID: Must not have value except ClientCache.
            _addCommand.clientID = clientId;
            _methodOverload      = methodOverload;
        }
コード例 #14
0
 internal ItemRemovedEvent(string key, string cacheId, ItemRemoveReason reason, UserBinaryObject value, string clientId, BitSet Flag, EventContext eventContext)
 {
     _key          = key;
     _cacheId      = cacheId;
     _reason       = reason;
     _value        = value;
     _clientId     = clientId;
     _flag         = Flag;
     _eventContext = eventContext;
 }
コード例 #15
0
 internal ItemRemoveCallback(short id, string key, object value, ItemRemoveReason reason, string clientId, BitSet Flag, EventContext eventContext, EventDataFilter dataFilter)
 {
     _id           = id;
     _key          = key;
     _value        = value as UserBinaryObject;
     _flag         = Flag;
     _reason       = reason;
     _clientID     = clientId;
     _eventContext = eventContext;
     _dataFilter   = dataFilter;
 }
コード例 #16
0
        private object ConvertToUserObject(CompressedValueEntry cmpEntry)
        {
            if (cmpEntry.Value is UserBinaryObject)
            {
                UserBinaryObject ubObject = cmpEntry.Value as UserBinaryObject;
                cmpEntry.Value = ubObject.GetFullObject();
            }

            if (cmpEntry.Value is CallbackEntry)
            {
                CallbackEntry e = cmpEntry.Value as CallbackEntry;
                cmpEntry.Value = e.Value;
            }

            return(CompactBinaryFormatter.FromByteBuffer((byte[])cmpEntry.Value, CacheId));
        }
コード例 #17
0
 public WriteToStreamCommand(string key, string lockHandle, int srcOffset, int dstOffset, int length,
                             byte[] buffer)
 {
     base.name                        = "WriteToStreamCommand";
     _writeToStreamCommand            = new Alachisoft.NCache.Common.Protobuf.WriteToStreamCommand();
     _writeToStreamCommand.key        = key;
     _writeToStreamCommand.lockHandle = lockHandle;
     _writeToStreamCommand.srcOffSet  = srcOffset;
     _writeToStreamCommand.dstOffSet  = dstOffset;
     _writeToStreamCommand.length     = length;
     if (buffer != null)
     {
         UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(buffer);
         _writeToStreamCommand.buffer.AddRange(ubObject.DataList);
     }
 }
コード例 #18
0
        public InsertCommand(string key, byte[] value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short removeCallback, short updateCallback, Hashtable queryInfo, BitSet flagMap, object lockId, LockAccessType accessType, string cacheId, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter)
        {
            base.name = "InsertCommand";
            base.key  = key;

            _insertCommand     = new Alachisoft.NCache.Common.Protobuf.InsertCommand();
            _insertCommand.key = key;

            Alachisoft.NCache.Caching.UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(value);
            _insertCommand.data.AddRange(ubObject.DataList);

            _insertCommand.requestId        = base.RequestId;
            _insertCommand.removeCallbackId = removeCallback;
            _insertCommand.updateCallbackId = updateCallback;
            _insertCommand.updateDataFilter = (short)updateCallbackFilter;
            _insertCommand.removeDataFilter = (short)removeCallabackFilter;
            _insertCommand.priority         = (int)priority;
            _insertCommand.flag             = flagMap.Data;
            if (lockId != null)
            {
                _insertCommand.lockId = lockId.ToString();
            }
            _insertCommand.lockAccessType = (int)accessType;


            if (absoluteExpiration != Web.Caching.Cache.NoAbsoluteExpiration)
            {
                _insertCommand.absExpiration = absoluteExpiration.Ticks;
            }

            if (slidingExpiration != Web.Caching.Cache.NoSlidingExpiration)
            {
                _insertCommand.sldExpiration = slidingExpiration.Ticks;
            }



            ObjectQueryInfo objectQueryInfo = new ObjectQueryInfo();

            if (queryInfo["query-info"] != null)
            {
                objectQueryInfo.queryInfo = ProtobufHelper.GetQueryInfoObj(queryInfo["query-info"] as Hashtable);
            }

            _insertCommand.objectQueryInfo = objectQueryInfo;
        }
コード例 #19
0
ファイル: DatasourceMgr.cs プロジェクト: fabrimaciel/colosoft
 /// <summary>
 /// Método do processo da tarefa.
 /// </summary>
 public void Process()
 {
     lock (this)
     {
         try
         {
             if (_val == null)
             {
                 ProviderCacheItem item       = null;
                 CacheEntry        cacheEntry = null;
                 UserBinaryObject  obj2       = null;
                 try
                 {
                     _parent.ReadThru(_key, out item, _resyncProviderName);
                     obj2 = _parent.GetCacheEntry(_key, item, ref _flag, (_groupInfo != null) ? _groupInfo.Group : null, (_groupInfo != null) ? _groupInfo.SubGroup : null, out cacheEntry);
                 }
                 catch (Exception exception)
                 {
                     _val = exception;
                     _parent._context.Logger.Error(("DatasourceMgr.ResyncCacheItem: " + exception.StackTrace).GetFormatter());
                 }
                 if (!(_val is Exception) && (obj2 != null))
                 {
                     _parent._context.CacheImpl.Insert(_key, cacheEntry, true, null, 0, LockAccessType.IGNORE_LOCK, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));
                 }
                 else
                 {
                     _parent._context.CacheImpl.Remove(_key, ItemRemoveReason.Expired, true, null, 0, LockAccessType.IGNORE_LOCK, new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation));
                 }
             }
         }
         catch (Exception exception2)
         {
             _val = exception2;
             _parent._context.Logger.Error((exception2.Message + exception2.StackTrace).GetFormatter());
         }
         finally
         {
             _parent._queue.Remove(_key);
         }
     }
 }
コード例 #20
0
        internal static EventCacheItem ConvertToEventItem(EventCacheEntry entry, EventDataFilter?datafilter)
        {
            if (datafilter == EventDataFilter.None || entry == null)
            {
                return(null);
            }

            EventCacheItem cacheItem = new EventCacheItem();

            cacheItem.priority = (int)entry.Priority;

            UserBinaryObject userBinary = entry.Value as UserBinaryObject;

            if (userBinary == null)
            {
                if (entry.Value is CallbackEntry)
                {
                    userBinary = ((CallbackEntry)entry.Value).Value as UserBinaryObject;
                }
            }

            if (userBinary != null)
            {
                cacheItem.value.AddRange(userBinary.DataList);
            }

            //Can be optimized
            if (datafilter != null)
            {
                if (datafilter == EventDataFilter.None)
                {
                    return(null);
                }
                else if (datafilter == EventDataFilter.Metadata)
                {
                    cacheItem.value.Clear();
                }
            }

            return(cacheItem);
        }
コード例 #21
0
        /// <summary>
        /// Makes a key and data package form the keys and values of hashtable
        /// </summary>
        /// <param name="dic">Hashtable containing the keys and values to be packaged</param>
        /// <param name="keys">Contains packaged keys after execution</param>
        /// <param name="data">Contains packaged data after execution</param>
        /// <param name="currentContext">Current cache</param>
        internal static List <Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse> PackageKeysValues(IDictionary dic)
        {
            int estimatedSize = 0;
            List <Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse> ListOfKeyPackageResponse = new List <Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse>();

            if (dic != null && dic.Count > 0)
            {
                Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse keyPackageResponse = new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse();

                IDictionaryEnumerator enu = dic.GetEnumerator();
                while (enu.MoveNext())
                {
                    Alachisoft.NCache.Common.Protobuf.Value value = new Alachisoft.NCache.Common.Protobuf.Value();
                    UserBinaryObject ubObject = ((CompressedValueEntry)enu.Value).Value as UserBinaryObject;
                    value.data.AddRange(ubObject.DataList);
                    keyPackageResponse.keys.Add((string)enu.Key);
                    keyPackageResponse.flag.Add(((CompressedValueEntry)enu.Value).Flag.Data);
                    keyPackageResponse.values.Add(value);

                    estimatedSize = estimatedSize + ubObject.Size;

                    if (estimatedSize >= ServiceConfiguration.ResponseDataSize) //If size is greater than specified size then add it and create new chunck
                    {
                        ListOfKeyPackageResponse.Add(keyPackageResponse);
                        keyPackageResponse = new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse();
                        estimatedSize      = 0;
                    }
                }

                if (estimatedSize != 0)
                {
                    ListOfKeyPackageResponse.Add(keyPackageResponse);
                }
            }
            else
            {
                ListOfKeyPackageResponse.Add(new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse());
            }

            return(ListOfKeyPackageResponse);
        }
コード例 #22
0
ファイル: MiscUtil.cs プロジェクト: nonomal/NCache
        internal static bool ReturnUserBinaryObjectToPool(UserBinaryObject userBinaryObject, PoolManager poolManager)
        {
            if (poolManager == null || userBinaryObject == null || !userBinaryObject.FromPool(poolManager))
            {
                return(false);
            }

            userBinaryObject.ReturnLeasableToPool();

            if (userBinaryObject is SmallUserBinaryObject smallUserBinaryObject)
            {
                poolManager.GetSmallUserBinaryObjectPool().Return(smallUserBinaryObject);
            }

            else if (userBinaryObject is LargeUserBinaryObject largeUserBinaryObject)
            {
                poolManager.GetLargeUserBinaryObjectPool().Return(largeUserBinaryObject);
            }

            return(true);
        }
コード例 #23
0
        internal static EventCacheItem ConvertToEventEntry(Alachisoft.NCache.Common.Protobuf.EventCacheItem cacheItem)
        {
            Byte[] objectValue = null;

            if (cacheItem == null)
            {
                return(null);
            }

            EventCacheItem item = new EventCacheItem();

            item.CacheItemPriority = (CacheItemPriority)cacheItem.priority;
            if (cacheItem.value != null && cacheItem.value.Count > 0)
            {
                UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(cacheItem.value.ToArray());
                objectValue = ubObject.GetFullObject();
                item.Value  = objectValue;
            }

            return(item);
        }
コード例 #24
0
        internal static EventCacheItem ConvertToEventItem(EventCacheEntry entry, EventDataFilter?datafilter)
        {
            if (datafilter == EventDataFilter.None || entry == null)
            {
                return(null);
            }

            EventCacheItem cacheItem = new EventCacheItem();

            cacheItem.group    = entry.Group;
            cacheItem.subGroup = entry.SubGroup;

            cacheItem.itemVersion        = entry.Version;
            cacheItem.priority           = (int)entry.Priority;
            cacheItem.resyncExpiredItems = entry.ReSyncExpiredItems;
            cacheItem.resyncProviderName = entry.ReSyncProviderCacheItem;

            UserBinaryObject userBinary = getData(entry);

            if (userBinary != null)
            {
                cacheItem.value.AddRange(userBinary.DataList);
            }

            // Can be optimized
            if (datafilter != null)
            {
                if (datafilter == EventDataFilter.None)
                {
                    return(null);
                }
                else if (datafilter == EventDataFilter.Metadata)
                {
                    cacheItem.value.Clear();
                }
            }
            return(cacheItem);
        }
コード例 #25
0
ファイル: AddCommand.cs プロジェクト: nonomal/NCache
        public override string GetCommandParameters(out string commandName)
        {
            StringBuilder details = new StringBuilder();

            commandName = "Add";
            details.Append("Command Key: " + cmdInfo.Key);
            details.Append(" ; ");

            UserBinaryObject binaryObject = cmdInfo.value as UserBinaryObject;

            if (binaryObject != null)
            {
                details.Append("Command Value Size: " + binaryObject.Size);
            }
            else
            {
                details.Append("Command Value: " + cmdInfo.value);
            }

            if (cmdInfo.Flag != null)
            {
                details.Append(" ; ");
                if (cmdInfo.Flag.IsBitSet(BitSetConstants.WriteThru))
                {
                    details.Append("WriteThru: " + cmdInfo.Flag.IsBitSet(BitSetConstants.WriteThru) + " ; ");
                }
                if (cmdInfo.Flag.IsBitSet(BitSetConstants.WriteBehind))
                {
                    details.Append("WriteBehind: " + cmdInfo.Flag.IsBitSet(BitSetConstants.WriteBehind) + " ; ");
                }
            }

            if (cmdInfo.ExpirationHint != null)
            {
                details.Append("Dependency: " + cmdInfo.ExpirationHint.GetType().Name);
            }
            return(details.ToString());
        }
コード例 #26
0
        internal static ItemRemovedEventResponse GetItemRemovedEventResponse(EventContext eventContext, string key, EventDataFilter?datafilter, BitSet flag, ItemRemoveReason reason, UserBinaryObject value)
        {
            Alachisoft.NCache.Common.Protobuf.ItemRemovedEventResponse itemRemoved = new Alachisoft.NCache.Common.Protobuf.ItemRemovedEventResponse();

            itemRemoved.key = key;

            itemRemoved.itemRemoveReason = (int)reason;

            //value sent seperately to support old clients
            if (eventContext.Item != null && eventContext.Item.Value != null)
            {
                itemRemoved.flag = eventContext.Item.Flags.Data;
                UserBinaryObject ubObject = getData(eventContext.Item);
                if (ubObject != null)
                {
                    itemRemoved.value.AddRange(ubObject.DataList);
                }
            }

            itemRemoved.eventId = new Common.Protobuf.EventId();
            if (eventContext != null)
            {
                itemRemoved.eventId.eventUniqueId    = eventContext.EventID.EventUniqueID;
                itemRemoved.eventId.operationCounter = eventContext.EventID.OperationCounter;
                itemRemoved.eventId.eventCounter     = eventContext.EventID.EventCounter;

                itemRemoved.eventId.item = ConvertToEventItem(eventContext.Item, datafilter);

                if (itemRemoved.eventId.item != null && itemRemoved.eventId.item.value != null)
                {
                    //value sent seperately to support old clients
                    itemRemoved.eventId.item.value.Clear();
                }
            }

            return(itemRemoved);
        }
コード例 #27
0
        internal static EventCacheItem ConvertToEventItem(EventCacheEntry entry, EventDataFilter?datafilter)
        {
            if (datafilter == EventDataFilter.None || entry == null)
            {
                return(null);
            }

            EventCacheItem cacheItem = new EventCacheItem();

            cacheItem.group    = entry.Group;
            cacheItem.subGroup = entry.SubGroup;

            cacheItem.itemVersion        = entry.Version;
            cacheItem.priority           = (int)entry.Priority;
            cacheItem.resyncExpiredItems = entry.ReSyncExpiredItems;
            cacheItem.resyncProviderName = entry.ReSyncProviderCacheItem;

            UserBinaryObject userBinary = getData(entry);

            if (userBinary != null)
            {
                cacheItem.value.AddRange(userBinary.DataList);
            }

            cacheItem.itemType = Alachisoft.NCache.Util.MiscUtil.EntryTypeToProtoItemType(entry.EntryType);
            cacheItem.flagMap  = entry.Flags.Data;
            //Can be optimized
            if (datafilter != null)
            {
                if (datafilter == EventDataFilter.None)
                {
                    return(null);
                }
            }

            return(cacheItem);
        }
コード例 #28
0
        /// <summary>
        /// Makes a key and data package form the keys and values of hashtable
        /// </summary>
        /// <param name="dic">Hashtable containing the keys and values to be packaged</param>
        /// <param name="keys">Contains packaged keys after execution</param>
        /// <param name="data">Contains packaged data after execution</param>
        /// <param name="currentContext">Current cache</param>
        internal static Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse PackageKeysValues(IDictionary dic, Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse keyPackageResponse)
        {
            if (dic != null && dic.Count > 0)
            {
                if (keyPackageResponse == null)
                {
                    keyPackageResponse = new Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse();
                }
                ;

                IDictionaryEnumerator enu = dic.GetEnumerator();
                while (enu.MoveNext())
                {
                    keyPackageResponse.keys.Add((string)enu.Key);
                    keyPackageResponse.flag.Add(((CompressedValueEntry)enu.Value).Flag.Data);
                    UserBinaryObject ubObject = ((CompressedValueEntry)enu.Value).Value as UserBinaryObject;
                    Alachisoft.NCache.Common.Protobuf.Value value = new Alachisoft.NCache.Common.Protobuf.Value();
                    value.data.AddRange(ubObject.DataList);
                    keyPackageResponse.values.Add(value);
                }
            }

            return(keyPackageResponse);
        }
コード例 #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="command"></param>
        /// <param name="expHint"></param>
        /// <param name="beginQuoteIndex"></param>
        /// <param name="endQuoteIndex"></param>
        public ExpirationHint CreateDependencyFromString(ref string command, ref byte[] data, string cacheId, ref int beginQuoteIndex, ref int endQuoteIndex, bool isBulkOps, object items, ref int currentXtDep)
        {
            bool   isInner = false;
            string interimCommand = null;
            int    interimBeginIndex = 0, interimEndIndex = 0;

            ExpirationHint          expirationHint = null;
            AggregateExpirationHint aggregateExpiration = null;

            do
            {
                beginQuoteIndex += interimEndIndex;

                UpdateDelimIndexes(command, '\r', ref beginQuoteIndex, ref endQuoteIndex);
                if (endQuoteIndex < 0)
                {
                    break;
                }

                interimCommand = command.Substring(beginQuoteIndex + 1, endQuoteIndex - beginQuoteIndex - 1).Remove(0, 1);

                if (interimCommand == string.Empty)
                {
                    break;
                }
                if (interimCommand.StartsWith("\""))
                {
                    endQuoteIndex = beginQuoteIndex;
                    break;
                }

                interimBeginIndex = interimEndIndex = 0;

                if (interimCommand.StartsWith("INNER") && !isInner)
                {
                    isInner             = true;
                    aggregateExpiration = new AggregateExpirationHint();
                }
                else if (interimCommand.StartsWith("FILEDEPENDENCY")

                         || interimCommand.StartsWith("KEYDEPENDENCY")

                         )
                {
                    string    value = null;
                    DateTime  startAfter;
                    ArrayList list = new ArrayList();

                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    while (true)
                    {
                        UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);

                        value = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                        int valueBeginIndex = 0, valueEndIndex = 0;

                        if (value.Equals("STARTAFTER"))
                        {
                            UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                            startAfter = new DateTime(Convert.ToInt64(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1)));

                            interimBeginIndex += valueBeginIndex; interimEndIndex += valueEndIndex;

                            break;
                        }
                        else
                        {
                            list.Add(value);
                        }
                    }

                    if (interimCommand.StartsWith("KEYDEPENDENCY"))
                    {
                        expirationHint = new KeyDependency((string[])list.ToArray(typeof(string)), startAfter);
                    }
                    else
                    {
                        expirationHint = new FileDependency((string[])list.ToArray(typeof(string)), startAfter);
                    }
                }
                else if (interimCommand.StartsWith("EXTDEPENDENCY"))
                {
                    if (!isBulkOps)
                    {
                        UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                        UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                        int extensibleDepStartIndex = Convert.ToInt32(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                        UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                        int extensibleDepEndIndex = Convert.ToInt32(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                        byte[] value = null;
                        byte[] extensibleDependency = new byte[extensibleDepEndIndex - extensibleDepStartIndex];
                        value = new byte[extensibleDepStartIndex];

                        MemoryStream mStream = new MemoryStream(data);
                        mStream.Read(value, 0, extensibleDepStartIndex);
                        mStream.Read(extensibleDependency, 0, extensibleDepEndIndex - extensibleDepStartIndex);
                        mStream.Close();

                        data = value;

                        expirationHint = (ExtensibleDependency)Serialization.Formatters.CompactBinaryFormatter.FromByteBuffer(extensibleDependency, cacheId);
                    }
                    else
                    {
                        ArrayList        userItems  = items as ArrayList;
                        UserBinaryObject userBinObj = userItems[currentXtDep++] as UserBinaryObject;
                        if (userBinObj != null)
                        {
                            expirationHint = (ExtensibleDependency)Serialization.Formatters.CompactBinaryFormatter.FromByteBuffer(userBinObj.GetFullObject(), cacheId);
                        }
                    }
                }
                else if (interimCommand.StartsWith("SQL7DEPENDENCY")

                         || interimCommand.StartsWith("OLEDBDEPENDENCY")

                         )
                {
                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    string connectionString = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);

                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    string cacheKey = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);


                    if (interimCommand.StartsWith("OLEDBDEPENDENCY"))
                    {
                        expirationHint = new OleDbCacheDependency(connectionString, cacheKey);
                    }
                    else
                    {
                        expirationHint = new Sql7CacheDependency(connectionString, cacheKey);
                    }
                }
                else if (interimCommand.StartsWith("YUKONDEPENDENCY"))
                {
                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    string connectionString = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);

                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    string queryString = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);

                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    string      commandType = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                    CommandType cmdType     = (CommandType)Convert.ToInt32(commandType);

                    UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                    string cmdParamId = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);


                    if (interimCommand.StartsWith("ORACLEDEPENDENCY"))
                    {
                        Hashtable cmdParams = new Hashtable();
                        if (cmdParamId != string.Empty)
                        {
                            while (true)
                            {
                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                if (interimEndIndex == -1)
                                {
                                    break;
                                }
                                string key = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string type = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                Runtime.Dependencies.OracleCmdParamsType oracleType = (Runtime.Dependencies.OracleCmdParamsType)Convert.ToInt32(type);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                object value = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string direction = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                Runtime.Dependencies.OracleParameterDirection oracleParamDirection = (Runtime.Dependencies.OracleParameterDirection)Convert.ToInt32(direction);


                                OracleCommandParams oracleParams = new OracleCommandParams(oracleType, value, oracleParamDirection);
                                cmdParams.Add(key, oracleParams);
                            }
                        }
                        if (cmdParams.Count > 0)
                        {
                            expirationHint = new OracleCacheDependency(connectionString, queryString, cmdType, cmdParams);
                        }
                        else
                        {
                            expirationHint = new OracleCacheDependency(connectionString, queryString, cmdType, new Hashtable());
                        }
                    }
                    else
                    {
                        Hashtable cmdParams = new Hashtable();
                        if (cmdParamId != string.Empty)
                        {
                            while (true)
                            {
                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                if (interimEndIndex == -1)
                                {
                                    break;
                                }
                                string key = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string    type    = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                SqlDbType sqlType = (SqlDbType)Convert.ToInt32(type);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string             direction      = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                ParameterDirection paramDirection = (ParameterDirection)Convert.ToInt32(direction);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string dbtype = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                DbType dbType = (DbType)Convert.ToInt32(dbtype);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string            cmpOptions     = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                SqlCompareOptions compareOptions = (SqlCompareOptions)Convert.ToInt32(cmpOptions);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string         srcVer     = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                DataRowVersion srcVersion = (DataRowVersion)Convert.ToInt32(srcVer);

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                object value = interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1);
                                if (value.ToString() == "#")
                                {
                                    value = null;
                                }

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                bool isNullable = Convert.ToBoolean(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                int localeId = Convert.ToInt32(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                int offset = Convert.ToInt32(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                byte precision = Convert.ToByte(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                byte scale = Convert.ToByte(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                int size = Convert.ToInt32(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string sourceColumn = (interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));
                                if (sourceColumn == "#")
                                {
                                    sourceColumn = "";
                                }

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                bool sourceColumnNullMapping = Convert.ToBoolean(interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                object sqlValue = (interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));
                                if (sqlValue.ToString() == "#")
                                {
                                    sqlValue = null;
                                }

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string typeName = (interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));
                                if (typeName == "#")
                                {
                                    typeName = "";
                                }

                                UpdateDelimIndexes(interimCommand, '"', ref interimBeginIndex, ref interimEndIndex);
                                string udtTypeName = (interimCommand.Substring(interimBeginIndex + 1, interimEndIndex - interimBeginIndex - 1));
                                if (udtTypeName == "#")
                                {
                                    udtTypeName = "";
                                }

                                SqlCmdParams sqlParams = new SqlCmdParams(sqlType, value);
                                sqlParams.CmpInfo                 = compareOptions;
                                sqlParams.Direction               = paramDirection;
                                sqlParams.IsNullable              = isNullable;
                                sqlParams.LocaleID                = localeId;
                                sqlParams.Offset                  = offset;
                                sqlParams.Precision               = precision;
                                sqlParams.Scale                   = scale;
                                sqlParams.ParamSize               = size;
                                sqlParams.SourceColumn            = sourceColumn;
                                sqlParams.SourceColumnNullMapping = sourceColumnNullMapping;
                                sqlParams.SqlValue                = sqlValue;
                                sqlParams.SrcVersion              = srcVersion;
                                sqlParams.TypeName                = typeName;
                                sqlParams.UdtName                 = udtTypeName;
                                cmdParams.Add(key, sqlParams);
                            }
                        }

                        if (cmdParams.Count > 0)
                        {
                            expirationHint = new SqlYukonCacheDependency(connectionString, queryString, cmdType, cmdParams);
                        }
                        else
                        {
                            expirationHint = new SqlYukonCacheDependency(connectionString, queryString, cmdType, new Hashtable());
                        }
                    }
                }

                if (interimCommand != "INNER" && isInner && expirationHint != null)
                {
                    aggregateExpiration.Add(expirationHint);
                }
            } while (endQuoteIndex > -1);

            return(aggregateExpiration == null ? expirationHint : aggregateExpiration);
        }
コード例 #30
0
        public BulkInsertCommand(string[] keys, CacheItem[] items, short onDataSourceItemUpdateCallbackId, Cache parent, string providerName, bool encryption, string cacheId, int methodOverload, string clientId, short updateCallbackId, short removeCallbackId, EventDataFilter updateCallbackDataFilter, EventDataFilter removeCallbackDataFilter, CallbackType callbackType = Runtime.Events.CallbackType.PushBasedNotification)
        {
            base.name = "BulkInsertCommand";

            _parent            = parent;
            base.BulkKeys      = keys;
            _bulkInsertCommand = new Common.Protobuf.BulkInsertCommand();
            _bulkInsertCommand.datasourceUpdatedCallbackId = onDataSourceItemUpdateCallbackId;
            _bulkInsertCommand.providerName = providerName;
            _bulkInsertCommand.requestId    = base.RequestId;
            _methodOverload = methodOverload;
            short initialUpdateCallbackId = updateCallbackId;
            short initialRemoveCallBackId = removeCallbackId;

            for (int i = 0; i < keys.Length; i++)
            {
                CacheItem item = items[i];

                _insertCommand     = new Common.Protobuf.InsertCommand();
                _insertCommand.key = keys[i];

                UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject((byte[])item.GetValue <object>());
                _insertCommand.data.AddRange(ubObject.DataList);

                DateTime absExpiration = default(DateTime);
                if (item.Expiration.Absolute != Cache.NoAbsoluteExpiration)
                {
                    absExpiration = item.Expiration.Absolute.ToUniversalTime();
                }

                if (absExpiration.Equals(Cache.DefaultAbsolute.ToUniversalTime()))
                {
                    _insertCommand.absExpiration = 1;
                }
                else if (absExpiration.Equals(Cache.DefaultAbsoluteLonger.ToUniversalTime()))
                {
                    _insertCommand.absExpiration = 2;
                }
                else if (absExpiration != Cache.NoAbsoluteExpiration)
                {
                    _insertCommand.absExpiration = absExpiration.Ticks;
                }

                if (item.SlidingExpiration.Equals(Cache.DefaultSliding))
                {
                    _insertCommand.sldExpiration = 1;
                }
                else if (item.SlidingExpiration.Equals(Cache.DefaultSlidingLonger))
                {
                    _insertCommand.sldExpiration = 2;
                }
                else if (item.SlidingExpiration != Cache.NoSlidingExpiration)
                {
                    _insertCommand.sldExpiration = item.SlidingExpiration.Ticks;
                }

                _insertCommand.flag     = item.FlagMap.Data;
                _insertCommand.priority = (int)item.Priority;
                //_insertCommand.dependency = item.Dependency == null ? null : Common.Util.DependencyHelper.GetProtoBufDependency(item.Dependency);

                // Client ID: Must not have value except ClientCache.
                _insertCommand.clientID     = clientId;
                _insertCommand.CallbackType = CallbackType(callbackType);


                EventDataFilter itemUpdateDataFilter  = updateCallbackDataFilter;
                EventDataFilter itemRemovedDataFilter = removeCallbackDataFilter;

                if (removeCallbackId <= 0)
                {
                    if (item.CacheItemRemovedCallback != null)
                    {
                        itemRemovedDataFilter = item.ItemRemovedDataFilter;
                        short[] callabackIds = _parent.EventManager.RegisterSelectiveEvent(item.CacheItemRemovedCallback, EventTypeInternal.ItemRemoved, itemRemovedDataFilter, callbackType);
                        removeCallbackId = callabackIds[1];
                    }
                    else if (item.ItemRemoveCallback != null)
                    {
                        removeCallbackId      = _parent.GetCallbackId(item.ItemRemoveCallback);
                        itemRemovedDataFilter = EventDataFilter.None;
                    }
                }
                if (updateCallbackId <= 0)
                {
                    if (item.CacheItemUpdatedCallback != null)
                    {
                        itemUpdateDataFilter = item.ItemUpdatedDataFilter;
                        short[] callabackIds = _parent.EventManager.RegisterSelectiveEvent(item.CacheItemUpdatedCallback, EventTypeInternal.ItemUpdated, itemUpdateDataFilter, callbackType);
                        updateCallbackId = callabackIds[0];
                    }
                    else if (item.ItemUpdateCallback != null)
                    {
                        updateCallbackId     = _parent.GetCallbackId(item.ItemUpdateCallback);
                        itemUpdateDataFilter = EventDataFilter.None;
                    }
                }
                _insertCommand.removeCallbackId = removeCallbackId;
                _insertCommand.updateCallbackId = updateCallbackId;
                _insertCommand.updateDataFilter = (short)itemUpdateDataFilter;
                _insertCommand.removeDataFilter = (short)itemRemovedDataFilter;

                _bulkInsertCommand.insertCommand.Add(_insertCommand);
                updateCallbackId = initialUpdateCallbackId;
                removeCallbackId = initialRemoveCallBackId;
            }
        }