List of usage examples for com.google.common.base StandardSystemProperty JAVA_IO_TMPDIR
StandardSystemProperty JAVA_IO_TMPDIR
To view the source code for com.google.common.base StandardSystemProperty JAVA_IO_TMPDIR.
Click Source Link
From source file:org.glowroot.container.TempDirs.java
public static File createTempDir(String prefix) throws IOException { final int tempDirAttempts = 10000; String javaTempDir = MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), "."); File baseDir = new File(javaTempDir); String baseName = prefix + "-" + System.currentTimeMillis() + "-"; for (int counter = 0; counter < tempDirAttempts; counter++) { File tempDir = new File(baseDir, baseName + counter); if (tempDir.mkdir()) { return tempDir; }/*from w w w . j a v a 2 s .c om*/ } throw new IOException("Failed to create directory within " + tempDirAttempts + " attempts (tried " + baseName + "0 to " + baseName + (tempDirAttempts - 1) + ')'); }
From source file:de.ks.flatadocdb.TempRepository.java
@Override protected void before() throws Throwable { path = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value(), "testRepository"); new DeleteDir(path).delete(); metaModel = new MetaModel(); repository = new Repository(path); repository.initialize(metaModel,// ww w . j a v a 2s . co m Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setDaemon(true).build())); }
From source file:org.glowroot.agent.init.ProcessInfoCreator.java
public static ProcessInfo create(String glowrootVersion) { RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); Long processId = parseProcessId(ManagementFactory.getRuntimeMXBean().getName()); String jvm = ""; String javaVmName = StandardSystemProperty.JAVA_VM_NAME.value(); if (javaVmName != null) { jvm = javaVmName + " (" + StandardSystemProperty.JAVA_VM_VERSION.value() + ", " + System.getProperty("java.vm.info") + ")"; }/* www. j a va 2 s .c o m*/ String java = ""; String javaVersion = StandardSystemProperty.JAVA_VERSION.value(); if (javaVersion != null) { java = "version " + javaVersion + ", vendor " + StandardSystemProperty.JAVA_VM_VENDOR.value(); } String heapDumpPath = getHeapDumpPathFromCommandLine(); if (heapDumpPath == null) { String javaTempDir = MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), "."); heapDumpPath = new File(javaTempDir).getAbsolutePath(); } ProcessInfo.Builder builder = ProcessInfo.newBuilder(); try { builder.setHostName(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { logger.warn(e.getMessage(), e); } if (processId != null) { builder.setProcessId(OptionalInt64.newBuilder().setValue(processId).build()); } return builder.setStartTime(runtimeMXBean.getStartTime()).setJvm(jvm).setJava(java) .addAllJvmArg(runtimeMXBean.getInputArguments()).setHeapDumpDefaultDir(heapDumpPath) .setGlowrootAgentVersion(glowrootVersion).build(); }
From source file:com.epam.ta.reportportal.util.ResourceCopierBean.java
/** * Sets destination as system temp directory and specified file name into * /*from w w w . j a v a2 s. co m*/ * @param to */ public void setTempDirDestination(String to) { this.destination = Files.asByteSink(new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), to)); }
From source file:pl.coffeepower.blog.messagebus.aeron.AeronModule.java
@Provides @Singleton//from w w w . j a v a 2s. c o m private MediaDriver createMediaDriver() { MediaDriver.Context context = new MediaDriver.Context().threadingMode(ThreadingMode.SHARED_NETWORK) .dirsDeleteOnStart(true); context.aeronDirectoryName(System.getProperty("aeron.dir", StandardSystemProperty.JAVA_IO_TMPDIR.value() + File.separator + "aeron" + File.separator + UUID.randomUUID().toString())); return MediaDriver.launch(context); }
From source file:com.google.copybara.MainArguments.java
/** * Returns the base working directory. This method should not be accessed directly by any other * class but Main./* www. j ava2 s.co m*/ */ public Path getBaseWorkdir(FileSystem fs) throws IOException { Path workdirPath; if (baseWorkdir == null) { // This is equivalent to Files.createTempDirectory(String.. but // works for any filesystem Path tmpDir = fs.getPath(StandardSystemProperty.JAVA_IO_TMPDIR.value()); // This is only needed if using a fs for testing. Files.createDirectories(tmpDir); workdirPath = Files.createTempDirectory(tmpDir, "workdir"); } else { workdirPath = fs.getPath(baseWorkdir).normalize(); } if (Files.exists(workdirPath) && !Files.isDirectory(workdirPath)) { // Better being safe throw new IOException("'" + workdirPath + "' exists and is not a directory"); } if (!isDirEmpty(workdirPath)) { System.err.println("WARNING: " + workdirPath + " is not empty"); } return workdirPath; }
From source file:org.openqa.selenium.remote.server.InMemorySession.java
private InMemorySession(WebDriver driver, Capabilities capabilities, Dialect downstream) throws IOException { this.driver = Preconditions.checkNotNull(driver); Capabilities caps;//from w w w. j a v a 2 s .c o m if (driver instanceof HasCapabilities) { caps = ((HasCapabilities) driver).getCapabilities(); } else { caps = capabilities; } this.capabilities = caps.asMap().entrySet().stream().filter(e -> e.getValue() != null) .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, Map.Entry::getValue)); this.id = new SessionId(UUID.randomUUID().toString()); this.downstream = Preconditions.checkNotNull(downstream); File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString()); Preconditions.checkState(tempRoot.mkdirs()); this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot); this.handler = new JsonHttpCommandHandler(new PretendDriverSessions(), LOG); }
From source file:org.openqa.selenium.grid.session.remote.RemoteSession.java
protected RemoteSession(Dialect downstream, Dialect upstream, SessionCodec codec, SessionId id, Map<String, Object> capabilities) { this.downstream = downstream; this.upstream = upstream; this.codec = codec; this.id = id; this.capabilities = capabilities; File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString()); Preconditions.checkState(tempRoot.mkdirs()); this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot); CommandExecutor executor = new ActiveSessionCommandExecutor(this); this.driver = new Augmenter() .augment(new RemoteWebDriver(executor, new ImmutableCapabilities(getCapabilities()))); }
From source file:com.epam.reportportal.utils.LaunchFile.java
public static File getTempDir() { File tempDir = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), "reportportal"); if (tempDir.mkdirs()) { LOGGER.debug("Temp directory for ReportPortal launch files is created: '{}'", tempDir.getAbsolutePath()); }// www . j a va 2s . com return tempDir; }
From source file:org.openqa.selenium.remote.server.ServicedSession.java
public ServicedSession(DriverService service, Dialect downstream, Dialect upstream, SessionCodec codec, SessionId id, Map<String, Object> capabilities) throws IOException { this.service = service; this.downstream = downstream; this.upstream = upstream; this.codec = codec; this.id = id; this.capabilities = capabilities; File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString()); Preconditions.checkState(tempRoot.mkdirs()); this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot); CommandExecutor executor = new ActiveSessionCommandExecutor(this); this.driver = new Augmenter() .augment(new RemoteWebDriver(executor, new ImmutableCapabilities(getCapabilities()))); }