Skip to content

Commit c182634

Browse files
authored
Apply some Zeppelin fixes for kafka (#110)
1 parent 547e5c7 commit c182634

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ build-zeppelin: build
134134
# attaches to terminal (not run as daemon)
135135
run-zeppelin: build-zeppelin
136136
kubectl apply -f deploy/docker/zeppelin/zeppelin-flink-engine.yaml
137+
kubectl apply -f deploy/docker/zeppelin/zeppelin-kafkadb.yaml
137138
docker run --rm -p 8080:8080 \
138139
--volume=${HOME}/.kube/config:/opt/zeppelin/.kube/config \
139140
--add-host=docker-for-desktop:host-gateway \

deploy/dev/kafka.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ spec:
4545
nodePort: 31092
4646
brokers:
4747
- broker: 0
48+
# advertisedHost: host.docker.internal # swap these lines to enable Zeppelin, TODO: figure out a way around this
4849
advertisedHost: 127.0.0.1
4950
nodePort: 31234
5051
config:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: hoptimator.linkedin.com/v1alpha1
2+
kind: Database
3+
metadata:
4+
name: kafka-database
5+
spec:
6+
schema: KAFKA
7+
url: jdbc:kafka://bootstrap.servers=host.docker.internal:9092
8+
dialect: Calcite

deploy/rbac.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ metadata:
55
name: hoptimator-operator
66
rules:
77
- apiGroups: ["hoptimator.linkedin.com"]
8-
resources: ["acls", "kafkatopics", "subscriptions", "sqljobs", "pipelines"]
8+
resources: ["acls", "databases", "engines", "jobtemplates", "kafkatopics", "pipelines", "sqljobs", "subscriptions", "tabletemplates", "views"]
99
verbs: ["get", "watch", "list", "update", "create"]
1010
- apiGroups: ["hoptimator.linkedin.com"]
11-
resources: ["kafkatopics/status", "subscriptions/status", "acls/status", "sqljobs/status", "pipelines/status"]
11+
resources: ["acls/status", "kafkatopics/status", "pipelines/status", "sqljobs/status", "subscriptions/status"]
1212
verbs: ["get", "patch"]
1313
- apiGroups: ["flink.apache.org"]
1414
resources: ["flinkdeployments", "flinksessionjobs"]

deploy/samples/kafkadb.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ spec:
3838
value.format = json
3939
scan.startup.mode = earliest-offset
4040
key.fields = KEY
41+
key.format = raw
4142
value.fields-include = EXCEPT_KEY
4243
4344
---

hoptimator-jdbc/src/main/java/com/linkedin/hoptimator/jdbc/HoptimatorDriver.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ public Connection connect(String url, Properties props) throws SQLException {
5757
return null;
5858
}
5959
try {
60+
// Load properties from the URL and from getConnection()'s properties.
61+
// URL properties take precedence.
62+
Properties properties = new Properties();
63+
properties.putAll(props); // via getConnection()
64+
properties.putAll(ConnectStringParser.parse(url.substring(getConnectStringPrefix().length())));
65+
6066
if (prepareFactory == null) {
6167
// funky way of extending Driver with a custom Prepare:
62-
return withPrepareFactory(() -> new Prepare(props))
63-
.connect(url, props);
68+
return withPrepareFactory(() -> new Prepare(properties))
69+
.connect(url, properties);
6470
}
65-
Connection connection = super.connect(url, props);
71+
Connection connection = super.connect(url, properties);
6672
if (connection == null) {
6773
throw new IOException("Could not connect to " + url);
6874
}
@@ -76,12 +82,6 @@ public Connection connect(String url, Properties props) throws SQLException {
7682
calciteConnection.setSchema("DEFAULT");
7783

7884
WrappedSchemaPlus wrappedRootSchema = new WrappedSchemaPlus(rootSchema);
79-
80-
// Load properties from the URL and from getConnection()'s properties.
81-
// URL properties take precedence.
82-
Properties properties = new Properties();
83-
properties.putAll(props); // via getConnection()
84-
properties.putAll(ConnectStringParser.parse(url.substring(getConnectStringPrefix().length())));
8585
String[] catalogs = properties.getProperty("catalogs", "").split(",");
8686

8787
if (catalogs.length == 0 || catalogs[0].length() == 0) {
@@ -92,7 +92,7 @@ public Connection connect(String url, Properties props) throws SQLException {
9292
} else {
9393
// load specific catalogs when loaded as `jdbc:hoptimator://catalogs=foo,bar`
9494
for (String catalog : catalogs) {
95-
CatalogService.catalog(catalog).register(wrappedRootSchema, props);
95+
CatalogService.catalog(catalog).register(wrappedRootSchema, properties);
9696
}
9797
}
9898

@@ -104,7 +104,7 @@ public Connection connect(String url, Properties props) throws SQLException {
104104

105105
@Override
106106
public Driver withPrepareFactory(Supplier<CalcitePrepare> prepareFactory) {
107-
return new HoptimatorDriver(prepareFactory);
107+
return new HoptimatorDriver(prepareFactory);
108108
}
109109

110110
public static class Prepare extends CalcitePrepareImpl {

hoptimator-kafka/src/test/resources/kafka-ddl.id

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ spec:
1313
entryClass: com.linkedin.hoptimator.flink.runner.FlinkRunner
1414
args:
1515
- CREATE DATABASE IF NOT EXISTS `KAFKA` WITH ()
16-
- CREATE TABLE IF NOT EXISTS `KAFKA`.`existing-topic-2` (`KEY` VARCHAR, `VALUE` BINARY) WITH ('connector'='kafka', 'key.fields'='KEY', 'properties.bootstrap.servers'='one-kafka-bootstrap.kafka.svc.cluster.local:9094', 'scan.startup.mode'='earliest-offset', 'topic'='existing-topic-2', 'value.fields-include'='EXCEPT_KEY', 'value.format'='json')
16+
- CREATE TABLE IF NOT EXISTS `KAFKA`.`existing-topic-2` (`KEY` VARCHAR, `VALUE` BINARY) WITH ('connector'='kafka', 'key.fields'='KEY', 'key.format'='raw', 'properties.bootstrap.servers'='one-kafka-bootstrap.kafka.svc.cluster.local:9094', 'scan.startup.mode'='earliest-offset', 'topic'='existing-topic-2', 'value.fields-include'='EXCEPT_KEY', 'value.format'='json')
1717
- CREATE DATABASE IF NOT EXISTS `KAFKA` WITH ()
18-
- CREATE TABLE IF NOT EXISTS `KAFKA`.`existing-topic-1` (`KEY` VARCHAR, `VALUE` BINARY) WITH ('connector'='kafka', 'key.fields'='KEY', 'properties.bootstrap.servers'='one-kafka-bootstrap.kafka.svc.cluster.local:9094', 'scan.startup.mode'='earliest-offset', 'topic'='existing-topic-1', 'value.fields-include'='EXCEPT_KEY', 'value.format'='json')
18+
- CREATE TABLE IF NOT EXISTS `KAFKA`.`existing-topic-1` (`KEY` VARCHAR, `VALUE` BINARY) WITH ('connector'='kafka', 'key.fields'='KEY', 'key.format'='raw', 'properties.bootstrap.servers'='one-kafka-bootstrap.kafka.svc.cluster.local:9094', 'scan.startup.mode'='earliest-offset', 'topic'='existing-topic-1', 'value.fields-include'='EXCEPT_KEY', 'value.format'='json')
1919
- INSERT INTO `KAFKA`.`existing-topic-1` (`KEY`, `VALUE`) SELECT * FROM `KAFKA`.`existing-topic-2`
2020
jarURI: file:///opt/hoptimator-flink-runner.jar
2121
parallelism: 1

0 commit comments

Comments
 (0)