List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:com.mnt.base.util.BaseConfiguration.java
/** * setup the home path, by default, the program should specify the SERVER_HOME_KEY in system env, and then configuration the home path * in VM parameters./*from www.j a v a 2s . co m*/ * * if not specify, the default server home is current folder. */ private static void populateServerHome() { String serverHomeKey = System.getProperty(SERVER_HOME_KEY); if (!CommonUtil.isEmpty(serverHomeKey)) { homeMode = true; serverHome = System.getProperty(serverHomeKey); if (CommonUtil.isEmpty(serverHome)) { serverHome = System.getenv(serverHomeKey); } if (serverHome == null) { serverHome = ""; } if (!serverHome.endsWith("/") && !serverHome.endsWith("\\")) { serverHome += File.separator; } } else { serverHome = ""; userDir = System.getProperty("user.dir"); if (!userDir.endsWith("/") && !userDir.endsWith("\\")) { userDir += File.separator; } homeMode = false; } }
From source file:com.kylinolap.job.engine.JobEngineConfig.java
private String getHadoopJobConfFilePath(CubeCapacity capaticy, boolean appendSuffix) throws IOException { String hadoopJobConfFile;/*from ww w .j av a2 s . c o m*/ if (appendSuffix) hadoopJobConfFile = (HADOOP_JOB_CONF_FILENAME + "_" + capaticy.toString().toLowerCase() + ".xml"); else hadoopJobConfFile = (HADOOP_JOB_CONF_FILENAME + ".xml"); String path = System.getProperty(KylinConfig.KYLIN_CONF); if (path == null) { path = System.getenv(KylinConfig.KYLIN_CONF); } if (path != null) { path = path + File.separator + hadoopJobConfFile; } if (null == path || !new File(path).exists()) { File defaultFilePath = new File("/etc/kylin/" + hadoopJobConfFile); if (defaultFilePath.exists()) { path = defaultFilePath.getAbsolutePath(); } else { logger.debug("Search conf file " + hadoopJobConfFile + " from classpath ..."); InputStream is = JobEngineConfig.class.getClassLoader().getResourceAsStream(hadoopJobConfFile); if (is == null) { logger.debug("Can't get " + hadoopJobConfFile + " from classpath"); logger.debug("No " + hadoopJobConfFile + " file were found"); } else { File tmp = File.createTempFile("hadoop_job_conf", ".xml"); inputStreamToFile(is, tmp); path = tmp.getAbsolutePath(); } } } if (null == path || !new File(path).exists()) { return ""; } return OptionsHelper.convertToFileURL(path); }
From source file:co.aurasphere.botmill.fb.test.api.UploadApiTest.java
@Before public void setup() { Assume.assumeTrue(isConfigurationExist()); FbBotMillContext.getInstance().setup(System.getenv("fb.page.token"), System.getenv("fb.validation.token")); }
From source file:io.fabric8.spring.cloud.discovery.KubernetesDiscoveryClient.java
@Override public ServiceInstance getLocalServiceInstance() { String serviceName = properties.getServiceName(); String podName = System.getenv(HOSTNAME); ServiceInstance defaultInstance = new DefaultServiceInstance(serviceName, "localhost", 8080, false); Endpoints endpoints = client.endpoints().withName(serviceName).get(); if (Utils.isNullOrEmpty(podName) || endpoints == null) { return defaultInstance; }/*from w w w.j a v a 2 s . c om*/ try { return endpoints.getSubsets().stream() .filter(s -> s.getAddresses().get(0).getTargetRef().getName().equals(podName)) .map(s -> (ServiceInstance) new KubernetesServiceInstance(serviceName, s.getAddresses().stream().findFirst().orElseThrow(IllegalStateException::new), s.getPorts().stream().findFirst().orElseThrow(IllegalStateException::new), false)) .findFirst().orElse(defaultInstance); } catch (Throwable t) { return defaultInstance; } }
From source file:io.ignitr.springboot.common.metadata.DeploymentContext.java
/** * @return application version */ public String getVersion() { return appVersion != null ? appVersion : System.getenv(ENV_APP_VERSION); }
From source file:com.appdynamics.cloudfoundry.appdservicebroker.CredentialsHolder.java
CredentialsHolder() { try {/*from w w w.java2s . c om*/ HashMap<String, JSONObject> appd_plans_map = (JSONObject) new JSONParser() .parse(System.getenv("APPD_PLANS")); init(appd_plans_map); } catch (ParseException pe) { log.error("Unable to parse the passed content: " + System.getenv("APPD_PLANS")); } }
From source file:com.github.lynxdb.server.common.CassandraConfig.java
@Override protected String getKeyspaceName() { return System.getenv("cassandra_keyspace"); }
From source file:net.orpiske.tcs.client.services.TagCloudServiceClient.java
private HttpHeaders getHeaders() { String user = System.getenv("TCS_USER"); String password = System.getenv("TCS_PASSWORD"); if (user == null || user.isEmpty()) { logger.fatal("The backend system username is not provided (please set " + "the TCS_USER environment variable)"); throw new InvalidCredentialsException("The backend system username is not provided"); }/*from w w w . ja va 2s .co m*/ if (password == null || password.isEmpty()) { logger.fatal("The backend system password is not provided (please set " + "the TCS_PASSWORD environment variable)"); throw new InvalidCredentialsException("The backend system password is not provided"); } String auth = user + ":" + password; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); byte[] encodedAuth = Base64.encodeBase64(auth.getBytes()); headers.add("Authorization", "Basic " + new String(encodedAuth)); return headers; }
From source file:com.liferay.nativity.control.win.WindowsNativityUtil.java
private static String _extractDLLFromJar() { _logger.trace("Extracting dll from jar"); String jarPath = "/"; String src64 = _createPath(jarPath, _NATIVITY_LIB_x64); String src86 = _createPath(jarPath, _NATIVITY_LIB_x86); String dataFolder = System.getenv("APPDATA"); String destFolder = _createPath(dataFolder, "Liferay"); if (!_createFolder(destFolder)) { return null; }//from w w w. j a va 2s . c o m String dest64 = _createPath(destFolder, _NATIVITY_LIB_x64); String dest86 = _createPath(destFolder, _NATIVITY_LIB_x86); if (_dllsExist(dest64, dest86)) { _logger.trace("DLL's exist, no need to extract from jar"); return destFolder; } _logger.trace("Trying {} {}", src64, dest64); _extractDLL(src64, dest64); _logger.trace("Trying {} {}", src86, dest86); _extractDLL(src86, dest86); return destFolder; }
From source file:com.cloudera.impala.planner.S3PlannerTest.java
/** * Environment variable TARGET_FILESYSTEM will be set to s3 when running against S3. * If not, then skip this test. Also remember the scheme://bucket for later. *///from ww w .j a v a 2 s . co m @Before public void setUpTest() { String targetFs = System.getenv("TARGET_FILESYSTEM"); // Skip if the config property was not set. i.e. not running against S3. assumeTrue(targetFs != null && targetFs.equals("s3")); String fsNameStr = System.getenv("DEFAULT_FS"); fsName = new Path(fsNameStr); }