Skip to content

Commit

Permalink
poolmanager: Remove link group attributes
Browse files Browse the repository at this point in the history
Link group attributes were not used. The following commands have
been removed from the command line interface:

psu remove linkGroup attribute
psu set linkGroup attribute

The latter of these still exists in the code as a noop to alove existing
poolmanager.conf files to be read.

Target: trunk
Require-notes: yes
Require-book: yes
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/6418/
  • Loading branch information
gbehrmann committed Jan 21, 2014
1 parent c3c4ab7 commit 02e47c4
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 189 deletions.
Expand Up @@ -2,11 +2,6 @@

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;

import diskCacheV111.poolManager.PoolSelectionUnit.SelectionLink;
Expand All @@ -16,8 +11,7 @@ class LinkGroup implements SelectionLinkGroup, Serializable {
private static final long serialVersionUID = 5425784079451748166L;
private final String _name;
private final Collection<SelectionLink> _links = new CopyOnWriteArraySet<>();
// no duplicates is allowed
private final Map<String, Set<String>> _attributes = new ConcurrentHashMap<>();

/*
* my personal view to default behavior
*/
Expand Down Expand Up @@ -51,50 +45,6 @@ public Collection<SelectionLink> getLinks() {
return _links;
}

@Override
public void attribute(String attribute, String value, boolean replace) {
Set<String> valuesSet;
if (!_attributes.containsKey(attribute)) {
valuesSet = new HashSet<>();
_attributes.put(attribute, valuesSet);
} else {
valuesSet = _attributes.get(attribute);
if (replace) {
valuesSet.clear();
}
}
valuesSet.add(value);
}

@Override
public Set<String> attribute(String attribute) {
return _attributes.get(attribute);
}

/**
*
* remove a value associated with a attribute if attribute is empty,
* remove attribute as well.
*
* @param attribute
* @param value
*/
@Override
public void removeAttribute(String attribute, String value) {
if (_attributes.containsKey(attribute)) {
Set<String> valuesSet = _attributes.get(attribute);
valuesSet.remove(value);
if (valuesSet.isEmpty()) {
_attributes.remove(attribute);
}
}
}

@Override
public Map<String, Set<String>> attributes() {
return new HashMap<>(_attributes);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder(_name);
Expand All @@ -110,14 +60,6 @@ public String toString() {
sb.append("[EMPTY]");
}
sb.append("\n");
sb.append(" Attributes:\n");
for (Map.Entry<String, Set<String>> aAttribute : _attributes.entrySet()) {
sb.append(" ").append(aAttribute.getKey()).append(" = ");
for (String aAttributeValue : aAttribute.getValue()) {
sb.append(aAttributeValue).append(" ");
}
sb.append("\n");
}
sb.append(" AccessLatency:\n");
sb.append(" ").append("onlineAllowed=").append(_isOnlineAllowed).append("\n");
sb.append(" ").append("nearlineAllowed=").append(_isNearlineAllowed).append("\n");
Expand Down
Expand Up @@ -154,10 +154,6 @@ public interface SelectionLinkGroup extends SelectionEntity{
public void add(SelectionLink link);
public boolean remove(SelectionLink link);
Collection<SelectionLink> getLinks();
void attribute(String attribute, String value, boolean replace);
Set<String> attribute(String attribute);
void removeAttribute(String attribute, String value);
Map<String, Set<String>> attributes();

void setCustodialAllowed(boolean isAllowed);
void setOutputAllowed(boolean isAllowed);
Expand Down
Expand Up @@ -273,18 +273,6 @@ public void printSetup(PrintWriter pw)
linkGroup.getName()).append(" ").println(
linkGroup.isOnlineAllowed());

for (Map.Entry<String, Set<String>> aAttribute : linkGroup
.attributes().entrySet()) {

String attributeName = aAttribute.getKey();
for (String aAttributeValue : aAttribute.getValue()) {
pw.append("psu set linkGroup attribute ").append(
linkGroup.getName()).append(" ").append(
attributeName).append("=").println(
aAttributeValue);
}
}

for (SelectionLink link : linkGroup.getLinks()) {
pw.append("psu addto linkGroup ").append(
linkGroup.getName()).append(" ").println(
Expand Down Expand Up @@ -2442,66 +2430,11 @@ private void addtoPoolGroup(String pGroupName, String poolName) throws IllegalAr
return "";
}

public final static String hh_psu_set_linkGroup_attribute = "<link group> [-r] attribute=value";

@Deprecated // Remove in 2.10
public String ac_psu_set_linkGroup_attribute_$_2(Args args) {

_psuWriteLock.lock();

try {
String linkGroupName = args.argv(0);

LinkGroup linkGroup = _linkGroups.get(linkGroupName);
if (linkGroup == null) {
throw new IllegalArgumentException("LinkGroup not found : "
+ linkGroupName);
}

String[] attrKeyValue = args.argv(1).split("=");

if (attrKeyValue.length == 1 || attrKeyValue[1] == null
|| attrKeyValue[1].length() == 0) {
return "bad value";
}

linkGroup.attribute(attrKeyValue[0], attrKeyValue[1], args
.hasOption("r"));

} finally {
_psuWriteLock.unlock();
}
return "";
return "psu set linkGroup attribute is obsolete.";
}

public final static String hh_psu_remove_linkGroup_attribute = "<link group> attribute=value";

public String ac_psu_remove_linkGroup_attribute_$_2(Args args) {

_psuWriteLock.lock();

try {
String linkGroupName = args.argv(0);

LinkGroup linkGroup = _linkGroups.get(linkGroupName);
if (linkGroup == null) {
throw new IllegalArgumentException("LinkGroup not found : "
+ linkGroupName);
}

String[] attrKeyValue = args.argv(1).split("=");

if (attrKeyValue.length == 1 || attrKeyValue[1] == null
|| attrKeyValue[1].length() == 0) {
return "bad value";
}
// remove
linkGroup.removeAttribute(attrKeyValue[0], attrKeyValue[1]);

} finally {
_psuWriteLock.unlock();
}
return "";
}

public final static String hh_psu_set_linkGroup_custodialAllowed = "<link group> <true|false>";

Expand Down
@@ -1,14 +1,8 @@
/*
* $Id: PoolLinkGroupInfo.java,v 1.8 2007-10-10 08:05:34 tigran Exp $
*/
package diskCacheV111.vehicles;

import com.google.common.base.Objects;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import diskCacheV111.poolManager.PoolSelectionUnit.SelectionLinkGroup;

Expand All @@ -23,7 +17,6 @@ public class PoolLinkGroupInfo implements Serializable {
private final boolean _outputAllowed;
private final boolean _nearlineAllowed;
private final boolean _onlineAllowed;
private final Map<String,Set<String> > _attributes = new HashMap<>();


public PoolLinkGroupInfo(SelectionLinkGroup linkGroup, long totalSpace, long availableSpace) {
Expand All @@ -35,11 +28,6 @@ public PoolLinkGroupInfo(SelectionLinkGroup linkGroup, long totalSpace, long ava
_outputAllowed = linkGroup.isOutputAllowed();
_nearlineAllowed = linkGroup.isNearlineAllowed();
_onlineAllowed = linkGroup.isOnlineAllowed();

Map<String, Set<String>> attributes = linkGroup.attributes();
if(attributes != null ) {
_attributes.putAll(attributes);
}
}

/**
Expand Down Expand Up @@ -118,51 +106,6 @@ public String toString()
.add("output", _outputAllowed)
.add("nearline", _nearlineAllowed)
.add("online", _onlineAllowed)
.add("attributes", _attributes)
.toString();
}
}
/*
* $Log: not supported by cvs2svn $
* Revision 1.7 2007/10/03 22:25:36 timur
* added support for the ling group roles using the syntax lhcb/Role=/lhcb/lhcbprod instead of lhcbRole=/lhcb/lhcbprod old syntax is still supported
*
* Revision 1.6 2007/01/12 21:10:22 timur
* fixed a NullPointerException issue if VOs are not specified in a LinkGroup
*
* Revision 1.5 2007/01/09 10:59:07 tigran
* PoolLinkGroupInfo creates hsmType based on attributes:
*
* psu create linkGroup spaceManagerGroup
* psu set linkGroup attribute spaceManagerGroup -r HSMType=osm
*
* Revision 1.4 2007/01/09 10:24:27 tigran
* PoolLinkGroupInfo created VOInfo based on attributes:
*
* psu create linkGroup spaceManagerGroup
* psu set linkGroup attribute spaceManagerGroup HSMType=osm
* psu set linkGroup attribute spaceManagerGroup VO=cms
* psu set linkGroup attribute spaceManagerGroup cmsRole=/cms/NULL/production
*
* TODO: this code have to be move into SpaceManager, while PoolManager has no idea about VO .
*
* Revision 1.3 2006/12/27 23:03:37 timur
* take hsm type from the constructor
*
* Revision 1.2 2006/10/27 21:32:14 timur
* changes to support LinkGroups by space manager
*
* Revision 1.1 2006/10/10 13:50:49 tigran
* added linkGroups:
*
* i) set of psu commands to manipulate linksGoups
* ii) PoolManager is able process GetPoolLinkGroups
* as a result an array of PoolLinkGroupInfo is returned with
* linkGroup names and avaliable space per goup
* iii) linkGroup may be requested in PoolMgrSelectPoolRequest
* if goup is not defined other links is taken
*
* TODO:
* exclude links whish are member of some groups from regular operations.
*
*/

0 comments on commit 02e47c4

Please sign in to comment.