protected BigClient(BigtableConfig config, Func <Channel> channelCreator) { Config = config; Channel = channelCreator(); ChannelCreator = channelCreator; ClusterId = config.ToClusterId(); }
public Loader(BigtableCredentials credentials, BigtableConfig config) { GrpcEnvironment.SetThreadPoolSize(BatchAndPoolSize); _adminClient = new BigAdminClient(credentials, config); _dataClient = new BigDataClient(credentials, config); }
public void Setup() { var test = "test"; var config = new BigtableConfig(test, test, test); var creds = new BigtableCredentials(); _admin = new BigAdminClient(creds, config); _data = new BigDataClient(creds, config); }
public static string ToProjectId(this BigtableConfig config) { if (String.IsNullOrEmpty(config.Cluster)) { throw new ApplicationException("Missing or invalid config.Project"); } return(String.Format(BigtableConstants.Templates.Project, config.Project)); }
public static string ToClusterId(this BigtableConfig config) { if (String.IsNullOrEmpty(config.Cluster)) { return(config.ToZoneId()); } return(String.Format(BigtableConstants.Templates.Cluster, config.ToZoneId(), config.Cluster)); }
public static string ToZoneId(this BigtableConfig config) { if (String.IsNullOrEmpty(config.Zone)) { return(config.ToProjectId()); } return(String.Format(BigtableConstants.Templates.Zone, config.ToProjectId(), config.Zone)); }
public async Task ConnectAsync(string configFile) { // Setup var config = await BigtableConfig.LoadAsync(configFile); var credentials = await BigtableCredentials.UseApplicationDefaultCredentialsAsync(); // Get mapper _bigtable = new Bigtable(credentials, config); }
public async Task Readme(string configFile) { // Load configuration var config = BigtableConfig.Load(configFile); // Create credentials var credentials = await BigtableCredentials.UseApplicationDefaultCredentialsAsync(); // Data client using (var dataClient = new BigDataClient(credentials, config)) { // Scan myTable var rows = await dataClient.GetRowsAsync( tableName : "myTable", startKey : "abc", endKey : "def", rowLimit : 20 ); // Show the user foreach (var row in rows) { // Write key to console Console.WriteLine("Key: " + row.KeyString); // Iterate the families which were returned foreach (var family in row.FieldsByFamily) { // Results are organized by family var familyName = family.Key; // Iterate the fields in this family foreach (var field in family.Value) { var fieldName = field.Key; // Iterate the versions of the field foreach (var cell in field.Value) { // Write to console Console.WriteLine("{0}:{1} = {2}", familyName, cell.ColumnName, cell.StringValue); } } } } } }
public static BigtableConfig GetConfig() { try { // Notify user Console.WriteLine("Loading config from: " + Constants.ConfigFileLocation); // Load config return(BigtableConfig.Load(Constants.ConfigFileLocation)); } catch (Exception exception) { // Notify user CommandLine.InformUser("Fatal", "Could not load config file: " + Constants.ConfigFileLocation); CommandLine.RenderException(exception); CommandLine.WaitForUserAndThen("exit"); // Giveup return(null); } }
public SimpleClient(BigtableConfig config) : this(config.Project, config.Zone, config.Cluster) { // Chained }
public BigAdminClient(BigtableCredentials credentials, BigtableConfig config, bool isReadOnly = false) : base(config, credentials.CreateAdminChannel) { // Create _client = new BigtableTableService.BigtableTableServiceClient(Channel); }
public ClientFactory() { _config = Utilities.GetConfig(); _credentials = BigtableCredentials.UseApplicationDefaultCredentialsAsync().Result; }
public static async Task Run(BigtableConfig config) { GrpcEnvironment.DisableLogging(); try { var credentials = await BigtableCredentials.UseApplicationDefaultCredentialsAsync(); // Admin client using (var loader = new Loader(credentials, config)) { // Examine cluster await loader.Initialize(); // Ensure pricing table exists if (loader.NoExampleTables) { var state = "Missing example tables."; var question = "Would you like to create and populate the example tables?"; if (!AskUserPermission(state, question)) { return; } } else if (loader.SomeExampleTables) { var state = "Missing some of the example tables."; var question = "Would you like to create and populate the missing tables?"; if (!AskUserPermission(state, question)) { return; } } else { var state = "Example tables are present."; var question = "Would you like to DROP, recreate, and populate the example tables?"; if (!AskUserPermission(state, question)) { return; } } await loader.LoadTables(); } } catch (Exception exception) { // Notify user CommandLine.InformUser("Oops", "Bootstrapping did not work out as planned."); CommandLine.RenderException(exception); // Giveup return; } finally { // Give user a chance to read screen if (Debugger.IsAttached) { CommandLine.WaitForUserAndThen("exit"); } } }
internal BigDataClient(BigtableConfig config, Func <Channel> channelCreator) : base(config, channelCreator) { // Create _client = new BigtableService.BigtableServiceClient(Channel); }
public BigDataClient(BigtableCredentials credentials, BigtableConfig config, bool isReadOnly = false) : base(config, () => credentials.CreateDataChannel(isReadOnly)) { // Create _client = new BigtableService.BigtableServiceClient(Channel); }
public BigtableReader(BigtableCredentials credentials, BigtableConfig config) { AdminClient = new Lazy <BigAdminClient>(() => new BigAdminClient(credentials, config)); DataClient = new Lazy <BigDataClient>(() => new BigDataClient(credentials, config)); }