Skip to content

Commit 1a798b4

Browse files
author
Komal Yadav
committed
Create_Tables
1 parent c7dc08b commit 1a798b4

3 files changed

Lines changed: 344 additions & 32 deletions

File tree

cdap-master/pom.xml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@
113113
<artifactId>cdap-messaging-ext-spanner</artifactId>
114114
<version>${project.version}</version>
115115
</dependency>
116-
<dependency>
117-
<groupId>io.cdap.cdap</groupId>
118-
<artifactId>cdap-metadata-ext-spanner</artifactId>
119-
<version>${project.version}</version>
120-
</dependency>
121116
<dependency>
122117
<groupId>org.apache.tephra</groupId>
123118
<artifactId>tephra-api</artifactId>
@@ -739,28 +734,6 @@
739734
</configuration>
740735
</execution>
741736

742-
<!-- Copy metadata extensions -->
743-
<execution>
744-
<id>copy-metadata-ext-spanner</id>
745-
<phase>process-resources</phase>
746-
<goals>
747-
<goal>copy-resources</goal>
748-
</goals>
749-
<configuration combine.self="override">
750-
<outputDirectory>${stage.metadata.ext.dir}/spanner</outputDirectory>
751-
<resources>
752-
<resource>
753-
<directory>
754-
${project.parent.basedir}/cdap-metadata-ext-spanner/target/libexec/
755-
</directory>
756-
<includes>
757-
<include>*.jar</include>
758-
</includes>
759-
</resource>
760-
</resources>
761-
</configuration>
762-
</execution>
763-
764737
<!-- Copy remote authenticator extensions -->
765738
<execution>
766739
<id>copy-authenticator-ext-gcp</id>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright © 2025 Cask Data, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package io.cdap.cdap.metadata.spanner;
17+
18+
import com.google.cloud.spanner.DatabaseAdminClient;
19+
import com.google.cloud.spanner.DatabaseClient;
20+
import com.google.cloud.spanner.DatabaseId;
21+
import com.google.cloud.spanner.Spanner;
22+
import java.util.Map;
23+
24+
/**
25+
* Utility class for spanner metadata storage.
26+
*/
27+
class SpannerConfig {
28+
29+
static final String PROJECT = "project";
30+
static final String INSTANCE = "instance";
31+
static final String DATABASE = "database";
32+
33+
static DatabaseClient getSpannerDbClient(String projectID, String instanceID, String databaseID, Spanner spanner) {
34+
DatabaseId db = DatabaseId.of(projectID, instanceID, databaseID);
35+
return spanner.getDatabaseClient(db);
36+
}
37+
38+
static DatabaseAdminClient getSpannerDbAdminClient(Spanner spanner) {
39+
return spanner.getDatabaseAdminClient();
40+
}
41+
42+
static String getInstanceID(Map<String, String> cConf) {
43+
String instance = cConf.get(INSTANCE);
44+
if (instance == null) {
45+
throw new IllegalArgumentException("Missing configuration " + PROJECT);
46+
}
47+
return instance;
48+
}
49+
50+
static String getDatabaseID(Map<String, String> cConf) {
51+
String instance = cConf.get(DATABASE);
52+
if (instance == null) {
53+
throw new IllegalArgumentException("Missing configuration " + DATABASE);
54+
}
55+
return cConf.get(DATABASE);
56+
}
57+
58+
static String getProjectID(Map<String, String> cConf) {
59+
String instance = cConf.get(PROJECT);
60+
if (instance == null) {
61+
throw new IllegalArgumentException("Missing configuration " + PROJECT);
62+
}
63+
return cConf.get(PROJECT);
64+
}
65+
}

0 commit comments

Comments
 (0)