Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 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(Hashtable 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;
        }
Ejemplo n.º 6
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(Hashtable 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 >= SocketServer.CHUNK_SIZE_FOR_OBJECT) //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;
        }