1
1
package com .sap .hadoop .windowing .cli2 ;
2
2
3
+ import org .apache .hadoop .hive .conf .HiveConf ;
4
+ import org .apache .hadoop .hive .conf .HiveConf .ConfVars ;
5
+ import org .apache .hadoop .hive .ql .session .SessionState ;
3
6
import org .apache .hadoop .hive .ql .session .SessionState .LogHelper ;
7
+ import org .apache .hadoop .hive .ql .session .SessionState .ResourceType ;
4
8
5
9
import com .sap .hadoop .windowing .Constants ;
6
10
import com .sap .hadoop .windowing .WindowingException ;
@@ -22,6 +26,7 @@ class WindowingClient implements HiveQueryExecutor
22
26
WindowingClient (WindowingHiveCliDriver hiveDriver ) throws WindowingException
23
27
{
24
28
this .hiveDriver = hiveDriver ;
29
+ setupConf (hiveDriver .getCfg ());
25
30
wshell = new WindowingShell ( hiveDriver .getCfg (), new Translator (), new MRExecutor ());
26
31
wshell .setHiveQryExec (this );
27
32
qryOutPrntr = new QueryOutputPrinter (hiveDriver .getHiveConsole ());
@@ -79,4 +84,45 @@ private boolean outputQueryResult()
79
84
{
80
85
return wshell .getCfg ().getBoolean (Constants .WINDOWING_OUTPUT_QUERY_RESULT , false );
81
86
}
87
+
88
+ private static final String [] addedJars = new String [] {
89
+ "lib/com.sap.hadoop.windowing-0.0.2-SNAPSHOT.jar" ,
90
+ "lib/antlr-runtime-3.0.1.jar" ,
91
+ "lib/groovy-all-1.8.0.jar" ,
92
+ "lib/hive-metastore-0.10.0-SNAPSHOT.jar"
93
+ };
94
+
95
+ private void setupConf (HiveConf cfg ) throws WindowingException
96
+ {
97
+ String hiveHome = System .getenv ("HIVE_HOME" );
98
+ // for testing purposes
99
+ hiveHome = hiveHome == null ? cfg .get ("HIVE_HOME" ) : hiveHome ;
100
+
101
+ if ( hiveHome == null )
102
+ {
103
+ throw new WindowingException ("Environment variable HIVE_HOME must be set." );
104
+ }
105
+
106
+ if ( !hiveHome .endsWith ("/" ))
107
+ {
108
+ hiveHome += "/" ;
109
+ }
110
+
111
+ /*
112
+ * add jars to SessionState
113
+ */
114
+ SessionState ss = SessionState .get ();
115
+ for (String j : addedJars )
116
+ {
117
+ ss .add_resource (ResourceType .JAR , hiveHome + j );
118
+ }
119
+
120
+ /*
121
+ * set run in childJvm to true
122
+ * why? because w/o this CLI tries to print status based on QueryPlan, which is null for us.
123
+ */
124
+ cfg .setBoolean (ConfVars .SUBMITVIACHILD .toString (), true );
125
+
126
+ cfg .setBoolean (Constants .WINDOWING_OUTPUT_QUERY_RESULT , true );
127
+ }
82
128
}
0 commit comments