Skip to content
Snippets Groups Projects
Commit c72ff15c authored by felmer's avatar felmer
Browse files

SSDM-3574: get data set codes from all commands of all queues not just the default queue

SVN: 36574
parent ec5b3fdb
No related branches found
No related tags found
No related merge requests found
package ch.systemsx.cisd.etlserver.plugins;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
......@@ -58,37 +58,38 @@ public class ResetArchivePendingTask implements IMaintenanceTask
// 1. Find datasets with DataSetArchivingStatus.ARCHIVE_PENDING
IEncapsulatedOpenBISService service = ServiceProvider.getOpenBISService();
List<SimpleDataSetInformationDTO> inArchivePendings = service.listPhysicalDataSetsByArchivingStatus(DataSetArchivingStatus.ARCHIVE_PENDING);
operationLog.info("Found " + inArchivePendings.size() + " datasets in " + DataSetArchivingStatus.ARCHIVE_PENDING.name() + " status.");
// 2. Filter out datasets that are not on the command queue
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<SimpleDataSetInformationDTO> dataSetsToUpdate = new ArrayList<SimpleDataSetInformationDTO>();
for (SimpleDataSetInformationDTO inArchivePending : inArchivePendings)
if (inArchivePendings.isEmpty() == false)
{
if (inQueue.contains(inArchivePending.getDataSetCode()) == false
&& inArchivePending.isPresentInArchive() == false)
operationLog.info("Found " + inArchivePendings.size() + " datasets in " + DataSetArchivingStatus.ARCHIVE_PENDING.name() + " status.");
// 2. Filter out datasets that are not on the command queue
IDataSetCommandExecutorProvider commandExecutorProvider =
(IDataSetCommandExecutorProvider) ServiceProvider
.getApplicationContext()
.getBean(COMMAND_EXECUTOR_BEAN);
Set<String> inQueue = new HashSet<>();
List<IDataSetCommandExecutor> executors = commandExecutorProvider.getAllExecutors();
for (IDataSetCommandExecutor executor : executors)
{
dataSetsToUpdate.add(inArchivePending);
operationLog.info(inArchivePending.getDataSetCode() + " not found in command queue, scheduled to update.");
inQueue.addAll(executor.getDataSetCodesFromCommandQueue());
}
}
// 3. Update datasets status to AVAILABLE
operationLog.info("Going to update " + dataSetsToUpdate.size() + " datasets.");
for (SimpleDataSetInformationDTO dataSetToUpdate : dataSetsToUpdate)
{
DataSetCodesWithStatus codesWithStatus = new DataSetCodesWithStatus(
Arrays.asList(dataSetToUpdate.getDataSetCode()),
DataSetArchivingStatus.AVAILABLE,
dataSetToUpdate.isPresentInArchive());
operationLog.info("Found " + inQueue.size() + " datasets in the command queue.");
List<String> dataSetsToUpdate = new ArrayList<>();
for (SimpleDataSetInformationDTO inArchivePending : inArchivePendings)
{
if (inQueue.contains(inArchivePending.getDataSetCode()) == false
&& inArchivePending.isPresentInArchive() == false)
{
dataSetsToUpdate.add(inArchivePending.getDataSetCode());
operationLog.info(inArchivePending.getDataSetCode() + " not found in command queue, scheduled to update.");
}
}
// 3. Update datasets status to AVAILABLE
operationLog.info("Going to update " + dataSetsToUpdate.size() + " datasets.");
DataSetCodesWithStatus codesWithStatus = new DataSetCodesWithStatus(dataSetsToUpdate,
DataSetArchivingStatus.AVAILABLE, false);
QueueingDataSetStatusUpdaterService.update(codesWithStatus);
}
operationLog.info(ResetArchivePendingTask.class.getSimpleName() + " Finished");
......
......@@ -18,7 +18,6 @@ package ch.systemsx.cisd.openbis.dss.generic.server;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
......@@ -194,6 +193,7 @@ class DataSetCommandExecutor implements IDataSetCommandExecutor
operationLog.debug("Scheduling " + command);
}
commandQueue.add(command);
operationLog.info("Scheduled: " + command.getDescription());
}
private IShareIdManager getShareIdManager()
......@@ -221,6 +221,7 @@ class DataSetCommandExecutor implements IDataSetCommandExecutor
for (IDataSetCommand command : commandQueue)
{
dataSetCodes.addAll(command.getDataSetCodes());
operationLog.info("Gather data set codes from command [" + command.getDescription() + "]");
}
return dataSetCodes;
}
......
......@@ -17,6 +17,7 @@
package ch.systemsx.cisd.openbis.dss.generic.server;
import java.io.File;
import java.util.List;
import ch.systemsx.cisd.openbis.dss.generic.shared.IProcessingPluginTask;
......@@ -30,6 +31,8 @@ public interface IDataSetCommandExecutorProvider
public void init(File storeRoot);
public IDataSetCommandExecutor getDefaultExecutor();
public List<IDataSetCommandExecutor> getAllExecutors();
public IDataSetCommandExecutor getExecutor(IProcessingPluginTask processingTask, String processingTaskKey);
}
......@@ -159,6 +159,13 @@ public class KeyBasedDataSetCommandExecutorProvider implements IDataSetCommandEx
}
return defaultExecutor;
}
@Override
public List<IDataSetCommandExecutor> getAllExecutors()
{
return new ArrayList<>(executorsByName.values());
}
@Override
public IDataSetCommandExecutor getExecutor(IProcessingPluginTask processingTask, String processingTaskKey)
......
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