* support -DthreadPool=n to override background matcher thread pool size (default is number of cores)

This commit is contained in:
Reinhard Pointner 2012-06-30 08:46:55 +00:00
parent 32e40255c8
commit 5145d906dd
5 changed files with 23 additions and 5 deletions

View File

@ -44,6 +44,20 @@ public final class Settings {
} }
public static boolean isUnixFS() {
return Boolean.parseBoolean(System.getProperty("unixfs"));
}
public static int getPreferredThreadPoolSize() {
try {
return Integer.parseInt(System.getProperty("threadPool"));
} catch (Exception e) {
return Runtime.getRuntime().availableProcessors();
}
}
public static String getApplicationDeployment() { public static String getApplicationDeployment() {
String deployment = System.getProperty("application.deployment"); String deployment = System.getProperty("application.deployment");
if (deployment != null) if (deployment != null)

View File

@ -6,6 +6,7 @@ import static java.lang.String.*;
import static java.util.Arrays.*; import static java.util.Arrays.*;
import static java.util.Collections.*; import static java.util.Collections.*;
import static net.sourceforge.filebot.MediaTypes.*; import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.Settings.*;
import static net.sourceforge.filebot.WebServices.*; import static net.sourceforge.filebot.WebServices.*;
import static net.sourceforge.filebot.cli.CLILogging.*; import static net.sourceforge.filebot.cli.CLILogging.*;
import static net.sourceforge.filebot.hash.VerificationUtilities.*; import static net.sourceforge.filebot.hash.VerificationUtilities.*;
@ -209,7 +210,7 @@ public class CmdlineOperations implements CmdlineInterface {
String newName = (format != null) ? format.format(new MediaBindingBean(episode, file)) : validateFileName(EpisodeFormat.SeasonEpisode.format(episode)); String newName = (format != null) ? format.format(new MediaBindingBean(episode, file)) : validateFileName(EpisodeFormat.SeasonEpisode.format(episode));
File newFile = new File(outputDir, newName + "." + getExtension(file)); File newFile = new File(outputDir, newName + "." + getExtension(file));
if (isInvalidFilePath(newFile) && !Boolean.parseBoolean(System.getProperty("unixfs"))) { if (isInvalidFilePath(newFile) && !isUnixFS()) {
CLILogger.config("Stripping invalid characters from new path: " + newName); CLILogger.config("Stripping invalid characters from new path: " + newName);
newFile = validateFilePath(newFile); newFile = validateFilePath(newFile);
} }
@ -444,7 +445,7 @@ public class CmdlineOperations implements CmdlineInterface {
String newName = (format != null) ? format.format(new MediaBindingBean(movie, file)) : validateFileName(MovieFormat.NameYear.format(movie)); String newName = (format != null) ? format.format(new MediaBindingBean(movie, file)) : validateFileName(MovieFormat.NameYear.format(movie));
File newFile = new File(outputDir, newName + "." + getExtension(file)); File newFile = new File(outputDir, newName + "." + getExtension(file));
if (isInvalidFilePath(newFile) && !Boolean.parseBoolean(System.getProperty("unixfs"))) { if (isInvalidFilePath(newFile) && !isUnixFS()) {
CLILogger.config("Stripping invalid characters from new path: " + newName); CLILogger.config("Stripping invalid characters from new path: " + newName);
newFile = validateFilePath(newFile); newFile = validateFilePath(newFile);
} }

View File

@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui.rename;
import static java.util.Collections.*; import static java.util.Collections.*;
import static net.sourceforge.filebot.MediaTypes.*; import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.Settings.*;
import static net.sourceforge.filebot.media.MediaDetection.*; import static net.sourceforge.filebot.media.MediaDetection.*;
import static net.sourceforge.filebot.similarity.Normalization.*; import static net.sourceforge.filebot.similarity.Normalization.*;
import static net.sourceforge.tuned.FileUtilities.*; import static net.sourceforge.tuned.FileUtilities.*;
@ -212,7 +213,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
} }
// match folder per folder in parallel // match folder per folder in parallel
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); ExecutorService executor = Executors.newFixedThreadPool(getPreferredThreadPoolSize());
try { try {
// merge all episodes // merge all episodes

View File

@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui.rename;
import static net.sourceforge.filebot.MediaTypes.*; import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.Settings.*;
import static net.sourceforge.filebot.media.MediaDetection.*; import static net.sourceforge.filebot.media.MediaDetection.*;
import static net.sourceforge.filebot.similarity.Normalization.*; import static net.sourceforge.filebot.similarity.Normalization.*;
import static net.sourceforge.tuned.FileUtilities.*; import static net.sourceforge.tuned.FileUtilities.*;
@ -158,7 +159,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
// map movies to (possibly multiple) files (in natural order) // map movies to (possibly multiple) files (in natural order)
Map<Movie, SortedSet<File>> filesByMovie = new HashMap<Movie, SortedSet<File>>(); Map<Movie, SortedSet<File>> filesByMovie = new HashMap<Movie, SortedSet<File>>();
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); ExecutorService executor = Executors.newFixedThreadPool(getPreferredThreadPoolSize());
try { try {
for (Future<Entry<File, Movie>> it : executor.invokeAll(grabMovieJobs)) { for (Future<Entry<File, Movie>> it : executor.invokeAll(grabMovieJobs)) {
// check if we managed to lookup the movie descriptor // check if we managed to lookup the movie descriptor

View File

@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui.rename;
import static java.util.Collections.*; import static java.util.Collections.*;
import static net.sourceforge.filebot.Settings.*;
import static net.sourceforge.tuned.FileUtilities.*; import static net.sourceforge.tuned.FileUtilities.*;
import static net.sourceforge.tuned.ui.TunedUtilities.*; import static net.sourceforge.tuned.ui.TunedUtilities.*;
@ -161,7 +162,7 @@ class ValidateDialog extends JDialog {
for (int i = 0; i < source.size(); i++) { for (int i = 0; i < source.size(); i++) {
// invalid file names are also invalid file paths // invalid file names are also invalid file paths
if (isInvalidFilePath(source.get(i)) && !Boolean.parseBoolean(System.getProperty("unixfs"))) { if (isInvalidFilePath(source.get(i)) && !isUnixFS()) {
invalidFilePaths.addIndex(i); invalidFilePaths.addIndex(i);
} }
} }