Skip to content
Snippets Groups Projects
Commit ae4d418f authored by gakin's avatar gakin
Browse files

SSDM-5025 : Introduce parallelized execution parameters in harvester config

SVN: 38186
parent dc3a8066
No related branches found
No related tags found
No related merge requests found
......@@ -23,11 +23,11 @@ package ch.ethz.sis.openbis.generic.server.dss.plugins.sync.harvester.config;
*/
public class BasicAuthCredentials
{
private String realm;
private final String realm;
private String user;
private final String user;
private String password;
private final String password;
public BasicAuthCredentials(String realm, String user, String pass)
{
......@@ -41,28 +41,13 @@ public class BasicAuthCredentials
return realm;
}
public void setRealm(String realm)
{
this.realm = realm;
}
public String getUser()
{
return user;
}
public void setUser(String user)
{
this.user = user;
}
public String getPassword()
{
return password;
}
public void setPassword(String pass)
{
this.password = pass;
}
}
/*
* Copyright 2017 ETH Zuerich, SIS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.ethz.sis.openbis.generic.server.dss.plugins.sync.harvester.config;
/**
*
*
* @author Ganime Betul Akin
*/
public class ParallelizedExecutionPreferences
{
private final Double machineLoad;
private final Integer maxThreads;
private final Integer retriesOnFail;
private final Boolean stopOnFailure;
public double getMachineLoad()
{
return machineLoad;
}
public int getMaxThreads()
{
return maxThreads;
}
public int getRetriesOnFail()
{
return retriesOnFail;
}
public boolean isStopOnFailure()
{
return stopOnFailure;
}
public ParallelizedExecutionPreferences(Double machineLoad, Integer maxThreads, Integer retriesOnFail, Boolean stopOnFailure)
{
this.machineLoad = machineLoad;
this.maxThreads = maxThreads;
this.retriesOnFail = retriesOnFail;
this.stopOnFailure = stopOnFailure;
}
}
......@@ -183,6 +183,9 @@ public class SyncConfig
// the data source openbis
private BasicAuthCredentials authCredentials;
// Data sets and attachment downloads are parallelized
private ParallelizedExecutionPreferences parallelizedExecutionPrefs;
// the username/password pair to be used on the harvester side
// to get the session token
private String harvesterUser;
......@@ -320,4 +323,9 @@ public class SyncConfig
{
this.verbose = verbose;
}
public void setParallelizedExecutionPrefs(double machineLoad, int maxThreads, int retriesOnFailure, boolean stopOnFailure)
{
this.parallelizedExecutionPrefs = new ParallelizedExecutionPreferences(machineLoad, maxThreads, retriesOnFailure, stopOnFailure);
}
}
......@@ -80,6 +80,14 @@ public class SynchronizationConfigReader
private static final String VERBOSE_PROPERTY_NAME = "verbose";
private static final String PARALLELIZED_EXECUTION_PREFS_MACHINE_LOAD_PROPERTY_NAME = "machine-load";
private static final String PARALLELIZED_EXECUTION_PREFS_MACHINE_MAX_THREADS_PROPERTY_NAME = "max-threads";
private static final String PARALLELIZED_EXECUTION_PREFS_RETRIES_ON_FAILURE_PROPERTY_NAME = "retries-on-failure";
private static final String PARALLELIZED_EXECUTION_PREFS_STOP_ON_FIRST_FAILURE_PROPERTY_NAME = "stop-on-first-failure";
private Integer defaultFullSyncIntervalInDays = 14;
private String defaultLogFileName = "synchronization_{alias}.log";
......@@ -88,6 +96,14 @@ public class SynchronizationConfigReader
private String defaultNotSyncedEntitiesFileName = "not-synced-entities_{alias}.txt";
private Double defaultMachineLoad = 0.5;
private Integer defaultMaxThreads = 10;
private Integer defaultRetriesOnFailure = 0;
private Boolean defaultStopOnFirstFailure = false;
private static final String LOG_FILE_PROPERTY_NAME = "log-file";
List<SyncConfig> configs = new ArrayList<>();
......@@ -160,6 +176,16 @@ public class SynchronizationConfigReader
{
config.setVerbose(true);
}
Double machineLoad = reader.getDouble(section, PARALLELIZED_EXECUTION_PREFS_MACHINE_LOAD_PROPERTY_NAME, defaultMachineLoad, false);
Integer maxThreads =
reader.getInt(section, PARALLELIZED_EXECUTION_PREFS_MACHINE_MAX_THREADS_PROPERTY_NAME, defaultMaxThreads, false);
Integer retriesOnFailure =
reader.getInt(section, PARALLELIZED_EXECUTION_PREFS_RETRIES_ON_FAILURE_PROPERTY_NAME, defaultRetriesOnFailure, false);
Boolean stopOnFailure =
reader.getBoolean(section, PARALLELIZED_EXECUTION_PREFS_STOP_ON_FIRST_FAILURE_PROPERTY_NAME, defaultStopOnFirstFailure);
config.setParallelizedExecutionPrefs(machineLoad, maxThreads, retriesOnFailure, stopOnFailure);
}
return configs;
}
......
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