Example #1
0
        /// <summary>
        /// Makes a key and data package form the keys and values of hashtable, for bulk operations
        /// </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>
        internal static void PackageKeysExceptions(Hashtable dic, Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse keyExceptionPackage)
        {
            int errorCode = -1;

            if (dic != null && dic.Count > 0)
            {
                IDictionaryEnumerator enu = dic.GetEnumerator();
                while (enu.MoveNext())
                {
                    CacheException cacheException = enu.Value as CacheException;
                    if (cacheException != null)
                    {
                        errorCode = cacheException.ErrorCode;
                    }
                    Exception ex = enu.Value as Exception;

                    if (ex != null)
                    {
                        keyExceptionPackage.keys.Add((string)enu.Key);

                        Alachisoft.NCache.Common.Protobuf.Exception exc = new Alachisoft.NCache.Common.Protobuf.Exception();
                        exc.message   = ex.Message;
                        exc.exception = ex.ToString();
                        exc.type      = Alachisoft.NCache.Common.Protobuf.Exception.Type.GENERALFAILURE;
                        exc.errorCode = errorCode;
                        keyExceptionPackage.exceptions.Add(exc);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Package keys and values where values can be Exception or not. If they are no exception, currently,
        /// 0 bytes is returned
        /// </summary>
        /// <param name="dic"></param>
        /// <param name="keyPackage"></param>
        /// <param name="dataPackage"></param>
        internal static void PackageMisc(Hashtable dic, List <Alachisoft.NCache.Common.Protobuf.DSUpdatedCallbackResult> results)
        {
            if (dic != null && dic.Count > 0)
            {
                IDictionaryEnumerator enu = dic.GetEnumerator();

                while (enu.MoveNext())
                {
                    Common.Protobuf.DSUpdatedCallbackResult result = new Alachisoft.NCache.Common.Protobuf.DSUpdatedCallbackResult();
                    result.key = (string)enu.Key;

                    if (enu.Value is Exception)
                    {
                        result.success = false;

                        Common.Protobuf.Exception ex = new Alachisoft.NCache.Common.Protobuf.Exception();
                        ex.message   = ((Exception)enu.Value).Message;
                        ex.exception = ((Exception)enu.Value).ToString();
                        ex.type      = Alachisoft.NCache.Common.Protobuf.Exception.Type.GENERALFAILURE;

                        result.exception = ex;
                    }
                    else if (enu.Value is OperationResult.Status)
                    {
                        switch ((OperationResult.Status)enu.Value)
                        {
                        case OperationResult.Status.Success:
                            result.success = true;
                            break;

                        case OperationResult.Status.Failure:
                        case OperationResult.Status.FailureDontRemove:
                            result.success = false;
                            break;
                        }
                    }
                    results.Add(result);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Makes a key and data package form the keys and values of hashtable, for bulk operations
        /// </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>
        internal static void PackageKeysExceptions(Hashtable dic, Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse keyExceptionPackage)
        {
            if (dic != null && dic.Count > 0)
            {
                IDictionaryEnumerator enu = dic.GetEnumerator();
                while (enu.MoveNext())
                {
                    Exception ex = enu.Value as Exception;
                    if (ex != null)
                    {
                        keyExceptionPackage.keys.Add((string)enu.Key);

                        Alachisoft.NCache.Common.Protobuf.Exception exc = new Alachisoft.NCache.Common.Protobuf.Exception();
                        exc.message   = ex.Message;
                        exc.exception = ex.ToString();
                        exc.type      = Alachisoft.NCache.Common.Protobuf.Exception.Type.GENERALFAILURE;

                        keyExceptionPackage.exceptions.Add(exc);
                    }
                    // for DS write failed operations
                    if (enu.Value is OperationResult.Status)
                    {
                        OperationResult.Status status = (OperationResult.Status)enu.Value;
                        if (status == OperationResult.Status.Failure || status == OperationResult.Status.FailureDontRemove)
                        {
                            keyExceptionPackage.keys.Add((string)enu.Key);
                            Alachisoft.NCache.Common.Protobuf.Exception message = new Alachisoft.NCache.Common.Protobuf.Exception();
                            message.message   = enu.Value.ToString();
                            message.exception = enu.Value.ToString();
                            message.type      = Alachisoft.NCache.Common.Protobuf.Exception.Type.GENERALFAILURE;
                            keyExceptionPackage.exceptions.Add(message);
                        }
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Makes a key and data package form the keys and values of hashtable, for bulk operations
        /// </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>
        internal static void PackageKeysExceptions(Hashtable dic, Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse keyExceptionPackage)
        {
            if (dic != null && dic.Count > 0)
            {
                IDictionaryEnumerator enu = dic.GetEnumerator();
                while (enu.MoveNext())
                {
                    Exception ex = enu.Value as Exception;
                    if (ex != null)
                    {
                        keyExceptionPackage.keys.Add((string)enu.Key);

                        Alachisoft.NCache.Common.Protobuf.Exception exc = new Alachisoft.NCache.Common.Protobuf.Exception();
                        exc.message = ex.Message;
                        exc.exception = ex.ToString();
                        exc.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.GENERALFAILURE;

                        keyExceptionPackage.exceptions.Add(exc);
                    }
                }
            }
        }