コード例 #1
0
 /// <summary>
 /// Set Status of transfered bucket locally
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="buckets"></param>
 /// <param name="sparsed"></param>
 private void SetBucketStatus(NodeIdentity owner, ArrayList buckets)
 {
     if (this._dispatcher != null)
     {
         IStateTransferOperation operation = CreateStateTransferOperation(StateTransferOpCode.SetBucketStatus);
         operation.Params.SetParamValue(ParamName.BucketList, buckets);
         operation.Params.SetParamValue(ParamName.BucketStatus, BucketStatus.Functional);
         operation.Params.SetParamValue(ParamName.BucketFinalShard, owner);
         operation.Params.SetParamValue(ParamName.IsSource, true);
         _dispatcher.DispatchOperation <Object>(operation);
     }
 }
コード例 #2
0
        /// <summary>
        /// Dispacth operations to the Configuration Server if configuration operations,and pass to upper layer otherwise
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="operation"></param>
        /// <returns></returns>

        public T DispatchOperation <T>(IStateTransferOperation operation) where T : class
        {
            switch (operation.OpCode)
            {
            // Send lock buckets request to configuration server
            case StateTransferOpCode.LockBucketsOnCS:
            // Send release lock buckets request to configuration server
            case StateTransferOpCode.ReleaseBucketsOnCS:
            // Announce State Transfer on configuration server
            case StateTransferOpCode.AnnounceBucketTxfer:
            // check if specified bucket is spared
            case StateTransferOpCode.IsSparsedBucket:
            // Verify Bucket Ownership
            case StateTransferOpCode.VerifyFinalOwnerShip:
            // Finalize State Transfer
            case StateTransferOpCode.FinalizeStateTransfer:
                return(context.ConfigurationSession.StateTransferOperation(context.ClusterName, operation) as T);

            case StateTransferOpCode.StateTxferCompeleted:
                OnStateTxfrCompleted(operation);
                break;

            case StateTransferOpCode.StateTxferFailed:
                OnStateTxfrFailed(operation);
                break;

            case StateTransferOpCode.GetShardPrimary:
                return(GetShardPrimary(operation) as T);
            }

            // For Shard/Cluster Level Operations
            return(dispatcher.DispatchOperation <T>(operation));
        }
コード例 #3
0
        /// <summary>
        /// Dispacth operations to the underlying Database Manager if local operations,and pass to upper layer otherwise
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="operation"></param>
        /// <returns></returns>
        public T DispatchOperation <T>(IStateTransferOperation operation) where T : class
        {
            switch (operation.OpCode)
            {
            // Param should contain at least db plus collection name and bucket id
            case StateTransferOpCode.GetBucketKeysFilterEnumerator:
            //case StateTransferOpCode.GetLogTable:
            //case StateTransferOpCode.RemoveLoggedOperations:
            case StateTransferOpCode.EmptyBucket:
            //case StateTransferOpCode.StartBeforeOperationLogging:
            //case StateTransferOpCode.StopBeforeOperationLogging:
            case StateTransferOpCode.ApplyLogOperations:
            case StateTransferOpCode.SetBucketStatus:
            case StateTransferOpCode.GetBucketStats:
            case StateTransferOpCode.GetBucketKeys:
            {
                if (context != null && context.DatabasesManager != null)
                {
                    return(context.DatabasesManager.OnOperationRecieved(operation) as T);
                }
                return(default(T));
            }

            //If State Transfer for this Database has been compeleted then call node level manager for compeletion
            case StateTransferOpCode.StateTxferCompeleted:
            //If State Transfer for this Database has been stopped then call node level manager for compeletion
            case StateTransferOpCode.StateTxferFailed:
            {
                OnCollectionTaskEnd(operation);
                return(default(T));
            }

                ////If State Transfer for this Database has been stopped then call node level manager for compeletion
                //case StateTransferOpCode.StateTxferFailed:
                //    {
                //        if (OnStateTxfrFailed(operation)) break;
                //        return default(T);
                //    }
            }
            return((T)dispatcher.DispatchOperation <T>(operation));
        }