Skip to content
Snippets Groups Projects
Commit 857ba76a authored by juanf's avatar juanf
Browse files

SSDM-3574 : Using default command queue from bean

SVN: 36563
parent 5555e2ea
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,8 @@ import org.springframework.transaction.annotation.Transactional;
import ch.systemsx.cisd.common.logging.LogCategory;
import ch.systemsx.cisd.common.logging.LogFactory;
import ch.systemsx.cisd.common.maintenance.IMaintenanceTask;
import ch.systemsx.cisd.openbis.dss.generic.server.CommandQueueLister;
import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutor;
import ch.systemsx.cisd.openbis.dss.generic.server.IDataSetCommandExecutorProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
import ch.systemsx.cisd.openbis.dss.generic.shared.QueueingDataSetStatusUpdaterService;
import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider;
......@@ -22,6 +23,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO;
public class ResetArchivePendingTask implements IMaintenanceTask
{
private static final String COMMAND_EXECUTOR_BEAN = "data-set-command-executor-provider";
private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, ResetArchivePendingTask.class);
@Override
......@@ -41,15 +44,14 @@ public class ResetArchivePendingTask implements IMaintenanceTask
operationLog.info("Found " + inArchivePendings.size() + " datasets in " + DataSetArchivingStatus.ARCHIVE_PENDING.name() + " status.");
// 2. Filter out datasets that are not on the command queue
Set<String> inQueue = null;
try
{
inQueue = CommandQueueLister.getDataSetCodesFromCommandQueue();
} catch (Exception ex)
{
operationLog.error("Command queue can't be read, aborting task.", ex);
return;
}
IDataSetCommandExecutorProvider commandExecutorProvider =
(IDataSetCommandExecutorProvider) ServiceProvider
.getApplicationContext()
.getBean(COMMAND_EXECUTOR_BEAN);
IDataSetCommandExecutor commandExecutor = commandExecutorProvider.getDefaultExecutor();
Set<String> inQueue = commandExecutor.getDataSetCodesFromCommandQueue();
operationLog.info("Found " + inQueue.size() + " datasets in the command queue.");
List<String> toUpdate = new ArrayList<String>();
for (SimpleDataSetInformationDTO inArchivePending : inArchivePendings)
......
......@@ -16,10 +16,6 @@
package ch.systemsx.cisd.openbis.dss.generic.server;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* A class that provides a lister for the commands in the command queue of the store.
*
......@@ -37,17 +33,4 @@ public final class CommandQueueLister
final ConfigParameters configParams = DataStoreServer.getConfigParameters();
DataSetCommandExecutor.listQueuedCommands(configParams.getCommandQueueDir());
}
public static Set<String> getDataSetCodesFromCommandQueue()
{
final ConfigParameters configParams = DataStoreServer.getConfigParameters();
List<IDataSetCommand> commands = DataSetCommandExecutor.getQueuedCommands(configParams.getCommandQueueDir());
Set<String> datasetCodes = new HashSet<String>();
for (IDataSetCommand command : commands)
{
datasetCodes.addAll(command.getDataSetCodes());
}
return datasetCodes;
}
}
......@@ -21,8 +21,10 @@ import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.StopWatch;
......@@ -212,6 +214,17 @@ class DataSetCommandExecutor implements IDataSetCommandExecutor
return hierarchicalContentProvider;
}
@Override
public Set<String> getDataSetCodesFromCommandQueue()
{
Set<String> dataSetCodes = new HashSet<String>();
for (IDataSetCommand command : commandQueue)
{
dataSetCodes.addAll(command.getDataSetCodes());
}
return dataSetCodes;
}
/**
* Returns the list of items in the command store of the given <var>store</var> directory.
*/
......
......@@ -18,13 +18,14 @@ package ch.systemsx.cisd.openbis.dss.generic.server;
import java.util.List;
import java.util.Map;
import java.util.Set;
import ch.systemsx.cisd.common.mail.MailClientParameters;
import ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetDeleter;
import ch.systemsx.cisd.openbis.dss.generic.shared.IProcessingPluginTask;
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.AbstractExternalData;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUploadContext;
import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
......@@ -41,6 +42,11 @@ public interface IDataSetCommandExecutor extends IDataSetDeleter
*/
void start();
/**
* Returns the codes of the DataSets currently in the queue.
*/
Set<String> getDataSetCodesFromCommandQueue();
/**
* Schedules uploading of all data sets to CIFEX using the specified upload context.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment