当前位置: 首页>>代码示例>>C#>>正文


C# IStoreTransactionScope.ExecuteCommandBatch方法代码示例

本文整理汇总了C#中IStoreTransactionScope.ExecuteCommandBatch方法的典型用法代码示例。如果您正苦于以下问题:C# IStoreTransactionScope.ExecuteCommandBatch方法的具体用法?C# IStoreTransactionScope.ExecuteCommandBatch怎么用?C# IStoreTransactionScope.ExecuteCommandBatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IStoreTransactionScope的用法示例。


在下文中一共展示了IStoreTransactionScope.ExecuteCommandBatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoLocalExecute

        /// <summary>
        /// Execute the operation against LSM in the current transaction scope.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>
        /// Results of the operation.
        /// </returns>
        public override IStoreResults DoLocalExecute(IStoreTransactionScope ts)
        {
            TraceHelper.Tracer.TraceInfo(
                TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                this.OperationName,
                "Started upgrading Local Shard Map structures at location {0}", base.Location);

            Stopwatch stopwatch = Stopwatch.StartNew();

            IStoreResults checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsLocalScript.Single());
            if (checkResult.StoreVersion == null)
            {
                // DEVNOTE(apurvs): do we want to throw here if LSM is not already deployed?
                // deploy initial version of LSM, if not found.
                ts.ExecuteCommandBatch(SqlUtils.CreateLocalScript);
            }

            if (checkResult.StoreVersion == null || checkResult.StoreVersion.Version < _targetVersion)
            {
                if (checkResult.StoreVersion == null)
                    ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeLocalScript, _targetVersion));
                else
                    ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeLocalScript, _targetVersion, checkResult.StoreVersion.Version));

                // Read LSM version again after upgrade.
                checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsLocalScript.Single());

                stopwatch.Stop();

                TraceHelper.Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                    this.OperationName,
                    "Finished upgrading store at location {0}. Duration: {1}",
                    base.Location,
                    stopwatch.Elapsed);
            }
            else
            {
                TraceHelper.Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                    this.OperationName,
                    "Local Shard Map at location {0} has version {1} equal to or higher than Client library version {2}, skipping upgrade.",
                    base.Location,
                    checkResult.StoreVersion,
                    GlobalConstants.GsmVersionClient);
            }

            return checkResult;
        }
开发者ID:CrossPoint,项目名称:elastic-db-tools,代码行数:56,代码来源:UpgradeStoreLocalOperation.cs

示例2: DoGlobalExecute

        /// <summary>
        /// Execute the operation against GSM in the current transaction scope.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>
        /// Results of the operation.
        /// </returns>
        public override IStoreResults DoGlobalExecute(IStoreTransactionScope ts)
        {
            TraceHelper.Tracer.TraceInfo(
                TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                this.OperationName,
                "Started upgrading Global Shard Map structures.");

            IStoreResults checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsGlobalScript.Single());

            Debug.Assert(checkResult.StoreVersion != null, "GSM store structures not found.");

            if (checkResult.StoreVersion.Version < _targetVersion)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();

                ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeGlobalScript, _targetVersion, checkResult.StoreVersion.Version));

                // read GSM version after upgrade.
                checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsGlobalScript.Single());

                // DEVNOTE(apurvs): verify (checkResult.StoreVersion == GlobalConstants.GsmVersionClient) and throw on failure.

                stopwatch.Stop();

                TraceHelper.Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                    this.OperationName,
                    "Finished upgrading Global Shard Map. Duration: {0}",
                    stopwatch.Elapsed);
            }
            else
            {
                TraceHelper.Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                    this.OperationName,
                    "Global Shard Map is at a version {0} equal to or higher than Client library version {1}, skipping upgrade.",
                    (checkResult.StoreVersion == null) ? "" : checkResult.StoreVersion.Version.ToString(),
                    GlobalConstants.GsmVersionClient);
            }

            return checkResult;
        }
开发者ID:CrossPoint,项目名称:elastic-db-tools,代码行数:49,代码来源:UpgradeStoreGlobalOperation.cs

