13
13
*/
14
14
package io .trino .plugin .hudi ;
15
15
16
+ import com .google .common .annotations .VisibleForTesting ;
16
17
import com .google .common .collect .ImmutableSet ;
17
18
import com .google .inject .Injector ;
18
19
import com .google .inject .Key ;
19
20
import com .google .inject .Module ;
20
21
import io .airlift .bootstrap .Bootstrap ;
21
22
import io .airlift .bootstrap .LifeCycleManager ;
23
+ import io .airlift .configuration .ConfigPropertyMetadata ;
22
24
import io .airlift .json .JsonModule ;
23
25
import io .opentelemetry .api .OpenTelemetry ;
24
26
import io .opentelemetry .api .trace .Tracer ;
25
27
import io .trino .filesystem .manager .FileSystemModule ;
26
28
import io .trino .plugin .base .classloader .ClassLoaderSafeConnectorPageSourceProvider ;
27
29
import io .trino .plugin .base .classloader .ClassLoaderSafeConnectorSplitManager ;
28
30
import io .trino .plugin .base .classloader .ClassLoaderSafeNodePartitioningProvider ;
31
+ import io .trino .plugin .base .config .ConfigUtils ;
29
32
import io .trino .plugin .base .jmx .MBeanServerModule ;
30
33
import io .trino .plugin .base .session .SessionPropertiesProvider ;
31
34
import io .trino .plugin .hive .NodeVersion ;
52
55
public class HudiConnectorFactory
53
56
implements ConnectorFactory
54
57
{
58
+ private static final Module DEFAULT_ADDITIONAL_MODULE = EMPTY_MODULE ;
59
+
55
60
@ Override
56
61
public String getName ()
57
62
{
@@ -62,38 +67,34 @@ public String getName()
62
67
public Connector create (String catalogName , Map <String , String > config , ConnectorContext context )
63
68
{
64
69
checkStrictSpiVersionMatch (context , this );
65
- return createConnector (catalogName , config , context , Optional .empty ());
70
+ return createConnector (catalogName , config , context , DEFAULT_ADDITIONAL_MODULE );
71
+ }
72
+
73
+ @ Override
74
+ public Set <String > getSecuritySensitivePropertyNames (String catalogName , Map <String , String > config , ConnectorContext context )
75
+ {
76
+ ClassLoader classLoader = HudiConnectorFactory .class .getClassLoader ();
77
+ try (ThreadContextClassLoader _ = new ThreadContextClassLoader (classLoader )) {
78
+ Bootstrap app = createBootstrap (catalogName , config , context , DEFAULT_ADDITIONAL_MODULE , true );
79
+
80
+ Set <ConfigPropertyMetadata > usedProperties = app .configureAndGetUsedProperties ();
81
+
82
+ return ConfigUtils .getSecuritySensitivePropertyNames (config , usedProperties );
83
+ }
66
84
}
67
85
86
+ @ VisibleForTesting
68
87
public static Connector createConnector (
69
88
String catalogName ,
70
89
Map <String , String > config ,
71
90
ConnectorContext context ,
72
- Optional < Module > module )
91
+ Module module )
73
92
{
74
93
ClassLoader classLoader = HudiConnectorFactory .class .getClassLoader ();
75
94
try (ThreadContextClassLoader _ = new ThreadContextClassLoader (classLoader )) {
76
- Bootstrap app = new Bootstrap (
77
- new MBeanModule (),
78
- new JsonModule (),
79
- new HudiModule (),
80
- new HiveMetastoreModule (Optional .empty ()),
81
- new FileSystemModule (catalogName , context .getNodeManager (), context .getOpenTelemetry (), false , false ),
82
- new MBeanServerModule (),
83
- module .orElse (EMPTY_MODULE ),
84
- binder -> {
85
- binder .bind (OpenTelemetry .class ).toInstance (context .getOpenTelemetry ());
86
- binder .bind (Tracer .class ).toInstance (context .getTracer ());
87
- binder .bind (NodeVersion .class ).toInstance (new NodeVersion (context .getNodeManager ().getCurrentNode ().getVersion ()));
88
- binder .bind (NodeManager .class ).toInstance (context .getNodeManager ());
89
- binder .bind (TypeManager .class ).toInstance (context .getTypeManager ());
90
- binder .bind (CatalogName .class ).toInstance (new CatalogName (catalogName ));
91
- });
92
-
93
- Injector injector = app
94
- .doNotInitializeLogging ()
95
- .setRequiredConfigurationProperties (config )
96
- .initialize ();
95
+ Bootstrap app = createBootstrap (catalogName , config , context , module , false );
96
+
97
+ Injector injector = app .initialize ();
97
98
98
99
LifeCycleManager lifeCycleManager = injector .getInstance (LifeCycleManager .class );
99
100
HudiTransactionManager transactionManager = injector .getInstance (HudiTransactionManager .class );
@@ -115,4 +116,38 @@ public static Connector createConnector(
115
116
hudiTableProperties .getTableProperties ());
116
117
}
117
118
}
119
+
120
+ private static Bootstrap createBootstrap (
121
+ String catalogName ,
122
+ Map <String , String > config ,
123
+ ConnectorContext context ,
124
+ Module module ,
125
+ boolean quietBootstrap )
126
+ {
127
+ Bootstrap app = new Bootstrap (
128
+ new MBeanModule (),
129
+ new JsonModule (),
130
+ new HudiModule (),
131
+ new HiveMetastoreModule (Optional .empty ()),
132
+ new FileSystemModule (catalogName , context .getNodeManager (), context .getOpenTelemetry (), false , quietBootstrap ),
133
+ new MBeanServerModule (),
134
+ module ,
135
+ binder -> {
136
+ binder .bind (OpenTelemetry .class ).toInstance (context .getOpenTelemetry ());
137
+ binder .bind (Tracer .class ).toInstance (context .getTracer ());
138
+ binder .bind (NodeVersion .class ).toInstance (new NodeVersion (context .getNodeManager ().getCurrentNode ().getVersion ()));
139
+ binder .bind (NodeManager .class ).toInstance (context .getNodeManager ());
140
+ binder .bind (TypeManager .class ).toInstance (context .getTypeManager ());
141
+ binder .bind (CatalogName .class ).toInstance (new CatalogName (catalogName ));
142
+ });
143
+
144
+ if (quietBootstrap ) {
145
+ app .quiet ()
146
+ .suppressErrorsAndWarnings ();
147
+ }
148
+
149
+ return app
150
+ .doNotInitializeLogging ()
151
+ .setRequiredConfigurationProperties (config );
152
+ }
118
153
}
0 commit comments