APISonar


com.google.common.io.Files.createTempDir

> com > google > common > io > Files > createTempDir
com APIs google APIs common APIs io APIs Files APIs createTempDir APIs

Example 1
public static String createTempDir() {
    final File tmpDir = Files.createTempDir();
    tmpDir.deleteOnExit();
    return tmpDir.getAbsolutePath();
  }
Example 2
public static File createAutoDeleteTempDir() {
    File tempdir = Files.createTempDir();
    tempdir.delete();
    tempdir.mkdir();

    tempdir.deleteOnExit();
    return tempdir;
  }
Example 3
public void reportLostStorageInWorkerRegister() throws Exception {
    File ssdDir = Files.createTempDir();
    String ssdPath = ssdDir.getAbsolutePath();
    File hddDir = Files.createTempDir();
    String hddPath = hddDir.getAbsolutePath();

    // Set to read only so worker storage paths cannot be initialize
    ssdDir.setReadOnly();
    hddDir.setReadOnly();

    startClusterWithWorkerStorage(ssdPath, hddPath);
    checkLostStorageResults(ssdPath, hddPath);
  }
Example 4
public static File createTempDir() {
        String systemTempDir = System.getProperty("java.io.tmpdir");
        if(!(systemTempDir.contains(VOLD_TEST_DATA_DIRECTORY_NAME))) {
            File parentDir = new File(systemTempDir + "/" + VOLD_TEST_DATA_DIRECTORY_NAME);
            parentDir.delete();
            parentDir.mkdir();
            parentDir.deleteOnExit();
            System.setProperty("java.io.tmpdir", parentDir.getAbsolutePath());
        }
        File tempdir = Files.createTempDir();
        tempdir.delete();
        tempdir.mkdir();
        tempdir.deleteOnExit();
        return tempdir;
    }
Example 5
public static String getTempDir(final String dirName) {
    final File dir = Files.createTempDir();
    dir.deleteOnExit();

    return dir.getAbsolutePath() + File.separator + dirName;
  }
Example 6
protected void setUp() throws IOException {
    File tempDir = Files.createTempDir();
    inputDir = new File(tempDir, "input");
    inputDir.mkdir();
    outputDir = new File(tempDir, "output");
    outputDir.mkdir();
  }
Example 7
private File createTemporaryProject(String inputFolder) throws IOException,
            ConfigurationException {
        File tempDir = Files.createTempDir();
        File scrDir = new File(tempDir, "src");
        scrDir.mkdir();
        copyFiles(new File(inputFolder), scrDir);
        createPomFile(tempDir, scrDir);
        return tempDir;

    }
Example 8
public ZookeeperTestService(Configuration config) {
    this.workDir = Files.createTempDir().getAbsolutePath();
    this.hadoopConf = config;
  }
Example 9
public DeployTester(String appPath, List<ModelFactory> modelFactories) {
        this(appPath, modelFactories,
             new ConfigserverConfig(new ConfigserverConfig.Builder()
                     .configServerDBDir(Files.createTempDir().getAbsolutePath())
                     .configDefinitionsDir(Files.createTempDir().getAbsolutePath())),
             Clock.systemUTC());
    }
Example 10
protected FileDataStoreFactory newDataStoreFactory() throws IOException {
    File dataDir = Files.createTempDir();
    dataDir.deleteOnExit();
    return new FileDataStoreFactory(dataDir);
  }
Example 11
private LogFilePath getTempLogFilePath(String topic) {
        return new LogFilePath(Files.createTempDir().toString(),
            topic,
            new String[]{"part-1"},
            0, 1, 0, ".log"
        );
    }
Example 12
private File unzipSldPackage(InputStream object) throws IOException {
        File tempDir = Files.createTempDir();

        org.geoserver.util.IOUtils.decompress(object, tempDir);

        return tempDir;
    }
Example 13
public void test() throws Exception {

    String resourceName = "orcWriterTest";

    File tmpDir = Files.createTempDir();

    FileSystem fs = FileSystem.get(new Configuration());

    Path output = new Path(tmpDir.getAbsolutePath(), "test");

    orcTools.writeJsonResourceRecordsAsBinary(resourceName, null, output, null);

    Assert.assertTrue(orcTools.checkSameFilesAndRecords(orcTools.readAllRecordsInJsonResource(resourceName, null),
        orcTools.readAllRecordsInBinaryDirectory(fs, output), true, null, false));
  }
Example 14
public DataOutputStream getTempOutputStream() throws IOException {
    tempPath = Files.createTempDir();
    tempPath.mkdirs();
    File tempFile = File.createTempFile("test", ".dat", tempPath);
    tempFilename = tempFile.getAbsolutePath();
    Path path = new Path("file:///" + tempFilename);
    conf = new Configuration();
    FileSystem fs = path.getFileSystem(conf);
    return fs.create(path);
  }
