32
32
import org .apache .hadoop .hive .conf .HiveConf ;
33
33
import org .apache .hadoop .hive .conf .HiveConf .ConfVars ;
34
34
import org .apache .hadoop .hive .ql .metadata .Hive ;
35
- import org .apache .hadoop .hive .ql .session .SessionState ;
36
35
import org .apache .hadoop .mapreduce .lib .input .FileInputFormat ;
37
36
import org .apache .hive .service .Service ;
38
37
import org .apache .hive .service .cli .CLIService ;
47
46
* a child JVM (which Hive calls local) or external.
48
47
*/
49
48
public class HiveEmbeddedServer2 {
50
- private String SCRATCH_DIR = "" ;
49
+ private String STORE_DIR = "" ;
51
50
private static final Logger log = LogServiceFactory .getLogService (Hive .class .getName ());
52
51
private HiveServer2 hiveServer ;
53
52
private HiveConf config ;
54
53
private int port ;
55
54
56
55
public void start (String storePath ) throws Exception {
57
56
log .info ("Starting Hive Local/Embedded Server..." );
58
- SCRATCH_DIR = storePath ;
57
+ STORE_DIR = storePath ;
59
58
if (hiveServer == null ) {
60
59
System .setProperty ("datanucleus.schema.autoCreateAll" , "true" );
61
60
System .setProperty ("hive.metastore.schema.verification" , "false" );
@@ -114,20 +113,17 @@ private CLIService getServiceClientInternal() {
114
113
115
114
private HiveConf configure () throws Exception {
116
115
log .info ("Setting The Hive Conf Variables" );
117
- String scratchDir = SCRATCH_DIR ;
118
-
119
116
Configuration cfg = new Configuration ();
120
117
HiveConf conf = new HiveConf (cfg , HiveConf .class );
121
118
conf .addToRestrictList ("columns.comments" );
122
119
conf .set ("hive.scratch.dir.permission" , "777" );
123
120
conf .setVar (ConfVars .SCRATCHDIRPERMISSION , "777" );
124
-
125
- conf .set ("hive.metastore.warehouse.dir" , scratchDir + "/warehouse" );
126
- conf .set ("hive.metastore.metadb.dir" , scratchDir + "/metastore_db" );
127
- conf .set ("hive.exec.scratchdir" , scratchDir );
121
+ conf .set ("hive.metastore.warehouse.dir" , STORE_DIR + "/warehouse" );
122
+ conf .set ("hive.metastore.metadb.dir" , STORE_DIR + "/metastore_db" );
123
+ conf .set ("hive.exec.scratchdir" , STORE_DIR + "/scratch" );
128
124
conf .set ("fs.permissions.umask-mode" , "000" );
129
125
conf .set ("javax.jdo.option.ConnectionURL" ,
130
- "jdbc:derby:;databaseName=" + scratchDir + "/metastore_db" + ";create=true" );
126
+ "jdbc:derby:;databaseName=" + STORE_DIR + "/metastore_db" + ";create=true" );
131
127
conf .set ("hive.metastore.local" , "true" );
132
128
conf .set ("hive.aux.jars.path" , "" );
133
129
conf .set ("hive.added.jars.path" , "" );
@@ -146,9 +142,6 @@ private HiveConf configure() throws Exception {
146
142
props .remove ("mapreduce.framework.name" );
147
143
props .setProperty ("fs.default.name" , "file:///" );
148
144
149
- // intercept SessionState to clean the threadlocal
150
- Field tss = SessionState .class .getDeclaredField ("tss" );
151
- tss .setAccessible (true );
152
145
return conf ;
153
146
}
154
147
0 commit comments