Skip to content

Commit

Permalink
Generalize by renaming, per @DmitryLitvintsev suggestion
Browse files Browse the repository at this point in the history
* `PoolManagerGetPoolsBySourcePoolPoolGroupMessage` -> `PoolManagerGetPoolsByPoolGroupOfPoolMessage`
* `PoolListBySourcePoolPoolGroup` -> `PoolListByPoolGroupOfPool`
* `getPoolsBySourcePoolPoolGroup()` -> `getPoolsByPoolGroupOfPool()`
* `(_?)sourcePool` -> `\1poolName`
* `getSourcePool()` -> `getPoolName()`
* "source pool" -> "pool"
  • Loading branch information
greenc-FNAL committed Sep 12, 2024
1 parent 55e5e29 commit 8f6e24a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public Collection<SelectionPool> getPoolsByPoolGroup(String poolGroup)
}

@Override
public Collection<SelectionPool> getPoolsBySourcePoolPoolGroup(String sourcePool) throws NoSuchElementException {
return psu.getPoolsBySourcePoolPoolGroup(sourcePool);
public Collection<SelectionPool> getPoolsByPoolGroupOfPool(String poolName) throws NoSuchElementException {
return psu.getPoolsByPoolGroupOfPool(poolName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package diskCacheV111.vehicles;

import static java.util.Objects.requireNonNull;

public class PoolManagerGetPoolsByPoolGroupOfPoolMessage
extends PoolManagerGetPoolsMessage {

private static final long serialVersionUID = 4423670920097918847L;

private final String _poolName;

public PoolManagerGetPoolsByPoolGroupOfPoolMessage(String poolName) {
_poolName = requireNonNull(poolName);
}

public String getPoolName() {
return _poolName;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import diskCacheV111.vehicles.PoolManagerGetPoolsByLinkMessage;
import diskCacheV111.vehicles.PoolManagerGetPoolsByNameMessage;
import diskCacheV111.vehicles.PoolManagerGetPoolsByPoolGroupMessage;
import diskCacheV111.vehicles.PoolManagerGetPoolsBySourcePoolPoolGroupMessage;
import diskCacheV111.vehicles.PoolManagerGetPoolsByPoolGroupOfPoolMessage;
import diskCacheV111.vehicles.PoolManagerPoolInformation;
import diskCacheV111.vehicles.PoolManagerPoolModeMessage;
import diskCacheV111.vehicles.PoolManagerPoolUpMessage;
Expand Down Expand Up @@ -525,12 +525,12 @@ private void getPoolInformation(
return msg;
}

public PoolManagerGetPoolsBySourcePoolPoolGroupMessage
messageArrived(PoolManagerGetPoolsBySourcePoolPoolGroupMessage msg) {
public PoolManagerGetPoolsByPoolGroupOfPoolMessage
messageArrived(PoolManagerGetPoolsByPoolGroupOfPoolMessage msg) {
try {
List<PoolManagerPoolInformation> pools = new ArrayList<>();
List<String> offlinePools = new ArrayList<>();
getPoolInformation(_selectionUnit.getPoolsBySourcePoolPoolGroup(msg.getSourcePool()), pools,
getPoolInformation(_selectionUnit.getPoolsByPoolGroupOfPool(msg.getPoolName()), pools,
offlinePools);
msg.setPools(pools);
msg.setOfflinePools(offlinePools);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ boolean updatePool(String poolName, CellAddressCore address, String canonicalHos

Collection<SelectionPool> getPoolsByPoolGroup(String poolGroup) throws NoSuchElementException;

Collection<SelectionPool> getPoolsBySourcePoolPoolGroup(String sourcePool) throws NoSuchElementException;
Collection<SelectionPool> getPoolsByPoolGroupOfPool(String poolName) throws NoSuchElementException;

Collection<SelectionPool> getAllDefinedPools(boolean enabledOnly);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2623,19 +2623,19 @@ public Collection<SelectionPool> getPoolsByPoolGroup(String poolGroup)
}

@Override
public Collection<SelectionPool> getPoolsBySourcePoolPoolGroup(String sourcePool)
public Collection<SelectionPool> getPoolsByPoolGroupOfPool(String poolName)
throws NoSuchElementException {
Collection<SelectionPoolGroup> groups;
try {
groups = getPoolGroupsOfPool(sourcePool);
groups = getPoolGroupsOfPool(poolName);
} catch (NoSuchElementException e) {
throw new NoSuchElementException("No pool group for nonexistent source pool: " + sourcePool);
throw new NoSuchElementException("No pool group for nonexistent pool: " + poolName);
}

if (groups.isEmpty()) {
throw new NoSuchElementException("No pool group for source pool: " + sourcePool);
throw new NoSuchElementException("No pool group for pool: " + poolName);
} else if (groups.size() > 1) {
throw new NoSuchElementException("No unique pool group for source pool: " + sourcePool);
throw new NoSuchElementException("No unique pool group for pool: " + poolName);
}

return new ArrayList<>(groups.iterator().next().getPools());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ private RefreshablePoolList createPoolList(String type, List<String> targets) {
return new PoolListByHsm(poolManager, targets);
case "pgroup":
if (targets.isEmpty()) {
return new PoolListBySourcePoolPoolGroup(poolManager, _context.getPoolName());
return new PoolListByPoolGroupOfPool(poolManager, _context.getPoolName());
} else {
return new PoolListByPoolGroup(poolManager, targets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
import static java.util.Objects.requireNonNull;

import com.google.common.util.concurrent.MoreExecutors;
import diskCacheV111.vehicles.PoolManagerGetPoolsBySourcePoolPoolGroupMessage;
import diskCacheV111.vehicles.PoolManagerGetPoolsByPoolGroupOfPoolMessage;
import org.dcache.cells.CellStub;

class PoolListBySourcePoolPoolGroup
class PoolListByPoolGroupOfPool
extends PoolListFromPoolManager {

private final CellStub _poolManager;
private final String _sourcePool;
private final String _poolName;

public PoolListBySourcePoolPoolGroup(CellStub poolManager, String sourcePool) {
public PoolListByPoolGroupOfPool(CellStub poolManager, String poolName) {
_poolManager = requireNonNull(poolManager);
_sourcePool = requireNonNull(sourcePool);
_poolName = requireNonNull(poolName);
}

@Override
public void refresh() {
CellStub.addCallback(
_poolManager.send(new PoolManagerGetPoolsBySourcePoolPoolGroupMessage(_sourcePool)),
_poolManager.send(new PoolManagerGetPoolsByPoolGroupOfPoolMessage(_poolName)),
this, MoreExecutors.directExecutor());
}

@Override
public String toString() {
return String.format("source pool %s, %d pools",
_sourcePool, _pools.size());
_poolName, _pools.size());
}
}

0 comments on commit 8f6e24a

Please sign in to comment.