Skip to content
Snippets Groups Projects
Commit cb93fb43 authored by Adam Laskowski's avatar Adam Laskowski
Browse files

BIS-745: Refactored ThreadParameters class

parent e7232154
No related branches found
No related tags found
No related merge requests found
......@@ -385,8 +385,8 @@ jython-version=2.7
#
default-incoming-share-id=1
default-incoming-share-minimum-free-space-in-gb=10
eln-lims-dropbox-allow-hidden-files=true
#eln-lims-dropbox-discard-files-patterns =
eln-lims-dropbox-discard-files-patterns=
eln-lims-dropbox-illegal-files-patterns=desktop\\.ini, IconCache\\.db, thumbs\\.db, \\..*, .*'.*, .*~.*, .*\\$.*, .*%.*
#
# Imaging plugin configuration
#
......
......@@ -17,8 +17,6 @@ package ch.systemsx.cisd.etlserver;
import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -35,22 +33,24 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.utils.SegmentedStoreUtils;
/**
* <i>ETL</i> thread specific parameters.
*
*
* @author Tomasz Pylak
*/
public final class ThreadParameters
{
/**
* A path to a script which should be called from command line before data set registration. The script gets two parameters: data set code and
* absolute path to the data set in the data store.
* A path to a script which should be called from command line before data set registration. The
* script gets two parameters: data set code and absolute path to the data set in the data
* store.
*/
@Private
static final String PRE_REGISTRATION_SCRIPT_KEY = "pre-registration-script";
/**
* A path to a script which should be called from command line after successful data set registration. The script gets two parameters: data set
* code and absolute path to the data set in the data store.
* A path to a script which should be called from command line after successful data set
* registration. The script gets two parameters: data set code and absolute path to the data set
* in the data store.
*/
@Private
static final String POST_REGISTRATION_SCRIPT_KEY = "post-registration-script";
......@@ -99,7 +99,8 @@ public final class ThreadParameters
@Private
public static final String INCOMING_SHARE_ID = "incoming-share-id";
private static final String INCOMING_SHARE_MINIMUM_FREE_SPACE_IN_GB = "incoming-share-minimum-free-space-in-gb";
private static final String INCOMING_SHARE_MINIMUM_FREE_SPACE_IN_GB =
"incoming-share-minimum-free-space-in-gb";
/*
* The properties that control the process of retrying registration by jython dropboxes
......@@ -131,15 +132,9 @@ public final class ThreadParameters
private static final String H5AR_FOLDERS = "h5ar-folders";
public static final String DISCARD_HIDDEN_FILES = "discard-hidden-files";
public static final String ALLOW_HIDDEN_FILES = "allow-hidden-files";
public static final String DISCARD_FILES_PATTERNS = "discard-files-patterns";
/**
* The (local) directory to monitor for new files and directories to move to the remote side. The directory where data to be processed by the ETL
* server become available.
* The (local) directory to monitor for new files and directories to move to the remote side.
* The directory where data to be processed by the ETL server become available.
*/
private final File incomingDataDirectory;
......@@ -189,21 +184,15 @@ public final class ThreadParameters
private final boolean h5arFolders;
private final boolean allowHiddenFiles;
private final String discardFilesPatterns;
private final Map<String, Pattern> discardFilesPatternsCache = new ConcurrentHashMap<>();
/**
* @param threadProperties parameters for one processing thread together with general parameters.
* @param threadProperties parameters for one processing thread together with general
* parameters.
*/
public ThreadParameters(final Properties threadProperties, final String threadName)
{
this.incomingDataDirectory = extractIncomingDataDir(threadProperties, threadName);
this.h5Folders = PropertyUtils.getBoolean(threadProperties, H5_FOLDERS, false);
this.h5arFolders = PropertyUtils.getBoolean(threadProperties, H5AR_FOLDERS, true);
this.allowHiddenFiles = PropertyUtils.getBoolean(threadProperties, ALLOW_HIDDEN_FILES, true);
this.createIncomingDirectories =
PropertyUtils.getBoolean(threadProperties, INCOMING_DIR_CREATE, true);
this.threadProperties = threadProperties;
......@@ -283,7 +272,6 @@ public final class ThreadParameters
ON_ERROR_DECISION_KEY + ".class", ex.getMessage());
}
this.onErrorDecisionClassOrNull = onErrorClass;
this.discardFilesPatterns = PropertyUtils.getProperty(threadProperties, DISCARD_FILES_PATTERNS, "");
}
private DataSetRegistrationPreStagingBehavior getOriginalnputDataSetBehaviour(
......@@ -423,7 +411,8 @@ public final class ThreadParameters
private static Long tryGetIncomingShareMinimumFreeSpace(Properties properties)
{
double min = PropertyUtils.getDouble(properties, INCOMING_SHARE_MINIMUM_FREE_SPACE_IN_GB, -1);
double min =
PropertyUtils.getDouble(properties, INCOMING_SHARE_MINIMUM_FREE_SPACE_IN_GB, -1);
return min < 0 ? null : (long) (min * FileUtils.ONE_GB);
}
......@@ -492,8 +481,10 @@ public final class ThreadParameters
if (operationLog.isInfoEnabled())
{
logLine("Top-level registrator: '%s'",
(null == topLevelDataSetRegistratorClassOrNull) ? TransferredDataSetHandler.class
.getName() : topLevelDataSetRegistratorClassOrNull.getName());
(null == topLevelDataSetRegistratorClassOrNull) ?
TransferredDataSetHandler.class
.getName() :
topLevelDataSetRegistratorClassOrNull.getName());
if (null == topLevelDataSetRegistratorClassOrNull)
{
IETLServerPlugin plugin = ETLServerPluginFactory.getPluginForThread(this);
......@@ -581,21 +572,6 @@ public final class ThreadParameters
return h5Folders;
}
public boolean allowHiddenFiles()
{
return allowHiddenFiles;
}
public String discardFilesPatterns()
{
return discardFilesPatterns;
}
public Map<String, Pattern> discardFilesPatternsCache()
{
return discardFilesPatternsCache;
}
public boolean hasH5ArAsFolders()
{
return h5arFolders;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment