Commit e353efd2 authored by Adam Knapp's avatar Adam Knapp

Limiting thread creation #402

Signed-off-by: Adam Knapp's avatarAdam Knapp <adam.knapp@ericsson.com>
parent f562fcff
......@@ -22,7 +22,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.Module;
......@@ -30,6 +32,8 @@ import org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module;
import org.eclipse.titan.designer.consoles.TITANDebugConsole;
import org.eclipse.titan.designer.core.LoadBalancingUtilities;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
import org.eclipse.titan.designer.preferences.PreferenceConstants;
import org.eclipse.titan.designer.productUtilities.ProductConstants;
/**
* Helper class to check broken parts.
......@@ -93,18 +97,30 @@ public final class BrokenPartsChecker {
// process the modules one-by-one
final long absoluteStart = System.nanoTime();
// When enabled do a quick parallel checking on the modules, where it is possible.
// 2 modules can be checked in parallel if the codes to be checked do not overlap.
// Please note, that this will not let all modules be processed in parallel,
// modules in import loops (and all modules depending on them) have to be checked in the single threaded way.
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
// When enabled do a quick parallel checking on the modules, where it is possible.
// 2 modules can be checked in parallel if the codes to be checked do not overlap.
// Please note, that this will not let all modules be processed in parallel,
// modules in import loops (and all modules depending on them) have to be checked in the single threaded way.
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final AtomicInteger activeExecutorCount = new AtomicInteger(0);
final List<Module> modulesToCheckCopy = new ArrayList<Module>(modulesToCheck);
......
......@@ -83,7 +83,7 @@ public class LoadFromTpd implements IApplication {
try {
final TpdImporter tpdImporter = new TpdImporter(null, true);
final List<IProject> projectsCreated = new ArrayList<IProject>();
result = tpdImporter.internalFinish(projectFiles[0], false, false, projectsCreated, monitor, null);
result = tpdImporter.internalFinish(projectFiles[0], false, false, false, projectsCreated, monitor, null);
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
result = false;
......
......@@ -34,6 +34,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.common.path.PathConverter;
import org.eclipse.titan.designer.commonFilters.ResourceExclusionHelper;
......@@ -110,14 +111,26 @@ public final class SymbolicLinkHandler {
PreferenceConstants.DISPLAYDEBUGINFORMATION, false, null);
final CountDownLatch latch = new CountDownLatch(files.size());
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
for (final IFile file : files.values()) {
// We want makefile to be symlinked
......@@ -392,14 +405,26 @@ public final class SymbolicLinkHandler {
monitor.beginTask(CREATING_OUTDATED_LINK_REMOVAL, files.size());
final CountDownLatch latch = new CountDownLatch(files.size());
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
for (final String key : files.keySet()) {
executor.execute(new Runnable() {
@Override
......@@ -469,14 +494,26 @@ public final class SymbolicLinkHandler {
monitor.beginTask(CREATING_OUTDATED_LINK_REMOVAL, files.size());
final CountDownLatch latch = new CountDownLatch(files.size());
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
for (final Map.Entry<String, IFile> entry : files.entrySet()) {
executor.execute(new Runnable() {
@Override
......
......@@ -39,6 +39,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.common.path.PathConverter;
import org.eclipse.titan.common.path.PathUtil;
......@@ -239,14 +240,26 @@ public final class InternalMakefileGenerator {
return;
}
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final CountDownLatch latch = new CountDownLatch(ttcn3Modules.size() + ttcnppModules.size() + ttcn3IncludeFiles.size() + asn1modules.size() + userFiles.size() + otherFiles.size()
+ baseDirectories.size() + additionallyIncludedFolders.size() + etsName != null ? 1 : 0);
......
......@@ -767,14 +767,26 @@ public final class ProjectSourceParser {
try {
final ConcurrentLinkedQueue<IProject> tobeSemanticallyAnalyzed = new ConcurrentLinkedQueue<IProject>();
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final CountDownLatch latch = new CountDownLatch(tobeAnalyzed.size());
for (final IProject tempProject : tobeAnalyzed) {
executor.execute(new Runnable() {
......
......@@ -405,14 +405,26 @@ public final class ProjectSourceSyntacticAnalyzer {
final SubMonitor parseProgress = SubMonitor.convert(progress, ttcn3FilesToCheck.size() + asn1FilesToCheck.size());
parseProgress.setTaskName("Parse");
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final TemporalParseData[] tempResults = new TemporalParseData[ttcn3FilesToCheck.size() + asn1FilesToCheck.size()];
int nofFilesProcessed = 0;
......@@ -648,15 +660,26 @@ public final class ProjectSourceSyntacticAnalyzer {
final SubMonitor parseProgress = SubMonitor.convert(progress, ttcn3FilesToCheck.size() + asn1FilesToCheck.size());
parseProgress.setTaskName("Syntactically analyzing");
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
final int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
final boolean limitAllThreadCreation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.LIMITALLTHREADCREATION, false, null);
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (limitAllThreadCreation) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final TemporalParseData[] tempResults = new TemporalParseData[ttcn3FilesToCheck.size() + asn1FilesToCheck.size()];
int nofFilesProcessed = 0;
......
......@@ -27,6 +27,7 @@ public final class PreferenceConstants {
public static final String RECONCILERTIMEOUT = ProductConstants.PRODUCT_ID_DESIGNER + ".reconcilerTimeout";
public static final String ENABLEREALTIMEEXTENSION = ProductConstants.PRODUCT_ID_DESIGNER + ".enableRealtimeExtension";
public static final String PROCESSINGUNITSTOUSE = ProductConstants.PRODUCT_ID_DESIGNER + ".processingUnitsToUse";
public static final String LIMITALLTHREADCREATION = ProductConstants.PRODUCT_ID_DESIGNER + ".limitAllThreadCreation";
//Actions on console before build
public static final String CONSOLE_ACTION_BEFORE_BUILD = ProductConstants.PRODUCT_ID_DESIGNER + ".consoleActionBeforeBuild";
......
......@@ -53,6 +53,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
preferenceStore.setDefault(PreferenceConstants.RECONCILERTIMEOUT, 1);
preferenceStore.setDefault(PreferenceConstants.ENABLEREALTIMEEXTENSION, false);
preferenceStore.setDefault(PreferenceConstants.PROCESSINGUNITSTOUSE, PreferenceConstantValues.AVAILABLEPROCESSORS);
preferenceStore.setDefault(PreferenceConstants.LIMITALLTHREADCREATION, false);
preferenceStore.setDefault(PreferenceConstants.CONSOLE_ACTION_BEFORE_BUILD, PreferenceConstantValues.BEFORE_BUILD_PRINT_CONSOLE_DELIMITERS);
// content assistance
......
......@@ -148,6 +148,7 @@ public final class TITANPreferencePage extends FieldEditorPreferencePage impleme
private BooleanFieldEditor reportProgramErrorWithMarker;
private BooleanFieldEditor treatOnTheFlyErrorsFatalforBuild;
private IntegerFieldEditor processingUnitsToUse;
private BooleanFieldEditor limitAllThreadCreation;
private BooleanFieldEditor displayDebugPreferences;//FIXME: remove this functionality!
private Composite comp;
......@@ -162,7 +163,7 @@ public final class TITANPreferencePage extends FieldEditorPreferencePage impleme
private class CreateNewLicense extends SelectionAdapter {
@Override
public void widgetSelected(final SelectionEvent e) {
openUrl("https://tcc-licorder.rnd.ki.sw.ericsson.se/order_form.php?type=ericsson");
openUrl("http://ttcn.ericsson.se/license");
}
}
......@@ -178,7 +179,7 @@ public final class TITANPreferencePage extends FieldEditorPreferencePage impleme
@Override
public void widgetSelected(final SelectionEvent e) {
openUrl("https://tcc-licorder.rnd.ki.sw.ericsson.se/order_form.php?type=ericsson"); //licenseID has been removed
openUrl("http://ttcn.ericsson.se/license"); //licenseID has been removed
}
}
......@@ -422,9 +423,17 @@ public final class TITANPreferencePage extends FieldEditorPreferencePage impleme
getFieldEditorParent());
processingUnitsToUse.getLabelControl(getFieldEditorParent()).setToolTipText(
"Maximum number of processors available right now: " + PreferenceConstantValues.AVAILABLEPROCESSORS);
processingUnitsToUse.getTextControl(getFieldEditorParent()).setToolTipText(
"Maximum number of processors available right now: " + PreferenceConstantValues.AVAILABLEPROCESSORS);
processingUnitsToUse.setValidRange(1, PreferenceConstantValues.AVAILABLEPROCESSORS + 1);
addField(processingUnitsToUse);
limitAllThreadCreation = new BooleanFieldEditor(PreferenceConstants.LIMITALLTHREADCREATION, "Limit maximum number of other parallel processes to this number",
getFieldEditorParent());
limitAllThreadCreation.getDescriptionControl(getFieldEditorParent()).setToolTipText(
"This might need to turn on when the OS runs out of threads, i.e. when 'OutOfMemoryError: unable to create native thread' exception is thrown");
addField(limitAllThreadCreation);
displayDebugPreferences = new BooleanFieldEditor(PreferenceConstants.DEBUG_PREFERENCE_PAGE_ENABLED, "Display debug preferences",
getFieldEditorParent());
addField(displayDebugPreferences);
......
......@@ -22,6 +22,8 @@ import org.eclipse.swt.widgets.Composite;
class NewTITANProjectImportOptionsPage extends WizardPage {
private static final String TITLE = "TITAN Project importation options";
private Button limitImportProcesses;
private boolean islimitImportProcesses = false;
private Button openPropertiesForAllImports;
private boolean isOpenPropertiesForAllImports = false;
private Button skipExistingProjects;
......@@ -33,7 +35,7 @@ class NewTITANProjectImportOptionsPage extends WizardPage {
@Override
public String getDescription() {
return "Finetune the ammount of data saved about the project";
return "Finetune the amount of data saved about the project";
}
@Override
......@@ -41,6 +43,10 @@ class NewTITANProjectImportOptionsPage extends WizardPage {
return TITLE;
}
public boolean islimitImportProcesses() {
return islimitImportProcesses;
}
public boolean isOpenPropertiesForAllImports() {
return isOpenPropertiesForAllImports;
}
......@@ -82,6 +88,20 @@ class NewTITANProjectImportOptionsPage extends WizardPage {
}
});
limitImportProcesses = new Button(pageComposite, SWT.CHECK);
limitImportProcesses.setText("Limit the number of parallel import processes");
limitImportProcesses.setToolTipText("This might need to turn on when the OS runs out of threads, "
+ "i.e. when 'OutOfMemoryError: unable to create native thread' exception is thrown");
limitImportProcesses.setEnabled(true);
limitImportProcesses.setSelection(false);
islimitImportProcesses = false;
limitImportProcesses.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
islimitImportProcesses = limitImportProcesses.getSelection();
}
});
setControl(pageComposite);
}
}
......@@ -66,7 +66,8 @@ public class NewTITANProjectImportWizard extends BasicNewResourceWizard implemen
try {
result = tpdImporter.internalFinish(mainPage.getProjectFile(), optionsPage.isSkipExistingProjects(),
optionsPage.isOpenPropertiesForAllImports(), projectsCreated, monitor, mainPage.getSearchPaths());
optionsPage.isOpenPropertiesForAllImports(), optionsPage.islimitImportProcesses(),
projectsCreated, monitor, mainPage.getSearchPaths());
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
result = false;
......
......@@ -57,6 +57,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.window.Window;
......@@ -72,6 +73,7 @@ import org.eclipse.titan.designer.consoles.TITANDebugConsole;
import org.eclipse.titan.designer.core.LoadBalancingUtilities;
import org.eclipse.titan.designer.core.TITANNature;
import org.eclipse.titan.designer.graphics.ImageCache;
import org.eclipse.titan.designer.preferences.PreferenceConstants;
import org.eclipse.titan.designer.productUtilities.ProductConstants;
import org.eclipse.titan.designer.properties.data.DOMErrorHandlerImpl;
import org.eclipse.titan.designer.properties.data.ProjectBuildPropertyData;
......@@ -119,6 +121,8 @@ public class TpdImporter {
private List<String> searchPaths;
private final Map<String, String> tpdNameAttrMap = new HashMap<String, String>();
private final Map<String, String> tpdURIMap = new HashMap<String, String>();
private boolean islimitImportProcesses = false;
private int processingUnitsToUse;
public TpdImporter(final Shell shell, final boolean headless) {
this.shell = shell;
......@@ -134,6 +138,10 @@ public class TpdImporter {
if (!headless) {
Activator.getDefault().pauseHandlingResourceChanges();
}
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final IPreferencesService prefs = Platform.getPreferencesService();
processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE,
availableProcessors, null);
}
/**
......@@ -151,11 +159,12 @@ public class TpdImporter {
* @return true if the import was successful, false otherwise.
* */
public boolean internalFinish(final String projectFile, final boolean isSkipExistingProjects,
final boolean isOpenPropertiesForAllImports, final List<IProject> projectsCreated, final IProgressMonitor monitor,
final List<String> searchPaths) {
final boolean isOpenPropertiesForAllImports, final boolean islimitImportProcesses,
final List<IProject> projectsCreated, final IProgressMonitor monitor, final List<String> searchPaths) {
if (projectFile == null || "".equals(projectFile.trim())) {
return false;
}
this.islimitImportProcesses = islimitImportProcesses;
if(searchPaths != null) {
this.searchPaths = new ArrayList<String>(searchPaths);
}
......@@ -218,14 +227,20 @@ public class TpdImporter {
// (where they are loaded from)
//========================
final Map<URI, IProject> projectMap = new ConcurrentHashMap<URI, IProject>();
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (islimitImportProcesses) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final AtomicBoolean isErroneous = new AtomicBoolean(false);
final LinkedBlockingDeque<IProject> projectsCreatedTemp = new LinkedBlockingDeque<IProject>();
......@@ -286,14 +301,12 @@ public class TpdImporter {
//====================================
//Load Project Data from all projects:
//====================================
final ExecutorService executor2 = Executors.newCachedThreadPool(new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
ExecutorService executor2;
if (islimitImportProcesses) {
executor2 = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor2 = Executors.newCachedThreadPool(threadFactory);
}
final CountDownLatch latch2 = new CountDownLatch(projectsToImport.size());
for (final URI file : projectsToImport.keySet()) {
......@@ -595,14 +608,20 @@ public class TpdImporter {
private boolean loadReferencedProjectsData(final Node referencedProjectsNode, final IProject project) {
final NodeList referencedProjectsList = referencedProjectsNode.getChildNodes();
final LinkedBlockingDeque<IProject> referencedProjects = new LinkedBlockingDeque<IProject>();
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (islimitImportProcesses) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final AtomicBoolean isErroneous = new AtomicBoolean(false);
final CountDownLatch latch = new CountDownLatch(referencedProjectsList.getLength());
......@@ -779,14 +798,20 @@ public class TpdImporter {
* */
private boolean loadFilesData(final Node filesNode, final IProject project, final URI projectFileFolderURI) {
final NodeList fileNodeList = filesNode.getChildNodes();
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
final ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setPriority(LoadBalancingUtilities.getThreadPriority());
return t;
}
});
};
ExecutorService executor;
if (islimitImportProcesses) {
executor = Executors.newFixedThreadPool(processingUnitsToUse, threadFactory);
} else {
executor = Executors.newCachedThreadPool(threadFactory);
}
final AtomicBoolean isErroneous = new AtomicBoolean(false);
final CountDownLatch latch = new CountDownLatch(fileNodeList.getLength());
......
......@@ -54,7 +54,7 @@ public class ImportProjectsFromTpd implements IApplication {
System.out.println("Importing from Tpd");
final TpdImporter tpdImporter = new TpdImporter(null, true);
final List<IProject> projectsCreated = new ArrayList<IProject>();
result = tpdImporter.internalFinish(projectFiles[0], false, false, projectsCreated, new N