Example #1
0
        public static void query()
        {
            var transport = new TBufferedTransport(new TSocket("hserver", 10000));
            var protocol  = new TBinaryProtocol(transport);
            var client    = new ThriftHive.Client(protocol);

            transport.Open();

            //client.execute("CREATE TABLE r(a STRING, b INT, c DOUBLE)");
            //client.execute("LOAD TABLE LOCAL INPATH '/path' INTO TABLE r");
            client.execute("SELECT * FROM pokes where foo=180");
            while (true)
            {
                var row = client.fetchOne();
                if (string.IsNullOrEmpty(row))
                {
                    break;
                }
                System.Console.WriteLine(row);
            }
            client.execute("SELECT * FROM pokes");
            var all = client.fetchAll();

            System.Console.WriteLine(all);

            transport.Close();
        }
Example #2
0
        public static void AddColumn()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);


            //client.createTable(Unitl.StrToBytes("t"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });
            //client.createTable(Unitl.StrToBytes("thetable"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });

            for (var i = 0; i < 10; i++)
            {
                client.mutateRow(Unitl.StrToBytes("t"),

                                 Unitl.StrToBytes("key"),
                                 new List <Mutation> {
                    new Mutation {
                        Column = Unitl.StrToBytes("default:" + i), Value = Unitl.StrToBytes(System.DateTime.Now.ToString())
                    }
                });
            }
            transport.Close();
        }
Example #3
0
        //剪切
        public List <string> MoveFile(string[] sourcePath, string dectPath)
        {
            TBufferedTransport tsport = null;

            ThriftHadoopFileSystem.Client client = Connect(out tsport);
            List <string> result = new List <string>();

            if (client != null)
            {
                foreach (string itemSource in sourcePath)
                {
                    Pathname pn = new Pathname()
                    {
                        pathname = itemSource
                    };
                    string fileName = itemSource.Substring(itemSource.LastIndexOf('/') + 1);
                    if (client.exists(pn))//如果存在才执行
                    {
                        bool thResult = client.rename(pn, new Pathname()
                        {
                            pathname = dectPath + "/" + fileName
                        });
                        if (!thResult)
                        {
                            result.Add(fileName);
                        }
                    }
                }
                tsport.Close();
            }
            return(result);
        }
Example #4
0
        //重命名文件或文件夹
        public bool ReName(string oldPath, string newPath)
        {
            TBufferedTransport tsport = null;

            ThriftHadoopFileSystem.Client client = Connect(out tsport);
            bool result = false;

            if (client != null)
            {
                Pathname pn = new Pathname()
                {
                    pathname = oldPath
                };
                if (client.exists(pn))//如果存在才执行
                {
                    result = client.rename(pn, new Pathname()
                    {
                        pathname = newPath
                    });
                }

                tsport.Close();
            }
            return(result);
        }
Example #5
0
        public static void BatAddData()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            //client.createTable(Unitl.StrToBytes(tablename), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("zbw911"), InMemory = false } });

            var bytevalue = Unitl.StrToBytes(Longdata);

            for (var j = 0; j < 100000; j++)
            {
                //var j = 0;
                for (var i = 0; i < 1000; i++)
                {
                    client.mutateRow(Unitl.StrToBytes("1"), Unitl.StrToBytes("" + i + "___" + j), new List <Mutation> {
                        new Mutation {
                            Column = Unitl.StrToBytes("zbw911"), Value = bytevalue
                        }
                    });
                }

                Console.WriteLine(j + "批=" + 1000 * j);
            }


            transport.Close();
        }
Example #6
0
        protected void HBaseMutateImage(string rowKey, byte[] image)
        {
            var socket    = new TSocket("172.24.2.144", 9090);
            var transport = new TBufferedTransport(socket);
            var protocol  = new TBinaryProtocol(transport);

            Hbase.Client hc = new Hbase.Client(protocol);
            transport.Open();

            //List<byte[]> tableNames = hc.getTableNames();

            byte[] table  = Encoding.UTF8.GetBytes("FiservImages");
            byte[] row    = Encoding.UTF8.GetBytes(rowKey);
            byte[] column = Encoding.UTF8.GetBytes("ImageData:Image");

            List <Mutation> mutation = new List <Mutation>();
            Mutation        m        = new Mutation();

            m.Column     = column;
            m.Value      = image;
            m.IsDelete   = false;
            m.WriteToWAL = true;
            mutation.Add(m);

            hc.mutateRow(table, row, mutation, null);
        }
