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; } }
/// <summary> /// Initializes a new instance of the <see cref="WebRequesterSecure"/> class. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="contentType">Type of the content.</param> public WebRequesterSecure(ClusterCredentials credentials, string contentType = "application/x-protobuf") { credentials.ArgumentNotNull("credentials"); _credentials = credentials; _contentType = contentType; }
/// <summary> /// Initializes a new instance of the <see cref="GatewayWebRequester"/> class. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="contentType">Type of the content.</param> public GatewayWebRequester(ClusterCredentials credentials, string contentType = "application/x-google-protobuf") { _credentials = credentials; _contentType = contentType; _credentialCache = new CredentialCache(); InitCache(); }
// The constructor public HBaseReader() { ClusterCredentials creds = new ClusterCredentials( new Uri(CLUSTERNAME), HADOOPUSERNAME, HADOOPUSERPASSWORD); client = new HBaseClient(creds); }
/// <summary> /// Initializes a new instance of the <see cref="GatewayWebRequester"/> class. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="contentType">Type of the content.</param> public GatewayWebRequester(ClusterCredentials credentials, string contentType = "application/x-protobuf") { credentials.ArgumentNotNull("credentials"); _credentials = credentials; _contentType = contentType; _credentialCache = new CredentialCache(); InitCache(); }
/// <summary> /// Initializes a new instance of the <see cref="GatewayWebRequester" /> class. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="contentType">Type of the content.</param> public GatewayWebRequester(ClusterCredentials credentials, string contentType = "application/x-protobuf") { credentials.ArgumentNotNull("credentials"); _credentials = credentials; _contentType = contentType; _credentialCache = new CredentialCache(); InitCache(); }
public HBaseReader() { var creds = new ClusterCredentials( new Uri(ConfigurationManager.AppSettings["Cluster"]), ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Pwd"]); client = new HBaseClient(creds); }
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); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting /// unmanaged resources. /// </summary> /// <remarks> /// Since this class is <see langword="sealed"/>, the standard <see /// cref="IDisposable.Dispose"/> pattern is not required. Also, <see /// cref="GC.SuppressFinalize"/> is not needed. /// </remarks> public void Dispose() { if (!_disposed) { if (_credentials != null) { _credentials.Dispose(); _credentials = null; } _disposed = true; } }
public void Test_Query_WhenAuthenticateNotCalled_ThrowsInvalidOperationException() { var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); var credentials = new ClusterCredentials { BucketCredentials = new Dictionary <string, string> { { "authenticated", "secret1" } } }; Assert.Throws <InvalidOperationException>(() => cluster.Query <dynamic>("select * from authenticated limit 1;")); }
public void Test_Query_WhenBucketOpenedThatIsNotInAuthenticator_Fails() { var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); var credentials = new ClusterCredentials { BucketCredentials = new Dictionary <string, string> { { "authenticated", "secret" } } }; cluster.Authenticate(credentials); Assert.Throws <AuthenticationException>(() => cluster.OpenBucket("default")); }
public void Test_Query_WhenInvalidPassword_ThrowsException() { var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); var credentials = new ClusterCredentials { BucketCredentials = new Dictionary <string, string> { { "authenticated", "secret1" } } }; cluster.Authenticate(credentials); Assert.Throws <AggregateException>(() => cluster.Query <dynamic>("select * from authenticated limit 1;")); }
static void Main(string[] args) { //Connect to HBase var credentials = new ClusterCredentials( new Uri(Properties.Settings.Default.HBaseClusterUrl), Properties.Settings.Default.HBaseClusterUserName, Properties.Settings.Default.HBaseClusterPassword); //Get the client var hbaseClient = new HBaseClient(credentials); char operation = ' '; //Loop until 'q' is selected do { Console.Write("(C)reate table, (d)elete table, or search for (s)tart or (e)nd events. Or (q)uit: "); //Get the character operation = Console.ReadKey().KeyChar; Console.WriteLine(); //Which operation? switch (operation) { case 'c': CreateHBaseTable(hbaseClient); break; case 'd': DeleteHBaseTable(hbaseClient); break; case 's': //Fall through since both Start and Event searches //have the same logic/signature case 'e': DateTime start = GetDateTime("start"); DateTime end = GetDateTime("end"); //Was it start or end we want to look for? string eventType = operation == 's' ? "START" : "END"; //Find sessions for the event type, by start and end times GetSessionsByTime(hbaseClient, eventType, start, end); break; default: break; } } while (operation != 'q'); }
/// <summary> /// Initialize the HBase settings and connections /// </summary> public void InitializeHBase() { this.HBaseClusterUrl = ConfigurationManager.AppSettings["HBaseClusterUrl"]; if (String.IsNullOrWhiteSpace(this.HBaseClusterUrl)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterUrl"); } this.HBaseClusterUserName = ConfigurationManager.AppSettings["HBaseClusterUserName"]; if (String.IsNullOrWhiteSpace(this.HBaseClusterUserName)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterUserName"); } this.HBaseClusterPassword = ConfigurationManager.AppSettings["HBaseClusterPassword"]; if (String.IsNullOrWhiteSpace(this.HBaseClusterPassword)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterPassword"); } this.HBaseTableName = ConfigurationManager.AppSettings["HBaseTableName"]; if (String.IsNullOrWhiteSpace(this.HBaseTableName)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseTableName"); } //Setup the credentials for HBase cluster this.HBaseClusterCredentials = new ClusterCredentials( new Uri(this.HBaseClusterUrl), this.HBaseClusterUserName, this.HBaseClusterPassword); this.HBaseClusterClient = new HBaseClient(this.HBaseClusterCredentials); //Query HBase for existing tables var tables = this.HBaseClusterClient.ListTables(); Context.Logger.Info("HBase Tables (" + tables.name.Count + "): " + String.Join(", ", tables.name)); //Create a HBase table if it not exists if (!tables.name.Contains(this.HBaseTableName)) { throw new Exception("Cannot find HBase table: " + this.HBaseTableName); } }
private HBaseClient GetClient() { _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt"); var options = RequestOptions.GetDefaultOptions(); options.RetryPolicy = RetryPolicy.NoRetry; 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 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); }
internal static ClusterCredentials CreateFromList(List <string> lines) { if (lines.Count() != 3) { throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, "Expected the credentials file to have exactly three lines, " + "first containing the cluster URL, second the username, third the password. " + "Given {0} lines!", lines.Count()), "lines"); } var rv = new ClusterCredentials(new Uri(lines[0]), lines[1], lines[2]); return(rv); }
public void Test_Query() { var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); var credentials = new ClusterCredentials { BucketCredentials = new Dictionary <string, string> { { "authenticated", "secret" } } }; cluster.Authenticate(credentials); var result = cluster.Query <dynamic>("select * from authenticated limit 1;"); Assert.AreEqual(QueryStatus.Success, result.Status); }
internal static ClusterCredentials CreateFromList(List<string> lines) { lines.ArgumentNotNull("lines"); if (lines.Count() != 3) { throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, "Expected the credentials file to have exactly three lines, " + "first containing the cluster URL, second the username, third the password. " + "Given {0} lines!", lines.Count()), "lines"); } var rv = new ClusterCredentials(new Uri(lines[0]), lines[1], lines[2]); return rv; }
private HBaseClient GetClient() { _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt"); var options = RequestOptions.GetDefaultOptions(); options.RetryPolicy = RetryPolicy.NoRetry; 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 Legacy_Credentials_Sets_ClassicAuthenticator_Properties() { var credentials = new ClusterCredentials { ClusterUsername = "******", ClusterPassword = "", BucketCredentials = new Dictionary <string, string> { { "default", "" }, { "authenticated", "secret" }, { "memcached", "" }, { "travel-sample", "wayward1" } } }; var authenticator = new ClassicAuthenticator(credentials); Assert.AreEqual(credentials.ClusterUsername, authenticator.ClusterUsername); Assert.AreEqual(credentials.ClusterPassword, authenticator.ClusterPassword); CollectionAssert.AreEquivalent(credentials.BucketCredentials, authenticator.BucketCredentials); }
public void Test_CanAuthenticate_KV() { var credentials = new ClusterCredentials { ClusterUsername = "******", ClusterPassword = "******", BucketCredentials = new AttributeDictionary { { "authenticated", "secret" } } }; var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); cluster.Authenticate(credentials); var bucket = cluster.OpenBucket("authenticated"); var result = bucket.Upsert("thekey", "thevalue"); Assert.IsTrue(result.Success); }
public void Test_CanAuthenticate_N1QL() { var credentials = new ClusterCredentials { ClusterUsername = "******", ClusterPassword = "******", BucketCredentials = new Dictionary <string, string> { { "authenticated", "secret" } } }; var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); cluster.Authenticate(credentials); var bucket = cluster.OpenBucket("authenticated"); var query = new QueryRequest("SELECT * FROM `authenticated`;"); var result = bucket.Query <dynamic>(query); Assert.IsTrue(result.Success); }
public void Test_CanAuthenticate_Views() { var credentials = new ClusterCredentials { ClusterUsername = "******", ClusterPassword = "******", BucketCredentials = new AttributeDictionary { { "authenticated", "secret" } } }; using (var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration())) { cluster.Authenticate(credentials); //if authentication failed - an exception would be thrown during bootstrapping var bucket = cluster.OpenBucket("authenticated"); var query = bucket.CreateQuery("somedoc", "someview"); var result = bucket.Query <dynamic>(query); //assert - view does not exist but should still return a response and no auth error Assert.IsFalse(result.Success); // Can see ServiceUnavailable on 4.x server versions when quering unknown design doc/view // https://issues.couchbase.com/browse/NCBC-1533 var expectedStatusCodes = new List <HttpStatusCode> { HttpStatusCode.NotFound }; if (ClusterVersionProvider.Instance.GetVersion(bucket) < new ClusterVersion(new Version(5, 0, 0))) { expectedStatusCodes.Add(HttpStatusCode.ServiceUnavailable); } Assert.IsTrue(expectedStatusCodes.Contains(result.StatusCode)); } }
protected override void Context() { _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) { if (name.StartsWith(TestTablePrefix, StringComparison.Ordinal)) { client.DeleteTable(name); } } // add a table specific to this test _testTableName = TestTablePrefix + _random.Next(10000); _testTableSchema = new TableSchema(); _testTableSchema.name = _testTableName; _testTableSchema.columns.Add(new ColumnSchema { name = "d" }); client.CreateTable(_testTableSchema); }
protected override void Context() { fromString = new ClusterCredentials(expectedUri, expectedUserName, expectedPlainPassword); fromSecureString = new ClusterCredentials(expectedUri, expectedUserName, originalSecurePassword); }
public static async void ExecuteProcedure(DataContract dataContract) { string connId = Guid.NewGuid().ToString(); RequestOptions options = RequestOptions.GetGatewayDefaultOptions(); var credentials = new ClusterCredentials(new Uri("jdbc:phoenix:10.16.0.206:/hbase-unsecure"), null, null); var client = new PhoenixClient(credentials); // In gateway mode, PQS requests will be https://<cluster dns name>.azurehdinsight.net/hbasephoenix<N>/ // Requests sent to hbasephoenix0/ will be forwarded to PQS on workernode0 options.AlternativeEndpoint = "hbasephoenix0/"; OpenConnectionResponse openConnResponse = null; StatementHandle statementHandle = null; try { //var info = new pbc::MapField<string, string>(); // Opening connection pbc::MapField <string, string> info = new pbc::MapField <string, string>(); openConnResponse = await client.OpenConnectionRequestAsync(connId, info, options); // Syncing connection ConnectionProperties connProperties = new ConnectionProperties { HasAutoCommit = true, AutoCommit = true, HasReadOnly = true, ReadOnly = false, TransactionIsolation = 0, Catalog = "", Schema = "", IsDirty = true }; await client.ConnectionSyncRequestAsync(connId, connProperties, options); var createStatementResponse = await client.CreateStatementRequestAsync(connId, options); string sql = "SELECT * FROM Customers"; ExecuteResponse executeResponse = await client.PrepareAndExecuteRequestAsync(connId, sql, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options); pbc::RepeatedField <Row> rows = executeResponse.Results[0].FirstFrame.Rows; // Loop through all of the returned rows and display the first two columns for (int i = 0; i < rows.Count; i++) { Row row = rows[i]; Console.WriteLine(row.Value[0].ScalarValue.StringValue + " " + row.Value[1].ScalarValue.StringValue); } // 100 is hard-coded on the server side as the default firstframe size // FetchRequestAsync is called to get any remaining rows Console.WriteLine(""); Console.WriteLine($"Number of rows: {rows.Count}"); // Fetch remaining rows, offset is not used, simply set to 0 // When FetchResponse.Frame.Done is true, all rows were fetched FetchResponse fetchResponse = await client.FetchRequestAsync(connId, createStatementResponse.StatementId, 0, int.MaxValue, options); Console.WriteLine($"Frame row count: {fetchResponse.Frame.Rows.Count}"); Console.WriteLine($"Fetch response is done: {fetchResponse.Frame.Done}"); Console.WriteLine(""); // Running query 2 string sql2 = "select count(*) from Customers"; ExecuteResponse countResponse = await client.PrepareAndExecuteRequestAsync(connId, sql2, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options); long count = countResponse.Results[0].FirstFrame.Rows[0].Value[0].ScalarValue.NumberValue; Console.WriteLine($"Total customer records: {count}"); Console.WriteLine(""); // Running query 3 string sql3 = "select StateProvince, count(*) as Number from Customers group by StateProvince order by Number desc"; ExecuteResponse groupByResponse = await client.PrepareAndExecuteRequestAsync(connId, sql3, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options); pbc::RepeatedField <Row> stateRows = groupByResponse.Results[0].FirstFrame.Rows; for (int i = 0; i < stateRows.Count; i++) { Row row = stateRows[i]; Console.WriteLine(row.Value[0].ScalarValue.StringValue + ": " + row.Value[1].ScalarValue.NumberValue); } } catch (Exception ex) { } finally { if (statementHandle != null) { await client.CloseStatementRequestAsync(connId, statementHandle.Id, options); statementHandle = null; } if (openConnResponse != null) { await client.CloseConnectionRequestAsync(connId, options); openConnResponse = null; } } }
public bool StartListening() { Background = Task.Run(async() => { while (true) { var clusterURL = ConfigurationManager.AppSettings["ClusterUrl"]; var hadoopUsername = ConfigurationManager.AppSettings["Username"]; var hadoopUserPassword = ConfigurationManager.AppSettings["Password"]; var hbaseTableName = ConfigurationManager.AppSettings["TableName"]; // Create a new instance of an HBase client. var creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword); var hbaseClient = new HBaseClient(creds); //Scan over rows in a table. Assume the table has integer keys and you want data between keys 25 and 35. var scanSettings = new Scanner() { batch = 10 }; var scannerInfo = await hbaseClient.CreateScannerAsync(hbaseTableName, scanSettings); CellSet next = null; var res = new List <HBaseEntry>(); var rowNum = 0; while ((next = hbaseClient.ScannerGetNext(scannerInfo)) != null) { res.AddRange(from row in next.rows let key = Encoding.UTF8.GetString(row.key) let value = Encoding.UTF8.GetString(row.values[0].data) let parts = key.Split(',') where parts.Length == 3 select new HBaseEntry() { Type = parts[0], Date = parts[1].Replace("0000000", "000"), RoomNumber = parts[2], Reading = value }); } var dateRangedList = res.Where(a => DateTime.Parse(a.Date) >= DateTime.UtcNow.AddDays(-5)).Select(a => a).ToList(); var map = new Dictionary <String, Dictionary <String, Dictionary <String, String> > > (); var tempList = dateRangedList.Where(a => a.Type == "Temperature").ToList(); var engyList = dateRangedList.Where(a => a.Type == "Energy").ToList(); var humList = dateRangedList.Where(a => a.Type == "Humidity").ToList(); var lghtList = dateRangedList.Where(a => a.Type == "Light").ToList(); map.Add("Temperature", GetDataAsMap(tempList)); map.Add("Energy", GetDataAsMap(engyList)); map.Add("Humidity", GetDataAsMap(humList)); map.Add("Light", GetDataAsMap(lghtList)); //get data var ctx = GlobalHost.ConnectionManager.GetHubContext <DashHub>(); ctx.Clients.All.acceptData(JsonConvert.SerializeObject(map)); Thread.Sleep(15000); } }); Background.Wait(); return(true); }
static async Task MainAsync(string[] args) { try { string clusterURL = "https://myClusterName.azurehdinsight.net"; string hadoopUsername = "******"; string hadoopUserPassword = "******"; string hbaseTableName = "sampleHbaseTable"; // Create a new instance of an HBase client. ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword); HBaseClient hbaseClient = new HBaseClient(creds); // Retrieve the cluster version. org.apache.hadoop.hbase.rest.protobuf.generated.Version version = await hbaseClient.GetVersionAsync(); Console.WriteLine("The HBase cluster version is " + version); // Create a new HBase table. TableSchema testTableSchema = new TableSchema(); testTableSchema.name = hbaseTableName; testTableSchema.columns.Add(new ColumnSchema() { name = "d" }); testTableSchema.columns.Add(new ColumnSchema() { name = "f" }); hbaseClient.CreateTableAsync(testTableSchema).Wait(); // Insert data into the HBase table. string testKey = "content"; string testValue = "the force is strong in this column"; CellSet cellSet = new CellSet(); CellSet.Row cellSetRow = new CellSet.Row { key = Encoding.UTF8.GetBytes(testKey) }; cellSet.rows.Add(cellSetRow); Cell value = new Cell { column = Encoding.UTF8.GetBytes("d:starwars"), data = Encoding.UTF8.GetBytes(testValue) }; cellSetRow.values.Add(value); hbaseClient.StoreCellsAsync(hbaseTableName, cellSet).Wait(); // Retrieve a cell by its key. cellSet = await hbaseClient.GetCellsAsync(hbaseTableName, testKey); Console.WriteLine("The data with the key '" + testKey + "' is: " + Encoding.UTF8.GetString(cellSet.rows[0].values[0].data)); // with the previous insert, it should yield: "the force is strong in this column" //Scan over rows in a table. Assume the table has integer keys and you want data between keys 25 and 35. Scanner scanSettings = new Scanner() { batch = 10, startRow = BitConverter.GetBytes(25), endRow = BitConverter.GetBytes(35) }; ScannerInformation scannerInfo = await hbaseClient.CreateScannerAsync(hbaseTableName, scanSettings, null); CellSet next = null; Console.WriteLine("Scan results"); while ((next = await hbaseClient.ScannerGetNextAsync(scannerInfo, null)) != null) { foreach (CellSet.Row row in next.rows) { Console.WriteLine(row.key + " : " + Encoding.UTF8.GetString(row.values[0].data)); } } } catch (Exception ex) { Console.WriteLine(ex); } Console.WriteLine("Press ENTER to continue ..."); Console.ReadLine(); }
protected override void Context() { target = new ClusterCredentials(new Uri("https://someurl.de/"), "uzern4m3", "s_mePassW0rd"); }
/// <summary> /// Initialize the HBase settings and connections /// </summary> public void InitializeHBase() { this.HBaseClusterUrl = Properties.Settings.Default.HBaseClusterUrl;//ConfigurationManager.AppSettings["HBaseClusterUrl"]; if (String.IsNullOrWhiteSpace(this.HBaseClusterUrl)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterUrl"); } this.HBaseClusterUserName = Properties.Settings.Default.HBaseClusterUserName;//ConfigurationManager.AppSettings["HBaseClusterUserName"]; if (String.IsNullOrWhiteSpace(this.HBaseClusterUserName)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterUserName"); } this.HBaseClusterPassword = Properties.Settings.Default.HBaseClusterPassword;//ConfigurationManager.AppSettings["HBaseClusterPassword"]; if (String.IsNullOrWhiteSpace(this.HBaseClusterPassword)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterPassword"); } this.HBaseTableName = Properties.Settings.Default.HBaseTableName;//ConfigurationManager.AppSettings["HBaseTableName"]; if (String.IsNullOrWhiteSpace(this.HBaseTableName)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseTableName"); } this.HBaseTableColumnFamily = Properties.Settings.Default.HBaseTableColumnFamily;//ConfigurationManager.AppSettings["HBaseTableColumnFamily"]; if (String.IsNullOrWhiteSpace(this.HBaseTableColumnFamily)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseTableColumnFamily"); } //TODO - DO NOT include the ROWKEY field in the column list as it is assumed to be at index 0 in tuple fields //Rest of the tuple fields are mapped with the column names provided var hbaseTableColumnNames = Properties.Settings.Default.HBaseTableColumnNames;//ConfigurationManager.AppSettings["HBaseTableColumnNames"]; if (String.IsNullOrWhiteSpace(hbaseTableColumnNames)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseTableColumnNames"); } //Setup the credentials for HBase cluster this.HBaseClusterCredentials = new ClusterCredentials( new Uri(this.HBaseClusterUrl), this.HBaseClusterUserName, this.HBaseClusterPassword); this.HBaseClusterClient = new HBaseClient(this.HBaseClusterCredentials); //Query HBase for existing tables var tables = this.HBaseClusterClient.ListTables(); Context.Logger.Info("Existing HBase tables - Count: {0}, Tables: {1}", tables.name.Count, String.Join(", ", tables.name)); //Read the HBaseTable Columns and convert them to byte[] this.HBaseTableColumns = hbaseTableColumnNames.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries). Select(c => c.Trim()).ToList(); //Create a HBase table if it not exists if (!tables.name.Contains(this.HBaseTableName)) { var tableSchema = new TableSchema(); tableSchema.name = this.HBaseTableName; tableSchema.columns.Add(new ColumnSchema() { name = this.HBaseTableColumnFamily }); HBaseClusterClient.CreateTable(tableSchema); Context.Logger.Info("Created HBase table: {0}", this.HBaseTableName); } else { Context.Logger.Info("Found an existing HBase table: {0}", this.HBaseTableName); } }
public void TestInitialize() { _credentials = ClusterCredentialsFactory.CreateFromFile(@"credentials.txt"); }