Skip to content
Snippets Groups Projects
Commit 5555e2ea authored by juanf's avatar juanf
Browse files

SSDM-3574 : Logs added

SVN: 36562
parent 3d213630
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,11 @@ import java.util.List; ...@@ -5,8 +5,11 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.apache.log4j.Logger;
import org.springframework.transaction.annotation.Transactional; 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.common.maintenance.IMaintenanceTask;
import ch.systemsx.cisd.openbis.dss.generic.server.CommandQueueLister; import ch.systemsx.cisd.openbis.dss.generic.server.CommandQueueLister;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
...@@ -19,27 +22,42 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO; ...@@ -19,27 +22,42 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO;
public class ResetArchivePendingTask implements IMaintenanceTask public class ResetArchivePendingTask implements IMaintenanceTask
{ {
private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, ResetArchivePendingTask.class);
@Override @Override
public void setUp(String pluginName, Properties properties) public void setUp(String pluginName, Properties properties)
{ {
operationLog.info("Task " + pluginName + " initialized.");
} }
@Transactional @Transactional
@Override @Override
public void execute() public void execute()
{ {
operationLog.info(ResetArchivePendingTask.class.getSimpleName() + " Started");
// 1. Find datasets with DataSetArchivingStatus.ARCHIVE_PENDING // 1. Find datasets with DataSetArchivingStatus.ARCHIVE_PENDING
IEncapsulatedOpenBISService service = ServiceProvider.getOpenBISService(); IEncapsulatedOpenBISService service = ServiceProvider.getOpenBISService();
List<SimpleDataSetInformationDTO> inArchivePendings = service.listPhysicalDataSetsByArchivingStatus(DataSetArchivingStatus.ARCHIVE_PENDING); 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 // 2. Filter out datasets that are not on the command queue
Set<String> inQueue = CommandQueueLister.getDataSetCodesFromCommandQueue(); Set<String> inQueue = null;
try
{
inQueue = CommandQueueLister.getDataSetCodesFromCommandQueue();
} catch (Exception ex)
{
operationLog.error("Command queue can't be read, aborting task.", ex);
return;
}
List<String> toUpdate = new ArrayList<String>(); List<String> toUpdate = new ArrayList<String>();
for (SimpleDataSetInformationDTO inArchivePending : inArchivePendings) for (SimpleDataSetInformationDTO inArchivePending : inArchivePendings)
{ {
if (!inQueue.contains(inArchivePending.getDataSetCode())) if (!inQueue.contains(inArchivePending.getDataSetCode()))
{ {
toUpdate.add(inArchivePending.getDataSetCode()); toUpdate.add(inArchivePending.getDataSetCode());
operationLog.info(inArchivePending.getDataSetCode() + " not found in command queue, scheduled to update.");
} }
} }
...@@ -47,8 +65,10 @@ public class ResetArchivePendingTask implements IMaintenanceTask ...@@ -47,8 +65,10 @@ public class ResetArchivePendingTask implements IMaintenanceTask
DataSetArchivingStatus status = DataSetArchivingStatus.AVAILABLE; DataSetArchivingStatus status = DataSetArchivingStatus.AVAILABLE;
boolean presentInArchive = false; boolean presentInArchive = false;
operationLog.info("Going to update " + toUpdate.size() + " datasets.");
DataSetCodesWithStatus codesWithStatus = new DataSetCodesWithStatus(toUpdate, status, presentInArchive); DataSetCodesWithStatus codesWithStatus = new DataSetCodesWithStatus(toUpdate, status, presentInArchive);
QueueingDataSetStatusUpdaterService.update(codesWithStatus); QueueingDataSetStatusUpdaterService.update(codesWithStatus);
operationLog.info(ResetArchivePendingTask.class.getSimpleName() + " Finished");
} }
} }
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