public void Execute() { var token = CancellationToken.None; if (done) { Console.WriteLine("Execute called more than once"); throw new InvalidOperationException(); } for (var i = 0; i < numIterations; i++) { try { if (!transport.IsOpen) { transport.OpenAsync(token).GetAwaiter().GetResult(); } } catch (TTransportException ex) { Console.WriteLine("*** FAILED ***"); Console.WriteLine("Connect failed: " + ex.Message); ReturnCode |= ErrorUnknown; Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); continue; } catch (Exception ex) { Console.WriteLine("*** FAILED ***"); Console.WriteLine("Connect failed: " + ex.Message); ReturnCode |= ErrorUnknown; Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); continue; } try { ReturnCode |= ExecuteClientTestAsync(client).GetAwaiter().GetResult();; } catch (Exception ex) { Console.WriteLine("*** FAILED ***"); Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); ReturnCode |= ErrorUnknown; } } try { transport.Close(); } catch (Exception ex) { Console.WriteLine("Error while closing transport"); Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); } done = true; }
/// <summary> /// Dispose the SDK instance, don't miss this after SDK usage. /// </summary> public void Dispose() { Subscriber?.Dispose(); Subscriber = null; Storage?.Dispose(); Storage = null; RuyiNetService?.Dispose(); RuyiNetService = null; SettingSys?.Dispose(); SettingSys = null; L10NService?.Dispose(); L10NService = null; UserService?.Dispose(); UserService = null; InputMgr?.Dispose(); InputMgr = null; SpeechService?.Dispose(); SpeechService = null; Media?.Dispose(); Media = null; OverlayService?.Dispose(); OverlayService = null; lowLatencyTransport?.Close(); LowLatencyProtocol?.Dispose(); lowLatencyTransport = null; LowLatencyProtocol = null; highLatencyTransport?.Close(); HighLatencyProtocol?.Dispose(); HighLatencyProtocol = null; highLatencyTransport = null; InstanceCount--; if (InstanceCount <= 0) { factory.SDKCleanup(); } }
public async void HbaseRWAllTest() { var sth = new Stopwatch(); int perCount = 10000; int allCount = 0; await _clientTransport.OpenAsync(); sth.Start(); await DelectedTableTest(); Console.WriteLine($"{nameof(DelectedTableTest)},time: {sth.Elapsed}"); sth.Restart(); await CreateTableTest(); Console.WriteLine($"{nameof(CreateTableTest)},time: {sth.Elapsed}"); sth.Restart(); for (int i = 0; i < 1; i++) { await WriteWithMappingTest(allCount, perCount); allCount += perCount; } Console.WriteLine($"{nameof(WriteWithMappingTest)},count: {allCount}, time: {sth.Elapsed}"); sth.Restart(); await ReadWithMappingTest(allCount - 1); Console.WriteLine($"{nameof(ReadWithMappingTest)},count: 1, time: {sth.Elapsed}"); sth.Restart(); await ScanWithStartTest("8", allCount / 5); Console.WriteLine($"{nameof(ScanWithStartTest)},count: {allCount / 5}, time: {sth.Elapsed}"); sth.Restart(); await ScanWithStopTest("0", "3", 3 *allCount / 10); Console.WriteLine($"{nameof(ScanWithStopTest)},count: {3 * allCount / 10}, time: {sth.Elapsed}"); _clientTransport.Close(); }
public override void Close() { CheckNotDisposed(); _transport.Close(); }
private async Task Execute(TClientTransport client, CancellationToken cancellationToken) { Logger.LogTrace("Started client request processing"); var processor = ItProcessorFactory.GetAsyncProcessor(client, this); TClientTransport inputTransport = null; TClientTransport outputTransport = null; TProtocol inputProtocol = null; TProtocol outputProtocol = null; object connectionContext = null; try { inputTransport = InputTransportFactory.GetTransport(client); outputTransport = OutputTransportFactory.GetTransport(client); inputProtocol = InputProtocolFactory.GetProtocol(inputTransport); outputProtocol = OutputProtocolFactory.GetProtocol(outputTransport); if (ServerEventHandler != null) { connectionContext = await ServerEventHandler.CreateContextAsync(inputProtocol, outputProtocol, cancellationToken); } while (!cancellationToken.IsCancellationRequested) { if (!await inputTransport.PeekAsync(cancellationToken)) { break; } if (ServerEventHandler != null) { await ServerEventHandler.ProcessContextAsync(connectionContext, inputTransport, cancellationToken); } if (!await processor.ProcessAsync(inputProtocol, outputProtocol, cancellationToken)) { break; } } } catch (TTransportException ttx) { Logger.LogTrace($"Transport exception: {ttx}"); } catch (Exception x) { Logger.LogError($"Error: {x}"); } if (ServerEventHandler != null) { await ServerEventHandler.DeleteContextAsync(connectionContext, inputProtocol, outputProtocol, cancellationToken); } inputTransport?.Close(); outputTransport?.Close(); Logger.LogTrace("Completed client request processing"); }