17
17
18
18
package org .apache .seatunnel .connectors .seatunnel .hbase .config ;
19
19
20
- import org .apache .seatunnel .shade .com .typesafe .config .Config ;
21
-
22
20
import org .apache .seatunnel .api .configuration .ReadonlyConfig ;
23
- import org .apache .seatunnel .common .config .TypesafeConfigUtils ;
24
21
25
22
import lombok .Builder ;
26
23
import lombok .Getter ;
29
26
import java .util .List ;
30
27
import java .util .Map ;
31
28
32
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .ENCODING ;
33
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .FAMILY_NAME ;
34
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .HBASE_BATCH_CONFIG ;
35
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .HBASE_CACHE_BLOCKS_CONFIG ;
36
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .HBASE_CACHING_CONFIG ;
37
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .HBASE_EXTRA_CONFIG ;
38
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .HBASE_TTL_CONFIG ;
39
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .NULL_MODE ;
40
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .ROWKEY_COLUMNS ;
41
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .ROWKEY_DELIMITER ;
42
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .TABLE ;
43
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .VERSION_COLUMN ;
44
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .WAL_WRITE ;
45
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .WRITE_BUFFER_SIZE ;
46
- import static org .apache .seatunnel .connectors .seatunnel .hbase .config .HbaseConfig .ZOOKEEPER_QUORUM ;
47
-
48
29
@ Builder
49
30
@ Getter
50
31
public class HbaseParameters implements Serializable {
@@ -65,27 +46,32 @@ public class HbaseParameters implements Serializable {
65
46
66
47
private Map <String , String > hbaseExtraConfig ;
67
48
68
- @ Builder .Default private int caching = HBASE_CACHING_CONFIG .defaultValue ();
49
+ @ Builder .Default private int caching = HbaseSinkOptions . HBASE_CACHING_CONFIG .defaultValue ();
69
50
70
- @ Builder .Default private int batch = HBASE_BATCH_CONFIG .defaultValue ();
51
+ @ Builder .Default private int batch = HbaseSinkOptions . HBASE_BATCH_CONFIG .defaultValue ();
71
52
72
- @ Builder .Default private Long ttl = HBASE_TTL_CONFIG .defaultValue ();
53
+ @ Builder .Default private Long ttl = HbaseSinkOptions . HBASE_TTL_CONFIG .defaultValue ();
73
54
74
- @ Builder .Default private boolean cacheBlocks = HBASE_CACHE_BLOCKS_CONFIG .defaultValue ();
55
+ @ Builder .Default
56
+ private boolean cacheBlocks = HbaseSinkOptions .HBASE_CACHE_BLOCKS_CONFIG .defaultValue ();
75
57
76
- @ Builder .Default private String rowkeyDelimiter = ROWKEY_DELIMITER .defaultValue ();
58
+ @ Builder .Default
59
+ private String rowkeyDelimiter = HbaseSinkOptions .ROWKEY_DELIMITER .defaultValue ();
77
60
78
- @ Builder .Default private HbaseConfig .NullMode nullMode = NULL_MODE .defaultValue ();
61
+ @ Builder .Default
62
+ private HbaseSinkOptions .NullMode nullMode = HbaseSinkOptions .NULL_MODE .defaultValue ();
79
63
80
- @ Builder .Default private boolean walWrite = WAL_WRITE .defaultValue ();
64
+ @ Builder .Default private boolean walWrite = HbaseSinkOptions . WAL_WRITE .defaultValue ();
81
65
82
- @ Builder .Default private int writeBufferSize = WRITE_BUFFER_SIZE .defaultValue ();
66
+ @ Builder .Default
67
+ private int writeBufferSize = HbaseSinkOptions .WRITE_BUFFER_SIZE .defaultValue ();
83
68
84
- @ Builder .Default private HbaseConfig .EnCoding enCoding = ENCODING .defaultValue ();
69
+ @ Builder .Default
70
+ private HbaseSinkOptions .EnCoding enCoding = HbaseSinkOptions .ENCODING .defaultValue ();
85
71
86
72
public static HbaseParameters buildWithConfig (ReadonlyConfig config ) {
87
73
HbaseParametersBuilder builder = HbaseParameters .builder ();
88
- String table = config .get (TABLE );
74
+ String table = config .get (HbaseBaseOptions . TABLE );
89
75
int colonIndex = table .indexOf (':' );
90
76
if (colonIndex != -1 ) {
91
77
String namespace = table .substring (0 , colonIndex );
@@ -97,29 +83,29 @@ public static HbaseParameters buildWithConfig(ReadonlyConfig config) {
97
83
}
98
84
99
85
// required parameters
100
- builder .zookeeperQuorum (config .get (ZOOKEEPER_QUORUM ));
101
- builder .rowkeyColumns (config .get (ROWKEY_COLUMNS ));
102
- builder .familyNames (config .get (FAMILY_NAME ));
103
-
104
- builder .rowkeyDelimiter (config .get (ROWKEY_DELIMITER ));
105
- builder .versionColumn (config .get (VERSION_COLUMN ));
106
- String nullMode = String .valueOf (config .get (NULL_MODE ));
107
- builder .nullMode (HbaseConfig .NullMode .valueOf (nullMode .toUpperCase ()));
108
- builder .walWrite (config .get (WAL_WRITE ));
109
- builder .writeBufferSize (config .get (WRITE_BUFFER_SIZE ));
110
- String encoding = String .valueOf (config .get (ENCODING ));
111
- builder .enCoding (HbaseConfig .EnCoding .valueOf (encoding .toUpperCase ()));
112
- builder .hbaseExtraConfig (config .get (HBASE_EXTRA_CONFIG ));
113
- builder .ttl (config .get (HBASE_TTL_CONFIG ));
86
+ builder .zookeeperQuorum (config .get (HbaseBaseOptions . ZOOKEEPER_QUORUM ));
87
+ builder .rowkeyColumns (config .get (HbaseBaseOptions . ROWKEY_COLUMNS ));
88
+ builder .familyNames (config .get (HbaseSinkOptions . FAMILY_NAME ));
89
+
90
+ builder .rowkeyDelimiter (config .get (HbaseSinkOptions . ROWKEY_DELIMITER ));
91
+ builder .versionColumn (config .get (HbaseSinkOptions . VERSION_COLUMN ));
92
+ String nullMode = String .valueOf (config .get (HbaseSinkOptions . NULL_MODE ));
93
+ builder .nullMode (HbaseSinkOptions .NullMode .valueOf (nullMode .toUpperCase ()));
94
+ builder .walWrite (config .get (HbaseSinkOptions . WAL_WRITE ));
95
+ builder .writeBufferSize (config .get (HbaseSinkOptions . WRITE_BUFFER_SIZE ));
96
+ String encoding = String .valueOf (config .get (HbaseSinkOptions . ENCODING ));
97
+ builder .enCoding (HbaseSinkOptions .EnCoding .valueOf (encoding .toUpperCase ()));
98
+ builder .hbaseExtraConfig (config .get (HbaseSinkOptions . HBASE_EXTRA_CONFIG ));
99
+ builder .ttl (config .get (HbaseSinkOptions . HBASE_TTL_CONFIG ));
114
100
return builder .build ();
115
101
}
116
102
117
- public static HbaseParameters buildWithSourceConfig (Config pluginConfig ) {
103
+ public static HbaseParameters buildWithSourceConfig (ReadonlyConfig pluginConfig ) {
118
104
HbaseParametersBuilder builder = HbaseParameters .builder ();
119
105
120
106
// required parameters
121
- builder .zookeeperQuorum (pluginConfig .getString ( ZOOKEEPER_QUORUM . key () ));
122
- String table = pluginConfig .getString ( TABLE . key () );
107
+ builder .zookeeperQuorum (pluginConfig .get ( HbaseBaseOptions . ZOOKEEPER_QUORUM ));
108
+ String table = pluginConfig .get ( HbaseBaseOptions . TABLE );
123
109
int colonIndex = table .indexOf (':' );
124
110
if (colonIndex != -1 ) {
125
111
String namespace = table .substring (0 , colonIndex );
@@ -129,18 +115,17 @@ public static HbaseParameters buildWithSourceConfig(Config pluginConfig) {
129
115
builder .table (table );
130
116
}
131
117
132
- if (pluginConfig .hasPath (HBASE_EXTRA_CONFIG .key ())) {
133
- Config extraConfig = pluginConfig .getConfig (HBASE_EXTRA_CONFIG .key ());
134
- builder .hbaseExtraConfig (TypesafeConfigUtils .configToMap (extraConfig ));
118
+ if (pluginConfig .getOptional (HbaseSinkOptions .HBASE_EXTRA_CONFIG ).isPresent ()) {
119
+ builder .hbaseExtraConfig (pluginConfig .get (HbaseSinkOptions .HBASE_EXTRA_CONFIG ));
135
120
}
136
- if (pluginConfig .hasPath ( HBASE_CACHING_CONFIG . key () )) {
137
- builder .caching (pluginConfig .getInt ( HBASE_CACHING_CONFIG . key () ));
121
+ if (pluginConfig .getOptional ( HbaseSinkOptions . HBASE_CACHING_CONFIG ). isPresent ( )) {
122
+ builder .caching (pluginConfig .get ( HbaseSinkOptions . HBASE_CACHING_CONFIG ));
138
123
}
139
- if (pluginConfig .hasPath ( HBASE_BATCH_CONFIG . key () )) {
140
- builder .batch (pluginConfig .getInt ( HBASE_BATCH_CONFIG . key () ));
124
+ if (pluginConfig .getOptional ( HbaseSinkOptions . HBASE_BATCH_CONFIG ). isPresent ( )) {
125
+ builder .batch (pluginConfig .get ( HbaseSinkOptions . HBASE_BATCH_CONFIG ));
141
126
}
142
- if (pluginConfig .hasPath ( HBASE_CACHE_BLOCKS_CONFIG . key () )) {
143
- builder .cacheBlocks (pluginConfig .getBoolean ( HBASE_CACHE_BLOCKS_CONFIG . key () ));
127
+ if (pluginConfig .getOptional ( HbaseSinkOptions . HBASE_CACHE_BLOCKS_CONFIG ). isPresent ( )) {
128
+ builder .cacheBlocks (pluginConfig .get ( HbaseSinkOptions . HBASE_CACHE_BLOCKS_CONFIG ));
144
129
}
145
130
return builder .build ();
146
131
}
0 commit comments