org.apache.commons.io.filefilter.RegexFileFilter Java Examples

The following examples show how to use org.apache.commons.io.filefilter.RegexFileFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: singer   Author: pinterest   File: LogFileUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static String getFilePathByInode(LogStream logStream, long inode)
    throws IOException {
  String result = null;
  String logDir = logStream.getLogDir();
  File dir = new File(logDir);
  if (dir.exists()) {
    SingerLogConfig logConfig = logStream.getSingerLog().getSingerLogConfig();
    String regexStr = logStream.getFileNamePrefix();
    if (logConfig.getFilenameMatchMode() == FileNameMatchMode.PREFIX) {
      regexStr += ".*";
    }
    LOG.info("Matching files under {} with filter {}", logDir, regexStr);
    FileFilter fileFilter = new RegexFileFilter(regexStr);
    File[] files = dir.listFiles(fileFilter);
    for (File file : files) {
      String path = file.getAbsolutePath();
      if (inode == SingerUtils.getFileInode(path)) {
        result = path;
        break;
      }
    }
  }
  return result;
}
 
Example #2
Source Project: singer   Author: pinterest   File: LogStreamManager.java    License: Apache License 2.0 6 votes vote down vote up
private List<SingerLog> getMatchedSingerLogsInternal(Path parentDir, File logFile) {
  LOG.debug("Getting Singer Logs for " + logFile.toString() + " in " + parentDir);
  List<SingerLog> singerLogs = new ArrayList<>();
  String pathStr = parentDir.toString();
  if (singerLogPaths.containsKey(pathStr)) {
    for (SingerLog log : singerLogPaths.get(pathStr)) {
      String regex = log.getSingerLogConfig().getLogStreamRegex();
      LOG.debug("Checking..." + regex + " matching " + logFile.toString());
      if (new RegexFileFilter(regex).accept(logFile)) {
        singerLogs.add(log);
      }
    }
  }
  if (singerLogs.isEmpty()) {
    LOG.debug("Did not find any matched SingerLog for {}", logFile);
  }
  return singerLogs;
}
 
Example #3
Source Project: webanno   Author: webanno   File: CasMergeSuiteTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void runTest()
    throws Exception
{
    Map<String, List<CAS>> casByUser = new HashMap<>();
    
    List<File> inputFiles = asList(
            referenceFolder.listFiles((FilenameFilter) new RegexFileFilter("user.*\\.tsv")));
    
    for (File inputFile : inputFiles) {
        casByUser.put(inputFile.getName(), asList(loadWebAnnoTsv3(inputFile).getCas()));
    }
    
    JCas curatorCas = createText(casByUser.values().stream().flatMap(Collection::stream)
            .findFirst().get().getDocumentText());

    DiffResult result = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser).toResult();

    // result.print(System.out);

    sut.reMergeCas(result, document, null, curatorCas.getCas(), getSingleCasByUser(casByUser));

    writeAndAssertEquals(curatorCas);
}
 
Example #4
Source Project: api-mining   Author: mast-group   File: DistinctTokenCount.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param args
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
public static void main(final String[] args) throws InstantiationException,
		IllegalAccessException, ClassNotFoundException {

	if (args.length != 2) {
		System.err.println("Usage: <directory> <tokenizerClass>");
		return;
	}

	final DistinctTokenCount tokCount = new DistinctTokenCount(args[1]);
	for (final File fi : FileUtils.listFiles(new File(args[0]),
			new RegexFileFilter(".*\\.java$"),
			DirectoryFileFilter.DIRECTORY)) {
		try {
			tokCount.addTokens(fi);
		} catch (final IOException e) {
			LOGGER.warning(ExceptionUtils.getFullStackTrace(e));
		}
	}

	tokCount.printCounts();
}
 
