ch.systemsx.cisd.openbis.dss.generic.shared.utils
Class SegmentedStoreUtils

java.lang.Object
  extended by ch.systemsx.cisd.openbis.dss.generic.shared.utils.SegmentedStoreUtils

public class SegmentedStoreUtils
extends java.lang.Object

Utility methods for segmented stores.


Constructor Summary
SegmentedStoreUtils()
           
 
Method Summary
static void cleanUp(ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO dataSet, java.io.File storeRoot, java.lang.String newShareId, ch.systemsx.cisd.openbis.dss.generic.shared.IShareIdManager shareIdManager, ch.systemsx.cisd.common.logging.ISimpleLogger logger)
          Deletes specified data set in the old share if it is already in the new one or in the new one if it is still in the old one.
static void deleteDataSet(ch.systemsx.cisd.openbis.generic.shared.basic.dto.IDatasetLocation dataSet, ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetDirectoryProvider dataSetDirectoryProvider, ch.systemsx.cisd.openbis.dss.generic.shared.IShareIdManager shareIdManager, ch.systemsx.cisd.common.logging.ISimpleLogger logger)
          Deletes specified data set.
static void deleteDataSetInstantly(java.lang.String dataSetCode, java.io.File dataSetDirInStore, ch.systemsx.cisd.common.logging.ISimpleLogger logger)
          Deletes specified data set at specified location.
static java.lang.String findIncomingShare(java.io.File incomingFolder, java.io.File storeRoot, ch.systemsx.cisd.common.logging.ISimpleLogger logger)
          Returns first the id of the first incoming share folder of specified store root which allows to move a file from specified incoming folder to the incoming share.
static java.io.File[] getShares(java.io.File storeRootDir)
          Lists all folders in specified store root directory which match share pattern.
static java.util.List<Share> getSharesWithDataSets(java.io.File storeRoot, java.lang.String dataStoreCode, boolean filterOutToBeIgnoredForShuffling, java.util.Set<java.lang.String> incomingShares, ch.systemsx.cisd.common.filesystem.IFreeSpaceProvider freeSpaceProvider, ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService service, ch.systemsx.cisd.common.logging.ISimpleLogger log)
          Gets a list of all shares of specified store root directory.
static void moveDataSetToAnotherShare(java.io.File dataSetDirInStore, java.io.File share, ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService service, ch.systemsx.cisd.openbis.dss.generic.shared.IShareIdManager shareIdManager, ch.systemsx.cisd.openbis.dss.generic.shared.IChecksumProvider checksumProvider, ch.systemsx.cisd.common.logging.ISimpleLogger logger)
          Moves the specified data set to the specified share.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SegmentedStoreUtils

public SegmentedStoreUtils()
Method Detail

getShares

public static java.io.File[] getShares(java.io.File storeRootDir)
Lists all folders in specified store root directory which match share pattern.


findIncomingShare

public static java.lang.String findIncomingShare(java.io.File incomingFolder,
                                                 java.io.File storeRoot,
                                                 ch.systemsx.cisd.common.logging.ISimpleLogger logger)
Returns first the id of the first incoming share folder of specified store root which allows to move a file from specified incoming folder to the incoming share.


getSharesWithDataSets

public static java.util.List<Share> getSharesWithDataSets(java.io.File storeRoot,
                                                          java.lang.String dataStoreCode,
                                                          boolean filterOutToBeIgnoredForShuffling,
                                                          java.util.Set<java.lang.String> incomingShares,
                                                          ch.systemsx.cisd.common.filesystem.IFreeSpaceProvider freeSpaceProvider,
                                                          ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService service,
                                                          ch.systemsx.cisd.common.logging.ISimpleLogger log)
Gets a list of all shares of specified store root directory. As a side effect it calculates and updates the size of all data sets if necessary.

Parameters:
dataStoreCode - Code of the data store to which the root belongs.
filterOutToBeIgnoredForShuffling - If true no share will be returned which has property ignored-for-shuffling == true
incomingShares - Set of IDs of incoming shares. Will be used to mark Share object in the returned list.
freeSpaceProvider - Provider of free space used for all shares.
service - Access to openBIS API in order to get all data sets and to update data set size.
log - Logger for logging size calculations.

moveDataSetToAnotherShare

public static void moveDataSetToAnotherShare(java.io.File dataSetDirInStore,
                                             java.io.File share,
                                             ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService service,
                                             ch.systemsx.cisd.openbis.dss.generic.shared.IShareIdManager shareIdManager,
                                             ch.systemsx.cisd.openbis.dss.generic.shared.IChecksumProvider checksumProvider,
                                             ch.systemsx.cisd.common.logging.ISimpleLogger logger)
Moves the specified data set to the specified share. The data set is folder in the store its name is the data set code. The destination folder is share. Its name is the share id.

This method works as follows:

  1. Copying data set to new share.
  2. Sanity check of successfully copied data set.
  3. Changing share id in openBIS AS.
  4. Deletes the data set at the old location after all locks on the data set have been released.

Parameters:
service - to access openBIS AS.
checksumProvider -

deleteDataSet

public static void deleteDataSet(ch.systemsx.cisd.openbis.generic.shared.basic.dto.IDatasetLocation dataSet,
                                 ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetDirectoryProvider dataSetDirectoryProvider,
                                 ch.systemsx.cisd.openbis.dss.generic.shared.IShareIdManager shareIdManager,
                                 ch.systemsx.cisd.common.logging.ISimpleLogger logger)
Deletes specified data set. This methods waits until any locks on the specified data set have been released.


deleteDataSetInstantly

public static void deleteDataSetInstantly(java.lang.String dataSetCode,
                                          java.io.File dataSetDirInStore,
                                          ch.systemsx.cisd.common.logging.ISimpleLogger logger)
Deletes specified data set at specified location. This methods doesn't wait for any locks and removes the data set instantly.


cleanUp

public static void cleanUp(ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO dataSet,
                           java.io.File storeRoot,
                           java.lang.String newShareId,
                           ch.systemsx.cisd.openbis.dss.generic.shared.IShareIdManager shareIdManager,
                           ch.systemsx.cisd.common.logging.ISimpleLogger logger)
Deletes specified data set in the old share if it is already in the new one or in the new one if it is still in the old one.

Parameters:
shareIdManager - provides the current share.