Starting HiveServer2 after deploying hive unexpectedly throws the following exception:
Repeatedly check the configuration file, the configuration is correct, is the start failure, there is no way can only be based on error information troubleshooting.
* Find the Hiveconf.java-->unitfor (String unit, Timeunit Defaultunit) method, which can be seen in code because the unit is a variable that throws an exception, Then continue to see where this method is called.
1 Public Statictimeunit unitfor (String unit, Timeunit defaultunit) {2Unit =Unit.trim (). toLowerCase ();3 if(Unit.isempty ()) {4 if(Defaultunit = =NULL) {5 Throw NewIllegalArgumentException ("Time unit is not specified");6 }7 returnDefaultunit;8}Else if(Unit.equals ("D") | | unit.startswith ("Day"))) {9 returntimeunit.days;Ten}Else if(Unit.equals ("h") | | unit.startswith ("hour")) { One returntimeunit.hours; A}Else if(Unit.equals ("M") | | unit.startswith ("min"))) { - returntimeunit.minutes; -}Else if(Unit.equals ("s") | | Unit.startswith ("SEC")) { the returntimeunit.seconds; -}Else if(Unit.equals ("MS") | | unit.startswith ("msec")) { - returntimeunit.milliseconds; -}Else if(Unit.equals ("Us") | | unit.startswith ("USEC")) { + returntimeunit.microseconds; -}Else if(Unit.equals ("ns") | | unit.startswith ("NSEC"))) { + returntimeunit.nanoseconds; A } at Throw NewIllegalArgumentException ("Invalid Time unit" +unit); -}
* Through the wrong information know is Hiveconf.java-->totime (String value, Timeunit inputunit, Timeunit outunit) method called Unitfor method, and pass the processed value value , continue to look at the code.
1 Public Static Long ToTime (String value, Timeunit inputunit, Timeunit outunit) {2 string[] parsed = parsetime (Value.trim ()); 3 return Outunit.convert (long.valueof (Parsed[0].trim () trim ()), Unitfor (parsed[1].trim (), Inputunit )); 4 }
* Through the wrong information know is Hiveconf.java-->gettimevar (Configuration conf, confvars var, timeunit Outunit) method called Totiime method, and through GetVar The (conf, Var) method passes the processed var value and continues to look at the code.
1 Public Static Long Gettimevar (Configuration conf, confvars var, timeunit outunit) {2 return ToTime (GetVar (Conf, Var), Getdefaulttimeunit (Var), outunit); 3 }
* The Gettimevar method is called by the Cliserver.java-->getoperationstatus method and continues to look at the code.
1 Publicoperationstatus getoperationstatus (operationhandle ophandle)2 throwshivesqlexception {3Operation operation =Sessionmanager.getoperationmanager (). Getoperation (Ophandle);4 /**5 * If This is a background operation run asynchronously,6 * We block for a configured duration, before we return7 * (duration:hive_server2_long_polling_timeout).8 * However, if the background operation is complete, we return immediately.9 */Ten if(Operation.shouldrunasync ()) { Onehiveconf conf =operation.getparentsession (). gethiveconf (); A LongTimeout =hiveconf.gettimevar (conf, - HiveConf.ConfVars.HIVE_SERVER2_LONG_POLLING_TIMEOUT, timeunit.milliseconds); - Try { the Operation.getbackgroundhandle (). Get (timeout, timeunit.milliseconds); -}Catch(TimeoutException e) { - //No Op, return to the caller since long polling timeout had expired -Log.trace (Ophandle + ": Long Polling timed out"); +}Catch(cancellationexception e) { - //The background operation thread was cancelled +Log.trace (Ophandle + ": The background operation was cancelled", e); A}Catch(executionexception e) { at //The background operation thread was aborted -Log.warn (Ophandle + ": The background operation was aborted", e); -}Catch(interruptedexception e) { - //No op, this thread is interrupted - //in this case, the call might return sooner than long polling timeout - } in } -Operationstatus Opstatus =operation.getstatus (); toLog.debug (Ophandle + ": Getoperationstatus ()"); + sessionmanager.clearipaddress (); - returnOpstatus; the}
* In the above method there is the following sentence code.
1 long timeout = Hiveconf.gettimevar (conf, HiveConf.ConfVars.HIVE_SERVER2_LONG_POLLING_ TIMEOUT, timeunit.milliseconds);
* You can see that the value of the HiveConf.ConfVars.HIVE_SERVER2_LONG_POLLING_TIMEOUT parameter is passed to the Gettimevar method, now look at this parameter.
1 hive_server2_long_polling_timeout ("Hive.server2.long.polling.timeout", "5000ms", new Timevalidator (timeunit.milliseconds))
* The hive.server2.long.polling.timeout parameter of the corresponding configuration file, in Hive-site.xml to see how much this value is.
1 <property>2 <name>hive.server2. Long.polling.timeout</name>3 <value>5000L</value>4 Long polling</description>5 </property>
* You can see that the value of this parameter is 5000L, looking back at the method of throwing an exception, found that if the judgment of the statement is no L this unit, to this understanding that the original configuration file is a bug, the configuration file this parameter value unit modified to MS, problem solving.
1 <property>2 <name>hive.server2. Long.polling.timeout</name>3 <value>5000ms</value>4 Long polling</description>5 </property>
The version used is: hive-0.13.1-cdh5.2.1, has confirmed that the subsequent version has fixed the bug.
Startup HiveServer2 throws "Java.lang.IllegalArgumentException:Invalid Time Unit L" exception