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


C# HBaseClient类代码示例

本文整理汇总了C#中HBaseClient的典型用法代码示例。如果您正苦于以下问题:C# HBaseClient类的具体用法?C# HBaseClient怎么用?C# HBaseClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: When_I_Scan_with_a_ColumnCountGetFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_ColumnCountGetFilter_I_get_the_expected_results()
        {
            // B column should not be returned, so set the value to null.
            List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords select r.WithBValue(null)).ToList();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new ColumnCountGetFilter(2);
            scanner.filter = filter.ToEncodedString();
            RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
            scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
            ScannerInformation scanInfo = null;
            try
            {
                scanInfo = client.CreateScannerAsync(_tableName, scanner, scanOptions).Result;
                List<FilterTestRecord> actualRecords = RetrieveResults(scanInfo, scanOptions).ToList();

                actualRecords.ShouldContainOnly(expectedRecords);
            }
            finally
            {
                if (scanInfo != null)
                {
                    client.DeleteScannerAsync(_tableName, scanInfo, scanOptions).Wait();
                }
            }
        }
开发者ID:hdinsight,项目名称:hbase-sdk-for-net,代码行数:27,代码来源:FilterTests.cs

示例2: HBaseWriter

 public HBaseWriter()
 {
     //Get the Hadoop Cluster info and create connection
     this.ClusterName = ConfigurationManager.AppSettings["ClusterName"];
     this.HadoopUserName = ConfigurationManager.AppSettings["HadoopUserName"];
     string HadoopUserPassword = ConfigurationManager.AppSettings["HadoopUserPassword"];
     this.HBaseTableName = ConfigurationManager.AppSettings["HBaseTableName"];
     SecureString pw = new SecureString();
     for(int i = 0; i < HadoopUserPassword.Length; i++){
         pw.InsertAt(i, HadoopUserPassword[i]);
     }
     Uri clusterUri = new Uri(this.ClusterName);
     ClusterCredentials creds = new ClusterCredentials(clusterUri, this.HadoopUserName, pw);
     this.client = new HBaseClient(creds);
     //create table and enable the hbase writer
     if (!client.ListTables().name.Contains(this.HBaseTableName))
     {
         // Create the table
         var tableSchema = new TableSchema();
         tableSchema.name = this.HBaseTableName;
         tableSchema.columns.Add(new ColumnSchema { name = "d" });
         client.CreateTable(tableSchema);
         Console.WriteLine("Table \"{0}\" created.", this.HBaseTableName);
     }
     WriterThread = new Thread(new ThreadStart(WriterThreadFunction));
     WriterThread.Start();
 }
开发者ID:anytimecnc,项目名称:ProjectTeddy,代码行数:27,代码来源:HBaseWriter.cs

示例3: TestLoadBalancerRetriesExhausted

        public void TestLoadBalancerRetriesExhausted()
        {
            int numServers = 4;
            int numFailures = 5;
            var client = new HBaseClient(numServers);

            int count = 0;
            Func<string, Task<int>> f = (endpoint) =>
            {
                count++;

                if (count < numFailures)
                {
                    throw new TimeoutException(count.ToString());
                }

                return EmitIntAsync(count);
            };

            try
            {
                var output = client.ExecuteAndGetWithVirtualNetworkLoadBalancing(f);
            }
            catch (TimeoutException ex)
            {
                Assert.AreEqual(ex.Message, numServers.ToString());

                return;
            }

            Assert.Fail();
        }
开发者ID:nayato,项目名称:hbase-sdk-for-net,代码行数:32,代码来源:VirtualNetworkLoadBalancerTests.cs

