21
21
import java .lang .reflect .Method ;
22
22
import java .util .concurrent .ExecutorService ;
23
23
import java .util .concurrent .SynchronousQueue ;
24
- import org .apache .commons .cli .OptionBuilder ;
25
24
import org .apache .hadoop .conf .Configuration ;
26
25
import org .apache .hadoop .hive .common .ZKDeRegisterWatcher ;
27
26
import org .apache .hadoop .hive .common .ZooKeeperHiveHelper ;
40
39
import org .apache .hadoop .hive .metastore .metrics .Metrics ;
41
40
import org .apache .hadoop .hive .metastore .security .HadoopThriftAuthBridge ;
42
41
import org .apache .hadoop .hive .metastore .security .MetastoreDelegationTokenManager ;
43
- import org .apache .hadoop .hive .metastore .utils .CommonCliOptions ;
44
42
import org .apache .hadoop .hive .metastore .utils .LogUtils ;
45
43
import org .apache .hadoop .hive .metastore .utils .MetaStoreUtils ;
46
44
import org .apache .hadoop .hive .metastore .utils .MetastoreVersionInfo ;
61
59
import org .apache .thrift .server .TServlet ;
62
60
import org .apache .thrift .server .TThreadPoolServer ;
63
61
import org .apache .thrift .transport .TServerSocket ;
62
+ import org .apache .thrift .transport .TSocket ;
64
63
import org .apache .thrift .transport .TTransport ;
64
+ import org .apache .thrift .transport .TTransportException ;
65
65
import org .apache .thrift .transport .TTransportFactory ;
66
66
67
67
import org .eclipse .jetty .security .ConstraintMapping ;
@@ -219,69 +219,14 @@ public static long renewDelegationToken(String tokenStrForm) throws IOException
219
219
return delegationTokenManager .renewDelegationToken (tokenStrForm );
220
220
}
221
221
222
- /**
223
- * HiveMetaStore specific CLI
224
- *
225
- */
226
- public static class HiveMetastoreCli extends CommonCliOptions {
227
- private int port ;
228
-
229
- @ SuppressWarnings ("static-access" )
230
- HiveMetastoreCli (Configuration configuration ) {
231
- super ("hivemetastore" , true );
232
- this .port = MetastoreConf .getIntVar (configuration , ConfVars .SERVER_PORT );
233
-
234
- // -p port
235
- OPTIONS .addOption (OptionBuilder
236
- .hasArg ()
237
- .withArgName ("port" )
238
- .withDescription ("Hive Metastore port number, default:"
239
- + this .port )
240
- .create ('p' ));
241
-
242
- }
243
- @ Override
244
- public void parse (String [] args ) {
245
- super .parse (args );
246
-
247
- // support the old syntax "hivemetastore [port]" but complain
248
- args = commandLine .getArgs ();
249
- if (args .length > 0 ) {
250
- // complain about the deprecated syntax -- but still run
251
- System .err .println (
252
- "This usage has been deprecated, consider using the new command "
253
- + "line syntax (run with -h to see usage information)" );
254
-
255
- this .port = Integer .parseInt (args [0 ]);
256
- }
257
-
258
- // notice that command line options take precedence over the
259
- // deprecated (old style) naked args...
260
-
261
- if (commandLine .hasOption ('p' )) {
262
- this .port = Integer .parseInt (commandLine .getOptionValue ('p' ));
263
- } else {
264
- // legacy handling
265
- String metastorePort = System .getenv ("METASTORE_PORT" );
266
- if (metastorePort != null ) {
267
- this .port = Integer .parseInt (metastorePort );
268
- }
269
- }
270
- }
271
-
272
- public int getPort () {
273
- return this .port ;
274
- }
275
- }
276
-
277
222
/*
278
223
Interface to encapsulate Http and binary thrift server for
279
224
HiveMetastore
280
225
*/
281
226
private interface ThriftServer {
282
- public void start () throws Throwable ;
283
- public boolean isRunning ();
284
- public IHMSHandler getHandler ();
227
+ void start () throws Throwable ;
228
+ boolean isRunning ();
229
+ IHMSHandler getHandler ();
285
230
}
286
231
287
232
/**
@@ -316,7 +261,7 @@ public static void main(String[] args) throws Throwable {
316
261
startupShutdownMessage (HiveMetaStore .class , args , LOG );
317
262
318
263
try {
319
- String msg = "Starting hive metastore on port " + cli .port ;
264
+ String msg = "Starting hive metastore on port " + cli .getPort () ;
320
265
LOG .info (msg );
321
266
if (cli .isVerbose ()) {
322
267
System .err .println (msg );
@@ -631,10 +576,6 @@ private static ThriftServer startBinaryMetastore(int port, HadoopThriftAuthBridg
631
576
keyStorePassword , keyStoreType , keyStoreAlgorithm , sslVersionBlacklist );
632
577
}
633
578
634
- if (tcpKeepAlive ) {
635
- serverSocket = new TServerSocketKeepAlive (serverSocket );
636
- }
637
-
638
579
ExecutorService executorService = new ThreadPoolExecutor (minWorkerThreads , maxWorkerThreads ,
639
580
60L , TimeUnit .SECONDS , new SynchronousQueue <>(), r -> {
640
581
Thread thread = new Thread (r );
@@ -643,7 +584,21 @@ private static ThriftServer startBinaryMetastore(int port, HadoopThriftAuthBridg
643
584
return thread ;
644
585
});
645
586
646
- TThreadPoolServer .Args args = new TThreadPoolServer .Args (serverSocket )
587
+ TThreadPoolServer .Args args =
588
+ new TThreadPoolServer .Args (new TServerSocket (serverSocket .getServerSocket ()) {
589
+ @ Override
590
+ public TSocket accept () throws TTransportException {
591
+ TSocket ts = super .accept ();
592
+ // get the limit from the configuration for every new connection
593
+ int maxThriftMessageSize = (int ) MetastoreConf .getSizeVar (
594
+ conf , MetastoreConf .ConfVars .THRIFT_METASTORE_CLIENT_MAX_MESSAGE_SIZE );
595
+ HMSHandler .LOG .debug ("Thrift maxMessageSize = {}" , maxThriftMessageSize );
596
+ if (maxThriftMessageSize > 0 ) {
597
+ ts .getConfiguration ().setMaxMessageSize (maxThriftMessageSize );
598
+ }
599
+ return ts ;
600
+ }
601
+ })
647
602
.processor (processor )
648
603
.transportFactory (transFactory )
649
604
.protocolFactory (protocolFactory )
0 commit comments