Example #7
0
        private static void t1(DateTime yesterday)
        {
            string viewTable  = "AdTxt" + yesterday.ToString("yyyy.MM.dd").Replace(".", "") + "View";
            string clickTable = "AdTxt" + yesterday.ToString("yyyy.MM.dd").Replace(".", "") + "View";

            StringBuilder sql = new StringBuilder();

            sql.Append("select '" + yesterday.ToString("yyyy-MM-dd hh:mm:ss.fffffff") + "' as ReportDate,vn.DealerId,vn.KeywordPId,");
            sql.Append("case when vn.num is null then 0L else  cn.num end  ViewNum,");
            sql.Append("case when cn.num is null then 0L else  cn.num end  clicknum,");
            sql.Append("case when vin.num is null then 0L else  vin.num end viewIpnum,");
            sql.Append("case when cin.num is null then 0L else  cin.num end  clickIpnum ");
            //sql.Append("unix_timestamp('" + DateTime.Now.ToShortDateString() + "') as createtime ");
            sql.Append("From (select a.VendorId as DealerId,v.KeywordPId,count(v.KeywordPId) Num  from " + viewTable + " v join temp_adtxt a on a.Id=v.AdTxtId inner join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) vn ");
            sql.Append("join (select a.VendorId as DealerId,v.KeywordPId,count(distinct v.Ip) Num  from " + viewTable + " v join temp_adtxt a on a.Id=v.AdTxtId join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) vin on vn.DealerId=vin.DealerId and vn.KeywordPId=vin.KeywordPId ");
            sql.Append("left outer join (select a.VendorId as DealerId,v.KeywordPId,count(v.KeywordPId) Num  from " + clickTable + " v join temp_adtxt a on a.Id=v.AdTxtId join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) cn on vn.DealerId=cn.DealerId and vn.KeywordPId=cn.KeywordPId ");
            sql.Append("left outer join (select a.VendorId as DealerId,v.KeywordPId,count(distinct v.Ip) Num  from " + clickTable + " v join temp_adtxt a on a.Id=v.AdTxtId join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) cin on vn.DealerId=cin.DealerId and vn.KeywordPId=cin.KeywordPId limit 1");
            int port      = 10000;
            var socket    = new TSocket("192.168.87.64", port);
            var transport = new TBufferedTransport(socket);
            var proto     = new TBinaryProtocol(transport);
            var client    = new ThriftHive.Client(proto);

            transport.Open();
            client.execute(sql.ToString());
            var rows2 = client.fetchAll();

            transport.Close();


            rows2.ForEach(Console.WriteLine);
        }
