diff --git a/etc/storm.properties.template b/etc/storm.properties.template index 628f944af..28ace2f50 100644 --- a/etc/storm.properties.template +++ b/etc/storm.properties.template @@ -9,54 +9,54 @@ # SRM service parameters # ============================ -# StoRM SRM default host and port used to initialize SURLs starting from SFN and also to -# publish info -srm_public_host = -srm_public_port = 8444 - -# List of comma separated strings identifying the accepted StoRM SRM end-points. -# Each end-point must be composed of [host]:[port]. This is used by StoRM to understand if a -# SURL is valid (managed or not). -srm_endpoints = +# List of accepted StoRM SRM end-points. +# srm_endpoints.1.host = storm.example +# srm_endpoints.1.port = 8444 +# srm_endpoints.2.host = alias.example +# srm_endpoints.2.port = 8444 # ============================ # FE/BE DBMS parameters # ============================ # Database connection configuration -db_username = storm -db_password = -db_hostname = -db_port = 3306 -db_properties = serverTimezone=UTC&autoReconnect=true +db.hostname = +db.username = storm +db.password = storm +db.port = 3306 +db.properties = serverTimezone=UTC&autoReconnect=true # Database connection pool configuration -db_pool_size = -1 -db_pool_min_idle = 10 -db_pool_max_wait_millis = 5000 -db_pool_test_on_borrow = true -db_pool_test_while_idle = true +db.pool.size = -1 +db.pool.min_idle = 10 +db.pool.max_wait_millis = 5000 +db.pool.test_on_borrow = true +db.pool.test_while_idle = true # ============================ # REST Services parameter # ============================ -rest_services_port = 9998 -rest_services_max_threads = 100 -rest_services_max_queue_size = 1000 +rest.port = 9998 +rest.max_threads = 100 +rest.max_queue_size = 1000 # ============================ # Sanity Check enabled # ============================ -sanity_check_enabled = true +sanity_checks_enabled = true # ============================ # XMLRPC Server parameter # ============================ -xmlrpc_server_port = 8080 -xmlrpc_max_threads = 256 -xmlrpc_max_queue_size = 1000 -xmlrpc_security_enabled = false -xmlrpc_security_token = +xmlrpc.port = 8080 +xmlrpc.max_threads = 256 +xmlrpc.max_queue_size = 1000 + +# ============================ +# XMLRPC & REST security token +# ============================ +security_enabled = true +security_token = secret-token # ================================ # Disk Usage Service Configuration @@ -68,13 +68,13 @@ xmlrpc_security_token = # The initial starting delay of the service and the period can also be configured. # # Enable/Disable the periodic run of the service -du_service_enabled = false +du.enabled = false # Enable/Disable parallel du execution -du_service_parallel_tasks_enabled = false +du.parallel_tasks_enabled = false # Initial delay of service start in seconds. Default: 60s -du_service_initial_delay = 60 +du.initial_delay = 60 # Interval of execution of the du in seconds. Default: 86400s (24h) -du_service_tasks_interval = 86400 +du.tasks_interval = 86400 # ================================ @@ -82,106 +82,106 @@ du_service_tasks_interval = 86400 # ================================ # Enable/disable the automatic directory creation during srmPrepareToPut requests. -directory_automatic_creation = false +directories.enable_automatic_creation = false # Enable/disable write permission on directory created through srmMkDir requests. -directory_writeperm = false +directories.enable_writeperm_on_creation = false # Default pinLifetime in seconds used for pinning files in case of srmPrepareToPut or srmPrapareToGet requests -pinlifetime_default = 259200 +pinlifetime.default = 259200 # Maximum allowed value for pinLifeTime. Values beyond the max will be dropped to max value. -pinlifetime_maximum = 1814400 +pinlifetime.maximum = 1814400 # Add extra slashes after the “authority” part of a TURL for FILE protocol. -extraslashes_file= +extraslashes.file = # Add extra slashes after the “authority” part of a TURL for RFIO protocol. -extraslashes_rfio= +extraslashes.rfio = # Add extra slashes after the “authority” part of a TURL for GSIFTP protocol. -extraslashes_gsiftp=/ +extraslashes.gsiftp = / # Add extra slashes after the “authority” part of a TURL for ROOT protocol. -extraslashes_root=/ +extraslashes.root = / # Initial delay in seconds before starting the garbage collector thread -gc_pinnedfiles_cleaning_delay = 10 +expired_spaces_agent.delay = 10 # Garbage Collector time interval in seconds. -gc_pinnedfiles_cleaning_interval = 300 +expired_spaces_agent.interval = 300 # Default FileSize -filesize_default = 1000000 +files.default_size = 1000000 # Default FileLifetime in seconds used for VOLATILE file in case of SRM request. -filelifetime_default = 259200 +files.default_lifetime = 259200 # Default file overwrite mode to use upon srmPrepareToPut requests. # Possible values are N (Never), A (Always), D (when files Differs). -default_overwrite = A +files.default_overwrite = A # Default File Storage Type to be used for srmPrepareToPut requests. # Possible values are V (Volatile), P (Permanent) and D (Durable) -default_storagetype = P +files.default_storagetype = P # Crusher Scheduler worker pool base size. -scheduler_crusher_worker_core_pool_size = 10 +requests_scheduler.core_pool_size = 10 # Crusher Schedule worker pool max size. -scheduler_crusher_worker_max_pool_size = 50 +requests_scheduler.max_pool_size = 50 # Request queue maximum size. -scheduler_crusher_queue_size = 2000 +requests_scheduler.queue_size = 2000 # PrepareToPut worker pool base size. -scheduler_chunksched_ptp_worker_core_pool_size = 50 +ptp_scheduler.core_pool_size = 50 # PrepareToPut worker pool max size. -scheduler_chunksched_ptp_worker_max_pool_size = 200 +ptp_scheduler.max_pool_size = 200 # PrepareToPut request queue maximum size. -scheduler_chunksched_ptp_queue_size = 1000 +ptp_scheduler.queue_size = 1000 # PrepareToGet worker pool base size. -scheduler_chunksched_ptg_worker_core_pool_size = 50 +ptg_scheduler.core_pool_size = 50 # PrepareToGet worker pool max size. -scheduler_chunksched_ptg_worker_max_pool_size = 200 +ptg_scheduler.max_pool_size = 200 # PrepareToGet request queue maximum size. -scheduler_chunksched_ptg_queue_size = 2000 +ptg_scheduler.queue_size = 2000 # BringOnline worker pool base size. -scheduler_chunksched_bol_worker_core_pool_size = 50 +bol_scheduler.core_pool_size = 50 # BringOnline Worker pool max size. -scheduler_chunksched_bol_worker_max_pool_size = 200 +bol_scheduler.max_pool_size = 200 # BringOnline request queue maximum size. -scheduler_chunksched_bol_queue_size = 2000 +bol_scheduler.queue_size = 2000 # Initial delay before starting to pick requests from the DB, in seconds. -asynch_picking_initial_delay = 1 +requests_picker_agent.delay = 1 # Polling interval in seconds to pick up new SRM requests. -asynch_picking_time_interval = 2 +requests_picker_agent.interval = 2 # Maximum number of requests picked up at each polling time. -asynch_picking_max_batch_size = 100 +requests_picker_agent.max_fetched_size = 100 # Maximum number of entries returned by an srmLs call. # Since in case of recursive srmLs results can be in order of million, # this prevent a server overload. -synch_ls_max_entries = 2000 +synch_ls.max_entries = 2000 # Default value for the parameter "allLevelRecursive" of the srmLS request. -synch_ls_default_all_level_recursive = false +synch_ls.default_all_level_recursive = false # Default value for the parameter "numOfLevels" of the srmLS request. -synch_ls_default_num_levels = 1 +synch_ls.default_num_levels = 1 # Default value for the parameter "offset" of the LS request. -synch_ls_default_offset = 0 +synch_ls.default_offset = 0 # Enable/Disable Garbage Collector -purging = true +completed_requests_agent.enabled = true # Time interval for between two requests in garbage collection. In seconds -purge_interval = 600 +completed_requests_agent.interval = 600 # Initial delay before starting the requests garbage collection process, in seconds. -purge_delay = 10 +completed_requests_agent.delay = 10 # Number of requests removed at each run. Every run purge max 800 requests in final status -purge_size = 800 - +completed_requests_agent.purge_size = 800 # Time after that the GC consider a _terminated_ request as garbage in seconds -expired_request_time = 21600 -# Time in seconds to consider an in-progress ptp request as expired. -expired_inprogress_time = 2592000 +completed_requests_agent.purge_age = 21600 + # Expired-Put-Requests-Agent transits expired put requests to a final state. # A put request is expired if pinLifetime is reached. # Time interval between two agent executions. In seconds -transit_interval = 300 +inprogress_requests_agent.interval = 300 # Delay on starting agent. In seconds -transit_delay = 10 +inprogress_requests_agent.delay = 10 +# Time in seconds to consider an in-progress ptp request as expired. +inprogress_requests_agent.ptp_expiration_time = 2592000 # Skip ACL setup for PtG requests -ptg_skip_acl_setup = false +skip_ptg_acl_setup = false info_quota_refresh_period = 900 http_turl_prefix = @@ -189,8 +189,8 @@ server_pool_status_check_timeout = 20000 abort_maxloop = 10 ping_properties_filename = ping-values.properties -health_bookkeeping_enabled = false -health_performance_measuring_enabled = false -health_electrocardiogram_period = 60 -health_performance_logbook_time_interval = 15 -health_performance_glance_time_interval = 15 \ No newline at end of file +hearthbeat.bookkeeping_enabled = false +hearthbeat.performance_measuring_enabled = false +hearthbeat.period = 60 +hearthbeat.performance_logbook_time_interval = 15 +hearthbeat.performance_glance_time_interval = 15 \ No newline at end of file diff --git a/pom.xml b/pom.xml index a35a9ef01..a175fff60 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,7 @@ 1.10 2.25.1 + 2.8.4 8.1.9.v20130131 1.7.2 1.2.3 @@ -194,6 +195,11 @@ jersey-bean-validation ${jerseyVersion} + + com.fasterxml.jackson.dataformat + jackson-dataformat-properties + ${jacksonVersion} + org.eclipse.jetty diff --git a/src/main/java/it/grid/storm/Main.java b/src/main/java/it/grid/storm/Main.java index 4a210522f..b23a27a28 100644 --- a/src/main/java/it/grid/storm/Main.java +++ b/src/main/java/it/grid/storm/Main.java @@ -13,20 +13,17 @@ public class Main { private static final Logger log = LoggerFactory.getLogger(Main.class); - /* System properties */ - private static final String CONFIG_FILE_PATH = "storm.configuration.file"; - private static final String REFRESH_RATE = "storm.configuration.refresh"; - + public static final String CONFIG_FILE_PROPERTY = "storm.configuration.file"; public static final String DEFAULT_CONFIG_FILE = "/etc/storm/backend-server/storm.properties"; - public static final int DEFAULT_REFRESH_RATE = 5000; private Main() {} public static void main(String[] args) { - initConfiguration(); + String filePath = getProperty(CONFIG_FILE_PROPERTY, DEFAULT_CONFIG_FILE); + Configuration.init(filePath); - StoRM storm = new StoRM(); + StoRM storm = new StoRM(Configuration.getInstance()); try { storm.init(); @@ -51,16 +48,4 @@ public static void main(String[] args) { exit(1); } } - - private static void initConfiguration() { - - String filePath = getProperty(CONFIG_FILE_PATH, DEFAULT_CONFIG_FILE); - int refreshRate; - try { - refreshRate = Integer.valueOf(getProperty(REFRESH_RATE)); - } catch (NumberFormatException e) { - refreshRate = DEFAULT_REFRESH_RATE; - } - Configuration.init(filePath, refreshRate); - } } diff --git a/src/main/java/it/grid/storm/StoRM.java b/src/main/java/it/grid/storm/StoRM.java index b622ed031..de340e707 100644 --- a/src/main/java/it/grid/storm/StoRM.java +++ b/src/main/java/it/grid/storm/StoRM.java @@ -91,10 +91,13 @@ public class StoRM { private boolean isRestServerRunning; private RestServer restServer; - private final Configuration config = Configuration.getInstance(); - private final ReservedSpaceCatalog spaceCatalog = ReservedSpaceCatalog.getInstance(); + private final Configuration config; + private final ReservedSpaceCatalog spaceCatalog; - public StoRM() { + public StoRM(Configuration config) { + + this.config = config; + this.spaceCatalog = ReservedSpaceCatalog.getInstance(); this.picker = new AdvancedPicker(); this.isPickerRunning = false; @@ -141,8 +144,8 @@ public void init() throws BootstrapException { private void configureLogging() { - String configurationDir = config.configurationDir(); - String logFile = configurationDir + "logging.xml"; + String logFile = String.format("%s/logging.xml", config.configurationDir()); + log.debug("Configure logging from %s file ...", logFile); Bootstrap.configureLogging(logFile); } @@ -278,11 +281,11 @@ public synchronized void stopXmlRpcServer() { private void configureRestService() { - int restServicePort = Configuration.getInstance().getRestServicesPort(); - boolean isTokenEnabled = Configuration.getInstance().getXmlRpcSecurityEnabled(); - String token = Configuration.getInstance().getXmlRpcToken(); - int maxThreads = Configuration.getInstance().getRestServicesMaxThreads(); - int maxQueueSize = Configuration.getInstance().getRestServicesMaxQueueSize(); + int restServicePort = config.getRestServicesPort(); + boolean isTokenEnabled = config.getXmlRpcSecurityEnabled(); + String token = config.getXmlRpcToken(); + int maxThreads = config.getRestServicesMaxThreads(); + int maxQueueSize = config.getRestServicesMaxQueueSize(); restServer = new RestServer(restServicePort, maxThreads, maxQueueSize, isTokenEnabled, token); } @@ -419,7 +422,7 @@ private void configureDiskUsageService() { isDiskUsageServiceEnabled = config.getDiskUsageServiceEnabled(); int delay = config.getDiskUsageServiceInitialDelay(); - int period = config.getDiskUsageServiceTasksInterval(); + long period = config.getDiskUsageServiceTasksInterval(); NamespaceInterface namespace = NamespaceDirector.getNamespace(); List quotaEnabledVfs = namespace.getVFSWithQuotaEnabled(); diff --git a/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java b/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java index eab06eae9..a6fa89cb8 100644 --- a/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java +++ b/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java @@ -55,8 +55,8 @@ class PermissionEvaluator { public static Boolean isOverwriteAllowed() { - return OverwriteModeConverter.getInstance() - .toSTORM(Configuration.getInstance().getDefaultOverwriteMode()) + return OverwriteModeConverter + .toSTORM(Configuration.getInstance().getDefaultOverwriteMode().toString()) .equals(TOverwriteMode.ALWAYS); } diff --git a/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java b/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java index e9f411749..25a28a0b0 100644 --- a/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java +++ b/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java @@ -111,7 +111,7 @@ public synchronized void update(PtPPersistentChunkData chunkData) { to.setPinLifetime(PinLifetimeConverter.getInstance().toDB(chunkData.pinLifetime().value())); to.setFileLifetime(FileLifetimeConverter.getInstance().toDB(chunkData.fileLifetime().value())); to.setFileStorageType(FileStorageTypeConverter.getInstance().toDB(chunkData.fileStorageType())); - to.setOverwriteOption(OverwriteModeConverter.getInstance().toDB(chunkData.overwriteOption())); + to.setOverwriteOption(OverwriteModeConverter.toDB(chunkData.overwriteOption()).name()); to.setNormalizedStFN(chunkData.getSURL().normalizedStFN()); to.setSurlUniqueID(Integer.valueOf(chunkData.getSURL().uniqueId())); to.setClientDN(chunkData.getUser().getDn()); @@ -249,7 +249,7 @@ private PtPPersistentChunkData makeOne(PtPChunkDataTO auxTO, TRequestToken rt) { } // overwriteOption! TOverwriteMode overwriteOption = - OverwriteModeConverter.getInstance().toSTORM(auxTO.overwriteOption()); + OverwriteModeConverter.toSTORM(auxTO.overwriteOption()); if (overwriteOption == TOverwriteMode.EMPTY) { errorSb.append("\nTOverwriteMode could not be translated " + "from its String representation! String: " + auxTO.overwriteOption()); diff --git a/src/main/java/it/grid/storm/checksum/ChecksumManager.java b/src/main/java/it/grid/storm/checksum/ChecksumManager.java index 3c2a74832..395423be9 100644 --- a/src/main/java/it/grid/storm/checksum/ChecksumManager.java +++ b/src/main/java/it/grid/storm/checksum/ChecksumManager.java @@ -17,16 +17,17 @@ package it.grid.storm.checksum; -import it.grid.storm.config.DefaultValue; -import it.grid.storm.ea.ExtendedAttributesException; -import it.grid.storm.ea.StormEA; - import java.io.FileNotFoundException; import java.util.Map; +import javax.ws.rs.NotSupportedException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import it.grid.storm.ea.ExtendedAttributesException; +import it.grid.storm.ea.StormEA; + public class ChecksumManager { private static final Logger log = LoggerFactory.getLogger(ChecksumManager.class); @@ -36,7 +37,7 @@ public class ChecksumManager { private ChecksumManager() { - defaultAlgorithm = DefaultValue.getChecksumAlgorithm(); + defaultAlgorithm = ChecksumAlgorithm.ADLER32; } public static synchronized ChecksumManager getInstance() { diff --git a/src/main/java/it/grid/storm/config/ConfigReader.java b/src/main/java/it/grid/storm/config/ConfigReader.java deleted file mode 100644 index 25ca3c757..000000000 --- a/src/main/java/it/grid/storm/config/ConfigReader.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. - * - * 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 it.grid.storm.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Iterator; - -import org.apache.commons.configuration.CompositeConfiguration; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ConfigReader { - - private static final Logger log = LoggerFactory.getLogger(ConfigReader.class); - - private Configuration c; - - private String configurationPathname = ""; - - public ConfigReader(String configurationPathname, int refresh) throws ConfigurationException { - - checkNotNull(configurationPathname, "Null configuration pathname."); - int refreshRate = refresh < 0 ? 0 : refresh; - this.configurationPathname = configurationPathname; - log.info("Configuration file {}. Refresh rate: {} seconds", configurationPathname, refreshRate); - - FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); - strategy.setRefreshDelay(refreshRate); - PropertiesConfiguration properties = new PropertiesConfiguration(configurationPathname); - logPropertiesConfiguration(properties); - properties.setReloadingStrategy(strategy); - this.c = new CompositeConfiguration(); - ((CompositeConfiguration) this.c).addConfiguration(properties); - log.info("Configuration read successfully."); - } - - private void logPropertiesConfiguration(PropertiesConfiguration properties) { - - log.debug("Configuration properties: "); - String key; - for (Iterator i = properties.getKeys(); i.hasNext();) { - key = (String) i.next(); - log.debug("{} = {}", key, properties.getProperty(key)); - } - } - - /** - * Method that returns the Apache object holding all configuration parameters! - */ - public Configuration getConfiguration() { - - return c; - } - - /** - * Method that returns the directory containing the configuration files: it is extrapolated from - * the complete pathname of the configuration file. If the pathname was not setup, an empty String - * is returned. - */ - public String configurationDirectory() { - - if (configurationPathname.isEmpty()) - return ""; - int lastSlash = this.configurationPathname.lastIndexOf(java.io.File.separator); - if (lastSlash == -1) - return ""; // no slash! - return this.configurationPathname.substring(0, lastSlash + 1); - } - -} diff --git a/src/main/java/it/grid/storm/config/Configuration.java b/src/main/java/it/grid/storm/config/Configuration.java index 14537e0ab..4998e9cbc 100644 --- a/src/main/java/it/grid/storm/config/Configuration.java +++ b/src/main/java/it/grid/storm/config/Configuration.java @@ -17,95 +17,24 @@ package it.grid.storm.config; -import static it.grid.storm.config.ConfigurationDefaults.AUTOMATIC_DIRECTORY_CREATION; -import static it.grid.storm.config.ConfigurationDefaults.BOL_CORE_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.BOL_MAX_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.BOL_QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.BOOK_KEEPING_ENABLED; -import static it.grid.storm.config.ConfigurationDefaults.CLEANING_INITIAL_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.CLEANING_TIME_INTERVAL; -import static it.grid.storm.config.ConfigurationDefaults.CORE_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.DB_PASSWORD; -import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MAX_WAIT_MILLIS; -import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MIN_IDLE; -import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_ON_BORROW; -import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_WHILE_IDLE; -import static it.grid.storm.config.ConfigurationDefaults.DB_PORT; -import static it.grid.storm.config.ConfigurationDefaults.DB_PROPERTIES; -import static it.grid.storm.config.ConfigurationDefaults.DB_USERNAME; -import static it.grid.storm.config.ConfigurationDefaults.DEFAULT_FILE_STORAGE_TYPE; -import static it.grid.storm.config.ConfigurationDefaults.DEFAULT_OVERWRITE_MODE; -import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_ENABLED; -import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_INITIAL_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED; -import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_TASKS_INTERVAL; -import static it.grid.storm.config.ConfigurationDefaults.ENABLE_WRITE_PERM_ON_DIRECTORY; -import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_INPROGRESS_PTP_TIME; -import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_REQUEST_PURGING; -import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_REQUEST_TIME; -import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_FILE_TURL; -import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_GSIFTP_TURL; -import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_RFIO_TURL; -import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_ROOT_TURL; -import static it.grid.storm.config.ConfigurationDefaults.FILE_DEFAULT_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.FILE_LIFETIME_DEFAULT; -import static it.grid.storm.config.ConfigurationDefaults.GPFS_QUOTA_REFRESH_PERIOD; -import static it.grid.storm.config.ConfigurationDefaults.HEARTHBEAT_PERIOD; -import static it.grid.storm.config.ConfigurationDefaults.HTTP_TURL_PREFIX; -import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_ALL_LEVEL_RECURSIVE; -import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_NUM_OF_LEVELS; -import static it.grid.storm.config.ConfigurationDefaults.LS_MAX_NUMBER_OF_ENTRY; -import static it.grid.storm.config.ConfigurationDefaults.LS_OFFSET; -import static it.grid.storm.config.ConfigurationDefaults.MAX_LOOP; -import static it.grid.storm.config.ConfigurationDefaults.MAX_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_GLANCE_TIME_INTERVAL; -import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_LOGBOOK_TIME_INTERVAL; -import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_MEASURING; -import static it.grid.storm.config.ConfigurationDefaults.PICKING_INITIAL_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.PICKING_MAX_BATCH_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PICKING_TIME_INTERVAL; -import static it.grid.storm.config.ConfigurationDefaults.PING_VALUES_PROPERTIES_FILENAME; -import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_DEFAULT; -import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_MAXIMUM; -import static it.grid.storm.config.ConfigurationDefaults.PTG_CORE_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTG_MAX_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTG_QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTG_SKIP_ACL_SETUP; -import static it.grid.storm.config.ConfigurationDefaults.PTP_CORE_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTP_MAX_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTP_QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PURGE_BATCH_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.REQUEST_PURGER_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.REQUEST_PURGER_PERIOD; -import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_THREADS; -import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_PORT; -import static it.grid.storm.config.ConfigurationDefaults.SANITY_CHECK_ENABLED; -import static it.grid.storm.config.ConfigurationDefaults.SERVER_POOL_STATUS_CHECK_TIMEOUT; -import static it.grid.storm.config.ConfigurationDefaults.SERVICE_SRM_PUBLIC_PORT; -import static it.grid.storm.config.ConfigurationDefaults.TRANSIT_INITIAL_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.TRANSIT_TIME_INTERVAL; -import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_THREADS; -import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_SECURITY_ENABLED; -import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_SECURITY_TOKEN; -import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_SERVER_PORT; import static java.lang.System.getProperty; import java.io.File; -import java.net.InetAddress; +import java.io.FileInputStream; +import java.io.IOException; import java.net.UnknownHostException; -import java.util.Iterator; import java.util.List; +import java.util.Properties; import java.util.stream.Collectors; -import org.apache.commons.configuration.ConfigurationException; import org.slf4j.Logger; -import com.google.common.collect.Lists; +import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper; +import it.grid.storm.config.converter.StormPropertiesConverter; +import it.grid.storm.config.model.OverwriteMode; +import it.grid.storm.config.model.StorageType; +import it.grid.storm.config.model.StormProperties; import it.grid.storm.namespace.NamespaceDirector; import it.grid.storm.namespace.model.Authority; @@ -121,160 +50,57 @@ public class Configuration { + private static Configuration instance = null; + + public static final String CURRENT_PROPERTIES_VERSION = "v2"; + private Logger log = NamespaceDirector.getLogger(); - private final ConfigReader cr; - - private static Configuration instance; - - /* Configuration file properties */ - - /* SRM public info */ - private static final String SERVICE_SRM_PUBLIC_HOST_KEY = "srm_public_host"; - private static final String SERVICE_SRM_PUBLIC_PORT_KEY = "srm_public_port"; - - /* SRM end-points */ - private static final String MANAGED_SRM_ENDPOINTS_KEY = "srm_endpoints"; - - /* Database */ - private static final String DB_USERNAME_KEY = "db_username"; - private static final String DB_PASSWORD_KEY = "db_password"; - private static final String DB_HOSTNAME_KEY = "db_hostname"; - private static final String DB_PORT_KEY = "db_port"; - private static final String DB_PROPERTIES_KEY = "db_properties"; - /* Database connection pool */ - private static final String DB_POOL_SIZE_KEY = "db_pool_size"; - private static final String DB_POOL_MIN_IDLE_KEY = "db_pool_min_idle"; - private static final String DB_POOL_MAX_WAIT_MILLIS_KEY = "db_pool_max_wait_millis"; - private static final String DB_POOL_TEST_ON_BORROW_KEY = "db_pool_test_on_borrow"; - private static final String DB_POOL_TEST_WHILE_IDLE_KEY = "db_pool_test_while_idle"; - /* REST service */ - private static final String REST_SERVICES_PORT_KEY = "rest_services_port"; - private static final String REST_SERVICES_MAX_THREADS_KEY = "rest_services_max_threads"; - private static final String REST_SERVICES_MAX_QUEUE_SIZE_KEY = "rest_services_max_queue_size"; - /* Sanity check enabled */ - private static final String SANITY_CHECK_ENABLED_KEY = "sanity_check_enabled"; - /* Disk usage service */ - public static final String DISKUSAGE_SERVICE_ENABLED_KEY = "du_service_enabled"; - private static final String DISKUSAGE_SERVICE_INITIAL_DELAY_KEY = "du_service_initial_delay"; - private static final String DISKUSAGE_SERVICE_TASKS_INTERVAL_KEY = "du_service_tasks_interval"; - private static final String DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED_KEY = - "du_service_parallel_tasks_enabled"; - /* XMLRPC */ - private static final String XMLRPC_MAX_THREADS_KEY = "xmlrpc_max_threads"; - private static final String XMLRPC_MAX_QUEUE_SIZE_KEY = "xmlrpc_max_queue_size"; - private static final String XMLRPC_SERVER_PORT_KEY = "xmlrpc_unsecure_server_port"; - private static final String XMLRPC_SECURITY_ENABLED_KEY = "xmlrpc_security_enabled"; - private static final String XMLRPC_SECURITY_TOKEN_KEY = "xmlrpc_security_token"; - - private static final String AUTOMATIC_DIRECTORY_CREATION_KEY = "directory_automatic_creation"; - private static final String ENABLE_WRITE_PERM_ON_DIRECTORY_KEY = "directory_writeperm"; - - private static final String PIN_LIFETIME_DEFAULT_KEY = "pinlifetime_default"; - private static final String PIN_LIFETIME_MAXIMUM_KEY = "pinlifetime_maximum"; - - private static final String EXTRA_SLASHES_FOR_FILE_TURL_KEY = "extraslashes_file"; - private static final String EXTRA_SLASHES_FOR_RFIO_TURL_KEY = "extraslashes_rfio"; - private static final String EXTRA_SLASHES_FOR_GSIFTP_TURL_KEY = "extraslashes_gsiftp"; - private static final String EXTRA_SLASHES_FOR_ROOT_TURL_KEY = "extraslashes_root"; - - private static final String CLEANING_INITIAL_DELAY_KEY = "gc_pinnedfiles_cleaning_delay"; - private static final String CLEANING_TIME_INTERVAL_KEY = "gc_pinnedfiles_cleaning_interval"; - - private static final String FILE_DEFAULT_SIZE_KEY = "filesize_default"; - private static final String FILE_LIFETIME_DEFAULT_KEY = "filelifetime_default"; - - private static final String TRANSIT_INITIAL_DELAY_KEY = "transit_delay"; - private static final String TRANSIT_TIME_INTERVAL_KEY = "transit_interval"; - - private static final String PICKING_INITIAL_DELAY_KEY = "asynch_picking_initial_delay"; - private static final String PICKING_TIME_INTERVAL_KEY = "asynch_picking_time_interval"; - private static final String PICKING_MAX_BATCH_SIZE_KEY = "asynch_picking_max_batch_size"; - - private static final String LS_MAX_NUMBER_OF_ENTRY_KEY = "synch_ls_max_entries"; - private static final String LS_DEFAULT_ALL_LEVEL_RECURSIVE_KEY = "synch_ls_default_all_level_recursive"; - private static final String LS_DEFAULT_NUM_OF_LEVELS_KEY = "synch_ls_default_num_levels"; - private static final String LS_OFFSET_KEY = "synch_ls_default_offset"; - - private static final String PTG_SKIP_ACL_SETUP_KEY = "ptg_skip_acl_setup"; - private static final String HTTP_TURL_PREFIX_KEY = "http_turl_prefix"; - - private static final String PTP_CORE_POOL_SIZE_KEY = - "scheduler_chunksched_ptp_worker_core_pool_size"; - private static final String PTP_MAX_POOL_SIZE_KEY = - "scheduler_chunksched_ptp_worker_max_pool_size"; - private static final String PTP_QUEUE_SIZE_KEY = "scheduler_chunksched_ptp_queueSize"; - private static final String PTG_CORE_POOL_SIZE_KEY = - "scheduler_chunksched_ptg_worker_core_pool_size"; - private static final String PTG_MAX_POOL_SIZE_KEY = - "scheduler_chunksched_ptg_worker_max_pool_size"; - private static final String PTG_QUEUE_SIZE_KEY = "scheduler_chunksched_ptg_queueSize"; - private static final String BOL_CORE_POOL_SIZE_KEY = - "scheduler_chunksched_bol_worker_core_pool_size"; - private static final String BOL_MAX_POOL_SIZE_KEY = - "scheduler_chunksched_bol_worker_max_pool_size"; - private static final String BOL_QUEUE_SIZE_KEY = "scheduler_chunksched_bol_queueSize"; - private static final String CORE_POOL_SIZE_KEY = "scheduler_crusher_worker_core_pool_size"; - private static final String MAX_POOL_SIZE_KEY = "scheduler_crusher_worker_max_pool_size"; - private static final String QUEUE_SIZE_KEY = "scheduler_crusher_queue_size"; - - private static final String DEFAULT_OVERWRITE_MODE_KEY = "default_overwrite"; - private static final String DEFAULT_FILE_STORAGE_TYPE_KEY = "default_storagetype"; - - private static final String EXPIRED_REQUEST_PURGING_KEY = "purging"; - private static final String REQUEST_PURGER_PERIOD_KEY = "purge_interval"; - private static final String PURGE_BATCH_SIZE_KEY = "purge_size"; - private static final String EXPIRED_REQUEST_TIME_KEY = "expired_request_time"; - private static final String EXPIRED_INPROGRESS_PTP_TIME_KEY = "expired_inprogress_time"; - private static final String REQUEST_PURGER_DELAY_KEY = "purge_delay"; - - private static final String PING_VALUES_PROPERTIES_FILENAME_KEY = "ping_properties_filename"; - - private static final String HEARTHBEAT_PERIOD_KEY = "health_electrocardiogram_period"; - private static final String PERFORMANCE_GLANCE_TIME_INTERVAL_KEY = - "health_performance_glance_time_interval"; - private static final String PERFORMANCE_LOGBOOK_TIME_INTERVAL_KEY = - "health_performance_logbook_time_interval"; - private static final String PERFORMANCE_MEASURING_KEY = "health_performance_measuring_enabled"; - private static final String BOOK_KEEPING_ENABLED_KEY = "health_bookkeeping_enabled"; - - private static final String MAX_LOOP_KEY = "abort_maxloop"; - - private static final String GPFS_QUOTA_REFRESH_PERIOD_KEY = "info_quota_refresh_period"; - - private static final String SERVER_POOL_STATUS_CHECK_TIMEOUT_KEY = - "server_pool_status_check_timeout"; - - public static void init(String filePath, int refreshRate) { - try { - instance = new Configuration(filePath, refreshRate); - } catch (ConfigurationException e) { - throw new ExceptionInInitializerError(e); - } + private File configFile; + private StormProperties properties; + + public static void init(String filePath) { + instance = new Configuration(filePath); } - private Configuration(String filePath, int refreshRate) throws ConfigurationException { + private Configuration(String filePath) { + + configFile = new File(filePath); - cr = new ConfigReader(filePath, refreshRate); + JavaPropsMapper mapper = new JavaPropsMapper(); + try { + properties = mapper.readValue(configFile, StormProperties.class); + if (properties.hasVersion()) { + log.info("Configuration properties:"); + properties.log(log); + } else { + // storm.properties before v1.12.0 + log.warn("It seems that your {} is not compliant with this StoRM Backend version.", + filePath); + log.warn("StoRM Backend will try to convert your old configuration to the latest ..."); + Properties old = new Properties(); + old.load(new FileInputStream(filePath)); + properties = StormPropertiesConverter.from(old); + log.info("This is your generated configuration:"); + properties.log(log); + File configFileV2 = new File(filePath + ".new"); + mapper.writeValue(configFileV2, properties); + log.info("Your configuration has been saved into {}", configFileV2); + } + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } } - /** - * Returns the sole instance of the Configuration class. - */ - public static Configuration getInstance() { + public synchronized static Configuration getInstance() { - return Configuration.instance; + return instance; } - /** - * Method that returns the directory holding the configuration file. The methods that make use of - * it are uncertain... must be found soon!!! Beware that the configuration directory is implicit - * in the complete pathname to the configuration file supplied in the command line when starting - * StoRM BE. - */ - public String configurationDir() { + public File configurationDir() { - return cr.configurationDirectory(); + return configFile.getParentFile(); } /** @@ -287,6 +113,14 @@ public String namespaceConfigPath() { return String.format("%s%setc", getProperty("user.dir"), File.separator); } + /** + * The published host of SRM service. It's used also to initialize a SURL starting from the SFN. + */ + public String getSrmServiceHostname() { + + return getManagedSrmEndpoints().get(0).getServiceHostname(); + } + /** * MANDATORY CONFIGURATION PARAMETER! Define the SURL end-points. * @@ -295,37 +129,17 @@ public String namespaceConfigPath() { */ public List getManagedSrmEndpoints() { - String defaultValue = String.format("%s:%d", getSrmServiceHostname(), getSrmServicePort()); - return cr.getConfiguration() - .getList(MANAGED_SRM_ENDPOINTS_KEY, Lists.newArrayList(defaultValue)) - .stream() - .map(o -> Authority.fromString(String.valueOf(o))) + return properties.srmEndpoints.stream() + .map(e -> new Authority(e.host, e.port)) .collect(Collectors.toList()); } - /** - * The published host of SRM service. It's used also to initialize a SURL starting from the SFN. - */ - public String getSrmServiceHostname() { - - try { - return cr.getConfiguration() - .getString(SERVICE_SRM_PUBLIC_HOST_KEY, InetAddress.getLocalHost().getHostName()); - } catch (UnknownHostException e) { - e.printStackTrace(); - log.error("Unable to get local FQDN hostname: please set {} into your storm.properties file", - SERVICE_SRM_PUBLIC_HOST_KEY); - System.exit(1); - return null; - } - } - /** * The published port of SRM service. It's used also to initialize a SURL starting from the SFN. */ public int getSrmServicePort() { - return cr.getConfiguration().getInt(SERVICE_SRM_PUBLIC_PORT_KEY, SERVICE_SRM_PUBLIC_PORT); + return getManagedSrmEndpoints().get(0).getServicePort(); } /** @@ -333,16 +147,7 @@ public int getSrmServicePort() { */ public String getDbHostname() { - try { - return cr.getConfiguration() - .getString(DB_HOSTNAME_KEY, InetAddress.getLocalHost().getHostName()); - } catch (UnknownHostException e) { - e.printStackTrace(); - log.error("Unable to get local FQDN hostname: please set {} into your storm.properties file", - DB_HOSTNAME_KEY); - System.exit(1); - return null; - } + return properties.db.hostname; } /** @@ -350,7 +155,7 @@ public String getDbHostname() { */ public int getDbPort() { - return cr.getConfiguration().getInt(DB_PORT_KEY, DB_PORT); + return properties.db.port; } /** @@ -358,7 +163,7 @@ public int getDbPort() { */ public String getDbUsername() { - return cr.getConfiguration().getString(DB_USERNAME_KEY, DB_USERNAME); + return properties.db.username; } /** @@ -366,7 +171,7 @@ public String getDbUsername() { */ public String getDbPassword() { - return cr.getConfiguration().getString(DB_PASSWORD_KEY, DB_PASSWORD); + return properties.db.password; } /** @@ -374,7 +179,7 @@ public String getDbPassword() { */ public String getDbProperties() { - return cr.getConfiguration().getString(DB_PROPERTIES_KEY, DB_PROPERTIES); + return properties.db.properties; } /** @@ -383,7 +188,7 @@ public String getDbProperties() { */ public int getDbPoolSize() { - return cr.getConfiguration().getInt(DB_POOL_SIZE_KEY, DB_POOL_SIZE); + return properties.db.pool.size; } /** @@ -391,7 +196,7 @@ public int getDbPoolSize() { */ public int getDbPoolMinIdle() { - return cr.getConfiguration().getInt(DB_POOL_MIN_IDLE_KEY, DB_POOL_MIN_IDLE); + return properties.db.pool.minIdle; } /** @@ -399,7 +204,7 @@ public int getDbPoolMinIdle() { */ public int getDbPoolMaxWaitMillis() { - return cr.getConfiguration().getInt(DB_POOL_MAX_WAIT_MILLIS_KEY, DB_POOL_MAX_WAIT_MILLIS); + return properties.db.pool.maxWaitMillis; } /** @@ -408,7 +213,7 @@ public int getDbPoolMaxWaitMillis() { */ public boolean isDbPoolTestOnBorrow() { - return cr.getConfiguration().getBoolean(DB_POOL_TEST_ON_BORROW_KEY, DB_POOL_TEST_ON_BORROW); + return properties.db.pool.testOnBorrow; } /** @@ -416,7 +221,7 @@ public boolean isDbPoolTestOnBorrow() { */ public boolean isDbPoolTestWhileIdle() { - return cr.getConfiguration().getBoolean(DB_POOL_TEST_WHILE_IDLE_KEY, DB_POOL_TEST_WHILE_IDLE); + return properties.db.pool.testWhileIdle; } /** @@ -424,26 +229,22 @@ public boolean isDbPoolTestWhileIdle() { */ public int getRestServicesPort() { - return cr.getConfiguration().getInt(REST_SERVICES_PORT_KEY, REST_SERVICES_PORT); + return properties.rest.port; } public int getRestServicesMaxThreads() { - int value = - cr.getConfiguration().getInt(REST_SERVICES_MAX_THREADS_KEY, REST_SERVICES_MAX_THREADS); - return value < 0 ? REST_SERVICES_MAX_THREADS : value; + return properties.rest.maxThreads; } public int getRestServicesMaxQueueSize() { - int value = cr.getConfiguration() - .getInt(REST_SERVICES_MAX_QUEUE_SIZE_KEY, REST_SERVICES_MAX_QUEUE_SIZE); - return value < 0 ? REST_SERVICES_MAX_QUEUE_SIZE : value; + return properties.rest.maxQueueSize; } public boolean getSanityCheckEnabled() { - return cr.getConfiguration().getBoolean(SANITY_CHECK_ENABLED_KEY, SANITY_CHECK_ENABLED); + return properties.sanityChecksEnabled; } /** @@ -451,55 +252,47 @@ public boolean getSanityCheckEnabled() { */ public int getXmlrpcMaxThreads() { - int value = cr.getConfiguration().getInt(XMLRPC_MAX_THREADS_KEY, XMLRPC_MAX_THREADS); - return value < 0 ? XMLRPC_MAX_THREADS : value; + return properties.xmlrpc.maxThreads; } public int getXmlrpcMaxQueueSize() { - int value = cr.getConfiguration().getInt(XMLRPC_MAX_QUEUE_SIZE_KEY, XMLRPC_MAX_QUEUE_SIZE); - return value < 0 ? XMLRPC_MAX_QUEUE_SIZE : value; + return properties.xmlrpc.maxQueueSize; } public int getXmlRpcServerPort() { - return cr.getConfiguration().getInt(XMLRPC_SERVER_PORT_KEY, XMLRPC_SERVER_PORT); + return properties.xmlrpc.port; } public Boolean getXmlRpcSecurityEnabled() { - return cr.getConfiguration().getBoolean(XMLRPC_SECURITY_ENABLED_KEY, XMLRPC_SECURITY_ENABLED); + return properties.security.enabled; } public String getXmlRpcToken() { - return cr.getConfiguration().getString(XMLRPC_SECURITY_TOKEN_KEY, XMLRPC_SECURITY_TOKEN); + return properties.security.token; } public boolean getDiskUsageServiceEnabled() { - return cr.getConfiguration() - .getBoolean(DISKUSAGE_SERVICE_ENABLED_KEY, DISKUSAGE_SERVICE_ENABLED); + return properties.du.enabled; } public int getDiskUsageServiceInitialDelay() { - return cr.getConfiguration() - .getInt(DISKUSAGE_SERVICE_INITIAL_DELAY_KEY, DISKUSAGE_SERVICE_INITIAL_DELAY); + return properties.du.initialDelay; } - public int getDiskUsageServiceTasksInterval() { + public long getDiskUsageServiceTasksInterval() { - // default: 604800 s => 1 week - return cr.getConfiguration() - .getInt(DISKUSAGE_SERVICE_TASKS_INTERVAL_KEY, DISKUSAGE_SERVICE_TASKS_INTERVAL); + return properties.du.tasksInterval; } public boolean getDiskUsageServiceTasksParallel() { - return cr.getConfiguration() - .getBoolean(DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED_KEY, - DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED); + return properties.du.parallelTasksEnabled; } public String getNamespaceConfigFilename() { @@ -513,7 +306,7 @@ public String getNamespaceConfigFilename() { */ public long getCleaningInitialDelay() { - return cr.getConfiguration().getLong(CLEANING_INITIAL_DELAY_KEY, CLEANING_INITIAL_DELAY); + return properties.expiredSpacesAgent.delay; } /** @@ -521,12 +314,12 @@ public long getCleaningInitialDelay() { */ public long getCleaningTimeInterval() { - return cr.getConfiguration().getLong(CLEANING_TIME_INTERVAL_KEY, CLEANING_TIME_INTERVAL); + return properties.expiredSpacesAgent.interval; } public long getFileDefaultSize() { - return cr.getConfiguration().getLong(FILE_DEFAULT_SIZE_KEY, FILE_DEFAULT_SIZE); + return properties.files.defaultSize; } /** @@ -536,7 +329,7 @@ public long getFileDefaultSize() { */ public long getFileLifetimeDefault() { - return cr.getConfiguration().getLong(FILE_LIFETIME_DEFAULT_KEY, FILE_LIFETIME_DEFAULT); + return properties.files.defaultLifetime; } /** @@ -547,7 +340,7 @@ public long getFileLifetimeDefault() { */ public long getPinLifetimeDefault() { - return cr.getConfiguration().getLong(PIN_LIFETIME_DEFAULT_KEY, PIN_LIFETIME_DEFAULT); + return properties.pinlifetime.defaultValue; } /** @@ -556,7 +349,7 @@ public long getPinLifetimeDefault() { */ public long getPinLifetimeMaximum() { - return cr.getConfiguration().getLong(PIN_LIFETIME_MAXIMUM_KEY, PIN_LIFETIME_MAXIMUM); + return properties.pinlifetime.maximum; } /** @@ -565,7 +358,7 @@ public long getPinLifetimeMaximum() { */ public long getTransitInitialDelay() { - return cr.getConfiguration().getLong(TRANSIT_INITIAL_DELAY_KEY, TRANSIT_INITIAL_DELAY); + return properties.inprogressRequestsAgent.delay; } /** @@ -573,7 +366,7 @@ public long getTransitInitialDelay() { */ public long getTransitTimeInterval() { - return cr.getConfiguration().getLong(TRANSIT_TIME_INTERVAL_KEY, TRANSIT_TIME_INTERVAL); + return properties.inprogressRequestsAgent.interval; } /** @@ -582,7 +375,7 @@ public long getTransitTimeInterval() { */ public long getPickingInitialDelay() { - return cr.getConfiguration().getLong(PICKING_INITIAL_DELAY_KEY, PICKING_INITIAL_DELAY); + return properties.requestsPickerAgent.delay; } /** @@ -590,7 +383,7 @@ public long getPickingInitialDelay() { */ public long getPickingTimeInterval() { - return cr.getConfiguration().getLong(PICKING_TIME_INTERVAL_KEY, PICKING_TIME_INTERVAL); + return properties.requestsPickerAgent.interval; } /** @@ -599,7 +392,7 @@ public long getPickingTimeInterval() { */ public int getPickingMaxBatchSize() { - return cr.getConfiguration().getInt(PICKING_MAX_BATCH_SIZE_KEY, PICKING_MAX_BATCH_SIZE); + return properties.requestsPickerAgent.maxFetchedSize; } /** @@ -608,7 +401,7 @@ public int getPickingMaxBatchSize() { */ public int getLsMaxNumberOfEntry() { - return cr.getConfiguration().getInt(LS_MAX_NUMBER_OF_ENTRY_KEY, LS_MAX_NUMBER_OF_ENTRY); + return properties.synchLs.maxEntries; } /** @@ -616,23 +409,23 @@ public int getLsMaxNumberOfEntry() { */ public boolean getLsAllLevelRecursive() { - return cr.getConfiguration().getBoolean(LS_DEFAULT_ALL_LEVEL_RECURSIVE_KEY, LS_DEFAULT_ALL_LEVEL_RECURSIVE); + return properties.synchLs.defaultAllLevelRecursive; } /** * Default value for the parameter "numOfLevels" of the LS request. */ - public int getLsNumOfLevels() { + public short getLsNumOfLevels() { - return cr.getConfiguration().getInt(LS_DEFAULT_NUM_OF_LEVELS_KEY, LS_DEFAULT_NUM_OF_LEVELS); + return properties.synchLs.defaultNumLevels; } /** * Default value for the parameter "offset" of the LS request. */ - public int getLsOffset() { + public short getLsOffset() { - return cr.getConfiguration().getInt(LS_OFFSET_KEY, LS_OFFSET); + return properties.synchLs.defaultOffset; } /** @@ -648,7 +441,7 @@ public int getLsOffset() { */ public int getPtPCorePoolSize() { - return cr.getConfiguration().getInt(PTP_CORE_POOL_SIZE_KEY, PTP_CORE_POOL_SIZE); + return properties.ptpScheduler.corePoolSize; } /** @@ -664,7 +457,7 @@ public int getPtPCorePoolSize() { */ public int getPtPMaxPoolSize() { - return cr.getConfiguration().getInt(PTP_MAX_POOL_SIZE_KEY, PTP_MAX_POOL_SIZE); + return properties.ptpScheduler.maxPoolSize; } /** @@ -681,7 +474,7 @@ public int getPtPMaxPoolSize() { */ public int getPtPQueueSize() { - return cr.getConfiguration().getInt(PTP_QUEUE_SIZE_KEY, PTP_QUEUE_SIZE); + return properties.ptpScheduler.queueSize; } /** @@ -698,7 +491,7 @@ public int getPtPQueueSize() { */ public int getPtGCorePoolSize() { - return cr.getConfiguration().getInt(PTG_CORE_POOL_SIZE_KEY, PTG_CORE_POOL_SIZE); + return properties.ptgScheduler.corePoolSize; } /** @@ -715,7 +508,7 @@ public int getPtGCorePoolSize() { */ public int getPtGMaxPoolSize() { - return cr.getConfiguration().getInt(PTG_MAX_POOL_SIZE_KEY, PTG_MAX_POOL_SIZE); + return properties.ptgScheduler.maxPoolSize; } /** @@ -732,7 +525,7 @@ public int getPtGMaxPoolSize() { */ public int getPtGQueueSize() { - return cr.getConfiguration().getInt(PTG_QUEUE_SIZE_KEY, PTG_QUEUE_SIZE); + return properties.ptgScheduler.queueSize; } /** @@ -749,7 +542,7 @@ public int getPtGQueueSize() { */ public int getBoLCorePoolSize() { - return cr.getConfiguration().getInt(BOL_CORE_POOL_SIZE_KEY, BOL_CORE_POOL_SIZE); + return properties.bolScheduler.corePoolSize; } /** @@ -766,7 +559,7 @@ public int getBoLCorePoolSize() { */ public int getBoLMaxPoolSize() { - return cr.getConfiguration().getInt(BOL_MAX_POOL_SIZE_KEY, BOL_MAX_POOL_SIZE); + return properties.bolScheduler.maxPoolSize; } /** @@ -783,7 +576,7 @@ public int getBoLMaxPoolSize() { */ public int getBoLQueueSize() { - return cr.getConfiguration().getInt(BOL_QUEUE_SIZE_KEY, BOL_QUEUE_SIZE); + return properties.bolScheduler.queueSize; } /** @@ -800,7 +593,7 @@ public int getBoLQueueSize() { */ public int getCorePoolSize() { - return cr.getConfiguration().getInt(CORE_POOL_SIZE_KEY, CORE_POOL_SIZE); + return properties.requestsScheduler.corePoolSize; } /** @@ -816,7 +609,7 @@ public int getCorePoolSize() { */ public int getMaxPoolSize() { - return cr.getConfiguration().getInt(MAX_POOL_SIZE_KEY, MAX_POOL_SIZE); + return properties.requestsScheduler.maxPoolSize; } /** @@ -833,7 +626,7 @@ public int getMaxPoolSize() { */ public int getQueueSize() { - return cr.getConfiguration().getInt(QUEUE_SIZE_KEY, QUEUE_SIZE); + return properties.requestsScheduler.queueSize; } /** @@ -842,8 +635,7 @@ public int getQueueSize() { */ public boolean getAutomaticDirectoryCreation() { - return cr.getConfiguration() - .getBoolean(AUTOMATIC_DIRECTORY_CREATION_KEY, AUTOMATIC_DIRECTORY_CREATION); + return properties.directories.enableAutomaticCreation; } /** @@ -853,25 +645,23 @@ public boolean getAutomaticDirectoryCreation() { */ public boolean getEnableWritePermOnDirectory() { - return cr.getConfiguration() - .getBoolean(ENABLE_WRITE_PERM_ON_DIRECTORY_KEY, ENABLE_WRITE_PERM_ON_DIRECTORY); + return properties.directories.enableWritepermOnCreation; } /** * Method used by TOverwriteModeConverter to establish the default OverwriteMode to use. */ - public String getDefaultOverwriteMode() { + public OverwriteMode getDefaultOverwriteMode() { - return cr.getConfiguration().getString(DEFAULT_OVERWRITE_MODE_KEY, DEFAULT_OVERWRITE_MODE); + return OverwriteMode.valueOf(properties.files.defaultOverwrite); } /** * Method used by FileStorageTypeConverter to establish the default TFileStorageType to use. */ - public String getDefaultFileStorageType() { + public StorageType getDefaultFileStorageType() { - return cr.getConfiguration() - .getString(DEFAULT_FILE_STORAGE_TYPE_KEY, DEFAULT_FILE_STORAGE_TYPE); + return StorageType.valueOf(properties.files.defaultStoragetype); } /** @@ -879,7 +669,7 @@ public String getDefaultFileStorageType() { */ public int getPurgeBatchSize() { - return cr.getConfiguration().getInt(PURGE_BATCH_SIZE_KEY, PURGE_BATCH_SIZE); + return properties.completedRequestsAgent.purgeSize; } /** @@ -889,7 +679,7 @@ public int getPurgeBatchSize() { */ public long getExpiredRequestTime() { - return cr.getConfiguration().getLong(EXPIRED_REQUEST_TIME_KEY, EXPIRED_REQUEST_TIME); + return properties.completedRequestsAgent.purgeAge; } /** @@ -898,7 +688,7 @@ public long getExpiredRequestTime() { */ public int getRequestPurgerDelay() { - return cr.getConfiguration().getInt(REQUEST_PURGER_DELAY_KEY, REQUEST_PURGER_DELAY); + return properties.completedRequestsAgent.delay; } /** @@ -907,7 +697,7 @@ public int getRequestPurgerDelay() { */ public int getRequestPurgerPeriod() { - return cr.getConfiguration().getInt(REQUEST_PURGER_PERIOD_KEY, REQUEST_PURGER_PERIOD); + return properties.completedRequestsAgent.interval; } /** @@ -917,13 +707,12 @@ public int getRequestPurgerPeriod() { */ public boolean getExpiredRequestPurging() { - return cr.getConfiguration().getBoolean(EXPIRED_REQUEST_PURGING_KEY, EXPIRED_REQUEST_PURGING); + return properties.completedRequestsAgent.enabled; } public long getInProgressPtpExpirationTime() { - return cr.getConfiguration() - .getLong(EXPIRED_INPROGRESS_PTP_TIME_KEY, EXPIRED_INPROGRESS_PTP_TIME); + return properties.inprogressRequestsAgent.ptpExpirationTime; } /** @@ -932,8 +721,7 @@ public long getInProgressPtpExpirationTime() { */ public String getExtraSlashesForFileTURL() { - return cr.getConfiguration() - .getString(EXTRA_SLASHES_FOR_FILE_TURL_KEY, EXTRA_SLASHES_FOR_FILE_TURL); + return properties.extraslashes.file; } /** @@ -942,8 +730,7 @@ public String getExtraSlashesForFileTURL() { */ public String getExtraSlashesForRFIOTURL() { - return cr.getConfiguration() - .getString(EXTRA_SLASHES_FOR_RFIO_TURL_KEY, EXTRA_SLASHES_FOR_RFIO_TURL); + return properties.extraslashes.rfio; } /** @@ -952,8 +739,7 @@ public String getExtraSlashesForRFIOTURL() { */ public String getExtraSlashesForGsiFTPTURL() { - return cr.getConfiguration() - .getString(EXTRA_SLASHES_FOR_GSIFTP_TURL_KEY, EXTRA_SLASHES_FOR_GSIFTP_TURL); + return properties.extraslashes.gsiftp; } /** @@ -962,8 +748,7 @@ public String getExtraSlashesForGsiFTPTURL() { */ public String getExtraSlashesForROOTTURL() { - return cr.getConfiguration() - .getString(EXTRA_SLASHES_FOR_ROOT_TURL_KEY, EXTRA_SLASHES_FOR_ROOT_TURL); + return properties.extraslashes.root; } /** @@ -972,41 +757,38 @@ public String getExtraSlashesForROOTTURL() { */ public String getPingValuesPropertiesFilename() { - return cr.getConfiguration() - .getString(PING_VALUES_PROPERTIES_FILENAME_KEY, PING_VALUES_PROPERTIES_FILENAME); + return properties.pingPropertiesFilename; } public int getHearthbeatPeriod() { - return cr.getConfiguration().getInt(HEARTHBEAT_PERIOD_KEY, HEARTHBEAT_PERIOD); + return properties.hearthbeat.period; } public int getPerformanceGlanceTimeInterval() { - return cr.getConfiguration() - .getInt(PERFORMANCE_GLANCE_TIME_INTERVAL_KEY, PERFORMANCE_GLANCE_TIME_INTERVAL); + return properties.hearthbeat.performanceGlanceTimeInterval; } public int getPerformanceLogbookTimeInterval() { - return cr.getConfiguration() - .getInt(PERFORMANCE_LOGBOOK_TIME_INTERVAL_KEY, PERFORMANCE_LOGBOOK_TIME_INTERVAL); + return properties.hearthbeat.performanceLogbookTimeInterval; } public boolean getPerformanceMeasuring() { - return cr.getConfiguration().getBoolean(PERFORMANCE_MEASURING_KEY, PERFORMANCE_MEASURING); + return properties.hearthbeat.performanceMeasuringEnabled; } public boolean getBookKeepingEnabled() { - return cr.getConfiguration().getBoolean(BOOK_KEEPING_ENABLED_KEY, BOOK_KEEPING_ENABLED); + return properties.hearthbeat.bookkeepingEnabled; } public int getMaxLoop() { - return cr.getConfiguration().getInt(MAX_LOOP_KEY, MAX_LOOP); + return properties.abortMaxloop; } public String getGridUserMapperClassname() { @@ -1031,45 +813,32 @@ public String getTaskoverKey() { public int getGPFSQuotaRefreshPeriod() { - return cr.getConfiguration().getInt(GPFS_QUOTA_REFRESH_PERIOD_KEY, GPFS_QUOTA_REFRESH_PERIOD); + return properties.infoQuotaRefreshPeriod; } public long getServerPoolStatusCheckTimeout() { - return cr.getConfiguration() - .getLong(SERVER_POOL_STATUS_CHECK_TIMEOUT_KEY, SERVER_POOL_STATUS_CHECK_TIMEOUT); + return properties.serverPoolStatusCheckTimeout; } public boolean getPTGSkipACLSetup() { - return cr.getConfiguration().getBoolean(PTG_SKIP_ACL_SETUP_KEY, PTG_SKIP_ACL_SETUP); + return properties.skipPtgAclSetup; } public String getHTTPTURLPrefix() { - return cr.getConfiguration().getString(HTTP_TURL_PREFIX_KEY, HTTP_TURL_PREFIX); + return properties.httpTurlPrefix; } public int getNetworkAddressCacheTtl() { - return 0; - } - public int getNetworkAddressCacheNegativeTtl() { return 0; } - @Override - public String toString() { + public int getNetworkAddressCacheNegativeTtl() { - StringBuilder sb = new StringBuilder(); - sb.append("Configuration={"); - Iterator keys = cr.getConfiguration().getKeys(); - while (keys.hasNext()) { - String name = keys.next(); - sb.append(name + "=" + cr.getConfiguration().getString(name)); - } - sb.append("}"); - return sb.toString(); + return 0; } } diff --git a/src/main/java/it/grid/storm/config/ConfigurationDefaults.java b/src/main/java/it/grid/storm/config/ConfigurationDefaults.java index 1610f51ab..d5b31f652 100644 --- a/src/main/java/it/grid/storm/config/ConfigurationDefaults.java +++ b/src/main/java/it/grid/storm/config/ConfigurationDefaults.java @@ -1,9 +1,12 @@ package it.grid.storm.config; +import it.grid.storm.config.model.OverwriteMode; +import it.grid.storm.config.model.StorageType; + public class ConfigurationDefaults { - /* SRM oublic info */ - public static final int SERVICE_SRM_PUBLIC_PORT = 8444; + /* SRM port for endpoints */ + public static final int DEFAULT_SRM_PORT = 8444; /* Database */ public static final int DB_PORT = 3306; @@ -17,7 +20,7 @@ public class ConfigurationDefaults { public static final int DB_POOL_MAX_WAIT_MILLIS = 5000; public static final boolean DB_POOL_TEST_ON_BORROW = true; public static final boolean DB_POOL_TEST_WHILE_IDLE = true; - + /* REST service */ public static final int REST_SERVICES_PORT = 9998; public static final int REST_SERVICES_MAX_THREADS = 100; @@ -30,63 +33,70 @@ public class ConfigurationDefaults { public static final int XMLRPC_MAX_THREADS = 256; public static final int XMLRPC_MAX_QUEUE_SIZE = 1000; public static final int XMLRPC_SERVER_PORT = 8080; - public static final boolean XMLRPC_SECURITY_ENABLED = true; - public static final String XMLRPC_SECURITY_TOKEN = "secret"; + + /* Rest and XMLRPC security settings */ + public static final boolean SECURITY_ENABLED = true; + public static final String SECURITY_TOKEN = "secret"; /* Disk usage service */ public static final boolean DISKUSAGE_SERVICE_ENABLED = false; public static final int DISKUSAGE_SERVICE_INITIAL_DELAY = 0; - public static final int DISKUSAGE_SERVICE_TASKS_INTERVAL = 604800; + public static final long DISKUSAGE_SERVICE_TASKS_INTERVAL = 604800L; public static final boolean DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED = false; + /* GC agents */ + public static final int INPROGRESS_REQUESTS_AGENT_DELAY = 50; + public static final int INPROGRESS_REQUESTS_AGENT_INTERVAL = 300; + public static final long INPROGRESS_REQUESTS_AGENT_PTP_EXPIRATION_TIME = 2592000L; + + public static final int EXPIRED_SPACES_AGENT_DELAY = 30; + public static final int EXPIRED_SPACES_AGENT_INTERVAL = 300; + + public static final boolean COMPLETED_REQUESTS_AGENT_ENABLED = true; + public static final int COMPLETED_REQUESTS_AGENT_DELAY = 10; + public static final int COMPLETED_REQUESTS_AGENT_INTERVAL = 600; + public static final boolean COMPLETED_REQUESTS_AGENT_IS_DYNAMIC = true; + public static final long COMPLETED_REQUESTS_AGENT_PURGE_AGE = 604800L; + public static final int COMPLETED_REQUESTS_AGENT_PURGE_SIZE = 800; + + /* schedulers */ + public static final int PTP_SCHEDULER_CORE_POOL_SIZE = 50; + public static final int PTP_SCHEDULER_MAX_POOL_SIZE = 200; + public static final int PTP_SCHEDULER_QUEUE_SIZE = 1000; + + public static final int PTG_SCHEDULER_CORE_POOL_SIZE = 50; + public static final int PTG_SCHEDULER_MAX_POOL_SIZE = 200; + public static final int PTG_SCHEDULER_QUEUE_SIZE = 2000; + + public static final int BOL_SCHEDULER_CORE_POOL_SIZE = 50; + public static final int BOL_SCHEDULER_MAX_POOL_SIZE = 200; + public static final int BOL_SCHEDULER_QUEUE_SIZE = 2000; - public static final long CLEANING_INITIAL_DELAY = 10L; - public static final long CLEANING_TIME_INTERVAL = 300L; + public static final int REQUESTS_SCHEDULER_CORE_POOL_SIZE = 10; + public static final int REQUESTS_SCHEDULER_MAX_POOL_SIZE = 50; + public static final int REQUESTS_SCHEDULER_QUEUE_SIZE = 2000; + + public static final int REQUESTS_PICKER_AGENT_DELAY = 1; + public static final int REQUESTS_PICKER_AGENT_INTERVAL = 2; + public static final int REQUESTS_PICKER_AGENT_MAX_FETCHED_SIZE = 100; + + /* advanced */ public static final long FILE_DEFAULT_SIZE = 1000000L; - public static final long FILE_LIFETIME_DEFAULT = 3600L; + public static final long FILE_LIFETIME_DEFAULT = 259200L; public static final long PIN_LIFETIME_DEFAULT = 259200L; public static final long PIN_LIFETIME_MAXIMUM = 1814400L; - public static final long TRANSIT_INITIAL_DELAY = 10L; - public static final long TRANSIT_TIME_INTERVAL = 300L; - public static final long PICKING_INITIAL_DELAY = 1L; - public static final long PICKING_TIME_INTERVAL = 2L; - public static final int PICKING_MAX_BATCH_SIZE = 100; public static final int LS_MAX_NUMBER_OF_ENTRY = 2000; public static final boolean LS_DEFAULT_ALL_LEVEL_RECURSIVE = false; - public static final int LS_DEFAULT_NUM_OF_LEVELS = 1; - public static final int LS_OFFSET = 0; - - public static final int PTP_CORE_POOL_SIZE = 50; - public static final int PTP_MAX_POOL_SIZE = 200; - public static final int PTP_QUEUE_SIZE = 1000; - - public static final int PTG_CORE_POOL_SIZE = 50; - public static final int PTG_MAX_POOL_SIZE = 200; - public static final int PTG_QUEUE_SIZE = 2000; - - public static final int BOL_CORE_POOL_SIZE = 50; - public static final int BOL_MAX_POOL_SIZE = 200; - public static final int BOL_QUEUE_SIZE = 2000; - - public static final int CORE_POOL_SIZE = 10; - public static final int MAX_POOL_SIZE = 50; - public static final int QUEUE_SIZE = 2000; + public static final short LS_DEFAULT_NUM_OF_LEVELS = 1; + public static final short LS_DEFAULT_OFFSET = 0; public static final boolean AUTOMATIC_DIRECTORY_CREATION = false; public static final boolean ENABLE_WRITE_PERM_ON_DIRECTORY = false; - public static final String DEFAULT_OVERWRITE_MODE = "N"; - public static final String DEFAULT_FILE_STORAGE_TYPE = "V"; - - public static final int PURGE_BATCH_SIZE = 800; - - public static final long EXPIRED_REQUEST_TIME = 604800L; - public static final int REQUEST_PURGER_DELAY = 10; - public static final int REQUEST_PURGER_PERIOD = 600; - public static final boolean EXPIRED_REQUEST_PURGING = true; - public static final long EXPIRED_INPROGRESS_PTP_TIME = 2592000L; + public static final String DEFAULT_OVERWRITE_MODE = OverwriteMode.N.name(); + public static final String DEFAULT_FILE_STORAGE_TYPE = StorageType.V.name(); public static final String EXTRA_SLASHES_FOR_FILE_TURL = ""; public static final String EXTRA_SLASHES_FOR_RFIO_TURL = ""; diff --git a/src/main/java/it/grid/storm/config/DefaultValue.java b/src/main/java/it/grid/storm/config/DefaultValue.java deleted file mode 100644 index b065f079d..000000000 --- a/src/main/java/it/grid/storm/config/DefaultValue.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. - * - * 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 it.grid.storm.config; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import it.grid.storm.checksum.ChecksumAlgorithm; - -public class DefaultValue { - - private static final Logger log = LoggerFactory.getLogger(DefaultValue.class); - - private DefaultValue() { - - } - - /** - * Retrieve default Space Type for anonymous user - */ - public static String getAnonymous_SpaceType() { - - return "volatile"; - } - - /** - * Retrieve default Space Type for named VO - */ - public static String getNamedVO_SpaceType(String voname) { - - String result = null; - if (result == null) { - log.info("Searching for ANONYMOUS parameter value.."); - result = getAnonymous_SpaceType(); - } - return result; - } - - /** - * Retrieve default Total Space Size for anonymous user - */ - public static long getAnonymous_TotalSpaceSize() { - - return 104857600; // 100 Mb - } - - /** - * Retrieve default Total Space Size for named VO - */ - public static long getNamedVO_TotalSpaceSize(String voname) { - - long result = -1; - if (result == -1) { - log.info("Searching for ANONYMOUS parameter value.."); - result = getAnonymous_TotalSpaceSize(); - } - return result; - } - - /** - * Retrieve default Total Space Size for anonymous user - */ - public static long getAnonymous_GuaranteedSpaceSize() { - - return 10485760; // 10 Mb - } - - /** - * Retrieve default Total Space Size for named VO - */ - public static long getNamedVO_GuaranteedSpaceSize(String voname) { - - long result = -1; - if (result == -1) { - log - .info("Searching for ANONYMOUS parameter value.."); - result = getAnonymous_GuaranteedSpaceSize(); - } - return result; - } - - /** - * Retrieve default Total Space Life Time for anonymous user - */ - public static long getAnonymous_SpaceLifeTime() { - - return 86400; // 24h - } - - /** - * Retrieve default Space Life Time for named VO - */ - public static long getNamedVO_SpaceLifeTime(String voname) { - - long result = -1; - if (result == -1) { - log.info("Searching for ANONYMOUS parameter value.."); - result = getAnonymous_SpaceLifeTime(); - } - return result; - } - - /** - * Retrieve default Checksum Algorithm - */ - public static ChecksumAlgorithm getChecksumAlgorithm() { - - return ChecksumAlgorithm.ADLER32; - } - -} diff --git a/src/main/java/it/grid/storm/config/converter/StormPropertiesConverter.java b/src/main/java/it/grid/storm/config/converter/StormPropertiesConverter.java new file mode 100644 index 000000000..3a1414ff9 --- /dev/null +++ b/src/main/java/it/grid/storm/config/converter/StormPropertiesConverter.java @@ -0,0 +1,458 @@ +package it.grid.storm.config.converter; + +import java.net.UnknownHostException; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import it.grid.storm.config.model.Endpoint; +import it.grid.storm.config.model.StormProperties; + +public class StormPropertiesConverter { + + /* Configuration file properties */ + private static final String MANAGED_SURLS_KEY = "storm.service.SURL.endpoint"; + private static final String SERVICE_HOSTNAME_KEY = "storm.service.FE-public.hostname"; + private static final String SERVICE_PORT_KEY = "storm.service.port"; + private static final String DB_URL_HOSTNAME_KEY = "storm.service.request-db.host"; + private static final String DB_URL_PROPERTIES_KEY = "storm.service.request-db.properties"; + private static final String DB_USER_NAME_KEY = "storm.service.request-db.username"; + private static final String DB_PASSWORD_KEY = "storm.service.request-db.passwd"; + private static final String BE_PERSISTENCE_POOL_DB_MAX_ACTIVE_KEY = + "persistence.internal-db.connection-pool.maxActive"; + private static final String BE_PERSISTENCE_POOL_DB_MAX_WAIT_KEY = + "persistence.internal-db.connection-pool.maxWait"; + private static final String XMLRPC_SERVER_PORT_KEY = "synchcall.xmlrpc.unsecureServerPort"; + private static final String XMLRPC_MAX_THREAD_KEY = "synchcall.xmlrpc.maxthread"; + private static final String XMLRPC_MAX_QUEUE_SIZE_KEY = "synchcall.xmlrpc.max_queue_size"; + private static final String REST_SERVICES_PORT_KEY = "storm.rest.services.port"; + private static final String REST_SERVICES_MAX_THREAD = "storm.rest.services.maxthread"; + private static final String REST_SERVICES_MAX_QUEUE_SIZE = "storm.rest.services.max_queue_size"; + private static final String XMLRPC_SECURITY_ENABLED_KEY = "synchcall.xmlrpc.security.enabled"; + private static final String XMLRPC_SECURITY_TOKEN_KEY = "synchcall.xmlrpc.security.token"; + + private static final String DISKUSAGE_SERVICE_ENABLED = "storm.service.du.enabled"; + private static final String DISKUSAGE_SERVICE_INITIAL_DELAY = "storm.service.du.delaySecs"; + private static final String DISKUSAGE_SERVICE_TASKS_INTERVAL = "storm.service.du.periodSecs"; + private static final String DISKUSAGE_SERVICE_TASKS_PARALLEL = "storm.service.du.parallelTasks"; + + private static final String SANITY_CHECK_ENABLED_KEY = "sanity-check.enabled"; + + private static final String LS_MAX_NUMBER_OF_ENTRY_KEY = "synchcall.directoryManager.maxLsEntry"; + private static final String LS_ALL_LEVEL_RECURSIVE_KEY = + "synchcall.directoryManager.default.AllLevelRecursive"; + private static final String LS_NUM_OF_LEVELS_KEY = "synchcall.directoryManager.default.Levels"; + private static final String LS_OFFSET_KEY = "synchcall.directoryManager.default.Offset"; + + private static final String AUTOMATIC_DIRECTORY_CREATION_KEY = "directory.automatic-creation"; + private static final String ENABLE_WRITE_PERM_ON_DIRECTORY_KEY = "directory.writeperm"; + + private static final String FILE_DEFAULT_SIZE_KEY = "fileSize.default"; + private static final String FILE_LIFETIME_DEFAULT_KEY = "fileLifetime.default"; + private static final String DEFAULT_OVERWRITE_MODE_KEY = "default.overwrite"; + private static final String DEFAULT_FILE_STORAGE_TYPE_KEY = "default.storagetype"; + + private static final String EXTRA_SLASHES_FOR_FILE_TURL_KEY = "extraslashes.file"; + private static final String EXTRA_SLASHES_FOR_RFIO_TURL_KEY = "extraslashes.rfio"; + private static final String EXTRA_SLASHES_FOR_GSIFTP_TURL_KEY = "extraslashes.gsiftp"; + private static final String EXTRA_SLASHES_FOR_ROOT_TURL_KEY = "extraslashes.root"; + + private static final String PTG_SKIP_ACL_SETUP = "ptg.skip-acl-setup"; + + private static final String HEARTHBEAT_PERIOD_KEY = "health.electrocardiogram.period"; + private static final String PERFORMANCE_GLANCE_TIME_INTERVAL_KEY = + "health.performance.glance.timeInterval"; + private static final String PERFORMANCE_LOGBOOK_TIME_INTERVAL_KEY = + "health.performance.logbook.timeInterval"; + private static final String PERFORMANCE_MEASURING_KEY = "health.performance.mesauring.enabled"; + private static final String BOOK_KEEPING_ENABLED_KEY = "health.bookkeeping.enabled"; + + private static final String PICKING_INITIAL_DELAY_KEY = "asynch.PickingInitialDelay"; + private static final String PICKING_TIME_INTERVAL_KEY = "asynch.PickingTimeInterval"; + private static final String PICKING_MAX_BATCH_SIZE_KEY = "asynch.PickingMaxBatchSize"; + + private static final String CORE_POOL_SIZE_KEY = "scheduler.crusher.workerCorePoolSize"; + private static final String MAX_POOL_SIZE_KEY = "scheduler.crusher.workerMaxPoolSize"; + private static final String QUEUE_SIZE_KEY = "scheduler.crusher.queueSize"; + + private static final String PTP_CORE_POOL_SIZE_KEY = + "scheduler.chunksched.ptp.workerCorePoolSize"; + private static final String PTP_MAX_POOL_SIZE_KEY = "scheduler.chunksched.ptp.workerMaxPoolSize"; + private static final String PTP_QUEUE_SIZE_KEY = "scheduler.chunksched.ptp.queueSize"; + private static final String PTG_CORE_POOL_SIZE_KEY = + "scheduler.chunksched.ptg.workerCorePoolSize"; + private static final String PTG_MAX_POOL_SIZE_KEY = "scheduler.chunksched.ptg.workerMaxPoolSize"; + private static final String PTG_QUEUE_SIZE_KEY = "scheduler.chunksched.ptg.queueSize"; + private static final String BOL_CORE_POOL_SIZE_KEY = + "scheduler.chunksched.bol.workerCorePoolSize"; + private static final String BOL_MAX_POOL_SIZE_KEY = "scheduler.chunksched.bol.workerMaxPoolSize"; + private static final String BOL_QUEUE_SIZE_KEY = "scheduler.chunksched.bol.queueSize"; + + private static final String PIN_LIFETIME_DEFAULT_KEY = "pinLifetime.default"; + private static final String PIN_LIFETIME_MAXIMUM_KEY = "pinLifetime.maximum"; + + private static final String CLEANING_INITIAL_DELAY_KEY = "gc.pinnedfiles.cleaning.delay"; + private static final String CLEANING_TIME_INTERVAL_KEY = "gc.pinnedfiles.cleaning.interval"; + + private static final String TRANSIT_INITIAL_DELAY_KEY = "transit.delay"; + private static final String TRANSIT_TIME_INTERVAL_KEY = "transit.interval"; + private static final String EXPIRED_INPROGRESS_PTP_TIME_KEY = "expired.inprogress.time"; + + private static final String PURGE_BATCH_SIZE_KEY = "purge.size"; + private static final String EXPIRED_REQUEST_TIME_KEY = "expired.request.time"; + private static final String REQUEST_PURGER_DELAY_KEY = "purge.delay"; + private static final String REQUEST_PURGER_PERIOD_KEY = "purge.interval"; + private static final String EXPIRED_REQUEST_PURGING_KEY = "purging"; + + private static final String PING_VALUES_PROPERTIES_FILENAME_KEY = "ping-properties.filename"; + private static final String MAX_LOOP_KEY = "abort.maxloop"; + private static final String GPFS_QUOTA_REFRESH_PERIOD_KEY = "info.quota.refresh.period"; + private static final String SERVER_POOL_STATUS_CHECK_TIMEOUT_KEY = + "server-pool.status-check.timeout"; + private static final String HTTP_TURL_PREFIX = "http.turl_prefix"; + + + public static StormProperties from(Properties old) throws UnknownHostException { + + StormProperties properties = new StormProperties(); + // version + properties.version = StormProperties.VERSION; + + // srmEndpoints + if (old.containsKey(SERVICE_HOSTNAME_KEY) || old.containsKey(MANAGED_SURLS_KEY)) { + // remove default value + properties.srmEndpoints.clear(); + } + if (old.containsKey(SERVICE_HOSTNAME_KEY)) { + int port = 8444; + String host = old.getProperty(SERVICE_HOSTNAME_KEY); + if (old.containsKey(SERVICE_PORT_KEY)) { + port = Integer.valueOf(old.getProperty(SERVICE_PORT_KEY)); + } + properties.srmEndpoints.add(Endpoint.build(host, port)); + } + if (old.containsKey(MANAGED_SURLS_KEY)) { + String surlsStr = old.getProperty(MANAGED_SURLS_KEY); + List surls = Arrays.asList(surlsStr.split(",")); + for (String surl : surls) { + Pattern pattern = Pattern.compile("srm://(.*?)/.*"); + Matcher matcher = pattern.matcher(surl); + if (matcher.find()) { + String host = matcher.group(1).split(":")[0]; + int port = Integer.valueOf(matcher.group(1).split(":")[1]); + Endpoint e = Endpoint.build(host, port); + if (!properties.srmEndpoints.contains(e)) { + properties.srmEndpoints.add(e); + } + } + } + + // db + if (old.containsKey(DB_URL_HOSTNAME_KEY)) { + properties.db.hostname = String.valueOf(old.getProperty(DB_URL_HOSTNAME_KEY)).trim(); + } + if (old.containsKey(DB_USER_NAME_KEY)) { + properties.db.username = String.valueOf(old.getProperty(DB_USER_NAME_KEY)).trim(); + } + if (old.containsKey(DB_PASSWORD_KEY)) { + properties.db.password = String.valueOf(old.getProperty(DB_PASSWORD_KEY)).trim(); + } + if (old.containsKey(DB_URL_PROPERTIES_KEY)) { + properties.db.properties = String.valueOf(old.getProperty(DB_URL_PROPERTIES_KEY)).trim(); + } + if (old.containsKey(BE_PERSISTENCE_POOL_DB_MAX_ACTIVE_KEY)) { + properties.db.pool.size = + Integer.valueOf(old.getProperty(BE_PERSISTENCE_POOL_DB_MAX_ACTIVE_KEY)); + } + if (old.containsKey(BE_PERSISTENCE_POOL_DB_MAX_WAIT_KEY)) { + properties.db.pool.maxWaitMillis = + Integer.valueOf(old.getProperty(BE_PERSISTENCE_POOL_DB_MAX_WAIT_KEY)); + } + + // xmlrpc + if (old.containsKey(XMLRPC_SERVER_PORT_KEY)) { + properties.xmlrpc.port = Integer.valueOf(old.getProperty(XMLRPC_SERVER_PORT_KEY)); + } + if (old.containsKey(XMLRPC_MAX_THREAD_KEY)) { + properties.xmlrpc.maxThreads = Integer.valueOf(old.getProperty(XMLRPC_MAX_THREAD_KEY)); + } + if (old.containsKey(XMLRPC_MAX_QUEUE_SIZE_KEY)) { + properties.xmlrpc.maxQueueSize = + Integer.valueOf(old.getProperty(XMLRPC_MAX_QUEUE_SIZE_KEY)); + } + + // rest + if (old.containsKey(REST_SERVICES_PORT_KEY)) { + properties.rest.port = Integer.valueOf(old.getProperty(REST_SERVICES_PORT_KEY)); + } + if (old.containsKey(REST_SERVICES_MAX_THREAD)) { + properties.rest.maxThreads = Integer.valueOf(old.getProperty(REST_SERVICES_MAX_THREAD)); + } + if (old.containsKey(REST_SERVICES_MAX_QUEUE_SIZE)) { + properties.rest.maxQueueSize = + Integer.valueOf(old.getProperty(REST_SERVICES_MAX_QUEUE_SIZE)); + } + + // security + if (old.containsKey(XMLRPC_SECURITY_ENABLED_KEY)) { + properties.security.enabled = Boolean.valueOf(old.getProperty(XMLRPC_SECURITY_ENABLED_KEY)); + } + if (old.containsKey(XMLRPC_SECURITY_TOKEN_KEY)) { + properties.security.token = + String.valueOf(old.getProperty(XMLRPC_SECURITY_TOKEN_KEY)).trim(); + } + + // du + if (old.containsKey(DISKUSAGE_SERVICE_ENABLED)) { + properties.du.enabled = Boolean.valueOf(old.getProperty(DISKUSAGE_SERVICE_ENABLED)); + } + if (old.containsKey(DISKUSAGE_SERVICE_INITIAL_DELAY)) { + properties.du.initialDelay = + Integer.valueOf(old.getProperty(DISKUSAGE_SERVICE_INITIAL_DELAY)); + } + if (old.containsKey(DISKUSAGE_SERVICE_TASKS_PARALLEL)) { + properties.du.parallelTasksEnabled = + Boolean.valueOf(old.getProperty(DISKUSAGE_SERVICE_TASKS_PARALLEL)); + } + if (old.containsKey(DISKUSAGE_SERVICE_TASKS_INTERVAL)) { + properties.du.tasksInterval = + Integer.valueOf(old.getProperty(DISKUSAGE_SERVICE_TASKS_INTERVAL)); + } + + // sanity check + if (old.containsKey(SANITY_CHECK_ENABLED_KEY)) { + properties.sanityChecksEnabled = Boolean.valueOf(old.getProperty(SANITY_CHECK_ENABLED_KEY)); + } + + // ls + if (old.containsKey(LS_MAX_NUMBER_OF_ENTRY_KEY)) { + properties.synchLs.maxEntries = + Integer.valueOf(old.getProperty(LS_MAX_NUMBER_OF_ENTRY_KEY)); + } + if (old.containsKey(LS_ALL_LEVEL_RECURSIVE_KEY)) { + properties.synchLs.defaultAllLevelRecursive = + Boolean.valueOf(old.getProperty(LS_ALL_LEVEL_RECURSIVE_KEY)); + } + if (old.containsKey(LS_NUM_OF_LEVELS_KEY)) { + properties.synchLs.defaultNumLevels = Short.valueOf(old.getProperty(LS_NUM_OF_LEVELS_KEY)); + } + if (old.containsKey(LS_OFFSET_KEY)) { + properties.synchLs.defaultOffset = Short.valueOf(old.getProperty(LS_OFFSET_KEY)); + } + + // directories + if (old.containsKey(AUTOMATIC_DIRECTORY_CREATION_KEY)) { + properties.directories.enableAutomaticCreation = + Boolean.valueOf(old.getProperty(AUTOMATIC_DIRECTORY_CREATION_KEY)); + } + if (old.containsKey(ENABLE_WRITE_PERM_ON_DIRECTORY_KEY)) { + properties.directories.enableWritepermOnCreation = + Boolean.valueOf(old.getProperty(ENABLE_WRITE_PERM_ON_DIRECTORY_KEY)); + } + + // files + if (old.containsKey(FILE_DEFAULT_SIZE_KEY)) { + properties.files.defaultSize = Long.valueOf(old.getProperty(FILE_DEFAULT_SIZE_KEY)); + } + if (old.containsKey(FILE_LIFETIME_DEFAULT_KEY)) { + properties.files.defaultLifetime = Long.valueOf(old.getProperty(FILE_LIFETIME_DEFAULT_KEY)); + } + if (old.containsKey(DEFAULT_OVERWRITE_MODE_KEY)) { + properties.files.defaultOverwrite = + String.valueOf(old.getProperty(DEFAULT_OVERWRITE_MODE_KEY)).trim(); + } + if (old.containsKey(DEFAULT_FILE_STORAGE_TYPE_KEY)) { + properties.files.defaultStoragetype = + String.valueOf(old.getProperty(DEFAULT_FILE_STORAGE_TYPE_KEY)).trim(); + } + + // extraslashes + if (old.containsKey(EXTRA_SLASHES_FOR_FILE_TURL_KEY)) { + properties.extraslashes.file = + String.valueOf(old.getProperty(EXTRA_SLASHES_FOR_FILE_TURL_KEY)).trim(); + } + if (old.containsKey(EXTRA_SLASHES_FOR_RFIO_TURL_KEY)) { + properties.extraslashes.rfio = + String.valueOf(old.getProperty(EXTRA_SLASHES_FOR_RFIO_TURL_KEY)).trim(); + } + if (old.containsKey(EXTRA_SLASHES_FOR_ROOT_TURL_KEY)) { + properties.extraslashes.root = + String.valueOf(old.getProperty(EXTRA_SLASHES_FOR_ROOT_TURL_KEY)).trim(); + } + if (old.containsKey(EXTRA_SLASHES_FOR_GSIFTP_TURL_KEY)) { + properties.extraslashes.gsiftp = + String.valueOf(old.getProperty(EXTRA_SLASHES_FOR_GSIFTP_TURL_KEY)).trim(); + } + + // skip ptg acl + if (old.containsKey(PTG_SKIP_ACL_SETUP)) { + properties.skipPtgAclSetup = Boolean.valueOf(old.getProperty(PTG_SKIP_ACL_SETUP)); + } + + // hearthbeat + if (old.containsKey(BOOK_KEEPING_ENABLED_KEY)) { + properties.hearthbeat.bookkeepingEnabled = + Boolean.valueOf(old.getProperty(BOOK_KEEPING_ENABLED_KEY)); + } + if (old.containsKey(PERFORMANCE_MEASURING_KEY)) { + properties.hearthbeat.performanceMeasuringEnabled = + Boolean.valueOf(old.getProperty(PERFORMANCE_MEASURING_KEY)); + } + if (old.containsKey(HEARTHBEAT_PERIOD_KEY)) { + properties.hearthbeat.period = Integer.valueOf(old.getProperty(HEARTHBEAT_PERIOD_KEY)); + } + if (old.containsKey(PERFORMANCE_LOGBOOK_TIME_INTERVAL_KEY)) { + properties.hearthbeat.performanceLogbookTimeInterval = + Integer.valueOf(old.getProperty(PERFORMANCE_LOGBOOK_TIME_INTERVAL_KEY)); + } + if (old.containsKey(PERFORMANCE_GLANCE_TIME_INTERVAL_KEY)) { + properties.hearthbeat.performanceGlanceTimeInterval = + Integer.valueOf(old.getProperty(PERFORMANCE_GLANCE_TIME_INTERVAL_KEY)); + } + + // requests picker + if (old.containsKey(PICKING_INITIAL_DELAY_KEY)) { + properties.requestsPickerAgent.delay = + Integer.valueOf(old.getProperty(PICKING_INITIAL_DELAY_KEY)); + } + if (old.containsKey(PICKING_TIME_INTERVAL_KEY)) { + properties.requestsPickerAgent.interval = + Integer.valueOf(old.getProperty(PICKING_TIME_INTERVAL_KEY)); + } + if (old.containsKey(PICKING_MAX_BATCH_SIZE_KEY)) { + properties.requestsPickerAgent.maxFetchedSize = + Integer.valueOf(old.getProperty(PICKING_MAX_BATCH_SIZE_KEY)); + } + + // requests scheduler + if (old.containsKey(CORE_POOL_SIZE_KEY)) { + properties.requestsScheduler.corePoolSize = + Integer.valueOf(old.getProperty(CORE_POOL_SIZE_KEY)); + } + if (old.containsKey(MAX_POOL_SIZE_KEY)) { + properties.requestsScheduler.maxPoolSize = + Integer.valueOf(old.getProperty(MAX_POOL_SIZE_KEY)); + } + if (old.containsKey(QUEUE_SIZE_KEY)) { + properties.requestsScheduler.queueSize = Integer.valueOf(old.getProperty(QUEUE_SIZE_KEY)); + } + + // ptp requests scheduler + if (old.containsKey(PTP_CORE_POOL_SIZE_KEY)) { + properties.ptpScheduler.corePoolSize = + Integer.valueOf(old.getProperty(PTP_CORE_POOL_SIZE_KEY)); + } + if (old.containsKey(PTP_MAX_POOL_SIZE_KEY)) { + properties.ptpScheduler.maxPoolSize = + Integer.valueOf(old.getProperty(PTP_MAX_POOL_SIZE_KEY)); + } + if (old.containsKey(PTP_QUEUE_SIZE_KEY)) { + properties.ptpScheduler.queueSize = Integer.valueOf(old.getProperty(PTP_QUEUE_SIZE_KEY)); + } + + // ptg requests scheduler + if (old.containsKey(PTG_CORE_POOL_SIZE_KEY)) { + properties.ptgScheduler.corePoolSize = + Integer.valueOf(old.getProperty(PTG_CORE_POOL_SIZE_KEY)); + } + if (old.containsKey(PTG_MAX_POOL_SIZE_KEY)) { + properties.ptgScheduler.maxPoolSize = + Integer.valueOf(old.getProperty(PTG_MAX_POOL_SIZE_KEY)); + } + if (old.containsKey(PTG_QUEUE_SIZE_KEY)) { + properties.ptgScheduler.queueSize = Integer.valueOf(old.getProperty(PTG_QUEUE_SIZE_KEY)); + } + + // bol requests scheduler + if (old.containsKey(BOL_CORE_POOL_SIZE_KEY)) { + properties.bolScheduler.corePoolSize = + Integer.valueOf(old.getProperty(BOL_CORE_POOL_SIZE_KEY)); + } + if (old.containsKey(BOL_MAX_POOL_SIZE_KEY)) { + properties.bolScheduler.maxPoolSize = + Integer.valueOf(old.getProperty(BOL_MAX_POOL_SIZE_KEY)); + } + if (old.containsKey(BOL_QUEUE_SIZE_KEY)) { + properties.bolScheduler.queueSize = Integer.valueOf(old.getProperty(BOL_QUEUE_SIZE_KEY)); + } + + // pin lifetime + if (old.containsKey(PIN_LIFETIME_DEFAULT_KEY)) { + properties.pinlifetime.defaultValue = + Integer.valueOf(old.getProperty(PIN_LIFETIME_DEFAULT_KEY)); + } + if (old.containsKey(PIN_LIFETIME_MAXIMUM_KEY)) { + properties.pinlifetime.maximum = Integer.valueOf(old.getProperty(PIN_LIFETIME_MAXIMUM_KEY)); + } + + // storage spaces agent + if (old.containsKey(CLEANING_INITIAL_DELAY_KEY)) { + properties.expiredSpacesAgent.delay = + Integer.valueOf(old.getProperty(CLEANING_INITIAL_DELAY_KEY)); + } + if (old.containsKey(CLEANING_TIME_INTERVAL_KEY)) { + properties.expiredSpacesAgent.interval = + Integer.valueOf(old.getProperty(CLEANING_TIME_INTERVAL_KEY)); + } + + // in progress requests agent + if (old.containsKey(TRANSIT_INITIAL_DELAY_KEY)) { + properties.inprogressRequestsAgent.delay = + Integer.valueOf(old.getProperty(TRANSIT_INITIAL_DELAY_KEY)); + } + if (old.containsKey(TRANSIT_TIME_INTERVAL_KEY)) { + properties.inprogressRequestsAgent.interval = + Integer.valueOf(old.getProperty(TRANSIT_TIME_INTERVAL_KEY)); + } + if (old.containsKey(EXPIRED_INPROGRESS_PTP_TIME_KEY)) { + properties.inprogressRequestsAgent.ptpExpirationTime = + Long.valueOf(old.getProperty(EXPIRED_INPROGRESS_PTP_TIME_KEY)); + } + + // completed requests agent + if (old.containsKey(EXPIRED_REQUEST_PURGING_KEY)) { + properties.completedRequestsAgent.enabled = + Boolean.valueOf(old.getProperty(EXPIRED_REQUEST_PURGING_KEY)); + } + if (old.containsKey(EXPIRED_REQUEST_TIME_KEY)) { + properties.completedRequestsAgent.purgeAge = + Long.valueOf(old.getProperty(EXPIRED_REQUEST_TIME_KEY)); + } + if (old.containsKey(PURGE_BATCH_SIZE_KEY)) { + properties.completedRequestsAgent.purgeSize = + Integer.valueOf(old.getProperty(PURGE_BATCH_SIZE_KEY)); + } + if (old.containsKey(REQUEST_PURGER_DELAY_KEY)) { + properties.completedRequestsAgent.delay = + Integer.valueOf(old.getProperty(REQUEST_PURGER_DELAY_KEY)); + } + if (old.containsKey(REQUEST_PURGER_PERIOD_KEY)) { + properties.completedRequestsAgent.interval = + Integer.valueOf(old.getProperty(REQUEST_PURGER_PERIOD_KEY)); + } + + // others + if (old.containsKey(HTTP_TURL_PREFIX)) { + properties.httpTurlPrefix = String.valueOf(old.getProperty(HTTP_TURL_PREFIX)); + } + if (old.containsKey(SERVER_POOL_STATUS_CHECK_TIMEOUT_KEY)) { + properties.serverPoolStatusCheckTimeout = + Integer.valueOf(old.getProperty(SERVER_POOL_STATUS_CHECK_TIMEOUT_KEY)); + } + if (old.containsKey(MAX_LOOP_KEY)) { + properties.abortMaxloop = Integer.valueOf(old.getProperty(MAX_LOOP_KEY)); + } + if (old.containsKey(GPFS_QUOTA_REFRESH_PERIOD_KEY)) { + properties.infoQuotaRefreshPeriod = + Integer.valueOf(old.getProperty(GPFS_QUOTA_REFRESH_PERIOD_KEY)); + } + if (old.containsKey(PING_VALUES_PROPERTIES_FILENAME_KEY)) { + properties.pingPropertiesFilename = + String.valueOf(old.getProperty(PING_VALUES_PROPERTIES_FILENAME_KEY)).trim(); + } + } + return properties; + } +} diff --git a/src/main/java/it/grid/storm/config/model/AdvancedDirectorySettings.java b/src/main/java/it/grid/storm/config/model/AdvancedDirectorySettings.java new file mode 100644 index 000000000..66ed0d920 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/AdvancedDirectorySettings.java @@ -0,0 +1,26 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.AUTOMATIC_DIRECTORY_CREATION; +import static it.grid.storm.config.ConfigurationDefaults.ENABLE_WRITE_PERM_ON_DIRECTORY; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class AdvancedDirectorySettings { + + public boolean enableAutomaticCreation; + public boolean enableWritepermOnCreation; + + public AdvancedDirectorySettings() { + enableAutomaticCreation = AUTOMATIC_DIRECTORY_CREATION; + enableWritepermOnCreation = ENABLE_WRITE_PERM_ON_DIRECTORY; + } + + public void log(Logger log, String prefix) { + log.info("{}.enable_automatic_creation: {}", prefix, enableAutomaticCreation); + log.info("{}.enable_writeperm_on_creation: {}", prefix, enableWritepermOnCreation); + } +} diff --git a/src/main/java/it/grid/storm/config/model/AdvancedFileSettings.java b/src/main/java/it/grid/storm/config/model/AdvancedFileSettings.java new file mode 100644 index 000000000..09982cb6e --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/AdvancedFileSettings.java @@ -0,0 +1,34 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.DEFAULT_FILE_STORAGE_TYPE; +import static it.grid.storm.config.ConfigurationDefaults.DEFAULT_OVERWRITE_MODE; +import static it.grid.storm.config.ConfigurationDefaults.FILE_DEFAULT_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.FILE_LIFETIME_DEFAULT; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class AdvancedFileSettings { + + public long defaultSize; + public long defaultLifetime; + public String defaultOverwrite; + public String defaultStoragetype; + + public AdvancedFileSettings() { + defaultSize = FILE_DEFAULT_SIZE; + defaultLifetime = FILE_LIFETIME_DEFAULT; + defaultOverwrite = DEFAULT_OVERWRITE_MODE; + defaultStoragetype = DEFAULT_FILE_STORAGE_TYPE; + } + + public void log(Logger log, String prefix) { + log.info("{}.default_size: {}", prefix, defaultSize); + log.info("{}.default_lifetime: {}", prefix, defaultLifetime); + log.info("{}.default_overwrite: {}", prefix, defaultOverwrite); + log.info("{}.default_storagetype: {}", prefix, defaultStoragetype); + } +} diff --git a/src/main/java/it/grid/storm/config/model/BolScheduler.java b/src/main/java/it/grid/storm/config/model/BolScheduler.java new file mode 100644 index 000000000..58b2d5f13 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/BolScheduler.java @@ -0,0 +1,30 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_QUEUE_SIZE; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class BolScheduler { + + public int corePoolSize; + public int maxPoolSize; + public int queueSize; + + public BolScheduler() { + corePoolSize = BOL_SCHEDULER_CORE_POOL_SIZE; + maxPoolSize = BOL_SCHEDULER_MAX_POOL_SIZE; + queueSize = BOL_SCHEDULER_QUEUE_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.core_pool_size: {}", prefix, corePoolSize); + log.info("{}.max_pool_size: {}", prefix, maxPoolSize); + log.info("{}.queue_size: {}", prefix, queueSize); + } +} diff --git a/src/main/java/it/grid/storm/config/model/CompletedRequestsAgent.java b/src/main/java/it/grid/storm/config/model/CompletedRequestsAgent.java new file mode 100644 index 000000000..2ba76b542 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/CompletedRequestsAgent.java @@ -0,0 +1,42 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_IS_DYNAMIC; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_PURGE_AGE; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_PURGE_SIZE; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class CompletedRequestsAgent { + + public boolean enabled; + public int delay; + public int interval; + public boolean isDynamic; + public long purgeAge; + public int purgeSize; + + public CompletedRequestsAgent() { + enabled = COMPLETED_REQUESTS_AGENT_ENABLED; + delay = COMPLETED_REQUESTS_AGENT_DELAY; + interval = COMPLETED_REQUESTS_AGENT_INTERVAL; + isDynamic = COMPLETED_REQUESTS_AGENT_IS_DYNAMIC; + purgeAge = COMPLETED_REQUESTS_AGENT_PURGE_AGE; + purgeSize = COMPLETED_REQUESTS_AGENT_PURGE_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.enabled: {}", prefix, enabled); + log.info("{}.delay: {}", prefix, delay); + log.info("{}.interval: {}", prefix, interval); + log.info("{}.is_dynamic: {}", prefix, isDynamic); + log.info("{}.purge_age: {}", prefix, purgeAge); + log.info("{}.purge_size: {}", prefix, purgeSize); + } +} diff --git a/src/main/java/it/grid/storm/config/model/DatabaseConnection.java b/src/main/java/it/grid/storm/config/model/DatabaseConnection.java new file mode 100644 index 000000000..0fd77b06a --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/DatabaseConnection.java @@ -0,0 +1,45 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.DB_PASSWORD; +import static it.grid.storm.config.ConfigurationDefaults.DB_PORT; +import static it.grid.storm.config.ConfigurationDefaults.DB_PROPERTIES; +import static it.grid.storm.config.ConfigurationDefaults.DB_USERNAME; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class DatabaseConnection { + + public String username; + public String password; + public String hostname; + public int port; + public String properties; + + public DatabasePoolProperties pool; + + public DatabaseConnection() throws UnknownHostException { + username = DB_USERNAME; + password = DB_PASSWORD; + hostname = InetAddress.getLocalHost().getHostName(); + port = DB_PORT; + properties = DB_PROPERTIES; + pool = new DatabasePoolProperties(); + } + + public void log(Logger log, String prefix) { + log.info("{}.hostname: {}", prefix, hostname); + log.info("{}.username: {}", prefix, username); + log.info("{}.password: {}", prefix, password); + log.info("{}.port: {}", prefix, port); + log.info("{}.properties: {}", prefix, properties); + pool.log(log, prefix + ".pool"); + } + +} diff --git a/src/main/java/it/grid/storm/config/model/DatabasePoolProperties.java b/src/main/java/it/grid/storm/config/model/DatabasePoolProperties.java new file mode 100644 index 000000000..0b3ac4e22 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/DatabasePoolProperties.java @@ -0,0 +1,38 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MAX_WAIT_MILLIS; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MIN_IDLE; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_ON_BORROW; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_WHILE_IDLE; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class DatabasePoolProperties { + + public int size; + public int minIdle; + public int maxWaitMillis; + public boolean testOnBorrow; + public boolean testWhileIdle; + + public DatabasePoolProperties() { + size = DB_POOL_SIZE; + minIdle = DB_POOL_MIN_IDLE; + maxWaitMillis = DB_POOL_MAX_WAIT_MILLIS; + testOnBorrow = DB_POOL_TEST_ON_BORROW; + testWhileIdle = DB_POOL_TEST_WHILE_IDLE; + } + + public void log(Logger log, String prefix) { + log.info("{}.size: {}", prefix, size); + log.info("{}.min_idle: {}", prefix, minIdle); + log.info("{}.max_wait_millis: {}", prefix, maxWaitMillis); + log.info("{}.test_on_borrow: {}", prefix, testOnBorrow); + log.info("{}.test_while_idle: {}", prefix, testWhileIdle); + } +} diff --git a/src/main/java/it/grid/storm/config/model/DiskUsageService.java b/src/main/java/it/grid/storm/config/model/DiskUsageService.java new file mode 100644 index 000000000..8e479f8e6 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/DiskUsageService.java @@ -0,0 +1,34 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_INITIAL_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_TASKS_INTERVAL; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class DiskUsageService { + + public boolean enabled; + public boolean parallelTasksEnabled; + public int initialDelay; + public long tasksInterval; + + public DiskUsageService() { + enabled = DISKUSAGE_SERVICE_ENABLED; + parallelTasksEnabled = DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED; + initialDelay = DISKUSAGE_SERVICE_INITIAL_DELAY; + tasksInterval = DISKUSAGE_SERVICE_TASKS_INTERVAL; + } + + public void log(Logger log, String prefix) { + log.info("{}.enabled: {}", prefix, enabled); + log.info("{}.parallel_tasks_enabled: {}", prefix, parallelTasksEnabled); + log.info("{}.initial_delay: {}", prefix, initialDelay); + log.info("{}.tasks_interval: {}", prefix, tasksInterval); + } +} diff --git a/src/main/java/it/grid/storm/config/model/Endpoint.java b/src/main/java/it/grid/storm/config/model/Endpoint.java new file mode 100644 index 000000000..6f6470b00 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/Endpoint.java @@ -0,0 +1,52 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.DEFAULT_SRM_PORT; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Objects; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class Endpoint { + + public String host; + public int port; + + public Endpoint() { + host = "localhost"; + port = DEFAULT_SRM_PORT;; + } + + public static Endpoint build(String host, int port) { + Endpoint e = new Endpoint(); + e.host = host; + e.port = port; + return e; + } + + public static Endpoint DEFAULT() throws UnknownHostException { + return build(InetAddress.getLocalHost().getHostName(), DEFAULT_SRM_PORT); + } + + @Override + public int hashCode() { + return Objects.hash(host, port); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Endpoint other = (Endpoint) obj; + return Objects.equals(host, other.host) && port == other.port; + } + + +} diff --git a/src/main/java/it/grid/storm/config/model/ExpiredSpacesAgent.java b/src/main/java/it/grid/storm/config/model/ExpiredSpacesAgent.java new file mode 100644 index 000000000..c749fb5ea --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/ExpiredSpacesAgent.java @@ -0,0 +1,26 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_SPACES_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_SPACES_AGENT_INTERVAL; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class ExpiredSpacesAgent { + + public int delay; + public int interval; + + public ExpiredSpacesAgent() { + delay = EXPIRED_SPACES_AGENT_DELAY; + interval = EXPIRED_SPACES_AGENT_INTERVAL; + } + + public void log(Logger log, String prefix) { + log.info("{}.delay: {}", prefix, delay); + log.info("{}.interval: {}", prefix, interval); + } +} diff --git a/src/main/java/it/grid/storm/config/model/ExtraslashesSettings.java b/src/main/java/it/grid/storm/config/model/ExtraslashesSettings.java new file mode 100644 index 000000000..3f286c1d6 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/ExtraslashesSettings.java @@ -0,0 +1,34 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_FILE_TURL; +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_GSIFTP_TURL; +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_RFIO_TURL; +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_ROOT_TURL; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class ExtraslashesSettings { + + public String file; + public String rfio; + public String root; + public String gsiftp; + + public ExtraslashesSettings() { + file = EXTRA_SLASHES_FOR_FILE_TURL; + rfio = EXTRA_SLASHES_FOR_RFIO_TURL; + root = EXTRA_SLASHES_FOR_ROOT_TURL; + gsiftp = EXTRA_SLASHES_FOR_GSIFTP_TURL; + } + + public void log(Logger log, String prefix) { + log.info("{}.file: {}", prefix, file); + log.info("{}.rfio: {}", prefix, rfio); + log.info("{}.root: {}", prefix, root); + log.info("{}.gsiftp: {}", prefix, gsiftp); + } +} diff --git a/src/main/java/it/grid/storm/config/model/HearthbeatSettings.java b/src/main/java/it/grid/storm/config/model/HearthbeatSettings.java new file mode 100644 index 000000000..9ce9f131e --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/HearthbeatSettings.java @@ -0,0 +1,38 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.BOOK_KEEPING_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.HEARTHBEAT_PERIOD; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_GLANCE_TIME_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_LOGBOOK_TIME_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_MEASURING; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class HearthbeatSettings { + + public boolean bookkeepingEnabled; + public boolean performanceMeasuringEnabled; + public int period; + public int performanceLogbookTimeInterval; + public int performanceGlanceTimeInterval; + + public HearthbeatSettings() { + bookkeepingEnabled = BOOK_KEEPING_ENABLED; + performanceMeasuringEnabled = PERFORMANCE_MEASURING; + period = HEARTHBEAT_PERIOD; + performanceLogbookTimeInterval = PERFORMANCE_LOGBOOK_TIME_INTERVAL; + performanceGlanceTimeInterval = PERFORMANCE_GLANCE_TIME_INTERVAL; + } + + public void log(Logger log, String prefix) { + log.info("{}.bookkeeping_enabled: {}", prefix, bookkeepingEnabled); + log.info("{}.performance_measuring_enabled: {}", prefix, performanceMeasuringEnabled); + log.info("{}.period: {}", prefix, period); + log.info("{}.performance_logbook_time_interval: {}", prefix, performanceLogbookTimeInterval); + log.info("{}.performance_glance_time_interval: {}", prefix, performanceGlanceTimeInterval); + } +} diff --git a/src/main/java/it/grid/storm/config/model/InProgressRequestsAgent.java b/src/main/java/it/grid/storm/config/model/InProgressRequestsAgent.java new file mode 100644 index 000000000..20c8cf408 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/InProgressRequestsAgent.java @@ -0,0 +1,30 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_PTP_EXPIRATION_TIME; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class InProgressRequestsAgent { + + public int delay; + public int interval; + public long ptpExpirationTime; + + public InProgressRequestsAgent() { + delay = INPROGRESS_REQUESTS_AGENT_DELAY; + interval = INPROGRESS_REQUESTS_AGENT_INTERVAL; + ptpExpirationTime = INPROGRESS_REQUESTS_AGENT_PTP_EXPIRATION_TIME; + } + + public void log(Logger log, String prefix) { + log.info("{}.delay: {}", prefix, delay); + log.info("{}.interval: {}", prefix, interval); + log.info("{}.ptp_expiration_time: {}", prefix, ptpExpirationTime); + } +} diff --git a/src/main/java/it/grid/storm/config/model/OverwriteMode.java b/src/main/java/it/grid/storm/config/model/OverwriteMode.java new file mode 100644 index 000000000..1c001cdfa --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/OverwriteMode.java @@ -0,0 +1,11 @@ +package it.grid.storm.config.model; + +import com.fasterxml.jackson.annotation.JsonFormat; + +@JsonFormat(shape = JsonFormat.Shape.STRING) +public enum OverwriteMode { + + N, + A, + D; +} diff --git a/src/main/java/it/grid/storm/config/model/PinlifetimeSettings.java b/src/main/java/it/grid/storm/config/model/PinlifetimeSettings.java new file mode 100644 index 000000000..c3f4fa0a3 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/PinlifetimeSettings.java @@ -0,0 +1,28 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_DEFAULT; +import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_MAXIMUM; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class PinlifetimeSettings { + + @JsonProperty("default") + public long defaultValue; + public long maximum; + + public PinlifetimeSettings() { + defaultValue = PIN_LIFETIME_DEFAULT; + maximum = PIN_LIFETIME_MAXIMUM; + } + + public void log(Logger log, String prefix) { + log.info("{}.default: {}", prefix, defaultValue); + log.info("{}.maximum: {}", prefix, maximum); + } +} diff --git a/src/main/java/it/grid/storm/config/model/PtgScheduler.java b/src/main/java/it/grid/storm/config/model/PtgScheduler.java new file mode 100644 index 000000000..71990f15f --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/PtgScheduler.java @@ -0,0 +1,30 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_QUEUE_SIZE; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class PtgScheduler { + + public int corePoolSize; + public int maxPoolSize; + public int queueSize; + + public PtgScheduler() { + corePoolSize = PTG_SCHEDULER_CORE_POOL_SIZE; + maxPoolSize = PTG_SCHEDULER_MAX_POOL_SIZE; + queueSize = PTG_SCHEDULER_QUEUE_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.core_pool_size: {}", prefix, corePoolSize); + log.info("{}.max_pool_size: {}", prefix, maxPoolSize); + log.info("{}.queue_size: {}", prefix, queueSize); + } +} diff --git a/src/main/java/it/grid/storm/config/model/PtpScheduler.java b/src/main/java/it/grid/storm/config/model/PtpScheduler.java new file mode 100644 index 000000000..ad51bb3a3 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/PtpScheduler.java @@ -0,0 +1,30 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_QUEUE_SIZE; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class PtpScheduler { + + public int corePoolSize; + public int maxPoolSize; + public int queueSize; + + public PtpScheduler() { + corePoolSize = PTP_SCHEDULER_CORE_POOL_SIZE; + maxPoolSize = PTP_SCHEDULER_MAX_POOL_SIZE; + queueSize = PTP_SCHEDULER_QUEUE_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.core_pool_size: {}", prefix, corePoolSize); + log.info("{}.max_pool_size: {}", prefix, maxPoolSize); + log.info("{}.queue_size: {}", prefix, queueSize); + } +} diff --git a/src/main/java/it/grid/storm/config/model/RequestsPickerAgent.java b/src/main/java/it/grid/storm/config/model/RequestsPickerAgent.java new file mode 100644 index 000000000..8ddec8d7d --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/RequestsPickerAgent.java @@ -0,0 +1,30 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_MAX_FETCHED_SIZE; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class RequestsPickerAgent { + + public int delay; + public int interval; + public int maxFetchedSize; + + public RequestsPickerAgent() { + delay = REQUESTS_PICKER_AGENT_DELAY; + interval = REQUESTS_PICKER_AGENT_INTERVAL; + maxFetchedSize = REQUESTS_PICKER_AGENT_MAX_FETCHED_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.delay: {}", prefix, delay); + log.info("{}.interval: {}", prefix, interval); + log.info("{}.max_fetched_size: {}", prefix, maxFetchedSize); + } +} diff --git a/src/main/java/it/grid/storm/config/model/RequestsScheduler.java b/src/main/java/it/grid/storm/config/model/RequestsScheduler.java new file mode 100644 index 000000000..e55435819 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/RequestsScheduler.java @@ -0,0 +1,31 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_QUEUE_SIZE; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class RequestsScheduler { + + public int corePoolSize; + public int maxPoolSize; + public int queueSize; + + public RequestsScheduler() { + corePoolSize = REQUESTS_SCHEDULER_CORE_POOL_SIZE; + maxPoolSize = REQUESTS_SCHEDULER_MAX_POOL_SIZE; + queueSize = REQUESTS_SCHEDULER_QUEUE_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.core_pool_size: {}", prefix, corePoolSize); + log.info("{}.max_pool_size: {}", prefix, maxPoolSize); + log.info("{}.queue_size: {}", prefix, queueSize); + } + +} diff --git a/src/main/java/it/grid/storm/config/model/RestServer.java b/src/main/java/it/grid/storm/config/model/RestServer.java new file mode 100644 index 000000000..df30fa3b1 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/RestServer.java @@ -0,0 +1,38 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_THREADS; +import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_PORT; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class RestServer { + + public int port; + public int maxThreads; + public int maxQueueSize; + + public RestServer() { + port = REST_SERVICES_PORT; + maxThreads = REST_SERVICES_MAX_THREADS; + maxQueueSize = REST_SERVICES_MAX_QUEUE_SIZE; + } + + public void setMaxThreads(int maxThreads) { + this.maxThreads = maxThreads > 0 ? maxThreads : REST_SERVICES_MAX_THREADS; + } + + public void setMaxQueueSize(int maxQueueSize) { + this.maxQueueSize = maxQueueSize > 0 ? maxQueueSize : REST_SERVICES_MAX_QUEUE_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.port: {}", prefix, port); + log.info("{}.max_threads: {}", prefix, maxThreads); + log.info("{}.max_queue_size: {}", prefix, maxQueueSize); + } +} diff --git a/src/main/java/it/grid/storm/config/model/SecuritySettings.java b/src/main/java/it/grid/storm/config/model/SecuritySettings.java new file mode 100644 index 000000000..bbf6f4922 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/SecuritySettings.java @@ -0,0 +1,26 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.SECURITY_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.SECURITY_TOKEN; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class SecuritySettings { + + public boolean enabled; + public String token; + + public SecuritySettings() { + enabled = SECURITY_ENABLED; + token = SECURITY_TOKEN; + } + + public void log(Logger log, String prefix) { + log.info("{}.enabled: {}", prefix, enabled); + log.info("{}.token: {}", prefix, token); + } +} diff --git a/src/main/java/it/grid/storm/config/model/StorageType.java b/src/main/java/it/grid/storm/config/model/StorageType.java new file mode 100644 index 000000000..aa78992c2 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/StorageType.java @@ -0,0 +1,11 @@ +package it.grid.storm.config.model; + +import com.fasterxml.jackson.annotation.JsonFormat; + +@JsonFormat(shape = JsonFormat.Shape.STRING) +public enum StorageType { + + V, + D, + P; +} diff --git a/src/main/java/it/grid/storm/config/model/StormProperties.java b/src/main/java/it/grid/storm/config/model/StormProperties.java new file mode 100644 index 000000000..834d218f1 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/StormProperties.java @@ -0,0 +1,128 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.GPFS_QUOTA_REFRESH_PERIOD; +import static it.grid.storm.config.ConfigurationDefaults.HTTP_TURL_PREFIX; +import static it.grid.storm.config.ConfigurationDefaults.MAX_LOOP; +import static it.grid.storm.config.ConfigurationDefaults.PING_VALUES_PROPERTIES_FILENAME; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SKIP_ACL_SETUP; +import static it.grid.storm.config.ConfigurationDefaults.SANITY_CHECK_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.SERVER_POOL_STATUS_CHECK_TIMEOUT; + +import java.net.UnknownHostException; +import java.util.List; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +import jersey.repackaged.com.google.common.collect.Lists; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class StormProperties { + + public static final String VERSION = "v2"; + public static final String UNRECOGNIZED_VERSION = "unknown"; + + public String version; + public List srmEndpoints; + public DatabaseConnection db; + public RestServer rest; + public XmlRpcServer xmlrpc; + public SecuritySettings security; + public DiskUsageService du; + public InProgressRequestsAgent inprogressRequestsAgent; + public ExpiredSpacesAgent expiredSpacesAgent; + public CompletedRequestsAgent completedRequestsAgent; + public RequestsPickerAgent requestsPickerAgent; + public RequestsScheduler requestsScheduler; + public PtpScheduler ptpScheduler; + public PtgScheduler ptgScheduler; + public BolScheduler bolScheduler; + public boolean sanityChecksEnabled; + public ExtraslashesSettings extraslashes; + public SynchLsSettings synchLs; + public PinlifetimeSettings pinlifetime; + public boolean skipPtgAclSetup; + public AdvancedFileSettings files; + public AdvancedDirectorySettings directories; + public HearthbeatSettings hearthbeat; + public int infoQuotaRefreshPeriod; + public String httpTurlPrefix; + public long serverPoolStatusCheckTimeout; + public int abortMaxloop; + public String pingPropertiesFilename; + + public StormProperties() throws UnknownHostException { + version = UNRECOGNIZED_VERSION; + srmEndpoints = Lists.newArrayList(Endpoint.DEFAULT()); + db = new DatabaseConnection(); + rest = new RestServer(); + xmlrpc = new XmlRpcServer(); + security = new SecuritySettings(); + du = new DiskUsageService(); + inprogressRequestsAgent = new InProgressRequestsAgent(); + expiredSpacesAgent = new ExpiredSpacesAgent(); + completedRequestsAgent = new CompletedRequestsAgent(); + requestsPickerAgent = new RequestsPickerAgent(); + requestsScheduler = new RequestsScheduler(); + ptpScheduler = new PtpScheduler(); + ptgScheduler = new PtgScheduler(); + bolScheduler = new BolScheduler(); + sanityChecksEnabled = SANITY_CHECK_ENABLED; + extraslashes = new ExtraslashesSettings(); + synchLs = new SynchLsSettings(); + pinlifetime = new PinlifetimeSettings(); + skipPtgAclSetup = PTG_SKIP_ACL_SETUP; + files = new AdvancedFileSettings(); + directories = new AdvancedDirectorySettings(); + hearthbeat = new HearthbeatSettings(); + infoQuotaRefreshPeriod = GPFS_QUOTA_REFRESH_PERIOD; + httpTurlPrefix = HTTP_TURL_PREFIX; + serverPoolStatusCheckTimeout = SERVER_POOL_STATUS_CHECK_TIMEOUT; + abortMaxloop = MAX_LOOP; + pingPropertiesFilename = PING_VALUES_PROPERTIES_FILENAME; + } + + public boolean hasVersion() { + return !UNRECOGNIZED_VERSION.equals(version); + } + + public void log(Logger log) { + + log.info("version: {}", version); + for (int i = 0; i < srmEndpoints.size(); i++) { + log.info("srm_endpoints.{}.host: {}", i+1, srmEndpoints.get(i).host); + log.info("srm_endpoints.{}.port: {}", i+1, srmEndpoints.get(i).port); + } + db.log(log, "db"); + rest.log(log, "rest"); + xmlrpc.log(log, "xmlrpc"); + security.log(log, "security"); + du.log(log, "du"); + inprogressRequestsAgent.log(log, "inprogress_requests_agent"); + expiredSpacesAgent.log(log, "expired_spaces_agent"); + completedRequestsAgent.log(log, "completed_requests_agent"); + requestsPickerAgent.log(log, "requests_picker_agent"); + requestsScheduler.log(log, "requests_scheduler"); + ptpScheduler.log(log, "ptp_scheduler"); + ptgScheduler.log(log, "ptg_scheduler"); + bolScheduler.log(log, "bol_scheduler"); + log.info("sanity_checks_enabled: {}", sanityChecksEnabled); + extraslashes.log(log, "extraslashes"); + synchLs.log(log, "synch_ls"); + pinlifetime.log(log, "pinlifetime"); + log.info("skip_ptg_acl_setup: {}", skipPtgAclSetup); + files.log(log, "files"); + directories.log(log, "directories"); + hearthbeat.log(log, "hearthbeat"); + log.info("info_quota_refresh_period: {}", infoQuotaRefreshPeriod); + log.info("http_turl_prefix: {}", httpTurlPrefix); + log.info("server_pool_status_check_timeout: {}", serverPoolStatusCheckTimeout); + log.info("abort_max_loop: {}", abortMaxloop); + log.info("ping_properties_filename: {}", pingPropertiesFilename); + } + +} diff --git a/src/main/java/it/grid/storm/config/model/SynchLsSettings.java b/src/main/java/it/grid/storm/config/model/SynchLsSettings.java new file mode 100644 index 000000000..9a6e10f0c --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/SynchLsSettings.java @@ -0,0 +1,34 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_ALL_LEVEL_RECURSIVE; +import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_NUM_OF_LEVELS; +import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_OFFSET; +import static it.grid.storm.config.ConfigurationDefaults.LS_MAX_NUMBER_OF_ENTRY; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class SynchLsSettings { + + public int maxEntries; + public boolean defaultAllLevelRecursive; + public short defaultNumLevels; + public short defaultOffset; + + public SynchLsSettings() { + maxEntries = LS_MAX_NUMBER_OF_ENTRY; + defaultAllLevelRecursive = LS_DEFAULT_ALL_LEVEL_RECURSIVE; + defaultNumLevels = LS_DEFAULT_NUM_OF_LEVELS; + defaultOffset = LS_DEFAULT_OFFSET; + } + + public void log(Logger log, String prefix) { + log.info("{}.max_entries: {}", prefix, maxEntries); + log.info("{}.default_all_level_recursive: {}", prefix, defaultAllLevelRecursive); + log.info("{}.default_num_levels: {}", prefix, defaultNumLevels); + log.info("{}.default_offset: {}", prefix, defaultOffset); + } +} diff --git a/src/main/java/it/grid/storm/config/model/XmlRpcServer.java b/src/main/java/it/grid/storm/config/model/XmlRpcServer.java new file mode 100644 index 000000000..c9a3d6e5a --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/XmlRpcServer.java @@ -0,0 +1,38 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_THREADS; +import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_SERVER_PORT; + +import org.slf4j.Logger; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class XmlRpcServer { + + public int port; + public int maxThreads; + public int maxQueueSize; + + public XmlRpcServer() { + port = XMLRPC_SERVER_PORT; + maxThreads = XMLRPC_MAX_THREADS; + maxQueueSize = XMLRPC_MAX_QUEUE_SIZE; + } + + public void setMaxThreads(int maxThreads) { + this.maxThreads = maxThreads > 0 ? maxThreads : XMLRPC_MAX_THREADS; + } + + public void setMaxQueueSize(int maxQueueSize) { + this.maxQueueSize = maxQueueSize > 0 ? maxQueueSize : XMLRPC_MAX_QUEUE_SIZE; + } + + public void log(Logger log, String prefix) { + log.info("{}.port: {}", prefix, port); + log.info("{}.max_threads: {}", prefix, maxThreads); + log.info("{}.max_queue_size: {}", prefix, maxQueueSize); + } +} diff --git a/src/main/java/it/grid/storm/config/model/v1/StormProperties.java b/src/main/java/it/grid/storm/config/model/v1/StormProperties.java new file mode 100644 index 000000000..39ddf7c28 --- /dev/null +++ b/src/main/java/it/grid/storm/config/model/v1/StormProperties.java @@ -0,0 +1,423 @@ +package it.grid.storm.config.model.v1; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class StormProperties { + + @JsonProperty("storm.service.SURL.endpoint") + public String managedSurls; + + @JsonProperty("storm.service.SURL.default-ports") + public String defaultPorts; + + @JsonProperty("storm.service.FE-public.hostname") + public String srmPublicHostname; + + @JsonProperty("storm.service.port") + public int srmPublicPort; + + @JsonProperty("storm.service.request-db.host") + public String dbHostname; + + @JsonProperty("storm.service.request-db.properties") + public String dbProperties; + + @JsonProperty("storm.service.request-db.username") + public String dbUsername; + + @JsonProperty("storm.service.request-db.passwd") + public String dbPassword; + + @JsonProperty("asynch.db.ReconnectPeriod") + public int dbReconnectPeriod; + + @JsonProperty("asynch.db.DelayPeriod") + public int dbDelayPeriod; + + @JsonProperty("gc.pinnedfiles.cleaning.delay") + public int gcPinnedfilesCleaningDelay; + + @JsonProperty("gc.pinnedfiles.cleaning.interval") + public int gcPinnedfilesCleaningInterval; + + @JsonProperty("fileSize.default") + public long filesizeDefault; + + @JsonProperty("fileLifetime.default") + public long fileLifetimeDefault; + + @JsonProperty("pinLifetime.default") + public long pinLifetimeDefault; + + @JsonProperty("pinLifetime.maximum") + public long pinLifetimeMaximum; + + @JsonProperty("transit.delay") + public int expiredRequestsAgentDelay; + + @JsonProperty("transit.interval") + public int expiredRequestsAgentInterval; + + @JsonProperty("asynch.PickingInitialDelay") + public int requestsPickerAgentDelay; + + @JsonProperty("asynch.PickingTimeInterval") + public int requestsPickerAgentInterval; + + @JsonProperty("asynch.PickingMaxBatchSize") + public int requestsPickerAgentMaxFetchedSize; + + @JsonProperty("synchcall.xmlrpc.maxthread") + public int xmlrpcMaxThreads; + + @JsonProperty("synchcall.xmlrpc.max_queue_size") + public int xmlrpcMaxQueueSize; + + @JsonProperty("persistence.internal-db.connection-pool.maxActive") + public int dbPoolMaxActiveConnections; + + @JsonProperty("persistence.internal-db.connection-pool.maxWait") + public int dbPoolMaxWait; + + @JsonProperty("synchcall.xmlrpc.unsecureServerPort") + public int xmlrpcPort; + + @JsonProperty("synchcall.directoryManager.maxLsEntry") + public int synchLsMaxEntries; + + @JsonProperty("synchcall.directoryManager.default.AllLevelRecursive") + public boolean synchLsDefaultAllLevelRecursive; + + @JsonProperty("synchcall.directoryManager.default.Levels") + public int synchLsDefaultNumLevels; + + @JsonProperty("synchcall.directoryManager.default.Offset") + public int synchLsDefaultOffset; + + @JsonProperty("scheduler.chunksched.ptp.workerCorePoolSize") + public int ptpSchedulerCorePoolSize; + + @JsonProperty("scheduler.chunksched.ptp.workerMaxPoolSize") + public int ptpSchedulerMaxPoolSize; + + @JsonProperty("scheduler.chunksched.ptp.queueSize") + public int ptpSchedulerQueueSize; + + @JsonProperty("scheduler.chunksched.ptg.workerCorePoolSize") + public int ptgSchedulerCorePoolSize; + + @JsonProperty("scheduler.chunksched.ptg.workerMaxPoolSize") + public int ptgSchedulerMaxPoolSize; + + @JsonProperty("scheduler.chunksched.ptg.queueSize") + public int ptgSchedulerQueueSize; + + @JsonProperty("scheduler.chunksched.bol.workerCorePoolSize") + public int bolSchedulerCorePoolSize; + + @JsonProperty("scheduler.chunksched.bol.workerMaxPoolSize") + public int bolSchedulerMaxPoolSize; + + @JsonProperty("scheduler.chunksched.bol.queueSize") + public int bolSchedulerQueueSize; + + @JsonProperty("scheduler.crusher.workerCorePoolSize") + public int requestsSchedulerCorePoolSize; + + @JsonProperty("scheduler.crusher.workerMaxPoolSize") + public int requestsSchedulerMaxPoolSize; + + @JsonProperty("scheduler.crusher.queueSize") + public int requestsSchedulerQueueSize; + + @JsonProperty("namespace.filename") + public String namespaceFilename; + + @JsonProperty("namespace.schema.filename") + public String namespaceSchemaFilename; + + @JsonProperty("namespace.refreshrate") + public int namespaceRefreshRate; + + @JsonProperty("namespace.automatic-config-reload") + public boolean namespaceAutomaticConfigReload; + + @JsonProperty("directory.automatic-creation") + public boolean directoriesAutomaticCreation; + + @JsonProperty("default.overwrite") + public String defaultOverwriteMode; + + @JsonProperty("default.storagetype") + public String defaultFileStorageType; + + @JsonProperty("purge.size") + public int completedRequestsAgentPurgeSize; + + @JsonProperty("expired.request.time") + public long completedRequestsAgentPurgeAge; + + @JsonProperty("expired.inprogress.time") + public long inProgressRequestsAgentPtpExpirationTime; + + @JsonProperty("purge.delay") + public int completedRequestsAgentPurgeDelay; + + @JsonProperty("purge.interval") + public int completedRequestsAgentInterval; + + @JsonProperty("purging") + public boolean completedRequestsAgentEnabled; + + @JsonProperty("extraslashes.file") + public String extraslashesFile; + + @JsonProperty("extraslashes.rfio") + public String extraslashesRfio; + + @JsonProperty("extraslashes.gsiftp") + public String extraslashesGsiftp; + + @JsonProperty("extraslashes.root") + public String extraslashesRoot; + + @JsonProperty("ping-properties.filename") + public String pingPropertiesFilename; + + @JsonProperty("health.electrocardiogram.period") + public int hearthbeatPeriod; + + @JsonProperty("health.performance.glance.timeInterval") + public int hearthbeatPerformanceGlanceTimeInterval; + + @JsonProperty("health.performance.logbook.timeInterval") + public int hearthbeatPerformanceLogbookTimeInterval; + + @JsonProperty("health.performance.mesauring.enabled") + public boolean hearthbeatPerformanceMeasuringEnabled; + + @JsonProperty("health.bookkeeping.enabled") + public boolean hearthbeatBookKeepingEnabled; + + @JsonProperty("directory.writeperm") + public boolean enabledWritePermOnDirectory; + + @JsonProperty("abort.maxloop") + public int abortMaxLoop; + + @JsonProperty("storm.rest.services.port") + public int restServicesPort; + + @JsonProperty("storm.rest.services.maxthread") + public int restServicesMaxThreads; + + @JsonProperty("storm.rest.services.max_queue_size") + public int restServicesMaxQueueSize; + + @JsonProperty("info.quota.refresh.period") + public int gpfsQuotaRefreshPeriod; + + @JsonProperty("server-pool.status-check.timeout") + public long serverPoolStatusCheckTimeout; + + @JsonProperty("sanity-check.enabled") + public boolean sanityCheckEnabled; + + @JsonProperty("synchcall.xmlrpc.security.enabled") + public boolean securityEnabled; + + @JsonProperty("synchcall.xmlrpc.security.token") + public String securityTokenValue; + + @JsonProperty("ptg.skip-acl-setup") + public boolean ptgSkipAclSetup; + + @JsonProperty("http.turl_prefix") + public String httpTurlPrefix; + + @JsonProperty("storm.service.du.enabled") + public boolean diskUsageServiceEnabled; + + @JsonProperty("storm.service.du.delaySecs") + public int diskUsageServiceInitialDelay; + + @JsonProperty("storm.service.du.periodSecs") + public int diskUsageServiceTasksInterval; + + @JsonProperty("storm.service.du.parallelTasks") + public boolean diskUsageServiceParallelTasksEnabled; + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("StormProperties [managedSurls="); + builder.append(managedSurls); + builder.append(", defaultPorts="); + builder.append(defaultPorts); + builder.append(", srmPublicHostname="); + builder.append(srmPublicHostname); + builder.append(", srmPublicPort="); + builder.append(srmPublicPort); + builder.append(", dbHostname="); + builder.append(dbHostname); + builder.append(", dbProperties="); + builder.append(dbProperties); + builder.append(", dbUsername="); + builder.append(dbUsername); + builder.append(", dbPassword="); + builder.append(dbPassword); + builder.append(", dbReconnectPeriod="); + builder.append(dbReconnectPeriod); + builder.append(", dbDelayPeriod="); + builder.append(dbDelayPeriod); + builder.append(", gcPinnedfilesCleaningDelay="); + builder.append(gcPinnedfilesCleaningDelay); + builder.append(", gcPinnedfilesCleaningInterval="); + builder.append(gcPinnedfilesCleaningInterval); + builder.append(", filesizeDefault="); + builder.append(filesizeDefault); + builder.append(", fileLifetimeDefault="); + builder.append(fileLifetimeDefault); + builder.append(", pinLifetimeDefault="); + builder.append(pinLifetimeDefault); + builder.append(", pinLifetimeMaximum="); + builder.append(pinLifetimeMaximum); + builder.append(", expiredRequestsAgentDelay="); + builder.append(expiredRequestsAgentDelay); + builder.append(", expiredRequestsAgentInterval="); + builder.append(expiredRequestsAgentInterval); + builder.append(", requestsPickerAgentDelay="); + builder.append(requestsPickerAgentDelay); + builder.append(", requestsPickerAgentInterval="); + builder.append(requestsPickerAgentInterval); + builder.append(", requestsPickerAgentMaxFetchedSize="); + builder.append(requestsPickerAgentMaxFetchedSize); + builder.append(", xmlrpcMaxThreads="); + builder.append(xmlrpcMaxThreads); + builder.append(", xmlrpcMaxQueueSize="); + builder.append(xmlrpcMaxQueueSize); + builder.append(", dbPoolMaxActiveConnections="); + builder.append(dbPoolMaxActiveConnections); + builder.append(", dbPoolMaxWait="); + builder.append(dbPoolMaxWait); + builder.append(", xmlrpcPort="); + builder.append(xmlrpcPort); + builder.append(", synchLsMaxEntries="); + builder.append(synchLsMaxEntries); + builder.append(", synchLsDefaultAllLevelRecursive="); + builder.append(synchLsDefaultAllLevelRecursive); + builder.append(", synchLsDefaultNumLevels="); + builder.append(synchLsDefaultNumLevels); + builder.append(", synchLsDefaultOffset="); + builder.append(synchLsDefaultOffset); + builder.append(", ptpSchedulerCorePoolSize="); + builder.append(ptpSchedulerCorePoolSize); + builder.append(", ptpSchedulerMaxPoolSize="); + builder.append(ptpSchedulerMaxPoolSize); + builder.append(", ptpSchedulerQueueSize="); + builder.append(ptpSchedulerQueueSize); + builder.append(", ptgSchedulerCorePoolSize="); + builder.append(ptgSchedulerCorePoolSize); + builder.append(", ptgSchedulerMaxPoolSize="); + builder.append(ptgSchedulerMaxPoolSize); + builder.append(", ptgSchedulerQueueSize="); + builder.append(ptgSchedulerQueueSize); + builder.append(", bolSchedulerCorePoolSize="); + builder.append(bolSchedulerCorePoolSize); + builder.append(", bolSchedulerMaxPoolSize="); + builder.append(bolSchedulerMaxPoolSize); + builder.append(", bolSchedulerQueueSize="); + builder.append(bolSchedulerQueueSize); + builder.append(", requestsSchedulerCorePoolSize="); + builder.append(requestsSchedulerCorePoolSize); + builder.append(", requestsSchedulerMaxPoolSize="); + builder.append(requestsSchedulerMaxPoolSize); + builder.append(", requestsSchedulerQueueSize="); + builder.append(requestsSchedulerQueueSize); + builder.append(", namespaceFilename="); + builder.append(namespaceFilename); + builder.append(", namespaceSchemaFilename="); + builder.append(namespaceSchemaFilename); + builder.append(", namespaceRefreshRate="); + builder.append(namespaceRefreshRate); + builder.append(", namespaceAutomaticConfigReload="); + builder.append(namespaceAutomaticConfigReload); + builder.append(", directoriesAutomaticCreation="); + builder.append(directoriesAutomaticCreation); + builder.append(", defaultOverwriteMode="); + builder.append(defaultOverwriteMode); + builder.append(", defaultFileStorageType="); + builder.append(defaultFileStorageType); + builder.append(", completedRequestsAgentPurgeSize="); + builder.append(completedRequestsAgentPurgeSize); + builder.append(", completedRequestsAgentPurgeAge="); + builder.append(completedRequestsAgentPurgeAge); + builder.append(", inProgressRequestsAgentPtpExpirationTime="); + builder.append(inProgressRequestsAgentPtpExpirationTime); + builder.append(", completedRequestsAgentPurgeDelay="); + builder.append(completedRequestsAgentPurgeDelay); + builder.append(", completedRequestsAgentInterval="); + builder.append(completedRequestsAgentInterval); + builder.append(", completedRequestsAgentEnabled="); + builder.append(completedRequestsAgentEnabled); + builder.append(", extraslashesFile="); + builder.append(extraslashesFile); + builder.append(", extraslashesRfio="); + builder.append(extraslashesRfio); + builder.append(", extraslashesGsiftp="); + builder.append(extraslashesGsiftp); + builder.append(", extraslashesRoot="); + builder.append(extraslashesRoot); + builder.append(", pingPropertiesFilename="); + builder.append(pingPropertiesFilename); + builder.append(", hearthbeatPeriod="); + builder.append(hearthbeatPeriod); + builder.append(", hearthbeatPerformanceGlanceTimeInterval="); + builder.append(hearthbeatPerformanceGlanceTimeInterval); + builder.append(", hearthbeatPerformanceLogbookTimeInterval="); + builder.append(hearthbeatPerformanceLogbookTimeInterval); + builder.append(", hearthbeatPerformanceMeasuringEnabled="); + builder.append(hearthbeatPerformanceMeasuringEnabled); + builder.append(", hearthbeatBookKeepingEnabled="); + builder.append(hearthbeatBookKeepingEnabled); + builder.append(", enabledWritePermOnDirectory="); + builder.append(enabledWritePermOnDirectory); + builder.append(", abortMaxLoop="); + builder.append(abortMaxLoop); + builder.append(", restServicesPort="); + builder.append(restServicesPort); + builder.append(", restServicesMaxThreads="); + builder.append(restServicesMaxThreads); + builder.append(", restServicesMaxQueueSize="); + builder.append(restServicesMaxQueueSize); + builder.append(", gpfsQuotaRefreshPeriod="); + builder.append(gpfsQuotaRefreshPeriod); + builder.append(", serverPoolStatusCheckTimeout="); + builder.append(serverPoolStatusCheckTimeout); + builder.append(", sanityCheckEnabled="); + builder.append(sanityCheckEnabled); + builder.append(", securityEnabled="); + builder.append(securityEnabled); + builder.append(", securityTokenValue="); + builder.append(securityTokenValue); + builder.append(", ptgSkipAclSetup="); + builder.append(ptgSkipAclSetup); + builder.append(", httpTurlPrefix="); + builder.append(httpTurlPrefix); + builder.append(", diskUsageServiceEnabled="); + builder.append(diskUsageServiceEnabled); + builder.append(", diskUsageServiceInitialDelay="); + builder.append(diskUsageServiceInitialDelay); + builder.append(", diskUsageServiceTasksInterval="); + builder.append(diskUsageServiceTasksInterval); + builder.append(", diskUsageServiceParallelTasksEnabled="); + builder.append(diskUsageServiceParallelTasksEnabled); + builder.append("]"); + return builder.toString(); + } + + + +} diff --git a/src/main/java/it/grid/storm/info/SpaceInfoManager.java b/src/main/java/it/grid/storm/info/SpaceInfoManager.java index 3cf3ebc41..16dbedb59 100644 --- a/src/main/java/it/grid/storm/info/SpaceInfoManager.java +++ b/src/main/java/it/grid/storm/info/SpaceInfoManager.java @@ -17,8 +17,6 @@ package it.grid.storm.info; -import static it.grid.storm.config.Configuration.DISKUSAGE_SERVICE_ENABLED_KEY; - import java.io.FileNotFoundException; import java.util.List; @@ -88,10 +86,8 @@ public void initializeUsedSpace() { log.info("The remaining {} storage spaces will be initialized by DiskUsage service", ssni.size()); } else { - log.warn( - "The remaining {} storage spaces WON'T be initialized with DUs. " - + "Please enable DiskUsage service by setting '{}' as true.", - ssni.size(), DISKUSAGE_SERVICE_ENABLED_KEY); + log.warn("The remaining {} storage spaces WON'T be initialized with DUs. " + + "Please enable DiskUsage service.", ssni.size()); } } diff --git a/src/main/java/it/grid/storm/info/du/DiskUsageService.java b/src/main/java/it/grid/storm/info/du/DiskUsageService.java index 94fdfb055..2764438dc 100644 --- a/src/main/java/it/grid/storm/info/du/DiskUsageService.java +++ b/src/main/java/it/grid/storm/info/du/DiskUsageService.java @@ -22,10 +22,10 @@ public class DiskUsageService { private ScheduledExecutorService executor; private boolean running; private int delay; - private int period; + private long period; private DiskUsageService(List vfss, ScheduledExecutorService executor, - int delay, int period) { + int delay, long period) { Preconditions.checkNotNull(vfss, "Invalid null list of Virtual FS"); Preconditions.checkNotNull(executor, "Invalid null scheduled executor service"); @@ -42,7 +42,7 @@ public int getDelay() { return delay; } - public int getPeriod() { + public long getPeriod() { return period; } @@ -52,19 +52,19 @@ public void setDelay(int delay) { this.delay = delay; } - public void setPeriod(int period) { + public void setPeriod(long period) { this.period = period; } public static DiskUsageService getSingleThreadScheduledService(List vfss, - int delay, int period) { + int delay, long period) { return new DiskUsageService(vfss, Executors.newSingleThreadScheduledExecutor(), delay, period); } public static DiskUsageService getScheduledThreadPoolService(List vfss, - int delay, int period) { + int delay, long period) { return new DiskUsageService(vfss, Executors.newScheduledThreadPool(vfss.size()), delay, period); } diff --git a/src/main/java/it/grid/storm/namespace/NamespaceDirector.java b/src/main/java/it/grid/storm/namespace/NamespaceDirector.java index 5359b03ad..78f683c0a 100644 --- a/src/main/java/it/grid/storm/namespace/NamespaceDirector.java +++ b/src/main/java/it/grid/storm/namespace/NamespaceDirector.java @@ -49,7 +49,7 @@ public static void init() { log.info("NAMESPACE : Initializing ..."); Configuration config = Configuration.getInstance(); - String configurationDir = config.configurationDir(); + String configurationDir = config.configurationDir().getAbsolutePath(); String namespaceFileName = config.getNamespaceConfigFilename(); String namespaceAbsoluteFilePath = getNamespaceFileAbsolutePath(configurationDir, namespaceFileName); diff --git a/src/main/java/it/grid/storm/persistence/converter/OverwriteModeConverter.java b/src/main/java/it/grid/storm/persistence/converter/OverwriteModeConverter.java index 6e87b8674..3cec9b8d7 100644 --- a/src/main/java/it/grid/storm/persistence/converter/OverwriteModeConverter.java +++ b/src/main/java/it/grid/storm/persistence/converter/OverwriteModeConverter.java @@ -17,16 +17,16 @@ package it.grid.storm.persistence.converter; -import java.util.Map; - -import com.google.common.collect.Maps; - import static it.grid.storm.srm.types.TOverwriteMode.ALWAYS; import static it.grid.storm.srm.types.TOverwriteMode.NEVER; import static it.grid.storm.srm.types.TOverwriteMode.WHENFILESAREDIFFERENT; +import java.util.Map; + +import com.google.common.collect.Maps; + +import it.grid.storm.config.model.OverwriteMode; import it.grid.storm.srm.types.TOverwriteMode; -import it.grid.storm.config.Configuration; /** * Package private auxiliary class used to convert between DB and StoRM object model representation @@ -38,66 +38,41 @@ */ public class OverwriteModeConverter { - private Map DBtoSTORM = Maps.newHashMap(); - private Map STORMtoDB = Maps.newHashMap(); - - private static OverwriteModeConverter c = new OverwriteModeConverter(); - - /** - * Private constructor that fills in the conversion table; in particular, DB uses String values to - * represent TOverwriteMode: - * - * N NEVER A ALWAYS D WHENFILESAREDIFFERENT - */ - private OverwriteModeConverter() { - - DBtoSTORM.put("N", NEVER); - DBtoSTORM.put("A", ALWAYS); - DBtoSTORM.put("D", WHENFILESAREDIFFERENT); - STORMtoDB.put(NEVER, "N"); - STORMtoDB.put(ALWAYS, "A"); - STORMtoDB.put(WHENFILESAREDIFFERENT, "D"); - } + private static Map STORMtoDB = Maps.newHashMap(); - /** - * Method that returns the only instance of OverwriteModeConverter. - */ - public static OverwriteModeConverter getInstance() { + static { - return c; + STORMtoDB.put(NEVER, OverwriteMode.N); + STORMtoDB.put(ALWAYS, OverwriteMode.A); + STORMtoDB.put(WHENFILESAREDIFFERENT, OverwriteMode.D); } - /** - * Method that returns the int used by DPM to represent the given TOverwriteMode. "" is returned - * if no match is found. - */ - public String toDB(TOverwriteMode om) { + public static OverwriteMode toDB(TOverwriteMode om) { - String aux = (String) STORMtoDB.get(om); - if (aux == null) - return ""; - return aux; + if (STORMtoDB.containsKey(om)) { + return STORMtoDB.get(om); + } + return OverwriteMode.N; } - /** - * Method that returns the TOverwriteMode used by StoRM to represent the supplied String - * representation of DPM. A configured default TOverwriteMode is returned in case no corresponding - * StoRM type is found. TOverwriteMode.EMPTY is returned if there are configuration errors. - */ - public TOverwriteMode toSTORM(String s) { - - TOverwriteMode aux = (TOverwriteMode) DBtoSTORM.get(s); - if (aux == null) - aux = (TOverwriteMode) DBtoSTORM.get(Configuration.getInstance().getDefaultOverwriteMode()); - if (aux == null) - return TOverwriteMode.EMPTY; - else - return aux; - } + public static TOverwriteMode toSTORM(String s) { - public String toString() { + OverwriteMode om = OverwriteMode.valueOf(s.trim().toUpperCase()); + return toSTORM(om); + } - return "OverWriteModeConverter.\nDBtoSTORM map:" + DBtoSTORM + "\nSTORMtoDB map:" + STORMtoDB; + public static TOverwriteMode toSTORM(OverwriteMode om) { + + switch (om) { + case N: + return TOverwriteMode.NEVER; + case A: + return TOverwriteMode.ALWAYS; + case D: + return TOverwriteMode.WHENFILESAREDIFFERENT; + default: + return TOverwriteMode.EMPTY; + } } } diff --git a/src/main/java/it/grid/storm/persistence/model/PtPChunkDataTO.java b/src/main/java/it/grid/storm/persistence/model/PtPChunkDataTO.java index c589f8bdb..91084941a 100644 --- a/src/main/java/it/grid/storm/persistence/model/PtPChunkDataTO.java +++ b/src/main/java/it/grid/storm/persistence/model/PtPChunkDataTO.java @@ -79,7 +79,7 @@ public PtPChunkDataTO() { TURLPrefix protocolPreferences = new TURLPrefix(); protocolPreferences.addProtocol(Protocol.GSIFTP); this.protocolList = TransferProtocolListConverter.toDB(protocolPreferences); - this.overwriteOption = OverwriteModeConverter.getInstance().toDB(TOverwriteMode.NEVER); + this.overwriteOption = OverwriteModeConverter.toDB(TOverwriteMode.NEVER).name(); this.status = StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_REQUEST_QUEUED); } diff --git a/src/main/java/it/grid/storm/srm/types/TFileStorageType.java b/src/main/java/it/grid/storm/srm/types/TFileStorageType.java index 6121f801b..8946052bb 100644 --- a/src/main/java/it/grid/storm/srm/types/TFileStorageType.java +++ b/src/main/java/it/grid/storm/srm/types/TFileStorageType.java @@ -19,6 +19,8 @@ import java.util.Map; +import it.grid.storm.config.model.StorageType; + /** * This class represents the TFileStorageType of an Srm request. * @@ -71,6 +73,20 @@ public static TFileStorageType getTFileStorageType(String type) { } } + public static TFileStorageType getTFileStorageType(StorageType type) { + + switch (type) { + case V: + return VOLATILE; + case P: + return PERMANENT; + case D: + return DURABLE; + default: + return EMPTY; + } + } + /** * Facility method to obtain a TFileStorageType object given its String representation. If an * invalid String is supplied, then an EMPTY TFileStorageType is returned. diff --git a/src/main/java/it/grid/storm/srm/types/TOverwriteMode.java b/src/main/java/it/grid/storm/srm/types/TOverwriteMode.java index 11210033b..95c0636bc 100644 --- a/src/main/java/it/grid/storm/srm/types/TOverwriteMode.java +++ b/src/main/java/it/grid/storm/srm/types/TOverwriteMode.java @@ -44,28 +44,4 @@ public String getValue() { return mode; } - - /** - * @param mode - * @return - * @throws IllegalArgumentException - */ - public static TOverwriteMode getTOverwriteMode(String mode) - throws IllegalArgumentException { - - if (mode == null) { - throw new IllegalArgumentException("Received null mode parameter"); - } - if (mode.equals(EMPTY.getValue())) - return EMPTY; - if (mode.equals(NEVER.getValue())) - return NEVER; - if (mode.equals(ALWAYS.getValue())) - return ALWAYS; - if (mode.equals(WHENFILESAREDIFFERENT.getValue())) - return WHENFILESAREDIFFERENT; - throw new IllegalArgumentException( - "No matching TOverwriteMode for String \'" + mode + "\'"); - } - } diff --git a/src/main/java/it/grid/storm/srm/types/TRequestToken.java b/src/main/java/it/grid/storm/srm/types/TRequestToken.java index f88cfaa74..38a510268 100644 --- a/src/main/java/it/grid/storm/srm/types/TRequestToken.java +++ b/src/main/java/it/grid/storm/srm/types/TRequestToken.java @@ -44,9 +44,6 @@ public class TRequestToken implements Serializable { private final Calendar expiration; - private static final long REQUEST_LIFETIME = Configuration.getInstance() - .getExpiredRequestTime() * 1000; - public TRequestToken(String requestToken, Date timestamp) throws InvalidTRequestTokenAttributesException { @@ -57,7 +54,9 @@ public TRequestToken(String requestToken, Date timestamp) Calendar expiration = null; if (timestamp != null) { expiration = Calendar.getInstance(); - expiration.setTimeInMillis(timestamp.getTime() + REQUEST_LIFETIME); + long requestLifetime = Configuration.getInstance() + .getExpiredRequestTime() * 1000; + expiration.setTimeInMillis(timestamp.getTime() + requestLifetime); } this.expiration = expiration; } diff --git a/src/main/java/it/grid/storm/synchcall/data/datatransfer/AnonymousPrepareToPutInputData.java b/src/main/java/it/grid/storm/synchcall/data/datatransfer/AnonymousPrepareToPutInputData.java index 6847eb4c1..848cbb304 100644 --- a/src/main/java/it/grid/storm/synchcall/data/datatransfer/AnonymousPrepareToPutInputData.java +++ b/src/main/java/it/grid/storm/synchcall/data/datatransfer/AnonymousPrepareToPutInputData.java @@ -30,91 +30,73 @@ * @author Michele Dibenedetto * */ -public class AnonymousPrepareToPutInputData extends - AnonymousFileTransferInputData implements PrepareToPutInputData { - - private TOverwriteMode overwriteMode = OverwriteModeConverter.getInstance() - .toSTORM(Configuration.getInstance().getDefaultOverwriteMode()); - private TSizeInBytes fileSize = TSizeInBytes.makeEmpty(); - private TLifeTimeInSeconds desiredFileLifetime; - - /** - * @param user - * @param surl - * @param transferProtocols - * @throws IllegalArgumentException - * @throws IllegalStateException - */ - public AnonymousPrepareToPutInputData(TSURL surl, TURLPrefix transferProtocols) - throws IllegalArgumentException, IllegalStateException { - - super(surl, transferProtocols); - this.desiredFileLifetime = TLifeTimeInSeconds.make(Configuration - .getInstance().getFileLifetimeDefault(), TimeUnit.SECONDS); - - } - - public AnonymousPrepareToPutInputData(TSURL surl, - TURLPrefix transferProtocols, TLifeTimeInSeconds desiredFileLifetime) - throws IllegalArgumentException, IllegalStateException { - - this(surl, transferProtocols); - this.desiredFileLifetime = desiredFileLifetime; - } - - /* - * (non-Javadoc) - * - * @see it.grid.storm.synchcall.data.datatransfer.PrepareToPutInputData# - * getOverwriteMode() - */ - @Override - public TOverwriteMode getOverwriteMode() { - - return overwriteMode; - } - - @Override - public void setOverwriteMode(TOverwriteMode overwriteMode) { - - this.overwriteMode = overwriteMode; - } - - /* - * (non-Javadoc) - * - * @see - * it.grid.storm.synchcall.data.datatransfer.PrepareToPutInputData#getFileSize - * () - */ - @Override - public TSizeInBytes getFileSize() { - - return fileSize; - } - - @Override - public void setFileSize(TSizeInBytes fileSize) { - - this.fileSize = fileSize; - } - - /* - * (non-Javadoc) - * - * @see it.grid.storm.synchcall.data.datatransfer.PrepareToPutInputData# - * getDesiredFileLifetime() - */ - @Override - public TLifeTimeInSeconds getDesiredFileLifetime() { - - return desiredFileLifetime; - } - - @Override - public void setDesiredFileLifetime(TLifeTimeInSeconds desiredFileLifetime) { - - this.desiredFileLifetime = desiredFileLifetime; - } +public class AnonymousPrepareToPutInputData extends AnonymousFileTransferInputData + implements PrepareToPutInputData { + + private static Configuration c = Configuration.getInstance(); + + private TOverwriteMode overwriteMode; + private TSizeInBytes fileSize; + private TLifeTimeInSeconds desiredFileLifetime; + + /** + * @param user + * @param surl + * @param transferProtocols + * @throws IllegalArgumentException + * @throws IllegalStateException + */ + public AnonymousPrepareToPutInputData(TSURL surl, TURLPrefix transferProtocols) + throws IllegalArgumentException, IllegalStateException { + + this(surl, transferProtocols, + TLifeTimeInSeconds.make(c.getFileLifetimeDefault(), TimeUnit.SECONDS)); + } + + public AnonymousPrepareToPutInputData(TSURL surl, TURLPrefix transferProtocols, + TLifeTimeInSeconds desiredFileLifetime) + throws IllegalArgumentException, IllegalStateException { + + super(surl, transferProtocols); + setDesiredFileLifetime(desiredFileLifetime); + setOverwriteMode(OverwriteModeConverter.toSTORM(c.getDefaultOverwriteMode())); + setFileSize(TSizeInBytes.makeEmpty()); + } + + @Override + public TOverwriteMode getOverwriteMode() { + + return overwriteMode; + } + + @Override + public void setOverwriteMode(TOverwriteMode overwriteMode) { + + this.overwriteMode = overwriteMode; + } + + @Override + public TSizeInBytes getFileSize() { + + return fileSize; + } + + @Override + public void setFileSize(TSizeInBytes fileSize) { + + this.fileSize = fileSize; + } + + @Override + public TLifeTimeInSeconds getDesiredFileLifetime() { + + return desiredFileLifetime; + } + + @Override + public void setDesiredFileLifetime(TLifeTimeInSeconds desiredFileLifetime) { + + this.desiredFileLifetime = desiredFileLifetime; + } } diff --git a/src/main/java/it/grid/storm/tape/recalltable/persistence/PropertiesDB.java b/src/main/java/it/grid/storm/tape/recalltable/persistence/PropertiesDB.java deleted file mode 100644 index b9932dbf9..000000000 --- a/src/main/java/it/grid/storm/tape/recalltable/persistence/PropertiesDB.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * - * Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. - * - * 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 it.grid.storm.tape.recalltable.persistence; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.List; -import java.util.Properties; -import java.util.UUID; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import it.grid.storm.config.Configuration; -import it.grid.storm.persistence.exceptions.DataAccessException; -import it.grid.storm.persistence.model.TapeRecallTO; -import it.grid.storm.srm.types.TRequestToken; - -/** - * @author zappi - * - */ -public class PropertiesDB { - - private static final Logger log = LoggerFactory.getLogger(PropertiesDB.class); - private static Configuration config = Configuration.getInstance(); - private final String dataFileName = "recall-table.txt"; - private final String propertiesDBName; - - public PropertiesDB() { - - String configurationDir = PropertiesDB.config.configurationDir(); - char sep = File.separatorChar; - propertiesDBName = configurationDir + sep + "etc" + sep + "db" + sep + dataFileName; - log.debug("Properties RecallTable-DB = {}", propertiesDBName); - } - - public PropertiesDB(boolean test) { - - String configurationDir; - if (test) { - configurationDir = System.getProperty("user.dir"); - } else { - configurationDir = PropertiesDB.config.configurationDir(); - } - char sep = File.separatorChar; - propertiesDBName = configurationDir + sep + "etc" + sep + "db" + sep + dataFileName; - // log.debug("Properties RecallTable-DB = " + propertiesDBName); - File tasksDBfile = new File(propertiesDBName); - boolean success = false; - try { - success = tasksDBfile.createNewFile(); - } catch (IOException e) { - log.error("Error while trying to check : {}", propertiesDBName, e); - } - if (success) { - log.debug("TaskDB = '{}' exists ? {}", propertiesDBName, success); - } - } - - // *************** PERSISTENCE METHODS **************** - - /** - * - * @param task - * @throws FileNotFoundException - * @throws IOException - * @throws DataAccessException - */ - public void addRecallTask(TapeRecallTO task) - throws FileNotFoundException, IOException, DataAccessException { - - Properties properties = new Properties(); - properties.load(new FileInputStream(propertiesDBName)); - - // Retrieve the Request-Token (unique-key) - TRequestToken taskToken = task.getRequestToken(); - if (taskToken == null) { - log.error("You are trying to store a Task without a task-id."); - throw new DataAccessException("You are trying to store a Task without a task-id."); - } - // Build the String related to Task-id - String taskStr = task.toString(); - // Insert the new property entry - properties.setProperty(taskToken.getValue(), taskStr); - // Store the properties into disk - properties.store(new FileOutputStream(propertiesDBName), null); - } - - public void setRecallTask(List listTasks) - throws FileNotFoundException, IOException, DataAccessException { - - Properties properties = new Properties(); - properties.load(new FileInputStream(propertiesDBName)); - - TRequestToken taskToken = null; - String taskStr = null; - for (TapeRecallTO TapeRecallTO : listTasks) { - // Retrieve the Task-id (unique-key) - taskToken = TapeRecallTO.getRequestToken(); - if (taskToken == null) { - log.error("You are trying to store a Task without a RequestToken."); - throw new DataAccessException("You are trying to store a Task without a Request-Token."); - } - // Build the String related to Task-id - taskStr = TapeRecallTO.toString(); - // Insert the new property entry - properties.setProperty(taskToken.getValue(), taskStr); - taskToken = null; - } - // Store the properties into disk - properties.store(new FileOutputStream(propertiesDBName), null); - } - - public void updateRecallTask(TapeRecallTO task) - throws FileNotFoundException, IOException, DataAccessException { - - Properties properties = new Properties(); - properties.load(new FileInputStream(propertiesDBName)); - - UUID taskId = task.getTaskId(); - - // Check if the Task exists within the Properties DB - boolean taskExist = properties.containsKey(taskId.toString()); - if (!(taskExist)) { - log.error("Unable to find the task with ID = {}", taskId); - throw new DataAccessException("Unable to find the task with ID = " + taskId); - } else { - // Build the String related to Task-id - String taskStr = task.toString(); - // Insert the new property entry - properties.setProperty(taskId.toString(), taskStr); - log.debug("Removed tasks '{}'", taskId); - } - - // Store the properties into disk - properties.store(new FileOutputStream(propertiesDBName), null); - } - - public void deleteRecallTask(UUID taskId) - throws FileNotFoundException, IOException, DataAccessException { - - Properties properties = new Properties(); - properties.load(new FileInputStream(propertiesDBName)); - - // Retrieve the Task from taskId - String task = properties.getProperty(taskId.toString()); - if (task == null) { - log.error("Unable to find the task with ID = {}", taskId); - throw new DataAccessException("Unable to find the task with ID = " + taskId); - } else { - properties.remove(taskId); - log.debug("Removed tasks '{}'", taskId); - } - - // Store the properties into disk - properties.store(new FileOutputStream(propertiesDBName), null); - } - -} diff --git a/src/main/java/it/grid/storm/xmlrpc/converter/datatransfer/PrepareToPutRequestConverter.java b/src/main/java/it/grid/storm/xmlrpc/converter/datatransfer/PrepareToPutRequestConverter.java index fc80595b8..7f3ba8929 100644 --- a/src/main/java/it/grid/storm/xmlrpc/converter/datatransfer/PrepareToPutRequestConverter.java +++ b/src/main/java/it/grid/storm/xmlrpc/converter/datatransfer/PrepareToPutRequestConverter.java @@ -21,7 +21,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import it.grid.storm.common.types.TURLPrefix; +import it.grid.storm.config.model.OverwriteMode; import it.grid.storm.griduser.GridUserInterface; +import it.grid.storm.persistence.converter.OverwriteModeConverter; import it.grid.storm.srm.types.TLifeTimeInSeconds; import it.grid.storm.srm.types.TOverwriteMode; import it.grid.storm.srm.types.TSURL; @@ -87,26 +89,17 @@ public InputData convertToInputData(Map inputParam) inputData.setFileSize(fileSize); } - String overwriteModeString = (String) inputParam - .get(OVERWRITE_MODE_PARAMETER_NAME); - if (overwriteModeString != null) { - TOverwriteMode overwriteMode; - try { - overwriteMode = TOverwriteMode.getTOverwriteMode(overwriteModeString); - } catch (IllegalArgumentException e) { - log.error("Unable to build TOverwriteMode from '{}'. IllegalArgumentException: {}" - , overwriteModeString - , e.getMessage() - , e); - throw new StoRMXmlRpcException("Unable to build PrepareToPutInputData"); - } - if (!overwriteMode.equals(TOverwriteMode.EMPTY)) { - inputData.setOverwriteMode(overwriteMode); - } else { - log - .warn("Unable to use the received '{}', interpreted as an empty value" , OVERWRITE_MODE_PARAMETER_NAME); - } - } + String overwriteModeString = (String) inputParam.get(OVERWRITE_MODE_PARAMETER_NAME); + if (overwriteModeString != null) { + TOverwriteMode overwriteMode = + OverwriteModeConverter.toSTORM(OverwriteMode.valueOf(overwriteModeString)); + if (!overwriteMode.equals(TOverwriteMode.EMPTY)) { + inputData.setOverwriteMode(overwriteMode); + } else { + log.warn("Unable to use the received '{} = {}', interpreted as an empty value", + OVERWRITE_MODE_PARAMETER_NAME, overwriteModeString); + } + } log.debug("PrepareToPutInputData Created!"); return inputData; } diff --git a/src/test/java/it/grid/storm/config/ConfigurationConverterTest.java b/src/test/java/it/grid/storm/config/ConfigurationConverterTest.java new file mode 100644 index 000000000..d939e33fd --- /dev/null +++ b/src/test/java/it/grid/storm/config/ConfigurationConverterTest.java @@ -0,0 +1,155 @@ +package it.grid.storm.config; + +import static it.grid.storm.config.ConfigurationDefaults.BOOK_KEEPING_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MIN_IDLE; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_ON_BORROW; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_WHILE_IDLE; +import static it.grid.storm.config.ConfigurationDefaults.DB_PORT; +import static it.grid.storm.config.ConfigurationDefaults.DB_PROPERTIES; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.GPFS_QUOTA_REFRESH_PERIOD; +import static it.grid.storm.config.ConfigurationDefaults.HEARTHBEAT_PERIOD; +import static it.grid.storm.config.ConfigurationDefaults.HTTP_TURL_PREFIX; +import static it.grid.storm.config.ConfigurationDefaults.MAX_LOOP; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_GLANCE_TIME_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_LOGBOOK_TIME_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_MEASURING; +import static it.grid.storm.config.ConfigurationDefaults.PING_VALUES_PROPERTIES_FILENAME; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SKIP_ACL_SETUP; +import static it.grid.storm.config.ConfigurationDefaults.SERVER_POOL_STATUS_CHECK_TIMEOUT; +import static org.junit.Assert.assertEquals; + +import java.io.File; + +import org.junit.Test; + +import com.google.common.collect.Lists; + +import it.grid.storm.config.model.OverwriteMode; +import it.grid.storm.config.model.StorageType; +import it.grid.storm.namespace.model.Authority; + +public class ConfigurationConverterTest { + + @Test + public void testLoadedConfigurationFromOldProperties() { + + Configuration.init("src/test/resources/v1.properties"); + Configuration config = Configuration.getInstance(); + + // SRM service + assertEquals(config.getSrmServiceHostname(), "fe.example.org"); + assertEquals(config.getSrmServicePort(), 8444); + assertEquals(config.getManagedSrmEndpoints(), + Lists.newArrayList(new Authority("fe.example.org", 8444), + new Authority("fe-01.example.org", 8444), + new Authority("fe-02.example.org", 8444))); + // database + assertEquals(config.getDbUsername(), "storm"); + assertEquals(config.getDbPassword(), "my-secret-password"); + assertEquals(config.getDbProperties(), DB_PROPERTIES); + assertEquals(config.getDbPort(), DB_PORT); + assertEquals(config.getDbPoolSize(), 10); + assertEquals(config.getDbPoolMinIdle(), DB_POOL_MIN_IDLE); + assertEquals(config.getDbPoolMaxWaitMillis(), 50); + assertEquals(config.isDbPoolTestOnBorrow(), DB_POOL_TEST_ON_BORROW); + assertEquals(config.isDbPoolTestWhileIdle(), DB_POOL_TEST_WHILE_IDLE); + // REST + assertEquals(config.getRestServicesPort(), 9998); + assertEquals(config.getRestServicesMaxThreads(), 256); + assertEquals(config.getRestServicesMaxQueueSize(), 1000); + // sanity check + assertEquals(config.getSanityCheckEnabled(), true); + // xmlrpc + assertEquals(config.getXmlRpcServerPort(), 8080); + assertEquals(config.getXmlrpcMaxThreads(), 100); + assertEquals(config.getXmlrpcMaxQueueSize(), 500); + assertEquals(config.getXmlRpcSecurityEnabled(), true); + assertEquals(config.getXmlRpcToken(), "abracadabra"); + // disk usage + assertEquals(config.getDiskUsageServiceEnabled(), true); + assertEquals(config.getDiskUsageServiceInitialDelay(), 60); + assertEquals(config.getDiskUsageServiceTasksInterval(), 360); + assertEquals(config.getDiskUsageServiceTasksParallel(), + DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED); + // + assertEquals(config.getCleaningInitialDelay(), 10); + assertEquals(config.getCleaningTimeInterval(), 300); + // + assertEquals(config.getFileDefaultSize(), 2000000); + assertEquals(config.getFileLifetimeDefault(), 300000); + assertEquals(config.getPinLifetimeDefault(), 310000); + assertEquals(config.getPinLifetimeMaximum(), 1900000); + + assertEquals(config.getPickingInitialDelay(), 15); + assertEquals(config.getPickingTimeInterval(), 25); + assertEquals(config.getPickingMaxBatchSize(), 150); + // LS + assertEquals(config.getLsMaxNumberOfEntry(), 3000); + assertEquals(config.getLsAllLevelRecursive(), true); + assertEquals(config.getLsNumOfLevels(), 3); + assertEquals(config.getLsOffset(), 2); + // + assertEquals(config.getPtPCorePoolSize(), 60); + assertEquals(config.getPtPMaxPoolSize(), 300); + assertEquals(config.getPtPQueueSize(), 2000); + + assertEquals(config.getPtGCorePoolSize(), 70); + assertEquals(config.getPtGMaxPoolSize(), 400); + assertEquals(config.getPtGQueueSize(), 3000); + + assertEquals(config.getBoLCorePoolSize(), 40); + assertEquals(config.getBoLMaxPoolSize(), 100); + assertEquals(config.getBoLQueueSize(), 1000); + + assertEquals(config.getCorePoolSize(), 20); + assertEquals(config.getMaxPoolSize(), 60); + assertEquals(config.getQueueSize(), 3000); + + assertEquals(config.getAutomaticDirectoryCreation(), true); + assertEquals(config.getEnableWritePermOnDirectory(), true); + + assertEquals(config.getDefaultOverwriteMode(), OverwriteMode.N); + assertEquals(config.getDefaultFileStorageType(), StorageType.P); + + assertEquals(config.getExpiredRequestPurging(), false); + assertEquals(config.getRequestPurgerDelay(), 100); + assertEquals(config.getRequestPurgerPeriod(), 600); + assertEquals(config.getPurgeBatchSize(), 1000); + assertEquals(config.getExpiredRequestTime(), 7200); + + assertEquals(config.getTransitInitialDelay(), 60); + assertEquals(config.getTransitTimeInterval(), 600); + assertEquals(config.getInProgressPtpExpirationTime(), 7000); + + assertEquals(config.getExtraSlashesForFileTURL(), "/file"); + assertEquals(config.getExtraSlashesForRFIOTURL(), "/rfio"); + assertEquals(config.getExtraSlashesForGsiFTPTURL(), "/gsiftp"); + assertEquals(config.getExtraSlashesForROOTTURL(), "/root"); + + assertEquals(config.getPingValuesPropertiesFilename(), PING_VALUES_PROPERTIES_FILENAME); + + assertEquals(config.getHearthbeatPeriod(), HEARTHBEAT_PERIOD); + assertEquals(config.getPerformanceGlanceTimeInterval(), PERFORMANCE_GLANCE_TIME_INTERVAL); + assertEquals(config.getPerformanceLogbookTimeInterval(), PERFORMANCE_LOGBOOK_TIME_INTERVAL); + assertEquals(config.getPerformanceMeasuring(), PERFORMANCE_MEASURING); + assertEquals(config.getBookKeepingEnabled(), BOOK_KEEPING_ENABLED); + + assertEquals(config.getMaxLoop(), MAX_LOOP); + + assertEquals(config.getGPFSQuotaRefreshPeriod(), GPFS_QUOTA_REFRESH_PERIOD); + + assertEquals(config.getServerPoolStatusCheckTimeout(), SERVER_POOL_STATUS_CHECK_TIMEOUT); + + assertEquals(config.getPTGSkipACLSetup(), PTG_SKIP_ACL_SETUP); + + assertEquals(config.getHTTPTURLPrefix(), HTTP_TURL_PREFIX); + + // check new file created + File exported = new File("src/test/resources/v1.properties.new"); + assertEquals(exported.exists(), true); + // clear file + exported.delete(); + + } +} diff --git a/src/test/java/it/grid/storm/config/DefaultConfigurationTest.java b/src/test/java/it/grid/storm/config/DefaultConfigurationTest.java index 3004eb48e..7111ce048 100644 --- a/src/test/java/it/grid/storm/config/DefaultConfigurationTest.java +++ b/src/test/java/it/grid/storm/config/DefaultConfigurationTest.java @@ -1,14 +1,15 @@ package it.grid.storm.config; -import static it.grid.storm.Main.DEFAULT_REFRESH_RATE; import static it.grid.storm.config.ConfigurationDefaults.AUTOMATIC_DIRECTORY_CREATION; -import static it.grid.storm.config.ConfigurationDefaults.BOL_CORE_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.BOL_MAX_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.BOL_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_QUEUE_SIZE; import static it.grid.storm.config.ConfigurationDefaults.BOOK_KEEPING_ENABLED; -import static it.grid.storm.config.ConfigurationDefaults.CLEANING_INITIAL_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.CLEANING_TIME_INTERVAL; -import static it.grid.storm.config.ConfigurationDefaults.CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_PURGE_AGE; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_PURGE_SIZE; import static it.grid.storm.config.ConfigurationDefaults.DB_PASSWORD; import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MAX_WAIT_MILLIS; import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MIN_IDLE; @@ -25,9 +26,8 @@ import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED; import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_TASKS_INTERVAL; import static it.grid.storm.config.ConfigurationDefaults.ENABLE_WRITE_PERM_ON_DIRECTORY; -import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_INPROGRESS_PTP_TIME; -import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_REQUEST_PURGING; -import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_REQUEST_TIME; +import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_SPACES_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_SPACES_AGENT_INTERVAL; import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_FILE_TURL; import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_GSIFTP_TURL; import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_RFIO_TURL; @@ -37,72 +37,70 @@ import static it.grid.storm.config.ConfigurationDefaults.GPFS_QUOTA_REFRESH_PERIOD; import static it.grid.storm.config.ConfigurationDefaults.HEARTHBEAT_PERIOD; import static it.grid.storm.config.ConfigurationDefaults.HTTP_TURL_PREFIX; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_PTP_EXPIRATION_TIME; import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_ALL_LEVEL_RECURSIVE; import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_NUM_OF_LEVELS; +import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_OFFSET; import static it.grid.storm.config.ConfigurationDefaults.LS_MAX_NUMBER_OF_ENTRY; -import static it.grid.storm.config.ConfigurationDefaults.LS_OFFSET; import static it.grid.storm.config.ConfigurationDefaults.MAX_LOOP; -import static it.grid.storm.config.ConfigurationDefaults.MAX_POOL_SIZE; import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_GLANCE_TIME_INTERVAL; import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_LOGBOOK_TIME_INTERVAL; import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_MEASURING; -import static it.grid.storm.config.ConfigurationDefaults.PICKING_INITIAL_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.PICKING_MAX_BATCH_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PICKING_TIME_INTERVAL; import static it.grid.storm.config.ConfigurationDefaults.PING_VALUES_PROPERTIES_FILENAME; import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_DEFAULT; import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_MAXIMUM; -import static it.grid.storm.config.ConfigurationDefaults.PTG_CORE_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTG_MAX_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTG_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_QUEUE_SIZE; import static it.grid.storm.config.ConfigurationDefaults.PTG_SKIP_ACL_SETUP; -import static it.grid.storm.config.ConfigurationDefaults.PTP_CORE_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTP_MAX_POOL_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PTP_QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.PURGE_BATCH_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.QUEUE_SIZE; -import static it.grid.storm.config.ConfigurationDefaults.REQUEST_PURGER_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.REQUEST_PURGER_PERIOD; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_MAX_FETCHED_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_QUEUE_SIZE; import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_QUEUE_SIZE; import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_THREADS; import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_PORT; import static it.grid.storm.config.ConfigurationDefaults.SANITY_CHECK_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.SECURITY_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.SECURITY_TOKEN; import static it.grid.storm.config.ConfigurationDefaults.SERVER_POOL_STATUS_CHECK_TIMEOUT; -import static it.grid.storm.config.ConfigurationDefaults.SERVICE_SRM_PUBLIC_PORT; -import static it.grid.storm.config.ConfigurationDefaults.TRANSIT_INITIAL_DELAY; -import static it.grid.storm.config.ConfigurationDefaults.TRANSIT_TIME_INTERVAL; import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_QUEUE_SIZE; import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_THREADS; -import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_SECURITY_ENABLED; import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_SERVER_PORT; import static org.junit.Assert.assertEquals; +import java.io.File; import java.net.InetAddress; import java.net.UnknownHostException; import org.junit.Test; -import com.google.common.collect.Lists; - -import it.grid.storm.namespace.model.Authority; +import it.grid.storm.config.model.OverwriteMode; +import it.grid.storm.config.model.StorageType; public class DefaultConfigurationTest { - static { - Configuration.init("empty.properties", DEFAULT_REFRESH_RATE); - } - @Test - public void testEmptyConfiguration() throws UnknownHostException { + public void testLoadedConfigurationFromOldProperties() throws UnknownHostException { + Configuration.init("src/test/resources/empty.properties"); Configuration config = Configuration.getInstance(); - // local FQDN hostname + String hostname = InetAddress.getLocalHost().getHostName(); + // SRM service assertEquals(config.getSrmServiceHostname(), hostname); - assertEquals(config.getSrmServicePort(), SERVICE_SRM_PUBLIC_PORT); - assertEquals(config.getManagedSrmEndpoints(), - Lists.newArrayList(new Authority(hostname, SERVICE_SRM_PUBLIC_PORT))); + assertEquals(config.getSrmServicePort(), 8444); + assertEquals(config.getManagedSrmEndpoints().size(), 1); + assertEquals(config.getManagedSrmEndpoints().get(0).getServiceHostname(), hostname); + assertEquals(config.getManagedSrmEndpoints().get(0).getServicePort(), 8444); // database assertEquals(config.getDbUsername(), DB_USERNAME); assertEquals(config.getDbPassword(), DB_PASSWORD); @@ -123,8 +121,8 @@ public void testEmptyConfiguration() throws UnknownHostException { assertEquals(config.getXmlRpcServerPort(), XMLRPC_SERVER_PORT); assertEquals(config.getXmlrpcMaxThreads(), XMLRPC_MAX_THREADS); assertEquals(config.getXmlrpcMaxQueueSize(), XMLRPC_MAX_QUEUE_SIZE); - assertEquals(config.getXmlRpcSecurityEnabled(), XMLRPC_SECURITY_ENABLED); - assertEquals(config.getXmlRpcToken(), null); + assertEquals(config.getXmlRpcSecurityEnabled(), SECURITY_ENABLED); + assertEquals(config.getXmlRpcToken(), SECURITY_TOKEN); // disk usage assertEquals(config.getDiskUsageServiceEnabled(), DISKUSAGE_SERVICE_ENABLED); assertEquals(config.getDiskUsageServiceInitialDelay(), DISKUSAGE_SERVICE_INITIAL_DELAY); @@ -132,53 +130,54 @@ public void testEmptyConfiguration() throws UnknownHostException { assertEquals(config.getDiskUsageServiceTasksParallel(), DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED); // - assertEquals(config.getCleaningInitialDelay(), CLEANING_INITIAL_DELAY); - assertEquals(config.getCleaningTimeInterval(), CLEANING_TIME_INTERVAL); + assertEquals(config.getCleaningInitialDelay(), EXPIRED_SPACES_AGENT_DELAY); + assertEquals(config.getCleaningTimeInterval(), EXPIRED_SPACES_AGENT_INTERVAL); // assertEquals(config.getFileDefaultSize(), FILE_DEFAULT_SIZE); assertEquals(config.getFileLifetimeDefault(), FILE_LIFETIME_DEFAULT); assertEquals(config.getPinLifetimeDefault(), PIN_LIFETIME_DEFAULT); assertEquals(config.getPinLifetimeMaximum(), PIN_LIFETIME_MAXIMUM); - assertEquals(config.getTransitInitialDelay(), TRANSIT_INITIAL_DELAY); - assertEquals(config.getTransitTimeInterval(), TRANSIT_TIME_INTERVAL); - assertEquals(config.getPickingInitialDelay(), PICKING_INITIAL_DELAY); - assertEquals(config.getPickingTimeInterval(), PICKING_TIME_INTERVAL); - assertEquals(config.getPickingMaxBatchSize(), PICKING_MAX_BATCH_SIZE); + + assertEquals(config.getPickingInitialDelay(), REQUESTS_PICKER_AGENT_DELAY); + assertEquals(config.getPickingTimeInterval(), REQUESTS_PICKER_AGENT_INTERVAL); + assertEquals(config.getPickingMaxBatchSize(), REQUESTS_PICKER_AGENT_MAX_FETCHED_SIZE); // LS assertEquals(config.getLsMaxNumberOfEntry(), LS_MAX_NUMBER_OF_ENTRY); assertEquals(config.getLsAllLevelRecursive(), LS_DEFAULT_ALL_LEVEL_RECURSIVE); assertEquals(config.getLsNumOfLevels(), LS_DEFAULT_NUM_OF_LEVELS); - assertEquals(config.getLsOffset(), LS_OFFSET); + assertEquals(config.getLsOffset(), LS_DEFAULT_OFFSET); // - assertEquals(config.getPtPCorePoolSize(), PTP_CORE_POOL_SIZE); - assertEquals(config.getPtPMaxPoolSize(), PTP_MAX_POOL_SIZE); - assertEquals(config.getPtPQueueSize(), PTP_QUEUE_SIZE); + assertEquals(config.getPtPCorePoolSize(), PTP_SCHEDULER_CORE_POOL_SIZE); + assertEquals(config.getPtPMaxPoolSize(), PTP_SCHEDULER_MAX_POOL_SIZE); + assertEquals(config.getPtPQueueSize(), PTP_SCHEDULER_QUEUE_SIZE); - assertEquals(config.getPtGCorePoolSize(), PTG_CORE_POOL_SIZE); - assertEquals(config.getPtGMaxPoolSize(), PTG_MAX_POOL_SIZE); - assertEquals(config.getPtGQueueSize(), PTG_QUEUE_SIZE); + assertEquals(config.getPtGCorePoolSize(), PTG_SCHEDULER_CORE_POOL_SIZE); + assertEquals(config.getPtGMaxPoolSize(), PTG_SCHEDULER_MAX_POOL_SIZE); + assertEquals(config.getPtGQueueSize(), PTG_SCHEDULER_QUEUE_SIZE); - assertEquals(config.getBoLCorePoolSize(), BOL_CORE_POOL_SIZE); - assertEquals(config.getBoLMaxPoolSize(), BOL_MAX_POOL_SIZE); - assertEquals(config.getBoLQueueSize(), BOL_QUEUE_SIZE); + assertEquals(config.getBoLCorePoolSize(), BOL_SCHEDULER_CORE_POOL_SIZE); + assertEquals(config.getBoLMaxPoolSize(), BOL_SCHEDULER_MAX_POOL_SIZE); + assertEquals(config.getBoLQueueSize(), BOL_SCHEDULER_QUEUE_SIZE); - assertEquals(config.getCorePoolSize(), CORE_POOL_SIZE); - assertEquals(config.getMaxPoolSize(), MAX_POOL_SIZE); - assertEquals(config.getQueueSize(), QUEUE_SIZE); + assertEquals(config.getCorePoolSize(), REQUESTS_SCHEDULER_CORE_POOL_SIZE); + assertEquals(config.getMaxPoolSize(), REQUESTS_SCHEDULER_MAX_POOL_SIZE); + assertEquals(config.getQueueSize(), REQUESTS_SCHEDULER_QUEUE_SIZE); assertEquals(config.getAutomaticDirectoryCreation(), AUTOMATIC_DIRECTORY_CREATION); assertEquals(config.getEnableWritePermOnDirectory(), ENABLE_WRITE_PERM_ON_DIRECTORY); - assertEquals(config.getDefaultOverwriteMode(), DEFAULT_OVERWRITE_MODE); - assertEquals(config.getDefaultFileStorageType(), DEFAULT_FILE_STORAGE_TYPE); + assertEquals(config.getDefaultOverwriteMode(), OverwriteMode.valueOf(DEFAULT_OVERWRITE_MODE)); + assertEquals(config.getDefaultFileStorageType(), StorageType.valueOf(DEFAULT_FILE_STORAGE_TYPE)); - assertEquals(config.getPurgeBatchSize(), PURGE_BATCH_SIZE); + assertEquals(config.getExpiredRequestPurging(), COMPLETED_REQUESTS_AGENT_ENABLED); + assertEquals(config.getRequestPurgerDelay(), COMPLETED_REQUESTS_AGENT_DELAY); + assertEquals(config.getRequestPurgerPeriod(), COMPLETED_REQUESTS_AGENT_INTERVAL); + assertEquals(config.getPurgeBatchSize(), COMPLETED_REQUESTS_AGENT_PURGE_SIZE); + assertEquals(config.getExpiredRequestTime(), COMPLETED_REQUESTS_AGENT_PURGE_AGE); - assertEquals(config.getExpiredRequestPurging(), EXPIRED_REQUEST_PURGING); - assertEquals(config.getExpiredRequestTime(), EXPIRED_REQUEST_TIME); - assertEquals(config.getRequestPurgerDelay(), REQUEST_PURGER_DELAY); - assertEquals(config.getRequestPurgerPeriod(), REQUEST_PURGER_PERIOD); - assertEquals(config.getInProgressPtpExpirationTime(), EXPIRED_INPROGRESS_PTP_TIME); + assertEquals(config.getTransitInitialDelay(), INPROGRESS_REQUESTS_AGENT_DELAY); + assertEquals(config.getTransitTimeInterval(), INPROGRESS_REQUESTS_AGENT_INTERVAL); + assertEquals(config.getInProgressPtpExpirationTime(), INPROGRESS_REQUESTS_AGENT_PTP_EXPIRATION_TIME); assertEquals(config.getExtraSlashesForFileTURL(), EXTRA_SLASHES_FOR_FILE_TURL); assertEquals(config.getExtraSlashesForRFIOTURL(), EXTRA_SLASHES_FOR_RFIO_TURL); @@ -203,5 +202,11 @@ public void testEmptyConfiguration() throws UnknownHostException { assertEquals(config.getHTTPTURLPrefix(), HTTP_TURL_PREFIX); + // check new file created + File exported = new File("src/test/resources/empty.properties.new"); + assertEquals(exported.exists(), true); + // clear file + exported.delete(); + } } diff --git a/src/test/java/it/grid/storm/config/model/StormPropertiesTest.java b/src/test/java/it/grid/storm/config/model/StormPropertiesTest.java new file mode 100644 index 000000000..78a17d3d1 --- /dev/null +++ b/src/test/java/it/grid/storm/config/model/StormPropertiesTest.java @@ -0,0 +1,295 @@ +package it.grid.storm.config.model; + +import static it.grid.storm.config.ConfigurationDefaults.AUTOMATIC_DIRECTORY_CREATION; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOL_SCHEDULER_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.BOOK_KEEPING_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_PURGE_AGE; +import static it.grid.storm.config.ConfigurationDefaults.COMPLETED_REQUESTS_AGENT_PURGE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.DB_PASSWORD; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MAX_WAIT_MILLIS; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_MIN_IDLE; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_ON_BORROW; +import static it.grid.storm.config.ConfigurationDefaults.DB_POOL_TEST_WHILE_IDLE; +import static it.grid.storm.config.ConfigurationDefaults.DB_PORT; +import static it.grid.storm.config.ConfigurationDefaults.DB_PROPERTIES; +import static it.grid.storm.config.ConfigurationDefaults.DB_USERNAME; +import static it.grid.storm.config.ConfigurationDefaults.DEFAULT_FILE_STORAGE_TYPE; +import static it.grid.storm.config.ConfigurationDefaults.DEFAULT_OVERWRITE_MODE; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_INITIAL_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.DISKUSAGE_SERVICE_TASKS_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.ENABLE_WRITE_PERM_ON_DIRECTORY; +import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_SPACES_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.EXPIRED_SPACES_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_FILE_TURL; +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_GSIFTP_TURL; +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_RFIO_TURL; +import static it.grid.storm.config.ConfigurationDefaults.EXTRA_SLASHES_FOR_ROOT_TURL; +import static it.grid.storm.config.ConfigurationDefaults.FILE_DEFAULT_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.FILE_LIFETIME_DEFAULT; +import static it.grid.storm.config.ConfigurationDefaults.GPFS_QUOTA_REFRESH_PERIOD; +import static it.grid.storm.config.ConfigurationDefaults.HEARTHBEAT_PERIOD; +import static it.grid.storm.config.ConfigurationDefaults.HTTP_TURL_PREFIX; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.INPROGRESS_REQUESTS_AGENT_PTP_EXPIRATION_TIME; +import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_ALL_LEVEL_RECURSIVE; +import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_NUM_OF_LEVELS; +import static it.grid.storm.config.ConfigurationDefaults.LS_DEFAULT_OFFSET; +import static it.grid.storm.config.ConfigurationDefaults.LS_MAX_NUMBER_OF_ENTRY; +import static it.grid.storm.config.ConfigurationDefaults.MAX_LOOP; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_GLANCE_TIME_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_LOGBOOK_TIME_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.PERFORMANCE_MEASURING; +import static it.grid.storm.config.ConfigurationDefaults.PING_VALUES_PROPERTIES_FILENAME; +import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_DEFAULT; +import static it.grid.storm.config.ConfigurationDefaults.PIN_LIFETIME_MAXIMUM; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SCHEDULER_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTG_SKIP_ACL_SETUP; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.PTP_SCHEDULER_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_DELAY; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_INTERVAL; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_PICKER_AGENT_MAX_FETCHED_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_CORE_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_MAX_POOL_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REQUESTS_SCHEDULER_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_MAX_THREADS; +import static it.grid.storm.config.ConfigurationDefaults.REST_SERVICES_PORT; +import static it.grid.storm.config.ConfigurationDefaults.SANITY_CHECK_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.SECURITY_ENABLED; +import static it.grid.storm.config.ConfigurationDefaults.SECURITY_TOKEN; +import static it.grid.storm.config.ConfigurationDefaults.SERVER_POOL_STATUS_CHECK_TIMEOUT; +import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_QUEUE_SIZE; +import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_MAX_THREADS; +import static it.grid.storm.config.ConfigurationDefaults.XMLRPC_SERVER_PORT; +import static it.grid.storm.config.model.StormProperties.UNRECOGNIZED_VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.File; +import java.io.IOException; +import java.net.InetAddress; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper; + +public class StormPropertiesTest { + + private static final Logger log = LoggerFactory.getLogger(StormPropertiesTest.class); + + @Test + public void testConfigurationLoadFromPropertiesV2() throws JsonParseException, JsonMappingException, IOException { + + JavaPropsMapper mapper = new JavaPropsMapper(); + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("storm.properties").getFile()); + StormProperties properties = mapper.readValue(file, StormProperties.class); + properties.log(log); + assertEquals(properties.version, "2"); + assertFalse(properties.srmEndpoints.isEmpty()); + assertEquals(properties.srmEndpoints.size(), 2); + assertEquals(properties.srmEndpoints.get(0).host, "storm.example"); + assertEquals(properties.srmEndpoints.get(0).port, 8444); + assertEquals(properties.srmEndpoints.get(1).host, "alias.example"); + assertEquals(properties.srmEndpoints.get(1).port, 8445); + assertEquals(properties.db.hostname, "storm.example"); + assertEquals(properties.db.username, "test"); + assertEquals(properties.db.password, "secret"); + assertEquals(properties.db.port, 3308); + assertEquals(properties.db.properties, "test"); + assertEquals(properties.db.pool.size, 200); + assertEquals(properties.db.pool.maxWaitMillis, 1200); + assertEquals(properties.db.pool.testOnBorrow, false); + assertEquals(properties.db.pool.testWhileIdle, false); + assertEquals(properties.rest.port, 9999); + assertEquals(properties.rest.maxThreads, 150); + assertEquals(properties.rest.maxQueueSize, 1500); + assertEquals(properties.xmlrpc.port, 9090); + assertEquals(properties.xmlrpc.maxThreads, 512); + assertEquals(properties.xmlrpc.maxQueueSize, 2000); + assertEquals(properties.security.enabled, true); + assertEquals(properties.security.token, "ilovejava"); + assertEquals(properties.du.enabled, true); + assertEquals(properties.du.parallelTasksEnabled, true); + assertEquals(properties.du.initialDelay, 120); + assertEquals(properties.du.tasksInterval, 200000); + assertEquals(properties.inprogressRequestsAgent.delay, 20); + assertEquals(properties.inprogressRequestsAgent.interval, 400); + assertEquals(properties.inprogressRequestsAgent.ptpExpirationTime, 333000); + assertEquals(properties.expiredSpacesAgent.delay, 20); + assertEquals(properties.expiredSpacesAgent.interval, 400); + assertEquals(properties.completedRequestsAgent.enabled, true); + assertEquals(properties.completedRequestsAgent.delay, 20); + assertEquals(properties.completedRequestsAgent.interval, 400); + assertEquals(properties.completedRequestsAgent.purgeSize, 1800); + assertEquals(properties.completedRequestsAgent.purgeAge, 22200); + assertEquals(properties.completedRequestsAgent.isDynamic, true); + assertEquals(properties.requestsScheduler.corePoolSize, 10); + assertEquals(properties.requestsScheduler.maxPoolSize, 50); + assertEquals(properties.requestsScheduler.queueSize, 2000); + assertEquals(properties.ptpScheduler.corePoolSize, 50); + assertEquals(properties.ptpScheduler.maxPoolSize, 200); + assertEquals(properties.ptpScheduler.queueSize, 1000); + assertEquals(properties.ptgScheduler.corePoolSize, 50); + assertEquals(properties.ptgScheduler.maxPoolSize, 200); + assertEquals(properties.ptgScheduler.queueSize, 2000); + assertEquals(properties.bolScheduler.corePoolSize, 50); + assertEquals(properties.bolScheduler.maxPoolSize, 200); + assertEquals(properties.bolScheduler.queueSize, 2000); + assertEquals(properties.requestsPickerAgent.delay, 10); + assertEquals(properties.requestsPickerAgent.interval, 20); + assertEquals(properties.requestsPickerAgent.maxFetchedSize, 1000); + assertEquals(properties.sanityChecksEnabled, false); + assertEquals(properties.extraslashes.file, "/file"); + assertEquals(properties.extraslashes.rfio, "/rfio"); + assertEquals(properties.extraslashes.root, "/root"); + assertEquals(properties.extraslashes.gsiftp, "/gsiftp"); + assertEquals(properties.synchLs.defaultAllLevelRecursive, true); + assertEquals(properties.synchLs.defaultNumLevels, 2); + assertEquals(properties.synchLs.defaultOffset, 1); + assertEquals(properties.synchLs.maxEntries, 3000); + assertEquals(properties.pinlifetime.defaultValue, 300000); + assertEquals(properties.pinlifetime.maximum, 18000000); + assertEquals(properties.skipPtgAclSetup, true); + assertEquals(properties.files.defaultSize, 100000); + assertEquals(properties.files.defaultLifetime, 300000); + assertEquals(properties.files.defaultOverwrite, "N"); + assertEquals(properties.files.defaultStoragetype, "P"); + assertEquals(properties.directories.enableAutomaticCreation, true); + assertEquals(properties.directories.enableWritepermOnCreation, true); + assertEquals(properties.hearthbeat.bookkeepingEnabled, true); + assertEquals(properties.hearthbeat.performanceMeasuringEnabled, true); + assertEquals(properties.hearthbeat.period, 30); + assertEquals(properties.hearthbeat.performanceLogbookTimeInterval, 10); + assertEquals(properties.hearthbeat.performanceGlanceTimeInterval, 10); + assertEquals(properties.infoQuotaRefreshPeriod, 900); + assertEquals(properties.httpTurlPrefix, "/"); + assertEquals(properties.serverPoolStatusCheckTimeout, 20000); + assertEquals(properties.abortMaxloop, 10); + assertEquals(properties.pingPropertiesFilename, "ping-values.properties"); + + } + + @Test + public void testEmptyConfiguration() + throws JsonParseException, JsonMappingException, IOException { + + String hostname = InetAddress.getLocalHost().getHostName(); + JavaPropsMapper mapper = new JavaPropsMapper(); + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("empty.properties").getFile()); + StormProperties properties = mapper.readValue(file, StormProperties.class); + assertEquals(properties.version, UNRECOGNIZED_VERSION); + assertFalse(properties.srmEndpoints.isEmpty()); + assertEquals(properties.srmEndpoints.size(), 1); + assertEquals(properties.srmEndpoints.get(0).host, hostname); + assertEquals(properties.srmEndpoints.get(0).port, 8444); + assertEquals(properties.db.hostname, hostname); + assertEquals(properties.db.username, DB_USERNAME); + assertEquals(properties.db.password, DB_PASSWORD); + assertEquals(properties.db.port, DB_PORT); + assertEquals(properties.db.properties, DB_PROPERTIES); + assertEquals(properties.db.pool.size, DB_POOL_SIZE); + assertEquals(properties.db.pool.maxWaitMillis, DB_POOL_MAX_WAIT_MILLIS); + assertEquals(properties.db.pool.minIdle, DB_POOL_MIN_IDLE); + assertEquals(properties.db.pool.testOnBorrow, DB_POOL_TEST_ON_BORROW); + assertEquals(properties.db.pool.testWhileIdle, DB_POOL_TEST_WHILE_IDLE); + assertEquals(properties.rest.port, REST_SERVICES_PORT); + assertEquals(properties.rest.maxThreads, REST_SERVICES_MAX_THREADS); + assertEquals(properties.rest.maxQueueSize, REST_SERVICES_MAX_QUEUE_SIZE); + assertEquals(properties.xmlrpc.port, XMLRPC_SERVER_PORT); + assertEquals(properties.xmlrpc.maxThreads, XMLRPC_MAX_THREADS); + assertEquals(properties.xmlrpc.maxQueueSize, XMLRPC_MAX_QUEUE_SIZE); + assertEquals(properties.security.enabled, SECURITY_ENABLED); + assertEquals(properties.security.token, SECURITY_TOKEN); + assertEquals(properties.du.enabled, DISKUSAGE_SERVICE_ENABLED); + assertEquals(properties.du.parallelTasksEnabled, DISKUSAGE_SERVICE_PARALLEL_TASKS_ENABLED); + assertEquals(properties.du.initialDelay, DISKUSAGE_SERVICE_INITIAL_DELAY); + assertEquals(properties.du.tasksInterval, DISKUSAGE_SERVICE_TASKS_INTERVAL); + assertEquals(properties.inprogressRequestsAgent.delay, INPROGRESS_REQUESTS_AGENT_DELAY); + assertEquals(properties.inprogressRequestsAgent.interval, INPROGRESS_REQUESTS_AGENT_INTERVAL); + assertEquals(properties.inprogressRequestsAgent.ptpExpirationTime, + INPROGRESS_REQUESTS_AGENT_PTP_EXPIRATION_TIME); + assertEquals(properties.expiredSpacesAgent.delay, EXPIRED_SPACES_AGENT_DELAY); + assertEquals(properties.expiredSpacesAgent.interval, EXPIRED_SPACES_AGENT_INTERVAL); + assertEquals(properties.completedRequestsAgent.enabled, COMPLETED_REQUESTS_AGENT_ENABLED); + assertEquals(properties.completedRequestsAgent.delay, COMPLETED_REQUESTS_AGENT_DELAY); + assertEquals(properties.completedRequestsAgent.interval, COMPLETED_REQUESTS_AGENT_INTERVAL); + assertEquals(properties.completedRequestsAgent.purgeSize, COMPLETED_REQUESTS_AGENT_PURGE_SIZE); + assertEquals(properties.completedRequestsAgent.purgeAge, COMPLETED_REQUESTS_AGENT_PURGE_AGE); + assertEquals(properties.completedRequestsAgent.isDynamic, COMPLETED_REQUESTS_AGENT_ENABLED); + assertEquals(properties.requestsScheduler.corePoolSize, REQUESTS_SCHEDULER_CORE_POOL_SIZE); + assertEquals(properties.requestsScheduler.maxPoolSize, REQUESTS_SCHEDULER_MAX_POOL_SIZE); + assertEquals(properties.requestsScheduler.queueSize, REQUESTS_SCHEDULER_QUEUE_SIZE); + assertEquals(properties.ptpScheduler.corePoolSize, PTP_SCHEDULER_CORE_POOL_SIZE); + assertEquals(properties.ptpScheduler.maxPoolSize, PTP_SCHEDULER_MAX_POOL_SIZE); + assertEquals(properties.ptpScheduler.queueSize, PTP_SCHEDULER_QUEUE_SIZE); + assertEquals(properties.ptgScheduler.corePoolSize, PTG_SCHEDULER_CORE_POOL_SIZE); + assertEquals(properties.ptgScheduler.maxPoolSize, PTG_SCHEDULER_MAX_POOL_SIZE); + assertEquals(properties.ptgScheduler.queueSize, PTG_SCHEDULER_QUEUE_SIZE); + assertEquals(properties.bolScheduler.corePoolSize, BOL_SCHEDULER_CORE_POOL_SIZE); + assertEquals(properties.bolScheduler.maxPoolSize, BOL_SCHEDULER_MAX_POOL_SIZE); + assertEquals(properties.bolScheduler.queueSize, BOL_SCHEDULER_QUEUE_SIZE); + assertEquals(properties.requestsPickerAgent.delay, REQUESTS_PICKER_AGENT_DELAY); + assertEquals(properties.requestsPickerAgent.interval, REQUESTS_PICKER_AGENT_INTERVAL); + assertEquals(properties.requestsPickerAgent.maxFetchedSize, + REQUESTS_PICKER_AGENT_MAX_FETCHED_SIZE); + assertEquals(properties.sanityChecksEnabled, SANITY_CHECK_ENABLED); + assertEquals(properties.extraslashes.file, EXTRA_SLASHES_FOR_FILE_TURL); + assertEquals(properties.extraslashes.rfio, EXTRA_SLASHES_FOR_RFIO_TURL); + assertEquals(properties.extraslashes.root, EXTRA_SLASHES_FOR_ROOT_TURL); + assertEquals(properties.extraslashes.gsiftp, EXTRA_SLASHES_FOR_GSIFTP_TURL); + assertEquals(properties.synchLs.defaultAllLevelRecursive, LS_DEFAULT_ALL_LEVEL_RECURSIVE); + assertEquals(properties.synchLs.defaultNumLevels, LS_DEFAULT_NUM_OF_LEVELS); + assertEquals(properties.synchLs.defaultOffset, LS_DEFAULT_OFFSET); + assertEquals(properties.synchLs.maxEntries, LS_MAX_NUMBER_OF_ENTRY); + assertEquals(properties.pinlifetime.defaultValue, PIN_LIFETIME_DEFAULT); + assertEquals(properties.pinlifetime.maximum, PIN_LIFETIME_MAXIMUM); + assertEquals(properties.skipPtgAclSetup, PTG_SKIP_ACL_SETUP); + assertEquals(properties.files.defaultSize, FILE_DEFAULT_SIZE); + assertEquals(properties.files.defaultLifetime, FILE_LIFETIME_DEFAULT); + assertEquals(properties.files.defaultOverwrite, DEFAULT_OVERWRITE_MODE); + assertEquals(properties.files.defaultStoragetype, DEFAULT_FILE_STORAGE_TYPE); + assertEquals(properties.directories.enableAutomaticCreation, AUTOMATIC_DIRECTORY_CREATION); + assertEquals(properties.directories.enableWritepermOnCreation, ENABLE_WRITE_PERM_ON_DIRECTORY); + assertEquals(properties.hearthbeat.bookkeepingEnabled, BOOK_KEEPING_ENABLED); + assertEquals(properties.hearthbeat.performanceMeasuringEnabled, PERFORMANCE_MEASURING); + assertEquals(properties.hearthbeat.period, HEARTHBEAT_PERIOD); + assertEquals(properties.hearthbeat.performanceLogbookTimeInterval, + PERFORMANCE_LOGBOOK_TIME_INTERVAL); + assertEquals(properties.hearthbeat.performanceGlanceTimeInterval, + PERFORMANCE_GLANCE_TIME_INTERVAL); + assertEquals(properties.infoQuotaRefreshPeriod, GPFS_QUOTA_REFRESH_PERIOD); + assertEquals(properties.httpTurlPrefix, HTTP_TURL_PREFIX); + assertEquals(properties.serverPoolStatusCheckTimeout, SERVER_POOL_STATUS_CHECK_TIMEOUT); + assertEquals(properties.abortMaxloop, MAX_LOOP); + assertEquals(properties.pingPropertiesFilename, PING_VALUES_PROPERTIES_FILENAME); + } + + @Test + public void testNewConfigurationVersionOverOldFile() throws JsonParseException, JsonMappingException, IOException { + + JavaPropsMapper mapper = new JavaPropsMapper(); + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("v1.properties").getFile()); + StormProperties properties = mapper.readValue(file, StormProperties.class); + assertEquals(properties.version, UNRECOGNIZED_VERSION); + } +} diff --git a/src/test/java/it/grid/storm/persistence/converter/OverwriteModeConverterTest.java b/src/test/java/it/grid/storm/persistence/converter/OverwriteModeConverterTest.java new file mode 100644 index 000000000..688440b9b --- /dev/null +++ b/src/test/java/it/grid/storm/persistence/converter/OverwriteModeConverterTest.java @@ -0,0 +1,30 @@ +package it.grid.storm.persistence.converter; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import it.grid.storm.config.model.OverwriteMode; +import it.grid.storm.srm.types.TOverwriteMode; + +public class OverwriteModeConverterTest { + + @Test + public void ConvertFromDb() { + + assertEquals(TOverwriteMode.ALWAYS, OverwriteModeConverter.toSTORM(OverwriteMode.A)); + assertEquals(TOverwriteMode.NEVER, OverwriteModeConverter.toSTORM(OverwriteMode.N)); + assertEquals(TOverwriteMode.WHENFILESAREDIFFERENT, OverwriteModeConverter.toSTORM(OverwriteMode.D)); + } + + @Test + public void ConvertToDb() { + + assertEquals(OverwriteMode.A, OverwriteModeConverter.toDB(TOverwriteMode.ALWAYS)); + assertEquals(OverwriteMode.N, OverwriteModeConverter.toDB(TOverwriteMode.NEVER)); + assertEquals(OverwriteMode.D, OverwriteModeConverter.toDB(TOverwriteMode.WHENFILESAREDIFFERENT)); + assertEquals(OverwriteMode.A.name(), "A"); + assertEquals(OverwriteMode.N.name(), "N"); + assertEquals(OverwriteMode.D.name(), "D"); + } +} diff --git a/src/test/java/it/grid/storm/rest/auth/RestTokenFilterTest.java b/src/test/java/it/grid/storm/rest/auth/RestTokenFilterTest.java index 3a7b11285..a8c9998da 100644 --- a/src/test/java/it/grid/storm/rest/auth/RestTokenFilterTest.java +++ b/src/test/java/it/grid/storm/rest/auth/RestTokenFilterTest.java @@ -1,6 +1,5 @@ package it.grid.storm.rest.auth; -import static it.grid.storm.Main.DEFAULT_REFRESH_RATE; import static it.grid.storm.rest.auth.RestTokenFilter.TOKEN_HEADER_NAME; import static it.grid.storm.rest.auth.RestTokenFilter.TOKEN_INIT_PARAM_NAME; import static javax.ws.rs.core.Response.Status.UNAUTHORIZED; @@ -21,6 +20,7 @@ import org.eclipse.jetty.servlet.FilterHolder; import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -33,10 +33,6 @@ public class RestTokenFilterTest { private final static String TMP_FILENAME = "tmp.txt"; - static { - Configuration.init("storm.properties", DEFAULT_REFRESH_RATE); - } - private HttpServletRequest getMockRequest(String token) { HttpServletRequest request = Mockito.mock(HttpServletRequest.class); Mockito.when(request.getHeader(TOKEN_HEADER_NAME)).thenReturn(token); @@ -62,6 +58,12 @@ private RestTokenFilter getRestTokenFilter(String token) throws Exception { return (RestTokenFilter) filterHolder.getFilter(); } + @Before + public void init() { + + Configuration.init("src/test/resources/storm.properties"); + } + @Test public void testMisconfiguration() throws Exception { diff --git a/src/test/java/it/grid/storm/rest/metadata/MetadataTests.java b/src/test/java/it/grid/storm/rest/metadata/MetadataTests.java index 966f275df..c8ca76582 100644 --- a/src/test/java/it/grid/storm/rest/metadata/MetadataTests.java +++ b/src/test/java/it/grid/storm/rest/metadata/MetadataTests.java @@ -14,6 +14,7 @@ import org.junit.Test; import org.mockito.Mockito; +import it.grid.storm.config.Configuration; import it.grid.storm.filesystem.FSException; import it.grid.storm.filesystem.FilesystemError; import it.grid.storm.namespace.NamespaceException; @@ -37,7 +38,7 @@ public class MetadataTests { private VirtualFSInterface vfs; private StoriMetadata expected; - + private VirtualFSInterface getVirtualFS(String name, String rootPath) throws NamespaceException { VirtualFSInterface vfs = Mockito.mock(VirtualFSInterface.class); @@ -80,6 +81,9 @@ private Metadata getMetadataServlet(StoriMetadataService s) { @Before public void init() throws NamespaceException { + + Configuration.init("src/test/resources/storm.properties"); + vfs = getVirtualFS(VFS_NAME, VFS_ROOTPATH); expected = StoriMetadata.builder() .absolutePath(FILE_PATH) diff --git a/src/test/java/it/grid/storm/rest/metadata/ResourceServiceTest.java b/src/test/java/it/grid/storm/rest/metadata/ResourceServiceTest.java index 989f5786c..8189ed657 100644 --- a/src/test/java/it/grid/storm/rest/metadata/ResourceServiceTest.java +++ b/src/test/java/it/grid/storm/rest/metadata/ResourceServiceTest.java @@ -104,7 +104,7 @@ private ResourceService getStoRIResourceServiceNoVFSs() throws NamespaceExceptio return new ResourceService(Collections.emptyList(), Lists.newArrayList(rule)); } - + @Before public void initLocalTmpDirectory() throws IOException { new File(DIR_PATH).mkdirs(); diff --git a/src/test/java/it/grid/storm/tape/recalltable/resources/TaskResourceTest.java b/src/test/java/it/grid/storm/tape/recalltable/resources/TaskResourceTest.java index 8ec1c71a3..0808b69aa 100644 --- a/src/test/java/it/grid/storm/tape/recalltable/resources/TaskResourceTest.java +++ b/src/test/java/it/grid/storm/tape/recalltable/resources/TaskResourceTest.java @@ -1,6 +1,5 @@ package it.grid.storm.tape.recalltable.resources; -import static it.grid.storm.Main.DEFAULT_REFRESH_RATE; import static it.grid.storm.persistence.model.TapeRecallTO.RecallTaskType.BOL; import static it.grid.storm.persistence.model.TapeRecallTO.RecallTaskType.PTG; import static it.grid.storm.tape.recalltable.resources.TaskInsertRequest.MAX_RETRY_ATTEMPTS; @@ -32,7 +31,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; -import it.grid.storm.config.Configuration; import it.grid.storm.griduser.VONameMatchingRule; import it.grid.storm.namespace.NamespaceException; import it.grid.storm.namespace.StoRI; @@ -58,19 +56,11 @@ public class TaskResourceTest { private static final String FILE_PATH = "/storage/test.vo/path/to/filename.dat"; private static final String STFN_PATH = "/test.vo/path/to/filename.dat"; - private VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); - - private StoRI STORI = getStoRI(VFS); - private UUID groupTaskID = UUID.randomUUID(); private TapeRecallCatalog RECALL_CATALOG = getTapeRecallCatalogInsertSuccess(groupTaskID); private TapeRecallCatalog BROKEN_RECALL_CATALOG = getTapeRecallCatalogInsertError(); - static { - Configuration.init("storm.properties", DEFAULT_REFRESH_RATE); - } - private TapeRecallTO createRandom(Date date, String voName) { TapeRecallTO result = new TapeRecallTO(); @@ -176,11 +166,11 @@ private TaskResource getTaskResource(ResourceService service, TapeRecallCatalog return new TaskResource(service, catalog); } - private void testGETTaskInfo(Response res) + private void testGETTaskInfo(Response res, StoRI stori) throws InvalidTRequestTokenAttributesException, DataAccessException, JsonParseException, JsonMappingException, IOException, NamespaceException, ResourceNotFoundException { - TaskResource recallEndpoint = getTaskResource(getResourceService(STORI), RECALL_CATALOG); + TaskResource recallEndpoint = getTaskResource(getResourceService(stori), RECALL_CATALOG); // extract response data URI location = URI.create(res.getHeaderString("Location")); @@ -209,6 +199,8 @@ public void testPOSTSuccess() throws DataAccessException, NamespaceException, JsonParseException, JsonMappingException, IOException, InvalidTRequestTokenAttributesException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = getTaskResource(getResourceService(STORI), RECALL_CATALOG); TaskInsertRequest request = TaskInsertRequest.builder() .stfn(STFN_PATH) @@ -221,7 +213,7 @@ public void testPOSTSuccess() assertNotNull(res.getHeaderString("Location")); assertEquals(res.getStatus(), CREATED.getStatusCode()); - testGETTaskInfo(res); + testGETTaskInfo(res, STORI); } @Test @@ -229,6 +221,8 @@ public void testPOSTSuccessWithNullVoName() throws DataAccessException, NamespaceException, JsonParseException, JsonMappingException, IOException, InvalidTRequestTokenAttributesException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = getTaskResource(getResourceService(STORI), RECALL_CATALOG); TaskInsertRequest request = TaskInsertRequest.builder() .stfn(STFN_PATH) @@ -241,7 +235,7 @@ public void testPOSTSuccessWithNullVoName() assertNotNull(res.getHeaderString("Location")); assertEquals(res.getStatus(), CREATED.getStatusCode()); - testGETTaskInfo(res); + testGETTaskInfo(res, STORI); } @Test @@ -270,6 +264,8 @@ public void testPOSTNamespaceErrorOnResolvingStfnPath() public void testPOSTBadVoNameRequested() throws DataAccessException, NamespaceException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = new TaskResource(getResourceService(STORI), RECALL_CATALOG); TaskInsertRequest request = TaskInsertRequest.builder() .stfn(STFN_PATH) @@ -306,6 +302,8 @@ public void testPOSTUnableToMapStfnPath() public void testPOSTDbException() throws DataAccessException, NamespaceException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = new TaskResource(getResourceService(STORI), BROKEN_RECALL_CATALOG); TaskInsertRequest request = TaskInsertRequest.builder() @@ -327,6 +325,8 @@ public void testPOSTDbException() public void testPOSTValidationRequestNullFilePath() throws DataAccessException, NamespaceException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = new TaskResource(getResourceService(STORI), BROKEN_RECALL_CATALOG); TaskInsertRequest request = TaskInsertRequest.builder().userId("test").build(); @@ -343,6 +343,8 @@ public void testPOSTValidationRequestNullFilePath() public void testPOSTValidationRequestNullUserId() throws DataAccessException, NamespaceException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = new TaskResource(getResourceService(STORI), BROKEN_RECALL_CATALOG); TaskInsertRequest request = TaskInsertRequest.builder().stfn(STFN_PATH).build(); @@ -359,6 +361,8 @@ public void testPOSTValidationRequestNullUserId() public void testPOSTValidationRequestInvalidNegativeRetryAttempts() throws DataAccessException, NamespaceException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = new TaskResource(getResourceService(STORI), BROKEN_RECALL_CATALOG); TaskInsertRequest request = @@ -377,6 +381,8 @@ public void testPOSTValidationRequestInvalidNegativeRetryAttempts() public void testPOSTValidationRequestInvalidTooManyRetryAttempts() throws DataAccessException, NamespaceException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = new TaskResource(getResourceService(STORI), BROKEN_RECALL_CATALOG); TaskInsertRequest request = TaskInsertRequest.builder() @@ -407,6 +413,8 @@ public void testGETTasksInProgressEmpty() throws DataAccessException, NamespaceException, JsonParseException, JsonMappingException, IOException, InvalidTRequestTokenAttributesException, ResourceNotFoundException { + VirtualFSInterface VFS = getVirtualFS(VFS_NAME, VFS_ROOTPATH, VFS_VONAME); + StoRI STORI = getStoRI(VFS); TaskResource recallEndpoint = getTaskResource(getResourceService(STORI), getTapeRecallCatalogInProgressNotEmpty()); Response res = recallEndpoint.getTasks(10); diff --git a/src/test/resources/storm.properties b/src/test/resources/storm.properties index 95b15e876..cbfcea85f 100644 --- a/src/test/resources/storm.properties +++ b/src/test/resources/storm.properties @@ -1,8 +1,104 @@ -srm_public_host = storm.example -srm_public_port = 8444 -srm_endpoints = storm.example:8444 -db_hostname = storm.example -db_username = storm -db_password = password -xmlrpc_security_enabled=true -xmlrpc_security_token=secret \ No newline at end of file +version = 2 + +srm_endpoints.1.host = storm.example +srm_endpoints.1.port = 8444 +srm_endpoints.2.host = alias.example +srm_endpoints.2.port = 8445 + +db.hostname = storm.example +db.username = test +db.password = secret +db.port = 3308 +db.properties = test +db.pool.size = 200 +db.pool.min_idle = 50 +db.pool.max_wait_millis = 1200 +db.pool.test_on_borrow = false +db.pool.test_while_idle = false + +rest.port = 9999 +rest.max_threads = 150 +rest.max_queue_size = 1500 + +xmlrpc.port = 9090 +xmlrpc.max_threads = 512 +xmlrpc.max_queue_size = 2000 + +security.enabled = true +security.token = ilovejava + +du.enabled: true +du.parallel_tasks_enabled: true +du.initial_delay: 120 +du.tasks_interval: 200000 + +inprogress_requests_agent.delay = 20 +inprogress_requests_agent.interval = 400 +inprogress_requests_agent.ptp_expiration_time = 333000 + +expired_spaces_agent.delay = 20 +expired_spaces_agent.interval = 400 + +completed_requests_agent.enabled = true +completed_requests_agent.delay = 20 +completed_requests_agent.interval = 400 +completed_requests_agent.is_dynamic = true +completed_requests_agent.purge_age = 22200 +completed_requests_agent.purge_size = 1800 + +requests_picker_agent.delay = 10 +requests_picker_agent.interval = 20 +requests_picker_agent.max_fetched_size = 1000 + +requests_scheduler.core_pool_size = 10 +requests_scheduler.max_pool_size = 50 +requests_scheduler.queue_size = 2000 + +ptp_scheduler.core_pool_size = 50 +ptp_scheduler.max_pool_size = 200 +ptp_scheduler.queue_size = 1000 + +ptg_scheduler.core_pool_size = 50 +ptg_scheduler.max_pool_size = 200 +ptg_scheduler.queue_size = 2000 + +bol_scheduler.core_pool_size = 50 +bol_scheduler.max_pool_size = 200 +bol_scheduler.queue_size = 2000 + +sanity_checks_enabled: false + +extraslashes.file: /file +extraslashes.rfio: /rfio +extraslashes.gsiftp: /gsiftp +extraslashes.root: /root + +synch_ls.max_entries = 3000 +synch_ls.default_all_level_recursive = true +synch_ls.default_num_levels = 2 +synch_ls.default_offset = 1 + +pinlifetime.default = 300000 +pinlifetime.maximum = 18000000 + +skip_ptg_acl_setup: true + +files.default_size = 100000 +files.default_lifetime = 300000 +files.default_overwrite = N +files.default_storagetype = P + +directories.enable_automatic_creation: true +directories.enable_writeperm_on_creation: true + +hearthbeat.bookkeeping_enabled = true +hearthbeat.performance_measuring_enabled = true +hearthbeat.period = 30 +hearthbeat.performance_logbook_time_interval = 10 +hearthbeat.performance_glance_time_interval = 10 + +info_quota_refresh_period = 900 +http_turl_prefix = / +server_pool_status_check_timeout = 20000 +abort_maxloop = 10 +ping_properties_filename = ping-values.properties diff --git a/src/test/resources/v1.properties b/src/test/resources/v1.properties new file mode 100644 index 000000000..154fde732 --- /dev/null +++ b/src/test/resources/v1.properties @@ -0,0 +1,85 @@ +storm.service.FE-public.hostname=fe.example.org + +storm.service.port = 8444 + +storm.service.SURL.endpoint = srm://fe-01.example.org:8444/srm/managerv2,srm://fe-02.example.org:8444/srm/managerv2,srm://fe.example.org:8444/srm/managerv2 + +storm.service.SURL.default-ports = 8444 + +storm.service.request-db.host = be.example.org +storm.service.request-db.username = storm +storm.service.request-db.passwd = my-secret-password + +directory.automatic-creation = true +directory.writeperm = true + +pinLifetime.default = 310000 +pinLifetime.maximum = 1900000 + +extraslashes.file = /file +extraslashes.rfio = /rfio +extraslashes.gsiftp = /gsiftp +extraslashes.root = /root + +fileLifetime.default = 300000 +fileSize.default = 2000000 + +default.overwrite = N +default.storagetype = P + +persistence.internal-db.connection-pool = true +persistence.internal-db.connection-pool.maxActive = 10 +persistence.internal-db.connection-pool.maxWait = 50 + +scheduler.crusher.workerCorePoolSize=20 +scheduler.crusher.workerMaxPoolSize=60 +scheduler.crusher.queueSize=3000 +scheduler.chunksched.ptp.workerCorePoolSize=60 +scheduler.chunksched.ptp.workerMaxPoolSize=300 +scheduler.chunksched.ptp.queueSize=2000 +scheduler.chunksched.ptg.workerCorePoolSize=70 +scheduler.chunksched.ptg.workerMaxPoolSize=400 +scheduler.chunksched.ptg.queueSize=3000 +scheduler.chunksched.bol.workerCorePoolSize=40 +scheduler.chunksched.bol.workerMaxPoolSize=100 +scheduler.chunksched.bol.queueSize=1000 + +asynch.PickingInitialDelay=15 +asynch.PickingTimeInterval=25 +asynch.PickingMaxBatchSize=150 + +synchcall.directoryManager.maxLsEntry = 3000 +synchcall.directoryManager.default.AllLevelRecursive = true +synchcall.directoryManager.default.Levels = 3 +synchcall.directoryManager.default.Offset = 2 + +storm.rest.services.port=9998 +storm.rest.services.maxthread=256 +storm.rest.services.max_queue_size=1000 + +synchcall.xmlrpc.unsecureServerPort=8080 +synchcall.xmlrpc.maxthread=100 +synchcall.xmlrpc.max_queue_size=500 +synchcall.xmlrpc.security.enabled=true +synchcall.xmlrpc.security.token=abracadabra + +gc.pinnedfiles.cleaning.delay = 10 +gc.pinnedfiles.cleaning.interval = 300 + +purging = false +purge.delay = 100 +purge.interval = 600 +purge.size = 1000 +expired.request.time = 7200 + +transit.delay = 60 +transit.interval = 600 +expired.inprogress.time = 7000 + +ptg.skip-acl-setup=false + +sanity-check.enabled=true + +storm.service.du.enabled=true +storm.service.du.delaySecs=60 +storm.service.du.periodSecs=360 \ No newline at end of file