Skip to content

Commit 00ffd5d

Browse files
committed
Add jars in WindowingClient;
set SUMBITCHILDJVM to true set windowingOutput to true
1 parent c22f4db commit 00ffd5d

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

windowing/src/main/java/com/sap/hadoop/windowing/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class Constants
2222
public static final String WINDOW_PARTITION_MEM_SIZE = "com.sap.hadoop.windowing.partition.memory.size";
2323

2424
public static final String WINDOW_PARTITION_CLASS = "com.sap.hadoop.windowing.partition.class";
25-
public static final String DEFAULT_WINDOW_PARTITION_CLASS = "com.sap.hadoop.ds.list.ByteBasedList";
25+
public static final String DEFAULT_WINDOW_PARTITION_CLASS = "com.sap.hadoop.ds.list.PartitionedByteBasedList";
2626

2727
/*
2828
* the difference between script & expression is that script is only parsed during translation,

windowing/src/main/java/com/sap/hadoop/windowing/cli2/WindowingClient.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.sap.hadoop.windowing.cli2;
22

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;
36
import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
7+
import org.apache.hadoop.hive.ql.session.SessionState.ResourceType;
48

59
import com.sap.hadoop.windowing.Constants;
610
import com.sap.hadoop.windowing.WindowingException;
@@ -22,6 +26,7 @@ class WindowingClient implements HiveQueryExecutor
2226
WindowingClient(WindowingHiveCliDriver hiveDriver) throws WindowingException
2327
{
2428
this.hiveDriver = hiveDriver;
29+
setupConf(hiveDriver.getCfg());
2530
wshell = new WindowingShell( hiveDriver.getCfg(), new Translator(), new MRExecutor());
2631
wshell.setHiveQryExec(this);
2732
qryOutPrntr = new QueryOutputPrinter(hiveDriver.getHiveConsole());
@@ -79,4 +84,45 @@ private boolean outputQueryResult()
7984
{
8085
return wshell.getCfg().getBoolean(Constants.WINDOWING_OUTPUT_QUERY_RESULT, false);
8186
}
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+
}
82128
}

0 commit comments

Comments
 (0)