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


C# AsyncResult.Join方法代码示例

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


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

示例1: Fetch


//.........这里部分代码省略.........
                            }
                            catch (AggregateException aggregateException)
                            {
                                foreach (var exception in aggregateException.Flatten().InnerExceptions)
                                {
                                    Logging.TraceException(exception);
                                }

                                throw;
                            }
                            catch (Exception exception)
                            {
                                Logging.TraceException(exception);
                                throw;
                            }

                            return AsyncCallbackResult.Continue;
                        }))
                {
                    foreach (var tableItem in tablesToFetch)
                    {
                        var table = this.entityContext.GetTable(tableItem.Key.First, tableItem.Key.Second);
                        if (table == null)
                        {
                            throw new PersistenceException(
                                string.Format(CultureInfo.InvariantCulture, @"Table {0}/{1} does not exists", tableItem.Key.First.TrimEnd('/'), tableItem.Key.Second));
                        }

                        var scanSpec = tableItem.Value.CreateScanSpec();

                        if (reviewScanSpec != null)
                        {
                            reviewScanSpec(table, scanSpec);
                        }

                        //// TODO add more infos + time, other places???
                        Logging.TraceEvent(
                            TraceEventType.Verbose, () => string.Format(CultureInfo.InvariantCulture, @"Begin scan {0} on table {1}", scanSpec, table.Name));

                        table.BeginScan(asynResult, scanSpec, tableItem);
                    }

                    asynResult.Join();
                    if (asynResult.Error != null)
                    {
                        throw asynResult.Error;
                    }

                    foreach (var tableItem in tablesToFetch)
                    {
                        if (tableItem.Value.IsEmpty.IsFalse())
                        {
                            //// TODO remaining cells should be deleted
                        }
                    }
                }
            }
            else
            {
                foreach (var tableItem in tablesToFetch)
                {
                    var table = this.entityContext.GetTable(tableItem.Key.First, tableItem.Key.Second);
                    if (table == null)
                    {
                        throw new PersistenceException(
                            string.Format(CultureInfo.InvariantCulture, @"Table {0}/{1} does not exists", tableItem.Key.First.TrimEnd('/'), tableItem.Key.Second));
                    }

                    var scanSpec = tableItem.Value.CreateScanSpec();

                    if (reviewScanSpec != null)
                    {
                        reviewScanSpec(table, scanSpec);
                    }

                    //// TODO add/remove more infos + time, other places???
                    Logging.TraceEvent(
                        TraceEventType.Verbose, () => string.Format(CultureInfo.InvariantCulture, @"Scan {0} on table {1}", scanSpec, table.Name));

                    using (var scanner = table.CreateScanner(scanSpec))
                    {
                        Cell cell;
                        while (scanner.Next(out cell))
                        {
                            EntityScanTarget entityScanTarget;
                            if (tableItem.Value.TryRemoveScanTarget(cell.Key, out entityScanTarget))
                            {
                                var fetchedCell = new FetchedCell(cell, entityScanTarget);
                                entityFetched(ref fetchedCell);
                            }
                        }

                        if (tableItem.Value.IsEmpty.IsFalse())
                        {
                            //// TODO remaining cells should be deleted
                        }
                    }
                }
            }
        }
开发者ID:andysoftdev,项目名称:ht4o,代码行数:101,代码来源:EntityScanner.cs

