From baec4923435d5969b7366ddd60787da82cea9a52 Mon Sep 17 00:00:00 2001 From: kaloyane <kaloyane> Date: Fri, 11 Mar 2011 14:13:48 +0000 Subject: [PATCH] [LMS-2087] Eager archiving (part 3 - fix serializable and dependency issues) SVN: 20308 --- .../dss/generic/server/DataStoreService.java | 9 +++-- .../server/IDataSetCommandExecutor.java | 3 +- .../server/plugins/demo/DemoArchiver.java | 6 ++-- .../AbstractArchiverProcessingPlugin.java | 8 ++--- .../plugins/standard/RsyncArchiver.java | 11 +++--- .../plugins/tasks/ArchiverPluginFactory.java | 5 ++- .../dss/generic/shared/IDataSetDeleter.java | 34 +++++++++++++++++++ .../dss/generic/shared/ServiceProvider.java | 23 +++++++++++++ .../cisd/yeastx/etl/MLArchiverTask.java | 6 ++-- 9 files changed, 78 insertions(+), 27 deletions(-) create mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetDeleter.java diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java index b986343df12..eb2274f75b1 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java @@ -37,8 +37,8 @@ import ch.systemsx.cisd.common.mail.MailClientParameters; import ch.systemsx.cisd.common.spring.AbstractServiceWithLogger; import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.common.utilities.IInitializable; -import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverPluginFactory; +import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IArchiverPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IProcessingPluginTask; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IReportingPluginTask; @@ -352,7 +352,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic private IArchiverPlugin createArchiver() { ArchiverPluginFactory factory = pluginTaskParameters.getArchiverTaskFactory(); - return factory.createInstance(storeRoot, commandExecutor); + return factory.createInstance(storeRoot); } private void scheduleTask(String sessionToken, String description, @@ -424,6 +424,11 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic return task.createLink(dataSet); } + public IDataSetCommandExecutor getDataSetCommandExecutor() + { + return commandExecutor; + } + private IShareIdManager getShareIdManager() { if (shareIdManager == null) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java index e05d54176df..bbe4781700b 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java @@ -21,6 +21,7 @@ import java.util.Map; import ch.systemsx.cisd.common.mail.MailClientParameters; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IProcessingPluginTask; +import ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetDeleter; import ch.systemsx.cisd.openbis.generic.shared.Constants; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; @@ -33,7 +34,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; * * @author Franz-Josef Elmer */ -public interface IDataSetCommandExecutor +public interface IDataSetCommandExecutor extends IDataSetDeleter { /** * Starts up executor. diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java index b9424650597..259e3a3f01e 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/demo/DemoArchiver.java @@ -25,7 +25,6 @@ import java.util.Set; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.BooleanStatus; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractArchiverProcessingPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; @@ -39,10 +38,9 @@ public class DemoArchiver extends AbstractArchiverProcessingPlugin private final static Set<String/* data set code */> archiveContents = new HashSet<String>(); - public DemoArchiver(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor) + public DemoArchiver(Properties properties, File storeRoot) { - super(properties, storeRoot, commandExecutor, null, null); + super(properties, storeRoot, null, null); } @Override diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java index 7bf9c34921f..a44a92d4c98 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AbstractArchiverProcessingPlugin.java @@ -30,11 +30,11 @@ import java.util.Properties; import ch.systemsx.cisd.common.collections.CollectionUtils; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.filesystem.BooleanStatus; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IArchiverPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ProcessingStatus; import ch.systemsx.cisd.openbis.dss.generic.shared.QueueingDataSetStatusUpdaterService; +import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetCodesWithStatus; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; @@ -55,14 +55,10 @@ public abstract class AbstractArchiverProcessingPlugin extends AbstractDatastore private final IStatusChecker unarchivePrerequisiteOrNull; - private final IDataSetCommandExecutor commandExecutor; - public AbstractArchiverProcessingPlugin(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor, IStatusChecker archivePrerequisiteOrNull, IStatusChecker unarchivePrerequisiteOrNull) { super(properties, storeRoot); - this.commandExecutor = commandExecutor; this.archivePrerequisiteOrNull = archivePrerequisiteOrNull; this.unarchivePrerequisiteOrNull = unarchivePrerequisiteOrNull; } @@ -153,7 +149,7 @@ public abstract class AbstractArchiverProcessingPlugin extends AbstractDatastore ArchiverTaskContext context) { // the deletion will happen at a later point in time - commandExecutor.scheduleDeletionOfDataSets(datasets); + ServiceProvider.getDataSetDeleter().scheduleDeletionOfDataSets(datasets); } public ProcessingStatus unarchive(List<DatasetDescription> datasets, diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java index 968fe01e44f..147908ddc27 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/RsyncArchiver.java @@ -24,7 +24,6 @@ import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.BooleanStatus; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ArchiverTaskContext; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; @@ -50,19 +49,17 @@ public class RsyncArchiver extends AbstractArchiverProcessingPlugin private final ISshCommandExecutorFactory sshCommandExecutorFactory; - public RsyncArchiver(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor) + public RsyncArchiver(Properties properties, File storeRoot) { - this(properties, storeRoot, commandExecutor, new RsyncCopierFactory(), - new SshCommandExecutorFactory()); + this(properties, storeRoot, new RsyncCopierFactory(), new SshCommandExecutorFactory()); } @Private - RsyncArchiver(Properties properties, File storeRoot, IDataSetCommandExecutor commandExecutor, + RsyncArchiver(Properties properties, File storeRoot, IPathCopierFactory pathCopierFactory, ISshCommandExecutorFactory sshCommandExecutorFactory) { - super(properties, storeRoot, commandExecutor, null, null); + super(properties, storeRoot, null, null); this.pathCopierFactory = pathCopierFactory; this.sshCommandExecutorFactory = sshCommandExecutorFactory; } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java index 0a399668baa..17db868e1f4 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/ArchiverPluginFactory.java @@ -28,7 +28,6 @@ import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.utilities.ClassUtils; import ch.systemsx.cisd.common.utilities.PropertyParametersUtil.SectionProperties; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; /** * Factory of Archiver Tasks. @@ -59,7 +58,7 @@ public class ArchiverPluginFactory return className != null; } - public IArchiverPlugin createInstance(File storeRoot, IDataSetCommandExecutor commandExecutor) + public IArchiverPlugin createInstance(File storeRoot) { if (isArchiverConfigured() == false) { @@ -68,7 +67,7 @@ public class ArchiverPluginFactory try { return ClassUtils.create(IArchiverPlugin.class, className, archiverProperties, - storeRoot, commandExecutor); + storeRoot); } catch (ConfigurationFailureException ex) { throw ex; // rethrow the exception without changing the message diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetDeleter.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetDeleter.java new file mode 100644 index 00000000000..b308f48b56a --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetDeleter.java @@ -0,0 +1,34 @@ +/* + * Copyright 2011 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.dss.generic.shared; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; + +/** + * @author Kaloyan Enimanev + */ +public interface IDataSetDeleter +{ + + /** + * Schedules deletion of all specified data sets. + */ + void scheduleDeletionOfDataSets(List<DatasetDescription> dataSets); + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java index 776ff22fe97..a01c0178058 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java @@ -16,12 +16,18 @@ package ch.systemsx.cisd.openbis.dss.generic.shared; +import org.apache.log4j.Logger; +import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter; import com.marathon.util.spring.StreamSupportingHttpInvokerServiceExporter; +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreService; + /** * Provider of remote service onto openBIS. * @@ -29,6 +35,9 @@ import com.marathon.util.spring.StreamSupportingHttpInvokerServiceExporter; */ public class ServiceProvider { + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, + ServiceProvider.class); + // applicationContex it lazily initialized private static BeanFactory applicationContext = null; @@ -82,6 +91,20 @@ public class ServiceProvider return ((DataSourceProvider) getApplicationContext().getBean("data-source-provider")); } + public static IDataSetDeleter getDataSetDeleter() + { + Advised advised = (Advised) getApplicationContext().getBean("data-store-service"); + try + { + DataStoreService dssService = (DataStoreService) advised.getTargetSource().getTarget(); + return dssService.getDataSetCommandExecutor(); + } catch (Exception ex) + { + operationLog.error("Cannot get IDataSetDeleter instance :" + ex.getMessage(), ex); + return null; + } + } + private ServiceProvider() { } diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java index 23dba3c5aa5..2d14a42b417 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/MLArchiverTask.java @@ -26,7 +26,6 @@ import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.BooleanStatus; import ch.systemsx.cisd.common.utilities.PropertyUtils; -import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractArchiverProcessingPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.HighWaterMarkChecker; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.IStatusChecker; @@ -59,10 +58,9 @@ public class MLArchiverTask extends AbstractArchiverProcessingPlugin private final String dataSourceName; - public MLArchiverTask(Properties properties, File storeRoot, - IDataSetCommandExecutor commandExecutor) + public MLArchiverTask(Properties properties, File storeRoot) { - super(properties, storeRoot, commandExecutor, null, tryCreateUnarchivingStatusChecker( + super(properties, storeRoot, null, tryCreateUnarchivingStatusChecker( properties, storeRoot)); dataSourceName = DataSourceProvider.extractDataSourceName(properties); // Check if given data source exists -- GitLab