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

SP-527, BIS-343:...

SP-527, BIS-343: ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.DataSetAndPathInfoDBConsistencyCheckTask removed. Bugs in ch.systemsx.cisd.etlserver.path.DataSetAndPathInfoDBConsistencyCheckTask fixed.

SVN: 28681
parent f1b5ad41
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ import ch.systemsx.cisd.common.utilities.ITimeProvider; ...@@ -32,6 +32,7 @@ import ch.systemsx.cisd.common.utilities.ITimeProvider;
import ch.systemsx.cisd.common.utilities.SystemTimeProvider; import ch.systemsx.cisd.common.utilities.SystemTimeProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DataSetAndPathInfoDBConsistencyChecker; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DataSetAndPathInfoDBConsistencyChecker;
import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO;
...@@ -46,10 +47,13 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas ...@@ -46,10 +47,13 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
BasicConstant.DATE_WITHOUT_TIMEZONE_PATTERN); BasicConstant.DATE_WITHOUT_TIMEZONE_PATTERN);
private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION,
DataSetAndPathInfoDBConsistencyCheckTask.class);
private static final Logger notificationLog = LogFactory.getLogger(LogCategory.NOTIFY, private static final Logger notificationLog = LogFactory.getLogger(LogCategory.NOTIFY,
DataSetAndPathInfoDBConsistencyCheckTask.class); DataSetAndPathInfoDBConsistencyCheckTask.class);
private final IEncapsulatedOpenBISService service; private IEncapsulatedOpenBISService service;
private IHierarchicalContentProvider fileProvider; private IHierarchicalContentProvider fileProvider;
...@@ -58,11 +62,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas ...@@ -58,11 +62,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas
private long timeInterval; private long timeInterval;
private ITimeProvider timeProvider; private ITimeProvider timeProvider;
public DataSetAndPathInfoDBConsistencyCheckTask(Properties properties, public DataSetAndPathInfoDBConsistencyCheckTask()
IEncapsulatedOpenBISService service)
{ {
this.service = service;
} }
DataSetAndPathInfoDBConsistencyCheckTask(IHierarchicalContentProvider fileProvider, DataSetAndPathInfoDBConsistencyCheckTask(IHierarchicalContentProvider fileProvider,
...@@ -88,7 +90,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas ...@@ -88,7 +90,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas
{ {
Date youngerThanDate = new Date(getTimeProvider().getTimeInMilliseconds() - timeInterval); Date youngerThanDate = new Date(getTimeProvider().getTimeInMilliseconds() - timeInterval);
List<SimpleDataSetInformationDTO> dataSets = List<SimpleDataSetInformationDTO> dataSets =
service.listOldestPhysicalDataSets(youngerThanDate, Integer.MAX_VALUE); getService().listOldestPhysicalDataSets(youngerThanDate, Integer.MAX_VALUE);
operationLog.info("Check " + dataSets.size() + " registered since "
+ DATE_FORMAT.format(youngerThanDate));
DataSetAndPathInfoDBConsistencyChecker checker = DataSetAndPathInfoDBConsistencyChecker checker =
new DataSetAndPathInfoDBConsistencyChecker(fileProvider, pathInfoProvider); new DataSetAndPathInfoDBConsistencyChecker(fileProvider, pathInfoProvider);
checker.check(dataSets); checker.check(dataSets);
...@@ -102,6 +106,15 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas ...@@ -102,6 +106,15 @@ public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTas
} }
} }
private IEncapsulatedOpenBISService getService()
{
if (service == null)
{
service = ServiceProvider.getOpenBISService();
}
return service;
}
private ITimeProvider getTimeProvider() private ITimeProvider getTimeProvider()
{ {
if (timeProvider == null) if (timeProvider == null)
......
/*
* Copyright 2013 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.server.plugins.standard;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang.time.DateUtils;
import org.apache.log4j.Logger;
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.time.DateTimeUtils;
import ch.systemsx.cisd.common.utilities.ITimeProvider;
import ch.systemsx.cisd.common.utilities.SystemTimeProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DataSetAndPathInfoDBConsistencyChecker;
import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO;
/**
* @author Franz-Josef Elmer
*/
public class DataSetAndPathInfoDBConsistencyCheckTask implements IMaintenanceTask
{
static final String CHECKING_TIME_INTERVAL_KEY = "checking-time-interval";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
BasicConstant.DATE_WITHOUT_TIMEZONE_PATTERN);
private static final Logger notificationLog = LogFactory.getLogger(LogCategory.NOTIFY,
DataSetAndPathInfoDBConsistencyCheckTask.class);
private final IEncapsulatedOpenBISService service;
private IHierarchicalContentProvider fileProvider;
private IHierarchicalContentProvider pathInfoProvider;
private long timeInterval;
private ITimeProvider timeProvider;
public DataSetAndPathInfoDBConsistencyCheckTask(Properties properties,
IEncapsulatedOpenBISService service)
{
this.service = service;
}
DataSetAndPathInfoDBConsistencyCheckTask(IHierarchicalContentProvider fileProvider,
IHierarchicalContentProvider pathInfoProvider, IEncapsulatedOpenBISService service,
ITimeProvider timeProvider)
{
this.fileProvider = fileProvider;
this.pathInfoProvider = pathInfoProvider;
this.service = service;
this.timeProvider = timeProvider;
}
@Override
public void setUp(String pluginName, Properties properties)
{
timeInterval =
DateTimeUtils.getDurationInMillis(properties, CHECKING_TIME_INTERVAL_KEY,
DateUtils.MILLIS_PER_DAY);
}
@Override
public void execute()
{
Date youngerThanDate = new Date(getTimeProvider().getTimeInMilliseconds() - timeInterval);
List<SimpleDataSetInformationDTO> dataSets =
service.listOldestPhysicalDataSets(youngerThanDate, Integer.MAX_VALUE);
DataSetAndPathInfoDBConsistencyChecker checker =
new DataSetAndPathInfoDBConsistencyChecker(fileProvider, pathInfoProvider);
checker.check(dataSets);
if (checker.noErrorAndInconsitencyFound() == false)
{
StringBuilder builder = new StringBuilder();
builder.append("File system and path info DB consistency check report for all data sets since ");
builder.append(DATE_FORMAT.format(youngerThanDate)).append("\n\n");
builder.append(checker.createReport());
notificationLog.error(builder.toString());
}
}
private ITimeProvider getTimeProvider()
{
if (timeProvider == null)
{
timeProvider = SystemTimeProvider.SYSTEM_TIME_PROVIDER;
}
return timeProvider;
}
}
...@@ -97,7 +97,8 @@ public class DataSetAndPathInfoDBConsistencyCheckTaskTest extends AssertJUnit ...@@ -97,7 +97,8 @@ public class DataSetAndPathInfoDBConsistencyCheckTaskTest extends AssertJUnit
task.execute(); task.execute();
assertEquals("", logRecorder.getLogContent()); assertEquals("INFO OPERATION.DataSetAndPathInfoDBConsistencyCheckTask - "
+ "Check 1 registered since 1970-01-01 01:00:00", logRecorder.getLogContent());
assertEquals(true, fileContent.isClosed()); assertEquals(true, fileContent.isClosed());
assertEquals(true, pathInfoContent.isClosed()); assertEquals(true, pathInfoContent.isClosed());
context.assertIsSatisfied(); context.assertIsSatisfied();
...@@ -114,7 +115,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTaskTest extends AssertJUnit ...@@ -114,7 +115,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTaskTest extends AssertJUnit
task.execute(); task.execute();
assertEquals("ERROR OPERATION.DataSetAndPathInfoDBConsistencyChecker - " assertEquals("INFO OPERATION.DataSetAndPathInfoDBConsistencyCheckTask - "
+ "Check 1 registered since 1970-01-01 01:00:00\n"
+ "ERROR OPERATION.DataSetAndPathInfoDBConsistencyChecker - "
+ "Couldn't check consistency of the file system and " + "Couldn't check consistency of the file system and "
+ "the path info database for a data set: ds1\n" + "the path info database for a data set: ds1\n"
+ "java.lang.RuntimeException: Oohps!\n" + "java.lang.RuntimeException: Oohps!\n"
...@@ -158,7 +161,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTaskTest extends AssertJUnit ...@@ -158,7 +161,9 @@ public class DataSetAndPathInfoDBConsistencyCheckTaskTest extends AssertJUnit
task.execute(); task.execute();
assertEquals( assertEquals(
"ERROR NOTIFY.DataSetAndPathInfoDBConsistencyCheckTask - " "INFO OPERATION.DataSetAndPathInfoDBConsistencyCheckTask - "
+ "Check 4 registered since 1970-01-01 01:00:00\n"
+ "ERROR NOTIFY.DataSetAndPathInfoDBConsistencyCheckTask - "
+ "File system and path info DB consistency check report " + "File system and path info DB consistency check report "
+ "for all data sets since 1970-01-01 01:00:00\n\n" + "for all data sets since 1970-01-01 01:00:00\n\n"
+ "Data sets checked:\n\nds1, ds2, ds3, ds4\n\n" + "Data sets checked:\n\nds1, ds2, ds3, ds4\n\n"
......
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