Skip to content

Commit

Permalink
poolmanager: Replace StorageInfo by FileAttributes in PSU
Browse files Browse the repository at this point in the history
Also avoid the use of the legacy StoageInfo#toString method.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Albert Rossir <arossi@fnal.gov>
Patch: http://rb.dcache.org/r/6357/
  • Loading branch information
gbehrmann committed Dec 18, 2013
1 parent 3ee3a23 commit c1eed0c
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 79 deletions.
Expand Up @@ -1734,7 +1734,7 @@ public void fileAttributesAvailable(){
new PoolMgrQueryPoolsMsg(DirectionType.READ,
_protocolName ,
_destination ,
_fileAttributes.getStorageInfo());
_fileAttributes);

CellMessage checkMessage = new CellMessage( _poolMgrPath , query ) ;
setStatus("Waiting for reply from PoolManager");
Expand Down
Expand Up @@ -23,10 +23,10 @@
import diskCacheV111.pools.PoolCostInfo;
import diskCacheV111.pools.PoolV2Mode;
import diskCacheV111.vehicles.GenericStorageInfo;
import diskCacheV111.vehicles.StorageInfo;

import org.dcache.poolmanager.Partition;
import org.dcache.poolmanager.PoolMonitor;
import org.dcache.vehicles.FileAttributes;
import org.dcache.webadmin.model.businessobjects.Pool;
import org.dcache.webadmin.model.dataaccess.PoolsDAO;
import org.dcache.webadmin.model.dataaccess.communication.CellMessageGenerator;
Expand Down Expand Up @@ -226,9 +226,10 @@ public PoolPreferenceLevel[] match(DirectionType type, String netUnitName,
String protocolUnitName, String hsm, String storageClass,
String linkGroupName) throws DAOException {
try {
StorageInfo storageInfo = new GenericStorageInfo(hsm, storageClass);
FileAttributes fileAttributes = new FileAttributes();
fileAttributes.setStorageInfo(new GenericStorageInfo(hsm, storageClass));
return getPoolSelectionUnit().match(type, netUnitName,
protocolUnitName, storageInfo, linkGroupName);
protocolUnitName, fileAttributes, linkGroupName);
} catch (NoSuchContextException ex) {
throw new DAOException("Data not available yet - PoolManger up already?", ex);
} catch (IllegalArgumentException ex) {
Expand Down
Expand Up @@ -529,7 +529,7 @@ public String apply(PoolSelectionUnit.SelectionPool pool) {
_selectionUnit.match(accessType,
msg.getNetUnitName(),
msg.getProtocolUnitName(),
msg.getStorageInfo(),
msg.getFileAttributes(),
null)));
msg.setSucceeded();
return msg;
Expand Down
Expand Up @@ -34,7 +34,6 @@
import diskCacheV111.vehicles.IpProtocolInfo;
import diskCacheV111.vehicles.PoolManagerPoolInformation;
import diskCacheV111.vehicles.ProtocolInfo;
import diskCacheV111.vehicles.StorageInfo;
import diskCacheV111.vehicles.StorageInfos;

import dmg.cells.nucleus.CellMessage;
Expand Down Expand Up @@ -149,7 +148,7 @@ private PoolPreferenceLevel[] match(DirectionType direction)
return _selectionUnit.match(direction,
hostName,
protocol,
StorageInfos.extractFrom(_fileAttributes),
_fileAttributes,
_linkGroup);
}

Expand Down Expand Up @@ -517,24 +516,23 @@ public static Set<FileAttribute> getRequiredAttributesForFileLocality()
return FileLocality.NONE;
}

StorageInfo storageInfo = StorageInfos.extractFrom(attributes);
PoolPreferenceLevel[] levels =
_selectionUnit.match(DirectionType.READ,
hostName,
"*/*",
storageInfo,
attributes,
null);

