예제 #1
0
        private HBaseClient GetClient()
        {
            _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt");
            var options = RequestOptions.GetDefaultOptions();

            options.RetryPolicy = Policy.Handle <HttpRequestException>().WaitAndRetryAsync(0, x => TimeSpan.Zero);

            var client = new HBaseClient(_credentials, options);

            #region VNet

            //options.TimeoutMillis = 30000;
            //options.KeepAlive = false;
            //options.Port = 8090;
            //options.AlternativeEndpoint = "/";
            //var client = new HBaseClient(null, options, new LoadBalancerRoundRobin(new List<string> { "ip address" }));

            #endregion

            return(client);
        }
        public void It_should_throw_the_file_does_not_exist()
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString());
            var fnfe =
                (FileNotFoundException)
                typeof(FileNotFoundException).ShouldBeThrownBy(() =>
                                                               DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromFile(path)));

            fnfe.FileName.ShouldEqual(path);
        }
        public void It_should_throw_when_the_list_is_too_short()
        {
            var lst = new List <string>();

            // empty
            var ae =
                (ArgumentException)
                typeof(ArgumentException).ShouldBeThrownBy(() =>
                                                           DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst)));

            ae.ParamName.ShouldEqual("lines");

            // one
            lst.Add(Guid.NewGuid().ToString());
            ae =
                (ArgumentException)
                typeof(ArgumentException).ShouldBeThrownBy(() =>
                                                           DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst)));
            ae.ParamName.ShouldEqual("lines");

            // two
            lst.Add(Guid.NewGuid().ToString());
            ae =
                (ArgumentException)
                typeof(ArgumentException).ShouldBeThrownBy(() =>
                                                           DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst)));
            ae.ParamName.ShouldEqual("lines");
        }
        public void It_should_throw_when_the_list_is_null()
        {
            var ane =
                (ArgumentNullException)
                typeof(ArgumentNullException).ShouldBeThrownBy(() =>
                                                               DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(null)));

            ane.ParamName.ShouldEqual("lines");
        }