Example #5
Source Project: tassal   Author: mast-group   File: DistinctTokenCount.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
public static void main(final String[] args) throws InstantiationException,
		IllegalAccessException, ClassNotFoundException {

	if (args.length != 2) {
		System.err.println("Usage: <directory> <tokenizerClass>");
		return;
	}

	final DistinctTokenCount tokCount = new DistinctTokenCount(args[1]);
	for (final File fi : FileUtils.listFiles(new File(args[0]),
			new RegexFileFilter(".*\\.java$"),
			DirectoryFileFilter.DIRECTORY)) {
		try {
			tokCount.addTokens(fi);
		} catch (final IOException e) {
			LOGGER.warning(ExceptionUtils.getFullStackTrace(e));
		}
	}

	tokCount.printCounts();
}
 
Example #6
Source Project: fdroidclient   Author: f-droid   File: App.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void initInstalledObbFiles(Apk apk) {
    File obbdir = getObbDir(apk.packageName);
    FileFilter filter = new RegexFileFilter("(main|patch)\\.[0-9-][0-9]*\\." + apk.packageName + "\\.obb");
    File[] files = obbdir.listFiles(filter);
    if (files == null) {
        return;
    }
    Arrays.sort(files);
    for (File f : files) {
        String filename = f.getName();
        String[] segments = filename.split("\\.");
        if (Integer.parseInt(segments[1]) <= apk.versionCode) {
            if ("main".equals(segments[0])) {
                apk.obbMainFile = filename;
                apk.obbMainFileSha256 = Utils.getBinaryHash(f, apk.hashType);
            } else if ("patch".equals(segments[0])) {
                apk.obbPatchFile = filename;
                apk.obbPatchFileSha256 = Utils.getBinaryHash(f, apk.hashType);
            }
        }
    }
}
 
Example #7
/**
 * Generates reports about the output of a poster run.
 * 
 * @param runDate the date the poster was run.
 */
protected void generatePosterOutputSummaryReport(Date runDate) {
    PosterOutputSummaryReport posterOutputSummaryReport = new PosterOutputSummaryReport();
    
    // summarize all the entries for the main poster
    File mainPosterFile = FileUtil.getNewestFile(new File(batchFileDirectoryName), new RegexFileFilter((LaborConstants.BatchFileSystem.POSTER_INPUT_FILE + "\\.[0-9_\\-]+\\" + GeneralLedgerConstants.BatchFileSystem.EXTENSION)));        
    if (mainPosterFile != null && mainPosterFile.exists()) {
        LaborOriginEntryFileIterator mainPosterIterator = new LaborOriginEntryFileIterator(mainPosterFile);
        while (mainPosterIterator.hasNext()) {
            OriginEntryInformation originEntry = mainPosterIterator.next();
            posterOutputSummaryReport.summarize(originEntry);
        }
    } else {
        LOG.warn("Could not Main Poster Input file, "+ LaborConstants.BatchFileSystem.POSTER_INPUT_FILE + ", for tabulation in the Poster Output Summary Report");
    }
    
    posterOutputSummaryReport.writeReport(laborPosterOutputSummaryReportWriterService);
}
 
Example #8
Source Project: codemining-core   Author: mast-group   File: DistinctTokenCount.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
public static void main(final String[] args) throws InstantiationException,
		IllegalAccessException, ClassNotFoundException {

	if (args.length != 2) {
		System.err.println("Usage: <directory> <tokenizerClass>");
		return;
	}

	final DistinctTokenCount tokCount = new DistinctTokenCount(args[1]);
	for (final File fi : FileUtils.listFiles(new File(args[0]),
			new RegexFileFilter(".*\\.java$"),
			DirectoryFileFilter.DIRECTORY)) {
		try {
			tokCount.addTokens(fi);
		} catch (final IOException e) {
			LOGGER.warning(ExceptionUtils.getFullStackTrace(e));
		}
	}

	tokCount.printCounts();
}
 