Example #8
0
        static void _Sets_hbase(string baseName, string columnFamily, DateTime transaction_date, List <global::BatchMutation> data)
        {
            var socket    = null as TSocket;
            var transport = null as TBufferedTransport;

            try
            {
                // Сделаем вычисление апи хоста по базе данных
                socket    = new TSocket(getHost(baseName, columnFamily), Port);
                transport = new TBufferedTransport(socket);
                var proto = new TBinaryProtocol(transport);
                var hbase = new Hbase.Client(proto);

                var tableName = getBaseTableHbase(baseName, columnFamily);

                transport.Open();

                if (data.Count == 1)
                {
                    hbase.mutateRowTs(tableName, data.First().Row, data.First().Mutations, transaction_date.Ticks, null);
                }
                else
                {
                    hbase.mutateRowsTs(tableName, data, transaction_date.Ticks, null);
                }
            }
            finally
            {
                if (transport != null)
                {
                    transport.Close();
                    transport = null;
                }
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            // Connection
            var socket    = new TSocket("hdp1.localdomain", 9090);
            var transport = new TBufferedTransport(socket);
            var protocol  = new TBinaryProtocol(transport);

            Hbase.Client hba = new Hbase.Client(protocol);
            transport.Open();

            // Get table names
            Console.WriteLine("<-GET LIST OF TABLES->");
            var tableNames = hba.getTableNames();

            foreach (var tableName in tableNames)
            {
                Console.WriteLine(Encoding.UTF8.GetString(tableName, 0, tableName.Length));
            }

            // Insert rows
            Console.WriteLine("<-INSERT->");
            Mutation _mutation = new Mutation();

            _mutation.IsDelete = false;
            _mutation.Column   = Encoding.UTF8.GetBytes("image:bodyimage");
            _mutation.Value    = Encoding.UTF8.GetBytes("newnew image 2.jpg");

            hba.mutateRow(Encoding.UTF8.GetBytes("blogposts"), Encoding.UTF8.GetBytes("post1"), new List <Mutation> {
                _mutation
            }, null);

            // Finished
            Console.WriteLine("<-FINISHED->");
            Console.ReadKey();
        }
Example #10
0
        /// <summary>
        /// Retrives the correct Thrift transport type based on the value in <see cref="Transport"/>.
        /// </summary>
        /// <returns>If <see cref="Transport"/> is <code>namedpipe</code> then a <see cref="TNamedPipeClientTransport"/> is used.  For all other values
        /// a <see cref="TSocket"/> is returned.  Depending on the value of <see cref="Framed"/> and <see cref="Buffered"/>, appropriate wrappers will be placed
        /// around the transport.
        /// </returns>
        public TTransport GetThriftTransport()
        {
            TTransport transport;

            switch (Transport)
            {
            case "namedpipe":
                transport = new TNamedPipeClientTransport(ServiceHost, NamedPipeName);
                break;

            //                case "socket":
            default:
                transport = new TSocket(ServiceHost, ServicePort);
                break;
            }

            if (Framed)
            {
                transport = new TFramedTransport(transport);
            }

            if (Buffered)
            {
                transport = new TBufferedTransport((TStreamTransport)transport, BufferSize);
            }

            return(transport);
        }
Example #11
0
        protected override async Task <TTransport> AcceptImplementationAsync(CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(await Task.FromCanceled <TTransport>(cancellationToken));
            }

            if (_server == null)
            {
                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
            }

            try
            {
                TTransport tSocketTransport = null;
                var        tcpClient        = await _server.AcceptTcpClientAsync();

                try
                {
                    tSocketTransport = new TSocketTransport(tcpClient)
                    {
                        Timeout = _clientTimeout
                    };

                    switch (_buffering)
                    {
                    case Buffering.BufferedTransport:
                        tSocketTransport = new TBufferedTransport(tSocketTransport);
                        break;

                    case Buffering.FramedTransport:
                        tSocketTransport = new TFramedTransport(tSocketTransport);
                        break;

                    default:
                        Debug.Assert(_buffering == Buffering.None);
                        break;
                    }

                    return(tSocketTransport);
                }
                catch (Exception)
                {
                    if (tSocketTransport != null)
                    {
                        tSocketTransport.Dispose();
                    }
                    else //  Otherwise, clean it up ourselves.
                    {
                        ((IDisposable)tcpClient).Dispose();
                    }

                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new TTransportException(ex.ToString());
            }
        }
Example #12
0
        private TTransport MakeTransport(URL url, TConfiguration configuration)
        {
            var ipaddress = IPAddress.Loopback;

            if (!NetUtil.IsAnyHost(url.Host) && !NetUtil.IsLocalHost(url.Host))
            {
                ipaddress = IPAddress.Parse(url.Host);
            }
            // construct endpoint transport
            TTransport transport         = null;
            Transport  selectedTransport = GetTransport(url);
            {
                switch (selectedTransport)
                {
                case Transport.Tcp:
                    transport = new TSocketTransport(ipaddress, url.Port, configuration);
                    break;

                case Transport.NamedPipe:
                    transport = new TNamedPipeTransport(".test", configuration);
                    break;

                case Transport.Http:
                    transport = new THttpTransport(new Uri($"http://{url.Host}:{url.Port}"), configuration);
                    break;

                case Transport.TcpTls:
                    transport = new TTlsSocketTransport(ipaddress, url.Port, configuration,
                                                        GetCertificate(), CertValidator, LocalCertificateSelectionCallback);
                    break;

                default:
                    Console.WriteLine("unhandled case");
                    break;
                }
            }

            // optionally add layered transport(s)
            Buffering selectedBuffering = GetBuffering(url);

            switch (selectedBuffering)
            {
            case Buffering.Buffered:
                transport = new TBufferedTransport(transport);
                break;

            case Buffering.Framed:
                transport = new TFramedTransport(transport);
                break;

            default:     // layered transport(s) are optional
                if (selectedBuffering != Buffering.None)
                {
                    Console.WriteLine("unhandled case");
                }
                break;
            }

            return(transport);
        }
Example #13
0
        public static void t2()
        {
            var transport = new TBufferedTransport(new TSocket("hserver", 10000));
            var protocol  = new TBinaryProtocol(transport);
            var client    = new ThriftHive.Client(protocol);

            transport.Open();


            var database = new Database();

            database.Name        = "helloworldDB";
            database.Description = "测试用的第一个DB";

            var tables = client.get_all_tables("default");

            //var tables = client.get_all_databases();

            foreach (var table in tables)
            {
                System.Console.WriteLine(table);
            }



            transport.Close();
        }
        internal ThriftMessageSender(Uri serviceUri)
        {
            socket    = new TSocket(serviceUri.Host, serviceUri.Port);
            transport = new TBufferedTransport(socket);
            transport.Open();

            client = new MessageService.Client(new TCompactProtocol(transport));
        }
Example #15
0
        private static TTransport GetTransport(string[] args)
        {
            TTransport transport = new TSocketTransport(IPAddress.Loopback, 9090, Configuration);

            // construct endpoint transport
            var transportArg = args.FirstOrDefault(x => x.StartsWith("-tr"))?.Split(':')?[1];

            if (Enum.TryParse(transportArg, true, out Transport selectedTransport))
            {
                switch (selectedTransport)
                {
                case Transport.Tcp:
                    transport = new TSocketTransport(IPAddress.Loopback, 9090, Configuration);
                    break;

                case Transport.NamedPipe:
                    transport = new TNamedPipeTransport(".test", Configuration);
                    break;

                case Transport.Http:
                    transport = new THttpTransport(new Uri("http://localhost:9090"), Configuration);
                    break;

                case Transport.TcpTls:
                    transport = new TTlsSocketTransport(IPAddress.Loopback, 9090, Configuration,
                                                        GetCertificate(), CertValidator, LocalCertificateSelectionCallback);
                    break;

                default:
                    Debug.Assert(false, "unhandled case");
                    break;
                }
            }

            // optionally add layered transport(s)
            var bufferingArg = args.FirstOrDefault(x => x.StartsWith("-bf"))?.Split(':')?[1];

            if (Enum.TryParse <Buffering>(bufferingArg, out var selectedBuffering))
            {
                switch (selectedBuffering)
                {
                case Buffering.Buffered:
                    transport = new TBufferedTransport(transport);
                    break;

                case Buffering.Framed:
                    transport = new TFramedTransport(transport);
                    break;

                default:     // layered transport(s) are optional
                    Debug.Assert(selectedBuffering == Buffering.None, "unhandled case");
                    break;
                }
            }

            return(transport);
        }
Example #16
0
        public HiveService(string serverHostName)
        {
            var socket = new TSocket(HiveConfigure.Instance.GetHostServer(serverHostName), HiveConfigure.Instance.GetHostPort(serverHostName));

            transport = new TBufferedTransport(socket);
            var proto = new TBinaryProtocol(transport);

            client = new ThriftHive.Client(proto);
        }
Example #17
0
        public static void test()
        {
            var hadoop_socket = new TSocket("hserver", 59256);

            hadoop_socket.Timeout = 10000;// Ten seconds

            //$hadoop_socket -> setRecvTimeout(20000); // Twenty seconds
            var hadoop_transport = new TBufferedTransport(hadoop_socket);
            var hadoop_protocol  = new TBinaryProtocol(hadoop_transport);
            var hadoopClient     = new ThriftHadoopFileSystem.Client(hadoop_protocol);

            hadoop_transport.Open();

            //if (hadoopClient.exists(new Pathname { pathname = "/user/root/input" }))
            //{
            //    System.Console.WriteLine("exists");
            //}
            //else
            //{
            //    Console.WriteLine("no exists");


            //}

            //hadoopClient.mkdirs(new Pathname { pathname = "/zbw911_user" });
            //hadoopClient.rm(new Pathname { pathname = "/zbw911_user" }, true);

            //var h = hadoopClient.createFile(new Pathname { pathname = "user_zbw911" }, 1, true, 1000, 1, 64000);


            var list = hadoopClient.listStatus(new Pathname {
                pathname = "/user/root"
            });

            foreach (var item in list)
            {
                System.Console.WriteLine(item);
                //if (item.Isdir)
                //{
                //    System.Console.WriteLine("文件夹:" + item.Path + ";权限:" + item.Permission);
                //}
                //else
                //{

                //    System.Console.WriteLine("文件:" + item.Path + ";权限:" + item.Permission);

                //}
            }

            //hadoopClient.close(h);



            //hadoopClient.open(new Pathname { pathname = "/user/root" });

            hadoop_transport.Close();
        }
Example #18
0
        public HiveService()
        {
            var socket = new TSocket(HiveConfigure.Instance.GetDefaultHost(), HiveConfigure.Instance.GetDefaultPort());

            transport = new TBufferedTransport(socket);
            var proto = new TBinaryProtocol(transport);

            client = new ThriftHive.Client(proto);
            transport.Open();
        }
Example #19
0
        public HiveService(string serverHostName, string sqoopServerHostName, string sqoopSqlServerHost, string sqoopDatabaseName, string sqoopUserName, string sqoopPassword)
        {
            var socket = new TSocket(HiveConfigure.Instance.GetHostServer(serverHostName), HiveConfigure.Instance.GetHostPort(serverHostName));

            transport = new TBufferedTransport(socket);
            var proto = new TBinaryProtocol(transport);

            client         = new ThriftHive.Client(proto);
            sqoopSqlServer = new SqoopSqlServerService(sqoopServerHostName, sqoopSqlServerHost, sqoopDatabaseName, sqoopUserName, sqoopPassword);
        }
Example #20
0
            public TTransport CreateTransport()
            {
                // endpoint transport
                TTransport trans = null;

                switch (transport)
                {
                case TransportChoice.Http:
                    Debug.Assert(url != null);
                    trans = new THttpTransport(new Uri(url), Configuration);
                    break;

                case TransportChoice.NamedPipe:
                    Debug.Assert(pipe != null);
                    trans = new TNamedPipeTransport(pipe, Configuration);
                    break;

                case TransportChoice.TlsSocket:
                    var cert = GetClientCert();
                    if (cert == null || !cert.HasPrivateKey)
                    {
                        throw new InvalidOperationException("Certificate doesn't contain private key");
                    }

                    trans = new TTlsSocketTransport(host, port, Configuration, 0,
                                                    cert,
                                                    (sender, certificate, chain, errors) => true,
                                                    null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12);
                    break;

                case TransportChoice.Socket:
                default:
                    trans = new TSocketTransport(host, port, Configuration);
                    break;
                }


                // layered transport
                switch (layered)
                {
                case LayeredChoice.Buffered:
                    trans = new TBufferedTransport(trans);
                    break;

                case LayeredChoice.Framed:
                    trans = new TFramedTransport(trans);
                    break;

                default:
                    Debug.Assert(layered == LayeredChoice.None);
                    break;
                }

                return(trans);
            }
        protected ServerConnector()
        {
            ConfigUtil.GetServerAddress(out _serverIP, out _serverPort);

            IsRunLocal = _serverIP == null;

            _socket       = new TSocket(_serverIP, _serverPort);
            _transport    = new TBufferedTransport(_socket);
            _protocol     = new TBinaryProtocol(_transport);
            _targetServer = new TransportServer.Client(_protocol);
        }
Example #22
0
        public MahoutService()
        {
            var socket = new TSocket(MahoutConfigure.Instance.GetDefaultHost(), MahoutConfigure.Instance.GetDefaultPort());

            transport = new TBufferedTransport(socket);
            var proto = new TBinaryProtocol(transport);

            mahoutClient = new MahoutThriftClient(proto);
            _daoInstance = new HiveService.HiveService();
            transport.Open();
        }
Example #23
0
        public ClientStation(string userName, string ipAddress, int port)
        {
            this.UserName  = userName;
            this.IPAddress = ipAddress;
            this.Port      = port;

            _socket       = new TSocket(this.IPAddress, this.Port);
            _transport    = new TBufferedTransport(_socket);
            _protocol     = new TBinaryProtocol(_transport);
            _targetClient = new TransportClient.Client(_protocol);
        }
        public async Task <ApiResponse> GetDataset(ClaimsPrincipal authenticatedUser, DatasetRequestDto requestedDataset)
        {
            try
            {
                TTransport transport = null;
                transport = new TSocketTransport(IPAddress.Loopback, 9090, null);
                transport = new TBufferedTransport(transport);
                var protocol = new TBinaryProtocol(transport);
                var client   = new HelloWorldService.Client(protocol);


                HelloWorldStruct test = new HelloWorldStruct
                {
                    Text = "This is a rpc test"
                };
                await client.OpenTransportAsync(CancellationToken.None);

                await client.HelloWorldAsync(test);



                var user = await _userManager.FindByIdAsync(authenticatedUser.GetSubjectId());

                var dataset = _persistenceManager.Context.DatasetFiles.FirstOrDefault(s =>
                                                                                      s.Id == requestedDataset.Id && s.CreatedById == user.Id);
                string path;
                if (dataset == null)
                {
                    return(new ApiResponse(Status404NotFound, L["Dataset not found."]));
                }

                if (requestedDataset.ShortVersion)
                {
                    path = $"{dataset.Path}\\{dataset.BlazorTitle}";
                }
                else
                {
                    path = $"{dataset.Path}\\{dataset.Title}";
                }

                DatasetRequestReplyDto replyDto = new DatasetRequestReplyDto
                {
                    Content = await File.ReadAllTextAsync(path)
                };

                return(new ApiResponse(Status200OK, null, replyDto));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error while retrieving dataset: {0}", ex.Message);
                return(new ApiResponse(Status400BadRequest, L["Error while retrieving the file."]));
            }
        }
Example #25
0
        static void Main(string[] args)
        {
            TTransport trans = new TSocket("localhost", 8585);

            trans = new TBufferedTransport(trans as TStreamTransport);
            trans.Open();
            TBinaryProtocol proto = new TBinaryProtocol(trans);

            helloSvc.Client client = new helloSvc.Client(proto);
            string          result = client.getMessage("Ginger");

            Console.WriteLine("Received from server: " + result);
        }
Example #26
0
        private static TTransport MakeTransport(string[] args)
        {
            // construct endpoint transport
            TTransport transport         = null;
            Transport  selectedTransport = GetTransport(args);
            {
                switch (selectedTransport)
                {
                case Transport.Tcp:
                    transport = new TSocketTransport(IPAddress.Loopback, 9090, Configuration);
                    break;

                case Transport.NamedPipe:
                    transport = new TNamedPipeTransport(".test", Configuration);
                    break;

                case Transport.Http:
                    transport = new THttpTransport(new Uri("http://localhost:9090"), Configuration);
                    break;

                case Transport.TcpTls:
                    transport = new TTlsSocketTransport(IPAddress.Loopback, 9090, Configuration,
                                                        GetCertificate(), CertValidator, LocalCertificateSelectionCallback);
                    break;

                default:
                    Debug.Assert(false, "unhandled case");
                    break;
                }
            }

            // optionally add layered transport(s)
            Buffering selectedBuffering = GetBuffering(args);

            switch (selectedBuffering)
            {
            case Buffering.Buffered:
                transport = new TBufferedTransport(transport);
                break;

            case Buffering.Framed:
                transport = new TFramedTransport(transport);
                break;

            default:     // layered transport(s) are optional
                Debug.Assert(selectedBuffering == Buffering.None, "unhandled case");
                break;
            }

            return(transport);
        }
Example #27
0
        public SqoopSqlServerService(string sqoopServerHostName, string sqlServerHost, string databaseName, string userName, string password)
        {
            _host     = sqlServerHost;
            _database = databaseName;
            _userName = userName;
            _password = password;

            var socket = new TSocket(SqoopConfigure.Instance.GetHostServer(sqoopServerHostName), SqoopConfigure.Instance.GetHostPort(sqoopServerHostName));

            transport = new TBufferedTransport(socket);
            var proto = new TBinaryProtocol(transport);

            sqoopClient = new SqoopThriftClient(proto);
        }
Example #28
0
            public TTransport CreateTransport()
            {
                if (url == null)
                {
                    // endpoint transport
                    TTransport trans = null;
                    if (pipe != null)
                    {
                        trans = new TNamedPipeClientTransport(pipe);
                    }
                    else
                    {
                        if (encrypted)
                        {
                            string          certPath = "../keys/client.p12";
                            X509Certificate cert     = new X509Certificate2(certPath, "thrift");
                            trans = new TTLSSocket(host, port, 0, cert,
                                                   (o, c, chain, errors) => true,
                                                   null, SslProtocols.Tls);
                        }
                        else
                        {
                            trans = new TSocket(host, port);
                        }
                    }

                    // layered transport
                    if (buffered)
                    {
                        trans = new TBufferedTransport(trans);
                    }
                    if (framed)
                    {
                        trans = new TFramedTransport(trans);
                    }

                    if (_isFirstTransport)
                    {
                        //ensure proper open/close of transport
                        trans.Open();
                        trans.Close();
                        _isFirstTransport = false;
                    }
                    return(trans);
                }
                else
                {
                    return(new THttpClient(new Uri(url)));
                }
            }
Example #29
0
        public static void Scan()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            var scanid = client.scannerOpenWithStop(Unitl.StrToBytes("t1"), Unitl.StrToBytes("rowno"), Unitl.StrToBytes("rowno"),
                                                    new List <byte[]> {
                Unitl.StrToBytes("f1:99913")
            });

            var result = client.scannerGet(scanid);

            var colum = client.getColumnDescriptors("t1".ToBytes());

            var rows = client.getRowsWithColumns("t1".ToBytes()
                                                 , new List <byte[]> {
                "rowno".ToBytes()
            }
                                                 , new List <byte[]> {
                "f1:9".ToBytes(), "f1:9999".ToBytes()
            });


            //scanid = client.scannerOpenWithPrefix("".ToBytes(), "".ToBytes(), new List<byte[]> { });

            var v = client.getVer("table".ToBytes(), "row".ToBytes(), "col".ToBytes(), 1000);

            foreach (var xx in v)
            {
            }



            foreach (var r in result)
            {
                Console.WriteLine(r.Columns[Unitl.StrToBytes("f1:99913")].Value);
            }

            client.scannerClose(scanid);

            transport.Close();
        }
Example #30
0
            public TTransport CreateTransport()
            {
                if (url == null)
                {
                    // endpoint transport
                    TTransport trans = null;

                    if (pipe != null)
                    {
                        trans = new TNamedPipeTransport(pipe);
                    }
                    else
                    {
                        if (encrypted)
                        {
                            var cert = GetClientCert();

                            if (cert == null || !cert.HasPrivateKey)
                            {
                                throw new InvalidOperationException("Certificate doesn't contain private key");
                            }

                            trans = new TTlsSocketTransport(host, port, 0, cert,
                                                            (sender, certificate, chain, errors) => true,
                                                            null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12);
                        }
                        else
                        {
                            trans = new TSocketTransport(host, port);
                        }
                    }

                    // layered transport
                    if (buffered)
                    {
                        trans = new TBufferedTransport(trans);
                    }

                    if (framed)
                    {
                        trans = new TFramedTransport(trans);
                    }

                    return(trans);
                }

                return(new THttpTransport(new Uri(url), null));
            }