Collection<String> locations = attributes.getLocations();
for (PoolPreferenceLevel level: levels) {
if (!Collections.disjoint(level.getPoolList(), locations)) {
return (storageInfo.isStored()
return (attributes.getStorageInfo().isStored()
? FileLocality.ONLINE_AND_NEARLINE
: FileLocality.ONLINE);
}
}

if (storageInfo.isStored()) {
if (attributes.getStorageInfo().isStored()) {
return FileLocality.NEARLINE;
}

Expand Down
Expand Up @@ -7,10 +7,11 @@
import java.util.Set;

import diskCacheV111.pools.PoolV2Mode;
import diskCacheV111.vehicles.StorageInfo;

import dmg.cells.nucleus.CellAddressCore;

import org.dcache.vehicles.FileAttributes;

public interface PoolSelectionUnit {

/**
Expand Down Expand Up @@ -184,7 +185,7 @@ public interface SelectionUnitGroup extends SelectionEntity {
public SelectionLink getLinkByName( String linkName ) throws NoSuchElementException ;
public PoolPreferenceLevel []
match( DirectionType type, String net , String protocol,
StorageInfo info, String linkGroup ) ;
FileAttributes fileAttributes, String linkGroup ) ;
public String [] getActivePools() ;
public String [] getDefinedPools( boolean enabledOnly ) ;
public String getVersion() ;
Expand Down
Expand Up @@ -28,12 +28,13 @@
import diskCacheV111.vehicles.GenericStorageInfo;
import diskCacheV111.vehicles.StorageInfo;

import dmg.cells.nucleus.CellCommandListener;
import dmg.cells.nucleus.CellSetupProvider;
import dmg.util.Args;
import dmg.util.CommandSyntaxException;

import dmg.cells.nucleus.CellCommandListener;
import dmg.cells.nucleus.CellSetupProvider;
import org.dcache.util.Glob;
import org.dcache.vehicles.FileAttributes;

public class PoolSelectionUnitV2
implements Serializable,
Expand Down Expand Up @@ -443,21 +444,21 @@ private LinkMap match(LinkMap linkMap, Unit unit, LinkGroup linkGroup,
return linkMap;
}

/**
* @Guarded by _psuReadLock
*/
@Override
public PoolPreferenceLevel[] match(DirectionType type, String netUnitName, String protocolUnitName,
StorageInfo storageInfo, String linkGroupName) {
FileAttributes fileAttributes, String linkGroupName) {

StorageInfo storageInfo = fileAttributes.getStorageInfo();
String storeUnitName = storageInfo.getStorageClass()+"@"+storageInfo.getHsm();
String dCacheUnitName = storageInfo.getCacheClass();

_log.debug("running match: type={} store={} dCacheUnit={} net={} protocol={} SI={} linkGoup={}", type,
storeUnitName, dCacheUnitName, netUnitName, protocolUnitName, storageInfo, linkGroupName);

Map<String, String> variableMap = storageInfo.getMap();

_log.debug("running match: type={} store={} dCacheUnit={} net={} protocol={} keys={} locations={} linkGroup={}",
type, storeUnitName, dCacheUnitName, netUnitName, protocolUnitName,
variableMap, storageInfo.locations(), linkGroupName);


PoolPreferenceLevel[] result = null;
_psuReadLock.lock();
try {
Expand Down Expand Up @@ -907,12 +908,13 @@ public Map<String, Link> match(Unit unit, LinkGroup linkGroup, DirectionType iot

try {
long start = System.currentTimeMillis();
StorageInfo si = GenericStorageInfo.valueOf(args.argv(1), args.argv(2));
FileAttributes fileAttributes = new FileAttributes();
fileAttributes.setStorageInfo(GenericStorageInfo.valueOf(args.argv(1), args.argv(2)));

PoolPreferenceLevel[] list = match(args.argv(0).equals("*") ? DirectionType.ANY
: DirectionType.valueOf(args.argv(0).toUpperCase()),
args.argv(3).equals("*") ? null : args.argv(3), args
.argv(4).equals("*") ? null : args.argv(4), si,
.argv(4).equals("*") ? null : args.argv(4), fileAttributes,
args.getOpt("linkGroup"));
start = System.currentTimeMillis() - start;

Expand Down Expand Up @@ -1525,12 +1527,12 @@ private Object[] fillLinkProperties(Link link, boolean resolve) {

public Object ac_psux_match_$_5(Args args)
{

StorageInfo si = GenericStorageInfo.valueOf(args.argv(1), args.argv(2));
FileAttributes fileAttributes = new FileAttributes();
fileAttributes.setStorageInfo(GenericStorageInfo.valueOf(args.argv(1), args.argv(2)));

PoolPreferenceLevel[] list = match(DirectionType.valueOf(args.argv(0).toUpperCase()),
args.argv(3).equals("*") ? null : args.argv(3),
args.argv(4).equals("*") ? null : args.argv(4), si, args.getOpt("linkGroup"));
args.argv(4).equals("*") ? null : args.argv(4), fileAttributes, args.getOpt("linkGroup"));
return list;
}

Expand Down
Expand Up @@ -4441,7 +4441,7 @@ private List<String> selectLinkGroupForWrite(ProtocolInfo protocolInfo, FileAttr
poolMonitor.getPoolSelectionUnit().match(PoolSelectionUnit.DirectionType.WRITE,
hostName,
protocol,
fileAttributes.getStorageInfo(),
fileAttributes,
linkGroup);
if (level.length > 0) {
outputLinkGroups.add(linkGroup);
Expand Down
Expand Up @@ -6,33 +6,39 @@

import diskCacheV111.poolManager.PoolSelectionUnit.DirectionType;

import org.dcache.namespace.FileAttribute;
import org.dcache.vehicles.FileAttributes;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

public class PoolMgrQueryPoolsMsg extends Message {
private final DirectionType _accessType ;

private String _netUnitName;
private String _protocolUnitName;
private StorageInfo _storageInfo;
private final String _netUnitName;
private final String _protocolUnitName;
private final FileAttributes _fileAttributes;
private List<String> []_poolList;

private static final long serialVersionUID = 4739697573589962019L;

public PoolMgrQueryPoolsMsg(DirectionType accessType,
String protocolUnit,
String netUnitName,
StorageInfo storageInfo) {
_accessType = accessType ;
_protocolUnitName = protocolUnit;
_netUnitName = netUnitName ;
_storageInfo = storageInfo ;

setReplyRequired(true);
assert _storageInfo != null;
FileAttributes fileAttributes) {
_accessType = checkNotNull(accessType);
_protocolUnitName = checkNotNull(protocolUnit);
_netUnitName = checkNotNull(netUnitName);
_fileAttributes = checkNotNull(fileAttributes);
checkArgument(fileAttributes.isDefined(FileAttribute.STORAGEINFO));

setReplyRequired(true);
}
public DirectionType getAccessType(){ return _accessType ; }

public String getNetUnitName(){ return _netUnitName ; }
public String getProtocolUnitName(){ return _protocolUnitName; }
public StorageInfo getStorageInfo(){ return _storageInfo ; }
public FileAttributes getFileAttributes() { return _fileAttributes; }
public void setPoolList( List<String> [] poolList ){ _poolList = poolList ; }
public List<String> [] getPools(){ return _poolList ; }
}

0 comments on commit c1eed0c

Please sign in to comment.