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

LMS-1995 NonBalancer becomes anonymous inner class of SegmentedStoreBalancingTask.

SVN: 19923
parent e5d9ddb2
No related branches found
No related tags found
No related merge requests found
......@@ -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
*/
......
/*
* 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, " ...");
}
}
}
}
......@@ -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
{
......
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