Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RuntimeEnv.java
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.common;
16 
17 import java.lang.System;
18 
19 import com.cloudera.impala.thrift.TStartupOptions;
21 
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 
30 public class RuntimeEnv {
31  private final static Logger LOG = LoggerFactory.getLogger(RuntimeEnv.class);
32 
33  public static RuntimeEnv INSTANCE = new RuntimeEnv();
34 
35  private int numCores_;
36 
37  // Indicates if column lineage information should be computed for each query.
38  private boolean computeLineage_;
39 
40  // Indicates whether this is an environment for testing.
41  private boolean isTestEnv_;
42 
43  public RuntimeEnv() {
44  reset();
45  try {
46  TStartupOptions opts = FeSupport.GetStartupOptions();
47  computeLineage_ = opts.compute_lineage;
48  } catch (InternalException e) {
49  LOG.error("Error retrieving BE startup options. Shutting down JVM");
50  System.exit(1);
51  }
52  }
53 
57  public void reset() {
58  numCores_ = Runtime.getRuntime().availableProcessors();
59  }
60 
61  public int getNumCores() { return numCores_; }
62  public void setNumCores(int numCores) { this.numCores_ = numCores; }
63  public void setTestEnv(boolean v) { isTestEnv_ = v; }
64  public boolean isTestEnv() { return isTestEnv_; }
65  public boolean computeLineage() { return computeLineage_; }
66 
67 }