Example #9
Source Project: gocd   Author: gocd   File: RailsAssetsService.java    License: Apache License 2.0 6 votes vote down vote up
public void initialize() throws IOException {
    if (!systemEnvironment.useCompressedJs()) {
        return;
    }
    String assetsDirPath = servletContext.getRealPath(servletContext.getInitParameter("rails.root") + "/public/assets/");
    File assetsDir = new File(assetsDirPath);
    if (!assetsDir.exists()) {
        throw new RuntimeException(String.format("Assets directory does not exist %s", assetsDirPath));
    }
    Collection files = FileUtils.listFiles(assetsDir, new RegexFileFilter(MANIFEST_FILE_PATTERN), null);
    if (files.isEmpty()) {
        throw new RuntimeException(String.format("Manifest json file was not found at %s", assetsDirPath));
    }

    File manifestFile = (File) files.iterator().next();

    LOG.info("Found rails assets manifest file named {} ", manifestFile.getName());
    String manifest = FileUtils.readFileToString(manifestFile, UTF_8);
    Gson gson = new Gson();
    railsAssetsManifest = gson.fromJson(manifest, RailsAssetsManifest.class);
    LOG.info("Successfully read rails assets manifest file located at {}", manifestFile.getAbsolutePath());
}
 
Example #10
Source Project: candybean   Author: sugarcrm   File: DataAdapter.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
protected static File[] getAllFilesBasedOnPattern(String fileFullDirPath,
		String testData, String ext) {
	File dir = new File(fileFullDirPath);
	File[] files;

	String pattern = testData + "." + ext + "|" + testData + "_[^_]+" + "."
			+ ext;
	
	if (selection == DataAdapter.Selection.SINGLE) {
		pattern = testData + "." + ext;
	}
	
	// System.out.println("\nFiles that match regular expression: " +
	// pattern);
	FileFilter filter = new RegexFileFilter(pattern);
	files = dir.listFiles(filter);

	return files;
}
 
Example #11
Source Project: deadcode4j   Author: Scout24   File: PackagingHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns each compile source root of a given <code>MavenProject</code> as a <code>Repository</code> instance
 * providing access to the Java files it contains.
 * Silently ignores compile source roots that do not exist in the file system.
 *
 * @since 2.0.0
 */
@Nonnull
protected Collection<Repository> getJavaFilesOfCompileSourceRootsAsRepositories(@Nonnull MavenProject project) {
    Collection<Repository> codeRepositories = newArrayList();
    for (String compileSourceRoot : emptyIfNull(project.getCompileSourceRoots())) {
        File compileSourceDirectory = new File(compileSourceRoot);
        if (!compileSourceDirectory.exists()) {
            logger.debug("  Compile Source Directory [{}] does not exist?", compileSourceDirectory);
            continue;
        }
        codeRepositories.add(new Repository(compileSourceDirectory,
                new OrFileFilter(DIRECTORY, new RegexFileFilter(".*\\.java$", INSENSITIVE))));
        logger.debug("  Found source directory [{}].", compileSourceRoot);
    }
    return codeRepositories;
}
 
Example #12
Source Project: spoofax   Author: metaborg   File: CopyPattern.java    License: Apache License 2.0 6 votes vote down vote up
@Override public None build(Input input) throws IOException {
    requireBuild(input.origin);

    require(input.srcDir, new DirectoryModifiedStamper());

    final Collection<File> files =
        FileUtils.listFiles(input.srcDir, new RegexFileFilter(input.pattern), FalseFileFilter.INSTANCE);
    for(File file : files) {
        require(file);
        final File dstFile = new File(input.dstDir, file.getName());
        FileUtils.copyFile(file, dstFile);
        provide(dstFile);
    }

    return None.val;
}
 
Example #13
Source Project: camunda-bpm-platform   Author: camunda   File: TemplateParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param sourceDirectory the template directory that stores the models
 * @return a map of model name and file path to it,
 * the map is ordered lexicographically by the model names
 */
protected static Map<String, String> resolveModels(String sourceDirectory) {
  File modelsDir = new File(sourceDirectory + "/models");
  Collection<File> modelFiles = FileUtils.listFiles(
      modelsDir, 
      new RegexFileFilter("^(.*?)"), 
      DirectoryFileFilter.DIRECTORY
      );

  Map<String, String> models = new TreeMap<>();
  for (File file : modelFiles) {
    String modelName = FilenameUtils.removeExtension(file.getName());
    String filePath = file.getAbsolutePath();
    String modelPackage = filePath
        .substring(filePath.lastIndexOf("org"), filePath.lastIndexOf(File.separator));
    
    models.put(modelName, modelPackage);
  }
  
  return models;
}
 