Example 15
public void testPathToDockerCertificatesIfDockerMachinePropertiesAreSet() throws Exception {

    File tmpDirectory = Files.createTempDir();
    tmpDirectory.deleteOnExit();

    Map<String, String> env = new HashMap<>();
    env.put(DockerConnectorConfiguration.DOCKER_CERT_PATH_PROPERTY, tmpDirectory.getAbsolutePath());

    String path = DockerConnectorConfiguration.dockerMachineCertsDirectoryPath(env);
    assertEquals(path, tmpDirectory.getAbsolutePath());
  }
Example 16
protected Properties getFlinkProperties() throws IOException {
    Properties p = new Properties();
    p.setProperty("zeppelin.flink.enableHive", "false");
    p.setProperty("zeppelin.flink.planner", "blink");
    p.setProperty("taskmanager.managed.memory.size", "32");
    p.setProperty("zeppelin.flink.hive.version", "2.3.4");
    File hiveConfDir = Files.createTempDir();
    //    hiveShell.getHiveConf().writeXml(new FileWriter(new File(hiveConfDir, "hive-site.xml")));
    p.setProperty("HIVE_CONF_DIR", hiveConfDir.getAbsolutePath());
    return p;
  }
Example 17
protected Class<?> doCompile(String clsName, String javaSource) throws Throwable {
        File tempFileLocation = Files.createTempDir();
        compiler = new NativeCompiler(tempFileLocation);
        Class type = compiler.compile(clsName, javaSource);
        tempFileLocation.deleteOnExit();
        return type;
    }
Example 18
protected File createTestApp() throws IOException {
        File testApp = Files.createTempDir();
        FileUtils.copyDirectory(new File("src/test/apps/content"), testApp);
        return testApp;
    }
Example 19
public static File extractExecutableFromJar(String executable) throws IOException {
        File tmpDir = Files.createTempDir();
        tmpDir.deleteOnExit();

        File command = new File(tmpDir, executable);
        FileUtils.copyURLToFile(Resources.getResource(executable), command);
        command.deleteOnExit();
        command.setExecutable(true);

        return command;
    }
Example 20
public void setup() throws Exception {
    tempDir = Files.createTempDir();
    countryDb = new File(tempDir, "GeoLite2-Country.mmdb");
    cityDb = new File(tempDir, "GeoLite2-City.mmdb");
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(countryDb));
    Resources.copy(Resources.getResource("GeoLite2-Country.mmdb"), out);
    out.flush();
    out.close();
    out = new BufferedOutputStream(new FileOutputStream(cityDb));
    Resources.copy(Resources.getResource("GeoLite2-City.mmdb"), out);
    out.flush();
    out.close();

  }
Example 21
private static URL makeJarUrlWithName(String name) throws IOException {
    File fullPath = new File(Files.createTempDir(), name);
    File jarFile = JarFileFinder.pickAnyJarFile();
    Files.copy(jarFile, fullPath);
    return fullPath.toURI().toURL();
  }
Example 22
protected Properties initIntpProperties() {
    Properties p = new Properties();
    p.setProperty("spark.master", "local[4]");
    p.setProperty("master", "local[4]");
    p.setProperty("spark.submit.deployMode", "client");
    p.setProperty("spark.app.name", "Zeppelin Test");
    p.setProperty("zeppelin.spark.useHiveContext", "false");
    p.setProperty("zeppelin.spark.maxResult", "3");
    p.setProperty("zeppelin.spark.importImplicit", "true");
    p.setProperty("zeppelin.pyspark.python", "python");
    p.setProperty("zeppelin.dep.localrepo", Files.createTempDir().getAbsolutePath());
    p.setProperty("zeppelin.python.gatewayserver_address", "127.0.0.1");
    p.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
    return p;
  }
Example 23
private File unzipSldPackage(Object input) throws IOException {
        File myTempDir = Files.createTempDir();

        org.geoserver.util.IOUtils.decompress((InputStream) input, myTempDir);

        File[] files = myTempDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".sld"));

        if (files == null || files.length != 1) {
            throw new IOException("No SLD file");
        }

        return files[0];
    }
Example 24
public void testShareLibLoadFilesFromLocalFs() throws Exception {
        final FileSystem localFs = newLocalFileSystem();
        final String testUserHome = Files.createTempDir().toString() + Path.SEPARATOR;
        try {
            setupShareLibLoadFiles(localFs, testUserHome);
            validateShareLibLoadFiles(localFs, FSUtils.FILE_SCHEME_PREFIX);
        }
        finally {
            localFs.delete(new Path(testUserHome), true);
        }
    }
Example 25
private static Properties loadConfig(int port, String zkConnect) {
        Properties properties = new Properties();
        properties.setProperty("port", String.valueOf(port));
        properties.setProperty("zookeeper.connect", zkConnect);
        properties.setProperty("broker.id", "0");
        properties.setProperty("log.dirs", Files.createTempDir().getAbsolutePath());
        properties.setProperty("delete.topic.enable", "true");
        properties.setProperty("offsets.topic.replication.factor", "1");
        properties.setProperty("group.initial.rebalance.delay.ms", "0");

        return properties;
    }