Search in sources :

Example 81 with FileFilter

use of java.io.FileFilter in project asterixdb by apache.

the class AsterixYARNClient method getAsterixDistributableLocation.

/**
     * Find the distributable asterix bundle, be it in the default location or in a user-specified location.
     *
     * @return
     */
private File getAsterixDistributableLocation() {
    //Look in the PWD for the "asterix" folder
    File tarDir = new File("asterix");
    if (!tarDir.exists()) {
        throw new IllegalArgumentException("Default directory structure not in use- please specify an asterix zip and base config file to distribute");
    }
    FileFilter tarFilter = new WildcardFileFilter("asterix-server*.zip");
    File[] tarFiles = tarDir.listFiles(tarFilter);
    if (tarFiles.length != 1) {
        throw new IllegalArgumentException("There is more than one canonically named asterix distributable in the default directory. Please leave only one there.");
    }
    return tarFiles[0];
}
Also used : FileFilter(java.io.FileFilter) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter) File(java.io.File) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter)

Example 82 with FileFilter

use of java.io.FileFilter in project drill by apache.

the class TestCTTAS method findTemporaryTableLocation.

private File[] findTemporaryTableLocation(String tableName) throws IOException {
    File sessionTempLocation = new File(getDfsTestTmpSchemaLocation(), session_id.toString());
    Path sessionTempLocationPath = new Path(sessionTempLocation.toURI().getPath());
    assertTrue("Session temporary location must exist", fs.exists(sessionTempLocationPath));
    assertEquals("Session temporary location permission should match", expectedFolderPermission, fs.getFileStatus(sessionTempLocationPath).getPermission());
    final String tableUUID = UUID.nameUUIDFromBytes(tableName.getBytes()).toString();
    return sessionTempLocation.listFiles(new FileFilter() {

        @Override
        public boolean accept(File path) {
            return path.isDirectory() && path.getName().equals(tableUUID);
        }
    });
}
Also used : Path(org.apache.hadoop.fs.Path) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) FileFilter(java.io.FileFilter) File(java.io.File)

Example 83 with FileFilter

use of java.io.FileFilter in project beam by apache.

the class NumShardsTest method testText.

@Test
public void testText() throws Exception {
    PCollection<String> inputWords = p.apply(Create.of(WORDS).withCoder(StringUtf8Coder.of()));
    PCollection<String> output = inputWords.apply(new WordCount.CountWords()).apply(MapElements.via(new WordCount.FormatAsTextFn()));
    output.apply(TextIO.write().to(outputDir.getAbsolutePath()).withNumShards(3).withSuffix(".txt"));
    p.run().waitUntilFinish();
    int count = 0;
    Set<String> expected = Sets.newHashSet("hi: 5", "there: 1", "sue: 2", "bob: 2");
    for (File f : tmpDir.getRoot().listFiles(new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            return pathname.getName().matches("out-.*\\.txt");
        }
    })) {
        count++;
        for (String line : Files.readLines(f, Charsets.UTF_8)) {
            assertTrue(line + " not found", expected.remove(line));
        }
    }
    assertEquals(3, count);
    assertTrue(expected.isEmpty());
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File) Test(org.junit.Test)

Example 84 with FileFilter

use of java.io.FileFilter in project carbondata by apache.

the class UnsafeSingleThreadFinalSortFilesMerger method getFilesToMergeSort.

private File[] getFilesToMergeSort() {
    // get all the merged files
    File file = new File(tempFileLocation);
    File[] fileList = file.listFiles(new FileFilter() {

        public boolean accept(File pathname) {
            return pathname.getName().startsWith(tableName);
        }
    });
    if (null == fileList || fileList.length < 0) {
        return new File[0];
    }
    return fileList;
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File)

Example 85 with FileFilter

use of java.io.FileFilter in project asterixdb by apache.

the class AsterixEventService method initBinary.

private static String initBinary(final String fileNamePattern) {
    File file = new File(asterixDir);
    File[] zipFiles = file.listFiles(new FileFilter() {

        public boolean accept(File arg0) {
            return arg0.getAbsolutePath().contains(fileNamePattern) && arg0.isFile();
        }
    });
    if (zipFiles.length == 0) {
        String msg = " Binary not found at " + asterixDir;
        LOGGER.log(Level.FATAL, msg);
        throw new IllegalStateException(msg);
    }
    if (zipFiles.length > 1) {
        String msg = " Multiple binaries found at " + asterixDir;
        LOGGER.log(Level.FATAL, msg);
        throw new IllegalStateException(msg);
    }
    return zipFiles[0].getAbsolutePath();
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File)

Aggregations

FileFilter (java.io.FileFilter)281 File (java.io.File)267 ArrayList (java.util.ArrayList)59 IOException (java.io.IOException)53 JarFile (java.util.jar.JarFile)22 URL (java.net.URL)17 Test (org.junit.Test)16 HashMap (java.util.HashMap)15 FileNotFoundException (java.io.FileNotFoundException)11 FilenameFilter (java.io.FilenameFilter)11 HashSet (java.util.HashSet)11 FileInputStream (java.io.FileInputStream)10 Pattern (java.util.regex.Pattern)10 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)10 MalformedURLException (java.net.MalformedURLException)9 URI (java.net.URI)9 Map (java.util.Map)7 Path (org.apache.hadoop.fs.Path)7 NotNull (org.jetbrains.annotations.NotNull)7 Treebank (edu.stanford.nlp.trees.Treebank)6