-
Notifications
You must be signed in to change notification settings - Fork 350
/
JdbcConfig.java
75 lines (61 loc) · 2 KB
/
JdbcConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright 2023 Datastrato.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.catalog.jdbc.config;
import com.datastrato.gravitino.Config;
import com.datastrato.gravitino.config.ConfigBuilder;
import com.datastrato.gravitino.config.ConfigEntry;
import java.util.Map;
public class JdbcConfig extends Config {
public static final ConfigEntry<String> JDBC_URL =
new ConfigBuilder("jdbc-url")
.doc("The url of the Jdbc connection")
.version("0.3.0")
.stringConf()
.createWithDefault(null);
public static final ConfigEntry<String> USERNAME =
new ConfigBuilder("jdbc-user")
.doc("The username of the Jdbc connection")
.version("0.3.0")
.stringConf()
.createWithDefault(null);
public static final ConfigEntry<String> PASSWORD =
new ConfigBuilder("jdbc-password")
.doc("The password of the Jdbc connection")
.version("0.3.0")
.stringConf()
.createWithDefault(null);
public static final ConfigEntry<Integer> POOL_MIN_SIZE =
new ConfigBuilder("jdbc.pool.min-size")
.doc("The minimum number of connections in the pool")
.version("0.3.0")
.intConf()
.createWithDefault(2);
public static final ConfigEntry<Integer> POOL_MAX_SIZE =
new ConfigBuilder("jdbc.pool.max-size")
.doc("The maximum number of connections in the pool")
.version("0.3.0")
.intConf()
.createWithDefault(10);
public String getJdbcUrl() {
return get(JDBC_URL);
}
public String getUsername() {
return get(USERNAME);
}
public String getPassword() {
return get(PASSWORD);
}
public int getPoolMinSize() {
return get(POOL_MIN_SIZE);
}
public int getPoolMaxSize() {
return get(POOL_MAX_SIZE);
}
public JdbcConfig(Map<String, String> properties) {
super(false);
loadFromMap(properties, k -> true);
assert null != getJdbcUrl();
}
}