Skip to content

Commit

Permalink
Revert "dcache-qos: (1) Double -resilient flag with -primary on psu p…
Browse files Browse the repository at this point in the history
…group"

This reverts commit fd92047.
  • Loading branch information
alrossi committed Dec 8, 2020
1 parent 539fa1e commit c80be44
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class DynamicPGroup extends PGroup {
private static final long serialVersionUID = 3725185696861231668L;
private final Map<String, String> tags;

DynamicPGroup(String name, boolean primary, Map<String, String> tags) {
super(name, primary);
DynamicPGroup(String name, boolean resilient, Map<String, String> tags) {
super(name, resilient);
this.tags = tags;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Collection<SelectionPoolGroup> getPoolGroupsPointingTo() {
if (pcore instanceof PGroup) {
PGroup original = (PGroup)pcore;
PGroup newPGroup = new PGroup(original.getName(),
original.isPrimary());
original.isResilient());
pGroups.add(newPGroup);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ interface SelectionPool extends SelectionEntity
}

interface SelectionPoolGroup extends SelectionEntity {
boolean isPrimary();
boolean isResilient();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void printSetup(PrintWriter pw)
_pGroups.values().stream().sorted(comparing(PGroup::getName)).forEachOrdered(
group -> {
pw.append("psu create pgroup ").append(group.getName());
if (group.isPrimary()) {
if (group.isResilient()) {
pw.append(" -resilient");
}

Expand Down Expand Up @@ -1121,10 +1121,10 @@ public String matchUnits(String netUnitName, ImmutableList<String> units) {
// the create's
//

public void createDynamicPoolGroup(String name, boolean isPrimary, Map<String, String> tags) {
public void createDynamicPoolGroup(String name, boolean isResilient, Map<String, String> tags) {
wlock();
try {
DynamicPGroup group = new DynamicPGroup(name, isPrimary, tags);
DynamicPGroup group = new DynamicPGroup(name, isResilient, tags);

if (_pGroups.putIfAbsent(group.getName(), group) != null) {
throw new IllegalArgumentException("Duplicated entry : " + name);
Expand All @@ -1136,10 +1136,10 @@ public void createDynamicPoolGroup(String name, boolean isPrimary, Map<String, S
}
}

public void createPoolGroup(String name, boolean isPrimary) {
public void createPoolGroup(String name, boolean isResilient) {
wlock();
try {
PGroup group = new PGroup(name, isPrimary);
PGroup group = new PGroup(name, isResilient);

if (_pGroups.putIfAbsent(group.getName(), group) != null) {
throw new IllegalArgumentException("Duplicated entry : " + name);
Expand Down Expand Up @@ -1419,7 +1419,7 @@ public Object listPoolGroupXml(String groupName) {
result[0] = groupName;
result[1] = group._poolList.keySet().toArray();
result[2] = group._linkList.keySet().toArray();
result[3] = group.isPrimary();
result[3] = group.isResilient();
xlsResult = result;
}
} finally {
Expand Down Expand Up @@ -1672,7 +1672,7 @@ public String listPoolGroups(boolean more, boolean detail, ImmutableList<String>
sb.append(group.getName()).append("\n");
if (detail) {
sb.append(" dynamic = ").append(group instanceof DynamicPGroup).append("\n")
.append(" resilient = ").append(group.isPrimary())
.append(" resilient = ").append(group.isResilient())
.append("\n")
.append(" linkList :\n");
group._linkList.values().stream().sorted(comparing(Link::getName)).forEachOrdered(
Expand Down Expand Up @@ -2585,21 +2585,21 @@ public String ac_psu_clear_im_really_sure(Args args)
return "";
}

public static final String hh_psu_create_pgroup = "<pool group> [-resilient (deprecated) || -primary]";
public static final String hh_psu_create_pgroup = "<pool group> [-resilient]";

@AffectsSetup
public String ac_psu_create_pgroup_$_1(Args args)
{
boolean primary = args.hasOption("resilient") || args.hasOption("primary");
if (args.hasOption("dynamic")) {
Map<String, String> tags = Splitter.on(',')
.omitEmptyStrings()
.trimResults()
.withKeyValueSeparator('=')
.split(args.getOption("tags", ""));
createDynamicPoolGroup(args.argv(0), primary, tags);

createDynamicPoolGroup(args.argv(0), args.hasOption("resilient"), tags);
} else {
createPoolGroup(args.argv(0), primary);
createPoolGroup(args.argv(0), args.hasOption("resilient"));
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,25 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
public final class StorageUnitInfoExtractor
{
/**
* For backward compatibility.
*/
public static Collection<String> getResilientGroupsFor(String unitName,
PoolSelectionUnit psu) {
return getPrimaryGroupsFor(unitName, psu);
}

/**
* @param primaryOnly return only primary groups.
* @param resilientOnly return only resilient groups.
* @return all the pool groups to which this storage unit is linked.
*/
public static Collection<String> getPoolGroupsFor(String unitName,
PoolSelectionUnit psu,
boolean primaryOnly)
boolean resilientOnly)
{
return psu.getPoolGroups().values().stream()
.filter((g) -> (primaryOnly ? g.isPrimary() : true) &&
.filter((g) -> (resilientOnly ? g.isResilient() : true) &&
hasStorageUnit(g.getName(), unitName, psu))
.map(SelectionPoolGroup::getName)
.collect(Collectors.toList());
}

/**
* @return all the primary pool groups to which this storage unit is linked.
* @return all the resilient pool groups to which this storage unit is linked.
*/
public static Collection<String> getPrimaryGroupsFor(String unitName, PoolSelectionUnit psu)
public static Collection<String> getResilientGroupsFor(String unitName,
PoolSelectionUnit psu)
{
return getPoolGroupsFor(unitName, psu, true);
}
Expand All @@ -122,18 +115,12 @@ public static Collection<StorageUnit> getStorageUnitsInGroup(String name,
return units;
}

/**
* For backward compatibility.
*/
public static boolean hasResilientStorageUnit(String poolGroup, PoolSelectionUnit psu) {
return hasPrimaryStorageUnit(poolGroup, psu);
}

/**
* @return true if the pool group has at least one storage group
* associated with it via a link, and the storage group is primary.
* associated with it via a link, and the storage group is resilient.
*/
public static boolean hasPrimaryStorageUnit(String poolGroup, PoolSelectionUnit psu)
public static boolean hasResilientStorageUnit(String poolGroup,
PoolSelectionUnit psu)
{
return getStorageUnitsInGroup(poolGroup, psu)
.stream()
Expand Down

0 comments on commit c80be44

Please sign in to comment.