Пример #1
0
            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;
            }
Пример #2
0
        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 async Task OpenAsync(CancellationToken cancellationToken)
        {
            CheckNotDisposed();

            await _transport.OpenAsync(cancellationToken).ConfigureAwait(false);
        }
Пример #4
0
        bool Init()
        {
            // Default to using binary protocol
            Func <TClientTransport, TProtocol> createProtocolFunc = (transport) => new TBinaryProtocolTS(transport);

            if (context.Transport == null)
            {
                if (context.endpoint == RuyiSDKContext.Endpoint.Web)
                {
                    lowLatencyTransport  = new THttpClientTransport(new Uri(context.RemoteAddress), null);
                    highLatencyTransport = lowLatencyTransport;
                    createProtocolFunc   = (transport) => new TJsonProtocol(transport);
                }
                else
                {
                    var host = OS.Util.GetIPAddress(context.RemoteAddress);
                    // init and open high/low latency transport, create protocols
                    var lowLatencyPort = context.LowLatencyPort == 0 ? ConstantsSDKDataTypesConstants.low_latency_socket_port : context.LowLatencyPort;
                    lowLatencyTransport = new TSocketTransportTS(host, lowLatencyPort, context.Timeout <= 0 ? SDKUtility.Instance.LowLatencyTimeout : context.Timeout);

                    var highLatencyPort = context.HighLatencyPort == 0 ? ConstantsSDKDataTypesConstants.high_latency_socket_port : context.HighLatencyPort;
                    highLatencyTransport = new TSocketTransportTS(host, highLatencyPort, context.Timeout <= 0 ? SDKUtility.Instance.HighLatencyTimeout : context.Timeout);
                }
            }
            else
            {
                lowLatencyTransport  = context.Transport;
                highLatencyTransport = context.Transport;
            }

            // If we have 1 transport we need 1 protocol, if 2 transports 2 protocol
            if (Object.ReferenceEquals(lowLatencyTransport, highLatencyTransport))
            {
                LowLatencyProtocol  = createProtocolFunc(lowLatencyTransport);
                HighLatencyProtocol = LowLatencyProtocol;
                lowLatencyTransport.OpenAsync().Wait();
            }
            else
            {
                LowLatencyProtocol  = createProtocolFunc(lowLatencyTransport);
                HighLatencyProtocol = createProtocolFunc(highLatencyTransport);

                Task.WaitAll(
                    lowLatencyTransport.OpenAsync(),
                    highLatencyTransport.OpenAsync()
                    );
            }

            if (!ValidateVersion())
            {
                return(false);
            }

            var pubout = ConstantsSDKDataTypesConstants.layer0_publisher_out_uri.SetAddress(context.RemoteAddress);

            factory = new Layer0.ZeroMQ.MDPSDKFactory(string.Empty, pubout);

            // init subscriber
            if (context.endpoint != RuyiSDKContext.Endpoint.Web && IsFeatureEnabled(SDKFeatures.Subscriber))
            {
                Subscriber = factory.CreateSubscriber();
            }

            // init storage layer
            if (IsFeatureEnabled(SDKFeatures.Storage))
            {
                var stoProtocol = new TMultiplexedProtocol(HighLatencyProtocol, ServiceIDs.STORAGELAYER.ServiceID());
                Storage = new StorageLayerService.Client(stoProtocol);
            }

            // init braincloud service
            if (IsFeatureEnabled(SDKFeatures.Online))
            {
                var bcProtocol = new TMultiplexedProtocol(HighLatencyProtocol, ServiceIDs.BCSERVICE.ServiceID());
                RuyiNetService = new RuyiNetClient(bcProtocol, Storage);
                //BCService = new BrainCloudService.Client(bcProtocal);
            }

            // init setting system
            if (IsFeatureEnabled(SDKFeatures.Settings))
            {
                var proto = new TMultiplexedProtocol(LowLatencyProtocol, ServiceIDs.SETTINGSYSTEM_EXTERNAL.ServiceID());
                SettingSys = new SDK.SettingSystem.Api.SettingSystemService.Client(proto);
            }

            // init L10N
            if (IsFeatureEnabled(SDKFeatures.L10N))
            {
                var proto = new TMultiplexedProtocol(LowLatencyProtocol, ServiceIDs.L10NSERVICE.ServiceID());
                L10NService = new LocalizationService.Client(proto);
            }

            // user manager
            if (IsFeatureEnabled(SDKFeatures.Users))
            {
                var proto = new TMultiplexedProtocol(HighLatencyProtocol, ServiceIDs.USER_SERVICE_EXTERNAL.ServiceID());
                UserService = new UserServExternal.Client(proto);
            }

            // input manger
            if (IsFeatureEnabled(SDKFeatures.Input))
            {
                var proto = new TMultiplexedProtocol(LowLatencyProtocol, ServiceIDs.INPUTMANAGER_EXTERNAL.ServiceID());
                InputMgr = new InputManagerService.Client(proto);
            }

            if (IsFeatureEnabled(SDKFeatures.Speech))
            {
                var proto = new TMultiplexedProtocol(HighLatencyProtocol, ServiceIDs.SPEECH.ServiceID());
                SpeechService = new SpeechService.Client(proto);
            }

            if (IsFeatureEnabled(SDKFeatures.Media))
            {
                var proto = new TMultiplexedProtocol(HighLatencyProtocol, ServiceIDs.MEDIA.ServiceID());
                Media = new MediaService.Client(proto);
            }
            if (IsFeatureEnabled(SDKFeatures.Overlay))
            {
                var proto = new TMultiplexedProtocol(LowLatencyProtocol, ServiceIDs.OVERLAYMANAGER_EXTERNAL.ServiceID());
                OverlayService = new ExternalOverlayManagerService.Client(proto);
            }
            return(true);
        }