Example #14
Source Project: singer   Author: pinterest   File: LogStream.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public void initialize() throws IOException {
  SingerLogConfig singerLogConfig = singerLog.getSingerLogConfig();
  String regexStr = fileNamePrefix;
  File logDir = new File(singerLogConfig.getLogDir());

  if (singerLogConfig.getFilenameMatchMode() == FileNameMatchMode.PREFIX) {
    regexStr += ".*";
  }

  LOG.info("Matching files under {} with filter {}", logDir, regexStr);
  FileFilter fileFilter = new RegexFileFilter(regexStr);
  File[] files = logDir.listFiles(fileFilter);

  // Sort the file first by last_modified timestamp and then by name in case two files have
  // the same mtime due to precision (mtime is up to seconds).
  Ordering ordering = Ordering.from(
      new CompositeFileComparator(
          LastModifiedFileComparator.LASTMODIFIED_COMPARATOR, NameFileComparator.NAME_REVERSE));
  List<File> logFiles = ordering.sortedCopy(Arrays.asList(files));

  LOG.info(files.length + " files matches the regex '{}'", regexStr);
  synchronized (logFilesInfoLock) {
    logFilePaths.clear();
    logFilePathsIndex.clear();
    for (File entry : logFiles) {
      long inode = SingerUtils.getFileInode(entry.toPath());
      append(new LogFile(inode), entry.toPath().toString());
    }
  }
  OpenTsdbMetricConverter.incr(SingerMetrics.LOGSTREAM_INITIALIZE, 1,
      "log=" + logStreamName, "host=" + SingerUtils.getHostname());
}
 
Example #15
Source Project: jkube   Author: eclipse   File: FileUtil.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static List<File> listFilesAndDirsRecursivelyInDirectory(File directory) {
    return FileUtils.listFilesAndDirs(directory, new RegexFileFilter("^(.*?)"),
        DirectoryFileFilter.DIRECTORY
    )
        .stream()
        .filter(f -> !f.equals(directory))
        .collect(Collectors.toList());
}
 
Example #16
Source Project: DDMQ   Author: didi   File: CarreraRecover.java    License: Apache License 2.0 5 votes vote down vote up
private static void recoverFromDropLog() {
    LOGGER.info("accept a mission");
    File dir = new File(CarreraConfig.RecoverFromDropLogDir);
    Collection<File> files = FileUtils.listFiles(dir, new RegexFileFilter(CarreraConfig.RecoverFromDropLogPattern), null);
    LOGGER.warn("dir:{},pattern:{},files.size:files:{},{}", CarreraConfig.RecoverFromDropLogDir, CarreraConfig.RecoverFromDropLogPattern, files.size(), files);
    for (File file : files) {
        recoverFromDropLog(file);
    }
    LOGGER.info("mission completed");
}
 
Example #17
Source Project: DDMQ   Author: didi   File: CarreraRecover.java    License: Apache License 2.0 5 votes vote down vote up
private static void recoverFromDropLog() {
    LOGGER.info("accept a mission");
    File dir = new File(CarreraConfig.RecoverFromDropLogDir);
    Collection<File> files = FileUtils.listFiles(dir, new RegexFileFilter(CarreraConfig.RecoverFromDropLogPattern), null);
    LOGGER.warn("dir:{},pattern:{},files.size:files:{},{}", CarreraConfig.RecoverFromDropLogDir, CarreraConfig.RecoverFromDropLogPattern, files.size(), files);
    for (File file : files) {
        recoverFromDropLog(file);
    }
    LOGGER.info("mission completed");
}
 
