diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/IDataSetMover.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/IDataSetMover.java index 50118fc9daeaae0fd2f341bbddb667e09f442af0..588fad95c704e1b3fa2d443ee858bbb3ee9d1f21 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/IDataSetMover.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/IDataSetMover.java @@ -17,10 +17,12 @@ package ch.systemsx.cisd.etlserver.plugins; import java.io.File; +import java.util.Properties; /** - * Strategy of moving a data set to another share. + * Strategy of moving a data set to another share. Implementations of this interface should + * have a public constructor with an argument of type {@link Properties}. * * @author Franz-Josef Elmer */ diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/NonBalancer.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/NonBalancer.java deleted file mode 100644 index fd16a31c2271bc4fa9548f63e0a10d408edb1b1b..0000000000000000000000000000000000000000 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/NonBalancer.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.etlserver.plugins; - -import static ch.systemsx.cisd.common.logging.LogLevel.INFO; - -import java.util.List; - -import org.apache.commons.io.FileUtils; - -import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.common.logging.ISimpleLogger; -import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; -import ch.systemsx.cisd.openbis.dss.generic.shared.utils.Share; -import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO; - -/** - * Implementation of {@link ISegmentedStoreBalancer} which just logs information about each share. - * - * @author Franz-Josef Elmer - */ -public class NonBalancer implements ISegmentedStoreBalancer -{ - - private static final int N = 3; - - public void balanceStore(List<Share> shares, IEncapsulatedOpenBISService service, - IDataSetMover dataSetMover, ISimpleLogger logger) - { - logger.log(INFO, "Data Store Shares:"); - for (Share share : shares) - { - List<SimpleDataSetInformationDTO> dataSets = share.getDataSetsOrderedBySize(); - logger.log( - INFO, - " Share " + share.getShareId() + " (free space: " - + FileUtils.byteCountToDisplaySize(share.calculateFreeSpace()) - + ") has " + dataSets.size() + " data sets occupying " - + FileUtilities.byteCountToDisplaySize(share.getTotalSizeOfDataSets()) - + "."); - for (int i = 0, n = Math.min(N, dataSets.size()); i < n; i++) - { - SimpleDataSetInformationDTO dataSet = dataSets.get(i); - logger.log( - INFO, - " " + dataSet.getDataSetCode() + " " - + FileUtilities.byteCountToDisplaySize(dataSet.getDataSetSize())); - } - if (dataSets.size() > N) - { - logger.log(INFO, " ..."); - } - } - } - -} diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/SegmentedStoreBalancingTask.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/SegmentedStoreBalancingTask.java index 1d496ba5c2723f417e42e9d5a663bffc3e3a822f..8f0c48c83850ad29b4be2594501c87c5b06fcf67 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/SegmentedStoreBalancingTask.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/SegmentedStoreBalancingTask.java @@ -16,15 +16,19 @@ package ch.systemsx.cisd.etlserver.plugins; +import static ch.systemsx.cisd.common.logging.LogLevel.INFO; + import java.io.File; import java.util.List; import java.util.Properties; +import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import ch.rinn.restrictions.Private; import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; +import ch.systemsx.cisd.common.filesystem.FileUtilities; import ch.systemsx.cisd.common.filesystem.IFreeSpaceProvider; import ch.systemsx.cisd.common.filesystem.SimpleFreeSpaceProvider; import ch.systemsx.cisd.common.logging.ISimpleLogger; @@ -41,6 +45,7 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DssPropertyParametersUtil; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.SegmentedStoreUtils; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.Share; +import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO; /** * Maintenance task which tries to balance a segmented store. @@ -49,6 +54,47 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.utils.Share; */ public class SegmentedStoreBalancingTask implements IMaintenanceTask { + private static final ISegmentedStoreBalancer DUMMY_BALANCER = new ISegmentedStoreBalancer() + { + private static final int N = 3; + + public void balanceStore(List<Share> shares, IEncapsulatedOpenBISService service, + IDataSetMover dataSetMover, ISimpleLogger logger) + { + logger.log(INFO, "Data Store Shares:"); + for (Share share : shares) + { + List<SimpleDataSetInformationDTO> dataSets = share.getDataSetsOrderedBySize(); + logger.log( + INFO, + " Share " + + share.getShareId() + + " (free space: " + + FileUtils.byteCountToDisplaySize(share.calculateFreeSpace()) + + ") has " + + dataSets.size() + + " data sets occupying " + + FileUtilities.byteCountToDisplaySize(share + .getTotalSizeOfDataSets()) + "."); + for (int i = 0, n = Math.min(N, dataSets.size()); i < n; i++) + { + SimpleDataSetInformationDTO dataSet = dataSets.get(i); + logger.log( + INFO, + " " + + dataSet.getDataSetCode() + + " " + + FileUtilities.byteCountToDisplaySize(dataSet + .getDataSetSize())); + } + if (dataSets.size() > N) + { + logger.log(INFO, " ..."); + } + } + } + }; + @Private static final String BALANCER_SECTION_NAME = "balancer"; @Private static final String CLASS_PROPERTY_NAME = "class"; @@ -116,7 +162,7 @@ public class SegmentedStoreBalancingTask implements IMaintenanceTask String className = balancerProps.getProperty(CLASS_PROPERTY_NAME); if (className == null) { - return new NonBalancer(); + return DUMMY_BALANCER; } try {