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];
}
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);
}
});
}
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());
}
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;
}
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();
}
Aggregations