示例3: DoLocalSourceExecute

        /// <summary>
        /// Performs the LSM operation on the source shard.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>Result of the operation.</returns>
        public override IStoreResults DoLocalSourceExecute(IStoreTransactionScope ts)
        {
            IStoreResults checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsLocalScript.Single());

            // Shard not already deployed, just need to add the proper entries.
            if (checkResult.StoreVersion == null)
            {
                // create initial version of LSM
                ts.ExecuteCommandBatch(SqlUtils.CreateLocalScript);

                // now upgrade LSM to latest version
                ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeLocalScript, GlobalConstants.LsmVersionClient));
            }

            // Now actually add the shard entries.
            return ts.ExecuteOperation(
                StoreOperationRequestBuilder.SpAddShardLocal,
                StoreOperationRequestBuilder.AddShardLocal(this.Id, false, _shardMap, _shard));
        }
开发者ID:CrossPoint,项目名称:elastic-db-tools,代码行数:24,代码来源:AddShardOperation.cs

示例4: DoGlobalExecute

        /// <summary>
        /// Execute the operation against GSM in the current transaction scope.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>
        /// Results of the operation.
        /// </returns>
        public override IStoreResults DoGlobalExecute(IStoreTransactionScope ts)
        {
            DateTime createStartTime = DateTime.UtcNow;

            TraceHelper.Tracer.TraceInfo(
                TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                this.OperationName,
                "Started creating Global Shard Map structures.");

            IStoreResults checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsGlobalScript.Single());

            // If we did find some store deployed.
            if (checkResult.StoreVersion != null)
            {
                // DEVNOTE(wbasheer): We need to have a way of erroring out if versions do not match.
                if (_createMode == ShardMapManagerCreateMode.KeepExisting)
                {
                    throw new ShardManagementException(
                        ShardManagementErrorCategory.ShardMapManagerFactory,
                        ShardManagementErrorCode.ShardMapManagerStoreAlreadyExists,
                        Errors._Store_ShardMapManager_AlreadyExistsGlobal);
                }

                TraceHelper.Tracer.TraceVerbose(
                    TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                    this.OperationName,
                    "Dropping existing Global Shard Map structures.");

                ts.ExecuteCommandBatch(SqlUtils.DropGlobalScript);
            }

            // Deploy initial version and run upgrade script to bring it to the specified version.
            ts.ExecuteCommandBatch(SqlUtils.CreateGlobalScript);

            ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeGlobalScript, _targetVersion));

            TraceHelper.Tracer.TraceInfo(
                TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                this.OperationName,
                "Finished creating Global Shard Map structures. Duration: {0}",
                DateTime.UtcNow - createStartTime);

            return new SqlResults();
        }
开发者ID:edtbot,项目名称:elastic-db-tools,代码行数:51,代码来源:CreateShardMapManagerGlobalOperation.cs

示例5: DoLocalSourceExecute

        /// <summary>
        /// Performs the LSM operation on the source shard.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>Result of the operation.</returns>
        public override IStoreResults DoLocalSourceExecute(IStoreTransactionScope ts)
        {
            // There should already be some version of LSM at this location as RecoveryMAnager.AttachShard() first reads existing shard maps from this location.

            IStoreResults checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsLocalScript.Single());
            Debug.Assert(checkResult.StoreVersion != null);

            // Upgrade local shard map to latest version before attaching.
            ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeLocalScript, GlobalConstants.LsmVersionClient, checkResult.StoreVersion.Version));

            // Now update the shards table in LSM.
            return ts.ExecuteOperation(
                StoreOperationRequestBuilder.SpUpdateShardLocal,
                StoreOperationRequestBuilder.UpdateShardLocal(this.Id, _shardMap, _shard));
        }
开发者ID:xdansmith,项目名称:elastic-db-tools,代码行数:20,代码来源:AttachShardOperation.cs


注:本文中的IStoreTransactionScope.ExecuteCommandBatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。