-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration: provide default copy behavior per #7623
When `migration copy -pnfsid=X -target=pgroup` is executed without specification of a pool group, identify and use the pool group to which the source's pool(s) belong, if this is singular. Motivation: More intuitive implementation of a common use case. Modules: dcache dcache-vehicles Modification: * Change summary: * `MigrationModule` now allows empty target specification for `migration copy` IFF `-target=pgroup`. * New message `class PoolManagerGetPoolsByPoolGroupOfPoolMessage extends Message`. * New `class PoolListByPoolGroupOfPool extends AbstractMessageCallback<PoolManagerGetPoolsByPoolGroupOfPoolMessage> implements RefreshablePoolList` * New `messageArrived(PoolManagerGetPoolsByPoolGroupOfPoolMessage msg)` overload for `PoolManagerV5`. * Change history: * Implement #7623 * Implement logic described by #7623 (comment) * Fix handling of target list to account for possible omission * Generalize by renaming, per @DmitryLitvintsev suggestion * `PoolManagerGetPoolsBySourcePoolPoolGroupMessage` -> `PoolManagerGetPoolsByPoolGroupOfPoolMessage` * `PoolListBySourcePoolPoolGroup` -> `PoolListByPoolGroupOfPool` * `getPoolsBySourcePoolPoolGroup()` -> `getPoolsByPoolGroupOfPool()` * `(_?)sourcePool` -> `\1poolName` * `getSourcePool()` -> `getPoolName()` * "source pool" -> "pool" * Move check of number of pool groups returned from server to client Per https://rb.dcache.org/r/14316/#comment29381 N.B. The MigrationModule itself appears to have no access to the `poolList` upon job completion to verify its parameters, so the size check on the map is currently implemented in `PoolListByPoolGroupOfPool.success()`. Please advise if this is incorrect. * Address https://rb.dcache.org/r/14316/#comment29388 * Fix imports per https://rb.dcache.org/r/14316/#comment29389 * Reformat new code per official DCache style * Fix variable name per https://rb.dcache.org/r/14316/#comment29392 Result: `migration copy -pnfsid=X -target=pgroup` successfully identifies and uses an appropriate default pool group, where a unique one exists. Release notes: Pool migration : use pool group of source as default destination pool group on copy with `-target=pgroup` when identifiable and unique. Target: master Request: Patch: https://rb.dcache.org/r/14316/ Requires-notes: yes Requires-book: no Acked-by: Tigran Mkrtchyan, Dmitry Litvintsev
- Loading branch information
1 parent
be9d1c7
commit cfeed0c
Showing
4 changed files
with
165 additions
and
6 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...les/src/main/java/diskCacheV111/vehicles/PoolManagerGetPoolsByPoolGroupOfPoolMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package diskCacheV111.vehicles; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class PoolManagerGetPoolsByPoolGroupOfPoolMessage | ||
extends Message { | ||
|
||
private static final long serialVersionUID = -4022990392097610436L; | ||
|
||
private final String _poolName; | ||
private Map<String, List<PoolManagerPoolInformation>> _poolsMap; | ||
private Collection<String> _offlinePools; | ||
|
||
public PoolManagerGetPoolsByPoolGroupOfPoolMessage(String poolName) { | ||
super(true); | ||
_poolName = requireNonNull(poolName); | ||
} | ||
|
||
public String getPoolName() { | ||
return _poolName; | ||
} | ||
|
||
public Map<String, List<PoolManagerPoolInformation>> getPoolsMap() { | ||
return _poolsMap; | ||
} | ||
|
||
public void setPoolsMap(Map<String, List<PoolManagerPoolInformation>> poolsMap) { | ||
_poolsMap = new HashMap<>(poolsMap); | ||
} | ||
|
||
public Collection<String> getOfflinePools() { | ||
return (_offlinePools == null) ? Collections.emptyList() : _offlinePools; | ||
} | ||
|
||
public void setOfflinePools(Collection<String> _offlinePools) { | ||
this._offlinePools = _offlinePools; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
modules/dcache/src/main/java/org/dcache/pool/migration/PoolListByPoolGroupOfPool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.dcache.pool.migration; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.util.concurrent.MoreExecutors; | ||
import diskCacheV111.vehicles.PoolManagerGetPoolsByPoolGroupOfPoolMessage; | ||
import diskCacheV111.vehicles.PoolManagerPoolInformation; | ||
import java.util.List; | ||
import org.dcache.cells.AbstractMessageCallback; | ||
import org.dcache.cells.CellStub; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
class PoolListByPoolGroupOfPool | ||
extends AbstractMessageCallback<PoolManagerGetPoolsByPoolGroupOfPoolMessage> | ||
implements RefreshablePoolList { | ||
|
||
private static final Logger LOGGER = | ||
LoggerFactory.getLogger(PoolListByPoolGroupOfPool.class); | ||
|
||
private final CellStub _poolManager; | ||
private final String _poolName; | ||
private ImmutableMap<String, List<PoolManagerPoolInformation>> _poolsMap; | ||
private ImmutableList<String> _offlinePools = ImmutableList.of(); | ||
|
||
private boolean _isValid; | ||
|
||
public PoolListByPoolGroupOfPool(CellStub poolManager, String poolName) { | ||
_poolManager = requireNonNull(poolManager); | ||
_poolName = requireNonNull(poolName); | ||
} | ||
|
||
@Override | ||
public synchronized boolean isValid() { | ||
return _isValid; | ||
} | ||
|
||
@Override | ||
public ImmutableList<String> getOfflinePools() { | ||
return _offlinePools; | ||
} | ||
|
||
@Override | ||
public ImmutableList<PoolManagerPoolInformation> getPools() { | ||
return _poolsMap.isEmpty() ? | ||
ImmutableList.of() : | ||
ImmutableList.copyOf(_poolsMap.values().iterator().next()); | ||
} | ||
|
||
@Override | ||
public void refresh() { | ||
CellStub.addCallback( | ||
_poolManager.send(new PoolManagerGetPoolsByPoolGroupOfPoolMessage(_poolName)), | ||
this, MoreExecutors.directExecutor()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("source pool %s, %d pools", | ||
_poolName, getPools().size()); | ||
} | ||
|
||
@Override | ||
public void success(PoolManagerGetPoolsByPoolGroupOfPoolMessage message) { | ||
_poolsMap = ImmutableMap.copyOf(message.getPoolsMap()); | ||
_offlinePools = ImmutableList.copyOf(message.getOfflinePools()); | ||
_isValid = (_poolsMap.size() == 1); | ||
} | ||
|
||
@Override | ||
public void failure(int rc, Object error) { | ||
LOGGER.error("Failed to query pool manager ({})", error); | ||
} | ||
} |