Example #18
Source Project: o2oa   Author: o2oa   File: DumpStorageTask.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
	try {
		logger.print("schedule dump storage task start.");
		DumpStorage action = new DumpStorage();
		action.execute(Config.currentNode().dumpStorage().path());
		if (Config.currentNode().dumpStorage().size() > 0) {
			File dir = new File(Config.base(), "local/dump");
			List<File> list = new ArrayList<>();
			if (dir.exists() && dir.isDirectory()) {
				for (File f : FileUtils.listFilesAndDirs(dir, FalseFileFilter.FALSE, new RegexFileFilter(
						"^dumpStorage_[1,2][0,9][0-9][0-9][0,1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9]$"))) {
					if (dir != f) {
						list.add(f);
					}
				}
				list = list.stream().sorted(Comparator.comparing(File::getName).reversed())
						.collect(Collectors.toList());
				if (list.size() > Config.currentNode().dumpStorage().size()) {
					for (int i = Config.currentNode().dumpStorage().size(); i < list.size(); i++) {
						File file = list.get(i);
						logger.print("dumpStorageTask delete{}.", file.getAbsolutePath());
						FileUtils.forceDelete(file);
					}
				}
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #19
Source Project: o2oa   Author: o2oa   File: DumpDataTask.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	try {
		logger.print("schedule dump data task start.");
		DumpData action = new DumpData();
		action.execute(Config.currentNode().dumpData().path());
		if (Config.currentNode().dumpData().size() > 0) {
			File dir = new File(Config.base(), "local/dump");
			List<File> list = new ArrayList<>();
			if (dir.exists() && dir.isDirectory()) {
				for (File f : FileUtils.listFilesAndDirs(dir, FalseFileFilter.FALSE, new RegexFileFilter(
						"^dumpData_[1,2][0,9][0-9][0-9][0,1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9]$"))) {
					if (dir != f) {
						list.add(f);
					}
				}
				list = list.stream().sorted(Comparator.comparing(File::getName).reversed())
						.collect(Collectors.toList());
				if (list.size() > Config.currentNode().dumpData().size()) {
					for (int i = Config.currentNode().dumpData().size(); i < list.size(); i++) {
						File file = list.get(i);
						logger.print("dumpDataTask delete:{}.", file.getAbsolutePath());
						FileUtils.forceDelete(file);
					}
				}
			}
		}
	} catch (Exception e) {
		throw new JobExecutionException(e);
	}
}
 
Example #20
Source Project: appassembler   Author: mojohaus   File: FileFilterHelper.java    License: MIT License 5 votes vote down vote up
/**
 * Make the given IOFileFilter aware of the given pattern.
 *
 * @param filter The filter to make aware of the pattern.
 * @param pattern The pattern which should be payed attention to.
 * @return The new generated filter.
 */
public static IOFileFilter makePatternFileNameAware( IOFileFilter filter, String pattern )
{
    IOFileFilter directoryAwareFilter =
        FileFilterUtils.notFileFilter( FileFilterUtils.andFileFilter( FileFilterUtils.fileFileFilter(),
                                                                      new RegexFileFilter( pattern ) ) );

    return FileFilterUtils.andFileFilter( filter, directoryAwareFilter );
}
 
Example #21
Source Project: api-mining   Author: mast-group   File: AbstractJygmentsTokenizer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public AbstractJygmentsTokenizer(final String fileSuffix)
		throws ResolutionException {
	lexer = Lexer.getForFileName("sample." + fileSuffix);
	// lexer.setStripAll(true);
	// lexer.setStripNewLines(true);
	// lexer.setTabSize(1);
	codeFilter = new RegexFileFilter(".*\\." + fileSuffix + "$");
}
 
Example #22
Source Project: product-iots   Author: wso2   File: CarbonServerManagerExtension.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * To check jacoco file sizes and wait for them to get created..
 *
 * @param filePath File Path of the jacoco data files.
 */
private void checkJacocoDataFileSizes(String filePath) {
    Collection<File> fileSetsCollection = FileUtils
            .listFiles(new File(filePath), new RegexFileFilter("[^s]+(." + "(?i)(exec))$"),
                    DirectoryFileFilter.DIRECTORY);

    for (File inputFile : fileSetsCollection) {
        if (inputFile.isDirectory()) {
            continue;
        }
        //retry to check whether exec data file is non empty.
        waitForCoverageDumpFileCreation(inputFile);
    }
}
 
Example #23
Source Project: varOne   Author: SparkMonitor   File: ThreadPoolMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.ThreadPoolMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_THREAD_POOL() throws IOException {
	MetricsReader reader = new ThreadPoolMetricsReader(null, MetricsType.THREAD_POOL);
	
	String applicationId = "application_1439169262151_0237";
	String metricsDir = this.getClass().getResource("/csvsink").getPath();
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+).executor.threadpool.*\\.csv");
	
	assertEquals(result.size(), 8);  
	this.assertContent(filter, result);
}
 
Example #24
Source Project: varOne   Author: SparkMonitor   File: ThreadPoolMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.ThreadPoolMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_EXEC_THREADPOOL_ACTIVETASK() throws IOException {
	MetricsReader reader = new ThreadPoolMetricsReader(null, MetricsType.EXEC_THREADPOOL_ACTIVETASK);
	
	String applicationId = "application_1439169262151_0237";
	String metricsDir = this.getClass().getResource("/csvsink").getPath();
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.EXEC_THREADPOOL_ACTIVETASK.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #25
Source Project: varOne   Author: SparkMonitor   File: ThreadPoolMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.ThreadPoolMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_EXEC_THREADPOOL_COMPLETETASK() throws IOException {
	MetricsReader reader = new ThreadPoolMetricsReader(null, MetricsType.EXEC_THREADPOOL_COMPLETETASK);
	
	String applicationId = "application_1439169262151_0237";
	String metricsDir = this.getClass().getResource("/csvsink").getPath();
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.EXEC_THREADPOOL_COMPLETETASK.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #26
Source Project: varOne   Author: SparkMonitor   File: ThreadPoolMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.ThreadPoolMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_EXEC_THREADPOOL_CURRPOOL_SIZE() throws IOException {
	MetricsReader reader = new ThreadPoolMetricsReader(null, MetricsType.EXEC_THREADPOOL_CURRPOOL_SIZE);
	
	String applicationId = "application_1439169262151_0237";
	String metricsDir = this.getClass().getResource("/csvsink").getPath();
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.EXEC_THREADPOOL_CURRPOOL_SIZE.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #27
Source Project: varOne   Author: SparkMonitor   File: ThreadPoolMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.ThreadPoolMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_EXEC_THREADPOOL_MAXPOOL_SIZE() throws IOException {
	MetricsReader reader = new ThreadPoolMetricsReader(null, MetricsType.EXEC_THREADPOOL_MAXPOOL_SIZE);
	
	String applicationId = "application_1439169262151_0237";
	String metricsDir = this.getClass().getResource("/csvsink").getPath();
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.EXEC_THREADPOOL_MAXPOOL_SIZE.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #28
Source Project: varOne   Author: SparkMonitor   File: JvmMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.JvmMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_JVM() throws IOException {
	MetricsReader reader = new JvmMetricsReader(null, MetricsType.JVM);
	
	String applicationId = "application_1439169262151_0237";
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+).jvm.(?!total).*\\.csv");
	
	assertEquals(result.size(), 38);  
	this.assertContent(filter, result);
}
 
Example #29
Source Project: varOne   Author: SparkMonitor   File: JvmMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.JvmMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_JVM_HEAP_COMMITED() throws IOException {
	MetricsReader reader = new JvmMetricsReader(null, MetricsType.JVM_HEAP_COMMITED);
	
	String applicationId = "application_1439169262151_0237";
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.JVM_HEAP_COMMITED.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #30
Source Project: varOne   Author: SparkMonitor   File: JvmMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.JvmMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testRead_JVM_HEAP_INIT() throws IOException {
	MetricsReader reader = new JvmMetricsReader(null, MetricsType.JVM_HEAP_INIT);
	
	String applicationId = "application_1439169262151_0237";
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.JVM_HEAP_INIT.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}