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,33 @@ 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
+ try (ThreadContextClassLoader _ = new ThreadContextClassLoader (HudiConnectorFactory .class .getClassLoader ())) {
77
+ Bootstrap app = createBootstrap (catalogName , config , context , DEFAULT_ADDITIONAL_MODULE , true );
78
+
79
+ Set <ConfigPropertyMetadata > usedProperties = app .configure ();
80
+
81
+ return ConfigUtils .getSecuritySensitivePropertyNames (config , usedProperties );
82
+ }
66
83
}
67
84
85
+ @ VisibleForTesting
68
86
public static Connector createConnector (
69
87
String catalogName ,
70
88
Map <String , String > config ,
71
89
ConnectorContext context ,
72
- Optional < Module > module )
90
+ Module module )
73
91
{
74
92
ClassLoader classLoader = HudiConnectorFactory .class .getClassLoader ();
75
93
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
- });
94
+ Bootstrap app = createBootstrap (catalogName , config , context , module , false );
92
95
93
- Injector injector = app
94
- .doNotInitializeLogging ()
95
- .setRequiredConfigurationProperties (config )
96
- .initialize ();
96
+ Injector injector = app .initialize ();
97
97
98
98
LifeCycleManager lifeCycleManager = injector .getInstance (LifeCycleManager .class );
99
99
HudiTransactionManager transactionManager = injector .getInstance (HudiTransactionManager .class );
@@ -115,4 +115,35 @@ public static Connector createConnector(
115
115
hudiTableProperties .getTableProperties ());
116
116
}
117
117
}
118
+
119
+ private static Bootstrap createBootstrap (
120
+ String catalogName ,
121
+ Map <String , String > config ,
122
+ ConnectorContext context ,
123
+ Module module ,
124
+ boolean quietBootstrap )
125
+ {
126
+ Bootstrap app = new Bootstrap (
127
+ new MBeanModule (),
128
+ new JsonModule (),
129
+ new HudiModule (),
130
+ new HiveMetastoreModule (Optional .empty ()),
131
+ new FileSystemModule (catalogName , context .getNodeManager (), context .getOpenTelemetry (), false , quietBootstrap ),
132
+ new MBeanServerModule (),
133
+ module ,
134
+ binder -> {
135
+ binder .bind (OpenTelemetry .class ).toInstance (context .getOpenTelemetry ());
136
+ binder .bind (Tracer .class ).toInstance (context .getTracer ());
137
+ binder .bind (NodeVersion .class ).toInstance (new NodeVersion (context .getNodeManager ().getCurrentNode ().getVersion ()));
138
+ binder .bind (NodeManager .class ).toInstance (context .getNodeManager ());
139
+ binder .bind (TypeManager .class ).toInstance (context .getTypeManager ());
140
+ binder .bind (CatalogName .class ).toInstance (new CatalogName (catalogName ));
141
+ });
142
+
143
+ return app
144
+ .withQuiet (quietBootstrap )
145
+ .withSkipErrorReporting (quietBootstrap )
146
+ .doNotInitializeLogging ()
147
+ .setRequiredConfigurationProperties (config );
148
+ }
118
149
}
0 commit comments