示例2: ScanTableAccrossInstancesAsync

        public void ScanTableAccrossInstancesAsync()
        {
            if (IsThrift) {
                return; // TODO, check what is wrong
            }

            InitializeTableData(tableA);
            InitializeTableData(tableB);

            var c = 0;
            using (var asyncResult = new AsyncResult(
                (ctx, _cells) =>
                    {
                        foreach (var _cell in _cells) {
                            Assert.IsFalse(string.IsNullOrEmpty(_cell.Key.Row));
                            Interlocked.Increment(ref c);
                        }

                        return AsyncCallbackResult.Continue;
                    })) {
                tableA.BeginScan(asyncResult, new ScanSpec().AddColumn("a"));
                tableB.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }

            Assert.AreEqual(CountA + CountB, c);

            c = 0;
            using (var asyncResult = new AsyncResult(
                (ctx, _cells) =>
                    {
                        foreach (var _cell in _cells) {
                            Assert.IsFalse(string.IsNullOrEmpty(_cell.Key.Row));
                            Interlocked.Increment(ref c);
                        }

                        return AsyncCallbackResult.Continue;
                    })) {
                tableA.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                tableB.BeginScan(asyncResult, new ScanSpec().AddColumn("c"));
                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }

            Assert.AreEqual(CountB + CountC, c);
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:49,代码来源:TestMultipleInstances.cs

示例3: AsyncSetAccrossInstances

        public void AsyncSetAccrossInstances(MutatorSpec mutatorSpec)
        {
            if (IsThrift) {
                return; // TODO, check what is wrong
            }

            var key = new Key { ColumnFamily = "a" };
            using (var asyncResult = new AsyncResult()) {
                using (var mutatorA = tableA.CreateAsyncMutator(asyncResult, mutatorSpec))
                using (var mutatorB = tableB.CreateAsyncMutator(asyncResult, mutatorSpec)) {
                    for (var n = 0; n < CountA; ++n) {
                        key.Row = Guid.NewGuid().ToString();
                        mutatorA.Set(key, Encoding.GetBytes(key.Row));
                        key.Row = Guid.NewGuid().ToString();
                        mutatorB.Set(key, Encoding.GetBytes(key.Row));
                    }
                }

                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
                Assert.AreEqual(CountA, GetCellCount(tableA));
                Assert.AreEqual(CountA, GetCellCount(tableB));
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:25,代码来源:TestMultipleInstances.cs

示例4: ScanTableMaxRowsAsync

        public void ScanTableMaxRowsAsync()
        {
            if (!HasAsyncTableScanner) {
                return;
            }

            var c = 0;
            using (var asyncResult = new AsyncResult(
                (ctx, cells) =>
                    {
                        foreach (var cell in cells) {
                            Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                            ++c;
                        }

                        return AsyncCallbackResult.Continue;
                    })) {
                table.BeginScan(asyncResult, new ScanSpec { MaxRows = CountC }.AddColumn("a"));
                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }

            Assert.AreEqual(CountC, c);

            c = 0;
            using (var asyncResult = new AsyncResult(
                (ctx, cells) =>
                    {
                        foreach (var cell in cells) {
                            Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                            ++c;
                        }

                        return AsyncCallbackResult.Continue;
                    })) {
                table.BeginScan(asyncResult, new ScanSpec { MaxRows = CountB }.AddColumn("a"));
                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }

            Assert.AreEqual(CountB, c);
        }
开发者ID:bfmw,项目名称:ht4n,代码行数:44,代码来源:TestAsyncTableScanner.cs

示例5: AsyncSetCollectionDifferentSizedValues

        public void AsyncSetCollectionDifferentSizedValues(MutatorSpec mutatorSpec)
        {
            if (!HasAsyncTableMutator) {
                return;
            }

            var sb = new StringBuilder();
            for (var n = 0; n < 0x40; ++n) {
                sb.Append(Guid.NewGuid().ToString());
            }

            var largeValue = Encoding.GetBytes(sb.ToString());
            for (var n = 0; n < 0x4000; ++n) {
                sb.Append(Guid.NewGuid().ToString());
            }

            var hugeValue = Encoding.GetBytes(sb.ToString());
            var smallValue = Encoding.GetBytes(Guid.NewGuid().ToString());

            var key = new Key { ColumnFamily = "a" };
            var cells = new List<Cell> {
                    new Cell(key.Clone() as Key, smallValue),
                    new Cell(key.Clone() as Key, null),
                    new Cell(key.Clone() as Key, smallValue),
                    new Cell(key.Clone() as Key, largeValue),
                    new Cell(key.Clone() as Key, null),
                    new Cell(key.Clone() as Key, smallValue),
                    new Cell(key.Clone() as Key, largeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, null),
                    new Cell(key.Clone() as Key, smallValue),
                    new Cell(key.Clone() as Key, largeValue)
                };

            using (var asyncResult = new AsyncResult()) {
                using (var mutator = table.CreateAsyncMutator(asyncResult, mutatorSpec)) {
                    mutator.Set(cells, true);
                }

                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
                foreach (var cell in cells) {
                    Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                }
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:47,代码来源:TestAsyncTableMutator.cs

示例6: ScanTableCancelAsync

        public void ScanTableCancelAsync()
        {
            if (!HasAsyncTableScanner) {
                return;
            }

            for (var r = 0; r < 5; ++r) {
                var c = 0;
                using (var asyncResult = new AsyncResult(
                    (ctx, cells) =>
                        {
                            foreach (var cell in cells) {
                                if (c == CountA) {
                                    return AsyncCallbackResult.Abort;
                                }

                                ++c;
                            }

                            return AsyncCallbackResult.Continue;
                        })) {
                    table.BeginScan(asyncResult);
                    asyncResult.Join();
                    Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                    Assert.IsTrue(asyncResult.IsCompleted);
                    Assert.IsTrue(asyncResult.IsCancelled);
                    Assert.AreEqual(CountA, c);

                    // The official Hypertable version does not support re-using of the future object using the thrift API
                    if (!IsThrift) {
                        c = 0;
                        table.BeginScan(
                            asyncResult,
                            (ctx, cells) =>
                                {
                                    c += cells.Count;
                                    return AsyncCallbackResult.Continue;
                                });
                        Assert.IsFalse(asyncResult.IsCompleted);
                        Assert.IsFalse(asyncResult.IsCancelled);
                        asyncResult.Join();
                        Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                        Assert.IsTrue(asyncResult.IsCompleted);
                        Assert.IsFalse(asyncResult.IsCancelled);
                        Assert.AreEqual(CountA + CountB + CountC, c);
                    }
                }

                using (var asyncResult = new AsyncResult(delegate { return AsyncCallbackResult.Continue; })) {
                    table.BeginScan(asyncResult);
                    Thread.Sleep(500);
                    asyncResult.Cancel();
                    Assert.IsTrue(asyncResult.IsCancelled);

                    // The official Hypertable version does not support re-using of the future object using the thrift API
                    if (!IsThrift) {
                        c = 0;
                        table.BeginScan(
                            asyncResult,
                            (ctx, cells) =>
                                {
                                    c += cells.Count;
                                    return AsyncCallbackResult.Continue;
                                });
                        Assert.IsFalse(asyncResult.IsCancelled);
                        asyncResult.Join();
                        Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                        Assert.IsTrue(asyncResult.IsCompleted);
                        Assert.IsFalse(asyncResult.IsCancelled);
                        Assert.AreEqual(CountA + CountB + CountC, c);
                    }
                }
            }
        }
开发者ID:bfmw,项目名称:ht4n,代码行数:74,代码来源:TestAsyncTableScanner.cs

示例7: ScanTableDifferentContextAsync

        public void ScanTableDifferentContextAsync()
        {
            if (!HasAsyncTableScanner) {
                return;
            }

            if (!IsHyper && !IsThrift) {
                Assert.Fail("Check implementation below for the new provider {0}", ProviderName);
            }

            var properties = new Dictionary<string, object> { { "Provider", IsHyper ? "Thrift" : "Hyper" } };
            var nsOtherName = NsName + "/other";
            using (var ctx = Hypertable.Context.Create(ConnectionString, properties))
            using (var client = ctx.CreateClient()) {
                try {
                    using (var nsOther = client.OpenNamespace(nsOtherName, OpenDispositions.OpenAlways))
                    using (var tableOther = nsOther.OpenTable("ScanTableDifferentContextAsync", Schema, OpenDispositions.CreateAlways)) {
                        InitializeTableData(tableOther);

                        var c = 0;
                        using (var asyncResult = new AsyncResult(
                            (_ctx, cells) =>
                                {
                                    foreach (var cell in cells) {
                                        Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                                        Interlocked.Increment(ref c);
                                    }

                                    return AsyncCallbackResult.Continue;
                                })) {
                            table.BeginScan(asyncResult, new ScanSpec().AddColumn("a"));
                            tableOther.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                            asyncResult.Join();
                            Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                            Assert.IsTrue(asyncResult.IsCompleted);
                        }

                        Assert.AreEqual(CountA + CountB, c);

                        c = 0;
                        using (var asyncResult = new AsyncResult(
                            (_ctx, cells) =>
                                {
                                    foreach (var cell in cells) {
                                        Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                                        Interlocked.Increment(ref c);
                                    }

                                    return AsyncCallbackResult.Continue;
                                })) {
                            table.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                            tableOther.BeginScan(asyncResult, new ScanSpec().AddColumn("a"));
                            asyncResult.Join();
                            Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                            Assert.IsTrue(asyncResult.IsCompleted);
                        }

                        Assert.AreEqual(CountB + CountA, c);
                    }
                }
                finally {
                    client.DropNamespace(nsOtherName, DropDispositions.Complete);
                }
            }
        }
开发者ID:bfmw,项目名称:ht4n,代码行数:65,代码来源:TestAsyncTableScanner.cs

示例8: AsyncSetThreaded

        public void AsyncSetThreaded(MutatorSpec mutatorSpec)
        {
            if (!HasAsyncTableMutator) {
                return;
            }

            var key = new Key { ColumnFamily = "a" };
            using (var asyncResult = new AsyncResult()) {
                using (var mutator = table.CreateAsyncMutator(asyncResult, mutatorSpec)) {
                    var c1 = 0;
                    var c2 = 0;

                    var t1 = new Thread(
                        () =>
                            {
                                for (var n = 0; n < Count; ++n, ++c1) {
                                    key.Row = Guid.NewGuid().ToString();
                                    mutator.Set(key, Encoding.GetBytes(key.Row));
                                }
                            });

                    var t2 = new Thread(
                        () =>
                            {
                                for (var n = 0; n < Count; ++n, ++c2) {
                                    key.Row = Guid.NewGuid().ToString();
                                    mutator.Set(key, Encoding.GetBytes(key.Row));
                                }
                            });

                    t1.Start();
                    t2.Start();
                    t1.Join();
                    t2.Join();
                    Assert.IsTrue(c1 > 0);
                    Assert.IsTrue(c2 > 0);
                }

                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:43,代码来源:TestAsyncTableMutator.cs

示例9: Unsupported

        public void Unsupported()
        {
            if (HasAsyncTableMutator) {
                return;
            }

            try {
                using (var asyncResult = new AsyncResult()) {
                    using (table.CreateAsyncMutator(asyncResult, null)) {
                    }

                    asyncResult.Join();
                }
            }
            catch (NotImplementedException) {
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:17,代码来源:TestAsyncTableMutator.cs

示例10: AsyncSetDifferentContext

        public void AsyncSetDifferentContext(MutatorSpec mutatorSpec)
        {
            if (!HasAsyncTableMutator) {
                return;
            }

            if (!IsHyper && !IsThrift) {
                Assert.Fail("Check implementation below for the new provider {0}", ProviderName);
            }

            var properties = new Dictionary<string, object> { { "Provider", IsHyper ? "Thrift" : "Hyper" } };

            using (var ctx = Hypertable.Context.Create(ConnectionString, properties))
            using (var client = ctx.CreateClient()) {
                var nsNameOther = NsName + "/other";
                try {
                    using (var nsOther = client.OpenNamespace(nsNameOther, OpenDispositions.OpenAlways))
                    using (var tableOther = nsOther.OpenTable("AsyncSetDifferentContext", Schema, OpenDispositions.CreateAlways)) {
                        var key = new Key { ColumnFamily = "a" };
                        using (var asyncResult = new AsyncResult()) {
                            using (var mutator = table.CreateAsyncMutator(asyncResult, mutatorSpec))
                            using (var mutatorOther = tableOther.CreateAsyncMutator(asyncResult, mutatorSpec)) {
                                for (var n = 0; n < Count; ++n) {
                                    key.Row = Guid.NewGuid().ToString();
                                    mutator.Set(key, Encoding.GetBytes(key.Row));
                                    key.Row = Guid.NewGuid().ToString();
                                    mutatorOther.Set(key, Encoding.GetBytes(key.Row));
                                }
                            }

                            asyncResult.Join();
                            Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                            Assert.IsTrue(asyncResult.IsCompleted);
                            Assert.AreEqual(Count, this.GetCellCount());
                            Assert.AreEqual(Count, GetCellCount(tableOther));
                        }
                    }
                }
                finally {
                    client.DropNamespace(nsNameOther, DropDispositions.Complete);
                }
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:43,代码来源:TestAsyncTableMutator.cs

示例11: AsyncSetMultipleTables

        public void AsyncSetMultipleTables(MutatorSpec mutatorSpec)
        {
            if (!HasAsyncTableMutator) {
                return;
            }

            const int CountTables = 10;
            var tables = new List<ITable>();
            try {
                for (var t = 0; t < CountTables; ++t) {
                    var table2 = EnsureTable(string.Format("AsyncSetMultipleTables-{0}", t), Schema);
                    tables.Add(table2);
                }

                var key = new Key { ColumnFamily = "a" };
                using (var asyncResult = new AsyncResult()) {
                    var mutators = new List<ITableMutator>();
                    try {
                        tables.ForEach(t => mutators.Add(t.CreateAsyncMutator(asyncResult, mutatorSpec)));
                        for (var n = 0; n < Count; ++n) {
                            mutators.ForEach(m => m.Set(key, Encoding.GetBytes(key.Row = Guid.NewGuid().ToString())));
                        }

                        asyncResult.Join();
                        Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                        Assert.IsTrue(asyncResult.IsCompleted);
                        tables.ForEach(t => Assert.AreEqual(Count, GetCellCount(t)));
                    }
                    finally {
                        mutators.ForEach(m => m.Dispose());
                    }
                }
            }
            finally {
                tables.ForEach(t => t.Dispose());
                for (var t = 0; t < CountTables; ++t) {
                    Ns.DropTable(string.Format("AsyncSetMultipleTables-{0}", t), DropDispositions.IfExists);
                }
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:40,代码来源:TestAsyncTableMutator.cs

示例12: AsyncSetCreateKeyLazy

        public void AsyncSetCreateKeyLazy(MutatorSpec mutatorSpec)
        {
            if (!HasAsyncTableMutator) {
                return;
            }

            using (var asyncResult = new AsyncResult()) {
                using (var mutator = table.CreateAsyncMutator(asyncResult, mutatorSpec)) {
                    for (var n = 0; n < Count; ++n) {
                        var key = new Key { ColumnFamily = "b" };
                        mutator.Set(key, Encoding.GetBytes(Guid.NewGuid().ToString()));
                        Assert.IsFalse(string.IsNullOrEmpty(key.Row));
                    }
                }

                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
                Assert.AreEqual(Count, this.GetCellCount());
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:21,代码来源:TestAsyncTableMutator.cs

示例13: AsyncSetCollectionThreaded

        public void AsyncSetCollectionThreaded(MutatorSpec mutatorSpec)
        {
            if (!HasAsyncTableMutator) {
                return;
            }

            var key = new Key { ColumnFamily = "a" };
            var cells1 = new List<Cell>();
            for (var n = 0; n < 16; ++n) {
                cells1.Add(new Cell(key.Clone() as Key, Encoding.GetBytes(Guid.NewGuid().ToString())));
            }

            var cells2 = new List<Cell>();
            for (var n = 0; n < 16; ++n) {
                cells2.Add(new Cell(key.Clone() as Key, Encoding.GetBytes(Guid.NewGuid().ToString())));
            }

            using (var asyncResult = new AsyncResult()) {
                using (var mutator = table.CreateAsyncMutator(asyncResult, mutatorSpec)) {
                    var c1 = 0;
                    var c2 = 0;

                    var t1 = new Thread(
                        () =>
                            {
                                for (var n = 0; n < Count; ++n, ++c1) {
                                    mutator.Set(cells1, true);
                                    if (n == Count / 2) {
                                        mutator.Flush();
                                    }
                                }
                            });

                    var t2 = new Thread(
                        () =>
                            {
                                for (var n = 0; n < Count; ++n, ++c2) {
                                    mutator.Set(cells2, true);
                                    if (n == Count / 2) {
                                        mutator.Flush();
                                    }
                                }
                            });

                    t1.Start();
                    t2.Start();
                    t1.Join();
                    t2.Join();
                    Assert.IsTrue(c1 > 0);
                    Assert.IsTrue(c2 > 0);
                }

                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:57,代码来源:TestAsyncTableMutator.cs

示例14: AsyncSetCollectionHugeValues

        public void AsyncSetCollectionHugeValues(MutatorSpec mutatorSpec)
        {
            if (!HasAsyncTableMutator) {
                return;
            }

            const int K = 1024;
            const int M = K * K;
            var hugeValue = new byte[M];
            new Random().NextBytes(hugeValue);

            var key = new Key { ColumnFamily = "a" };
            var cells = new List<Cell> {
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue),
                    new Cell(key.Clone() as Key, hugeValue)
                };

            using (var asyncResult = new AsyncResult()) {
                using (var mutator = table.CreateAsyncMutator(asyncResult, mutatorSpec)) {
                    mutator.Set(cells, true);
                }

                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
                foreach (var cell in cells) {
                    Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                }
            }
        }
开发者ID:andysoftdev,项目名称:ht4n,代码行数:39,代码来源:TestAsyncTableMutator.cs

示例15: ScanMultipleTableColumnFamilyAsync

        public void ScanMultipleTableColumnFamilyAsync()
        {
            if (!HasAsyncTableScanner) {
                return;
            }

            using (var table2 = EnsureTable("ScanMultipleTableColumnFamilyAsync", Schema)) {
                InitializeTableData(table2);

                var c = 0;
                using (var asyncResult = new AsyncResult(
                    (ctx, cells) =>
                        {
                            foreach (var cell in cells) {
                                Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                                Interlocked.Increment(ref c);
                            }

                            return AsyncCallbackResult.Continue;
                        })) {
                    table.BeginScan(asyncResult, new ScanSpec().AddColumn("a"));
                    table2.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                    asyncResult.Join();
                    Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                    Assert.IsTrue(asyncResult.IsCompleted);
                }

                Assert.AreEqual(CountA + CountB, c);

                c = 0;
                using (var asyncResult = new AsyncResult(
                    (ctx, cells) =>
                        {
                            foreach (var cell in cells) {
                                Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                                Interlocked.Increment(ref c);
                            }

                            return AsyncCallbackResult.Continue;
                        })) {
                    table2.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                    table.BeginScan(asyncResult, new ScanSpec().AddColumn("c"));
                    asyncResult.Join();
                    Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                    Assert.IsTrue(asyncResult.IsCompleted);
                }

                Assert.AreEqual(CountB + CountC, c);
            }
        }
开发者ID:bfmw,项目名称:ht4n,代码行数:50,代码来源:TestAsyncTableScanner.cs


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