SpannerImpl(SpannerRpc gapicRpc, int defaultPrefetchChunks, SpannerOptions options) { super(options); this.gapicRpc = gapicRpc; this.defaultPrefetchChunks = defaultPrefetchChunks; this.dbAdminClient = new DatabaseAdminClientImpl(options.getProjectId(), gapicRpc); this.instanceClient = new InstanceAdminClientImpl(options.getProjectId(), gapicRpc, dbAdminClient); }
spanner = getSpanner(properties, host, project); if (project == null) { project = spanner.getOptions().getProjectId();
spanner.getDatabaseClient(DatabaseId.of(options.getProjectId(), instanceId, databaseId));
@Test public void builder() { String host = "http://localhost:8000/"; String projectId = "test-project"; Map<String, String> labels = new HashMap<>(); labels.put("env", "dev"); SpannerOptions options = SpannerOptions.newBuilder() .setHost(host) .setProjectId(projectId) .setPrefetchChunks(2) .setSessionLabels(labels) .build(); assertThat(options.getHost()).isEqualTo(host); assertThat(options.getProjectId()).isEqualTo(projectId); assertThat(options.getPrefetchChunks()).isEqualTo(2); assertThat(options.getSessionLabels()).containsExactlyEntriesIn(labels); }
@Override protected void before() throws Throwable { this.initializeConfig(); this.config.setUp(); SpannerOptions options = config.spannerOptions(); String instanceProperty = System.getProperty(TEST_INSTANCE_PROPERTY, ""); InstanceId instanceId; if (!instanceProperty.isEmpty()) { instanceId = InstanceId.of(instanceProperty); isOwnedInstance = false; logger.log(Level.INFO, "Using existing test instance: {0}", instanceId); } else { instanceId = InstanceId.of(config.spannerOptions().getProjectId(), "test-instance"); isOwnedInstance = true; } testHelper = RemoteSpannerHelper.create(options, instanceId); instanceAdminClient = testHelper.getClient().getInstanceAdminClient(); logger.log(Level.FINE, "Test env endpoint is {0}", options.getHost()); if (isOwnedInstance) { initializeInstance(instanceId); } }
public GapicSpannerRpc(SpannerOptions options) { this.projectId = options.getProjectId(); this.projectName = PROJECT_NAME_TEMPLATE.instantiate("project", this.projectId);
DatabaseId.of(options.getProjectId(), instanceId, databaseId));
try { String command = args[0]; DatabaseId db = DatabaseId.of(options.getProjectId(), args[1], args[2]); String clientProject = spanner.getOptions().getProjectId(); if (!db.getInstanceId().getProject().equals(clientProject)) { System.err.println(
options.getProjectId(), instanceId, databaseId));
options.getProjectId(), instanceId, databaseId));
SpannerImpl(SpannerRpc gapicRpc, int defaultPrefetchChunks, SpannerOptions options) { super(options); this.gapicRpc = gapicRpc; this.defaultPrefetchChunks = defaultPrefetchChunks; this.dbAdminClient = new DatabaseAdminClientImpl(options.getProjectId(), gapicRpc); this.instanceClient = new InstanceAdminClientImpl(options.getProjectId(), gapicRpc, dbAdminClient); }
public SpannerAccessor connectToSpanner() { SpannerOptions.Builder builder = SpannerOptions.newBuilder(); if (getProjectId() != null) { builder.setProjectId(getProjectId().get()); } if (getServiceFactory() != null) { builder.setServiceFactory(this.getServiceFactory()); } if (getHost() != null) { builder.setHost(getHost().get()); } String userAgentString = USER_AGENT_PREFIX + "/" + ReleaseInfo.getReleaseInfo().getVersion(); builder.setHeaderProvider(FixedHeaderProvider.create("user-agent", userAgentString)); SpannerOptions options = builder.build(); Spanner spanner = options.getService(); DatabaseClient databaseClient = spanner.getDatabaseClient( DatabaseId.of(options.getProjectId(), getInstanceId().get(), getDatabaseId().get())); BatchClient batchClient = spanner.getBatchClient( DatabaseId.of(options.getProjectId(), getInstanceId().get(), getDatabaseId().get())); DatabaseAdminClient databaseAdminClient = spanner.getDatabaseAdminClient(); return new SpannerAccessor(spanner, databaseClient, databaseAdminClient, batchClient); } }
public GapicSpannerRpc(SpannerOptions options) { this.projectId = options.getProjectId(); this.projectName = PROJECT_NAME_TEMPLATE.instantiate("project", this.projectId);