示例4: Context

        protected override void Context()
        {
            if (!_arrangementCompleted)
            {
                // at present, no tables are modified so only arrange the tables once per test pass
                // and putting the arrangement into a static context.
                // (this knocked test runs down to ~30 seconds from ~5 minutes).

                _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt");
                var client = new HBaseClient(_credentials);

                // ensure tables from previous tests are cleaned up
                TableList tables = client.ListTables();
                foreach (string name in tables.name)
                {
                    string pinnedName = name;
                    if (name.StartsWith(TableNamePrefix, StringComparison.Ordinal))
                    {
                        client.DeleteTable(pinnedName);
                    }
                }

                AddTable();
                PopulateTable();

                _arrangementCompleted = true;
            }
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:28,代码来源:FilterTests.cs

示例5: HBaseReader

 // The constructor
 public HBaseReader()
 {
     ClusterCredentials creds = new ClusterCredentials(
                     new Uri(CLUSTERNAME),
                     HADOOPUSERNAME,
                     HADOOPUSERPASSWORD);
     client = new HBaseClient(creds);
 }
开发者ID:datasciencedojo,项目名称:TwitterHBaseLab,代码行数:9,代码来源:HBaseReader.cs

示例6: HBaseReader

 public HBaseReader()
 {
     var creds = new ClusterCredentials(
                     new Uri(ConfigurationManager.AppSettings["Cluster"]),
                     ConfigurationManager.AppSettings["User"],
                     ConfigurationManager.AppSettings["Pwd"]);
     client = new HBaseClient(creds);
 }
开发者ID:mkellerman,项目名称:tweet-sentiment,代码行数:8,代码来源:HBaseReader.cs

示例7: When_I_Scan_all_I_get_the_expected_results

        public void When_I_Scan_all_I_get_the_expected_results()
        {
            var client = new HBaseClient(_credentials);
            var scan = new Scanner();

            ScannerInformation scanInfo = client.CreateScanner(_tableName, scan);
            List<FilterTestRecord> actualRecords = RetrieveResults(scanInfo).ToList();

            actualRecords.ShouldContainOnly(_allExpectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:10,代码来源:FilterTests.cs

示例8: HBaseReaderClient

        public HBaseReaderClient(string hbaseclusterurl, string hbaseclusterusername, string hbaseclusteruserpassword)
        {
            this.HBaseClusterUrl = hbaseclusterurl;
            this.HBaseClusterUserName = hbaseclusterusername;
            this.HBaseClusterUserPassword = hbaseclusteruserpassword;

            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true;

            this.HBaseClusterCredentials = new ClusterCredentials(new Uri(HBaseClusterUrl), HBaseClusterUserName, HBaseClusterUserPassword);
            this.HBaseClusterClient = new HBaseClient(HBaseClusterCredentials);
        }
开发者ID:cleydson,项目名称:hdinsight-storm-examples,代码行数:11,代码来源:EventHubAggreatorHBaseReader.cs

示例9: EventHBaseWriter

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="tablename"></param>
        public EventHBaseWriter(Context context, Dictionary<string, Object> parms = null)
        {
            this.context = context;

            this.appConfig = new AppConfig();

            Dictionary<string, List<Type>> inputSchema = new Dictionary<string, List<Type>>();
            inputSchema.Add(Constants.DEFAULT_STREAM_ID, AggregatedTupleFields);

            this.context.DeclareComponentSchema(new ComponentStreamSchema(inputSchema, null));

            //Setup the credentials for HBase cluster
            HBaseClusterCredentials = 
                new ClusterCredentials(
                    new Uri(this.appConfig.HBaseClusterUrl), 
                    this.appConfig.HBaseClusterUserName, 
                    this.appConfig.HBaseClusterUserPassword);

            HBaseClusterClient = new HBaseClient(HBaseClusterCredentials);

            //Query HBase for existing tables
            var tabs = HBaseClusterClient.ListTables();
            Context.Logger.Info("HBase Tables (" + tabs.name.Count + "): " + String.Join(", ", tabs.name));

            this.PrimaryKey = this.appConfig.PrimaryKey;
            this.SecondaryKey = this.appConfig.SecondaryKey;

            this.HBaseTableName =
                this.appConfig.HBaseTableNamePrefix +
                this.appConfig.PrimaryKey + this.appConfig.SecondaryKey +
                this.appConfig.HBaseTableNameSuffix;

            Context.Logger.Info("HBaseTableName = " + this.HBaseTableName);

            //Create a HBase table if it not exists
            if (!tabs.name.Contains(this.HBaseTableName))
            {
                var tableSchema = new TableSchema();
                tableSchema.name = this.HBaseTableName;
                tableSchema.columns.Add(new ColumnSchema() { name = "v" });
                HBaseClusterClient.CreateTable(tableSchema);
                Context.Logger.Info("Created HBase Table: " + this.HBaseTableName);
            }

            Context.Logger.Info("HBaseOverwrite: " + this.appConfig.HBaseOverwrite);

            globalstopwatch = new Stopwatch();
            globalstopwatch.Start();

            emitstopwatch = new Stopwatch();
            emitstopwatch.Start();
        }
开发者ID:cleydson,项目名称:hdinsight-storm-examples,代码行数:57,代码来源:EventHBaseWriter.cs

示例10: Main

        static void Main(string[] args)
        {

            while (true)
            {
                Random rnd = new Random();
                Console.Clear();

                string clusterURL = "https://hb12345.azurehdinsight.net";
                string userName = "HDUser";
                string password = "HDPa$$w0rd";

                // Connect to HBase cluster
                ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL),
                                                                  userName, password);
                HBaseClient hbaseClient = new HBaseClient(creds);

                // Get all stocks
                Scanner scanSettings = new Scanner()
                {
                    batch = 10,
                    startRow = Encoding.UTF8.GetBytes("AAA"),
                    endRow = Encoding.UTF8.GetBytes("ZZZ")
                };

                ScannerInformation stockScanner = hbaseClient.CreateScanner("Stocks", scanSettings);
                CellSet stockCells = null;
                while ((stockCells = hbaseClient.ScannerGetNext(stockScanner)) != null)
                {
                    foreach (var row in stockCells.rows)
                    {
                        string stock = Encoding.UTF8.GetString(row.key);
                        Double currentPrice = Double.Parse(Encoding.UTF8.GetString(row.values[1].data));
                        Double newPrice = currentPrice + (rnd.NextDouble() * (1 - -1) + -1);
                        Cell c = new Cell
                        {
                            column = Encoding.UTF8.GetBytes("Current:Price"),
                            data =
                           Encoding.UTF8.GetBytes(newPrice.ToString())
                        };
                        row.values.Insert(2, c);
                        Console.WriteLine(stock + ": " + currentPrice.ToString() + " := "
                                                       + newPrice.ToString());
                    }
                    hbaseClient.StoreCells("Stocks", stockCells);
                }
            }

        }
开发者ID:TomLous,项目名称:edx-dat202.2x-rt-analytics-hadoop-azure,代码行数:49,代码来源:Program.cs

示例11: HBaseReader

 public HBaseReader()
 {
     //Get the Hadoop Cluster info and create connection
     this.ClusterName = ConfigurationManager.AppSettings["ClusterName"];
     this.HadoopUserName = ConfigurationManager.AppSettings["HadoopUserName"];
     string HadoopUserPassword = ConfigurationManager.AppSettings["HadoopUserPassword"];
     SecureString pw = new SecureString();
     for (int i = 0; i < HadoopUserPassword.Length; i++)
     {
         pw.InsertAt(i, HadoopUserPassword[i]);
     }
     Uri clusterUri = new Uri(this.ClusterName);
     ClusterCredentials creds = new ClusterCredentials(clusterUri, this.HadoopUserName, pw);
     this.client = new HBaseClient(creds);
 }
开发者ID:anytimecnc,项目名称:ProjectTeddy,代码行数:15,代码来源:HBaseReader.cs

示例12: HBaseStore

        public HBaseStore()
        {
            // Initialize HBase connection
            var credentials = CreateFromFile(@"credentials.txt");
            client = new HBaseClient(credentials);

            if (!client.ListTables().name.Contains(TABLE_BY_WORDS_NAME))
            {
                // Create the table
                var tableSchema = new TableSchema();
                tableSchema.name = TABLE_BY_WORDS_NAME;
                tableSchema.columns.Add(new ColumnSchema { name = "d" });
                client.CreateTable(tableSchema);
            }
        }
开发者ID:mkellerman,项目名称:tweet-sentiment,代码行数:15,代码来源:HBaseStore.cs

示例13: CreateHBaseTable

 /// <summary>
 /// Create a new HBase table
 /// </summary>
 /// <param name="hbaseClient">client used to connect to HBase</param>
 public static void CreateHBaseTable(HBaseClient hbaseClient)
 {
     //Define the 'cf family
     //Set versions to retain to 5
     ColumnSchema cf = new ColumnSchema() {
         name = Properties.Settings.Default.HBaseTableColumnFamily,
         maxVersions = 5
     };
     //Define the table
     TableSchema tableSchema = new TableSchema();
     tableSchema.name = Properties.Settings.Default.HBaseTableName;
     tableSchema.columns.Add(cf);
     //Create the table
     hbaseClient.CreateTable(tableSchema);
     Console.WriteLine("Table created.");
 }
开发者ID:Blackmist,项目名称:hdinsight-storm-dotnet-event-correlation,代码行数:20,代码来源:Program.cs

示例14: CreateTable

        /// <summary>
        /// Create a new HBase table
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public static bool CreateTable(string tableName, string[] columnFamilysKeys)
        {
            TableSchema tableSchema = new TableSchema();
            tableSchema.name = tableName;
            foreach (var columnFamilySKey in columnFamilysKeys)
            {
                tableSchema.columns.Add(new ColumnSchema() { name = columnFamilySKey });
            }

            if (hbaseClient == null)
                hbaseClient = CreateHBaseClient(clusterURL, httpName, httpUserPassword);

            int millisecondsTimeout = 3000;
            return hbaseClient.CreateTableAsync(tableSchema).Wait(millisecondsTimeout);

        }
开发者ID:terri5,项目名称:testClouder,代码行数:21,代码来源:HBaseHelper.cs

示例15: InitHBase

        private static void InitHBase()
        {
            try
            {
                clusterURL = System.Configuration.ConfigurationManager.AppSettings["HBaseClusterURL"].ToString();
                httpName = System.Configuration.ConfigurationManager.AppSettings["HBaseHttpName"].ToString();
                httpUserPassword = System.Configuration.ConfigurationManager.AppSettings["HBaseHttpUserPassword"].ToString();
                hbaseClient = CreateHBaseClient(clusterURL, httpName, httpUserPassword);
            }
            catch (Exception e)
            {

                Console.Error.WriteLine(e.Message + "\r\n" + e.StackTrace);
                Console.ReadKey();
            }
            
        }
开发者ID:terri5,项目名称:testClouder,代码行数:17,代码来源:HBaseHelper.cs


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