Skip to content

Commit

Permalink
pool: Rename repository and store related classes
Browse files Browse the repository at this point in the history
As requested by Paul.

Serialized classes are not renamed.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Paul Millar <paul.millar@desy.de>

Reviewed at https://rb.dcache.org/r/9488/
  • Loading branch information
gbehrmann committed Jun 29, 2016
1 parent d1fab17 commit 5a9db09
Show file tree
Hide file tree
Showing 50 changed files with 467 additions and 468 deletions.
Expand Up @@ -61,7 +61,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

import org.dcache.cells.CellStub;
import org.dcache.pool.repository.EntryChangeEvent;
import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.StateChangeEvent;
import org.dcache.pool.repository.StateChangeListener;
import org.dcache.pool.repository.StickyChangeEvent;
Expand All @@ -87,7 +87,7 @@ public void accessTimeChanged(EntryChangeEvent event) {

@Override
public void stateChanged(StateChangeEvent event) {
if (event.getNewState() == EntryState.BROKEN) {
if (event.getNewState() == ReplicaState.BROKEN) {
corruptFileTopic.notify(new CorruptFileMessage(poolName,
event.getPnfsId()));
}
Expand Down
Expand Up @@ -61,13 +61,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

import java.util.concurrent.ExecutorService;

import diskCacheV111.util.CacheException;
import diskCacheV111.util.PnfsId;
import diskCacheV111.vehicles.Message;
import dmg.cells.nucleus.CellMessageReceiver;
import dmg.cells.nucleus.Reply;
import org.dcache.cells.MessageReply;
import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.Repository;
import org.dcache.pool.repository.StickyRecord;
import org.dcache.vehicles.resilience.ForceSystemStickyBitMessage;
Expand Down Expand Up @@ -97,7 +96,7 @@ public Reply messageArrived(RemoveReplicaMessage message) {
MessageReply<Message> reply = new MessageReply<>();
executor.execute(() -> {
try {
repository.setState(message.getPnfsId(), EntryState.REMOVED);
repository.setState(message.getPnfsId(), ReplicaState.REMOVED);
reply.reply(message);
} catch (Exception e) {
reply.fail(message, e);
Expand Down
Expand Up @@ -83,7 +83,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import org.dcache.pool.migration.PoolSelectionStrategy;
import org.dcache.pool.migration.Task;
import org.dcache.pool.migration.TaskParameters;
import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.StickyRecord;
import org.dcache.resilience.data.FileOperation;
import org.dcache.resilience.data.FileOperationMap;
Expand Down Expand Up @@ -329,7 +329,7 @@ public Task handleMakeOneCopy(FileAttributes attributes) {
1);

Task task = new Task(taskParameters, completionHandler, source, pnfsId,
EntryState.CACHED, ONLINE_STICKY_RECORD,
ReplicaState.CACHED, ONLINE_STICKY_RECORD,
Collections.EMPTY_LIST, attributes,
attributes.getAccessTime());
LOGGER.trace("Created migration task for {}: {}.", pnfsId, task);
Expand Down
Expand Up @@ -7,7 +7,7 @@
import diskCacheV111.util.RetentionPolicy;
import diskCacheV111.vehicles.StorageInfo;

import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.StickyRecord;
import org.dcache.vehicles.FileAttributes;

Expand Down Expand Up @@ -38,17 +38,17 @@ public List<StickyRecord> getStickyRecords(FileAttributes fileAttributes)
}

@Override
public EntryState getTargetState(FileAttributes fileAttributes)
public ReplicaState getTargetState(FileAttributes fileAttributes)
{
// flush to tape only if the file defined as a 'tape
// file'( RP = Custodial) and the HSM is defined
StorageInfo info = fileAttributes.getStorageInfo();
if (info.getKey("overwrite") != null) {
return EntryState.CACHED;
return ReplicaState.CACHED;
} else if (!info.isStored() && fileAttributes.getRetentionPolicy().equals(RetentionPolicy.CUSTODIAL)) {
return EntryState.PRECIOUS;
return ReplicaState.PRECIOUS;
} else {
return EntryState.CACHED;
return ReplicaState.CACHED;
}
}
}
Expand Up @@ -32,7 +32,7 @@

import org.dcache.alarms.AlarmMarkerFactory;
import org.dcache.alarms.PredefinedAlarm;
import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.ReplicaDescriptor;
import org.dcache.pool.repository.Repository;
import org.dcache.pool.repository.Repository.OpenFlags;
Expand Down Expand Up @@ -439,8 +439,8 @@ private void scanFiles(PnfsId[] repository)
{
for (PnfsId id : repository) {
try {
if (_repository.getState(id) == EntryState.CACHED ||
_repository.getState(id) == EntryState.PRECIOUS) {
if (_repository.getState(id) == ReplicaState.CACHED ||
_repository.getState(id) == ReplicaState.PRECIOUS) {
ReplicaDescriptor handle =
_repository.openEntry(id, EnumSet.of(OpenFlags.NOATIME));
try {
Expand All @@ -459,7 +459,7 @@ private void scanFiles(PnfsId[] repository)
poolName,
e.getMessage());
try {
_repository.setState(id, EntryState.BROKEN);
_repository.setState(id, ReplicaState.BROKEN);
} catch (CacheException f) {
_log.warn("Failed to mark {} as BROKEN: {}", id, f.getMessage());
}
Expand Down
Expand Up @@ -8,7 +8,7 @@

import org.dcache.pool.repository.AbstractStateChangeListener;
import org.dcache.pool.repository.CacheEntry;
import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.Repository;
import org.dcache.pool.repository.SpaceSweeperPolicy;
import org.dcache.pool.repository.StateChangeEvent;
Expand Down Expand Up @@ -61,11 +61,11 @@ public long getLru()
public void stateChanged(StateChangeEvent event)
{
try {
if (event.getNewState() == EntryState.CACHED) {
if (event.getNewState() == ReplicaState.CACHED) {
PnfsId id = event.getPnfsId();
CacheEntry entry = event.getNewEntry();
if (!entry.isSticky()) {
_repository.setState(id, EntryState.REMOVED);
_repository.setState(id, ReplicaState.REMOVED);
_log.debug(entry.getPnfsId() + " : removed.");
}
}
Expand Down
52 changes: 26 additions & 26 deletions modules/dcache/src/main/java/org/dcache/pool/classic/PoolV4.java
Expand Up @@ -99,14 +99,14 @@
import org.dcache.pool.repository.AbstractStateChangeListener;
import org.dcache.pool.repository.Account;
import org.dcache.pool.repository.CacheEntry;
import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.IllegalTransitionException;
import org.dcache.pool.repository.ReplicaDescriptor;
import org.dcache.pool.repository.Repository;
import org.dcache.pool.repository.SpaceRecord;
import org.dcache.pool.repository.StateChangeEvent;
import org.dcache.pool.repository.StickyRecord;
import org.dcache.pool.repository.v5.CacheRepositoryV5;
import org.dcache.pool.repository.v5.ReplicaRepository;
import org.dcache.util.Args;
import org.dcache.util.IoPriority;
import org.dcache.util.Version;
Expand Down Expand Up @@ -157,7 +157,7 @@ public class PoolV4

private PnfsHandler _pnfs;
private StorageClassContainer _storageQueue;
private CacheRepositoryV5 _repository;
private ReplicaRepository _repository;

private Account _account;

Expand Down Expand Up @@ -320,7 +320,7 @@ public void setPnfsHandler(PnfsHandler pnfs)
}

@Required
public void setRepository(CacheRepositoryV5 repository)
public void setRepository(ReplicaRepository repository)
{
assertNotRunning("Cannot set repository after initialization");
if (_repository != null) {
Expand Down Expand Up @@ -554,7 +554,7 @@ private class HFlagMaintainer extends AbstractStateChangeListener
@Override
public void stateChanged(StateChangeEvent event)
{
if (event.getOldState() == EntryState.FROM_CLIENT) {
if (event.getOldState() == ReplicaState.FROM_CLIENT) {
PnfsId id = event.getPnfsId();
if (_hasTapeBackend) {
_pnfs.putPnfsFlag(id, "h", "yes");
Expand All @@ -574,14 +574,14 @@ private class RepositoryLoader extends AbstractStateChangeListener
public void stateChanged(StateChangeEvent event)
{
PnfsId id = event.getPnfsId();
EntryState from = event.getOldState();
EntryState to = event.getNewState();
ReplicaState from = event.getOldState();
ReplicaState to = event.getNewState();

if (from == to) {
return;
}

if (to == EntryState.PRECIOUS) {
if (to == ReplicaState.PRECIOUS) {
_log.debug("Adding {} to flush queue", id);

if (_hasTapeBackend) {
Expand All @@ -597,7 +597,7 @@ public void stateChanged(StateChangeEvent event)
_log.error("Error adding {} to flush queue: {}", id, e.getMessage());
}
}
} else if (from == EntryState.PRECIOUS) {
} else if (from == ReplicaState.PRECIOUS) {
_log.debug("Removing {} from flush queue", id);
if (!_storageQueue.removeCacheEntry(id)) {
_log.info("File {} not found in flush queue", id);
Expand All @@ -612,7 +612,7 @@ private class NotifyBillingOnRemoveListener
@Override
public void stateChanged(StateChangeEvent event)
{
if (_reportOnRemovals && event.getNewState() == EntryState.REMOVED) {
if (_reportOnRemovals && event.getNewState() == ReplicaState.REMOVED) {
CacheEntry entry = event.getNewEntry();
RemoveFileInfoMessage msg =
new RemoveFileInfoMessage(getCellAddress().toString(), entry.getPnfsId());
Expand Down Expand Up @@ -722,13 +722,13 @@ public Mover<?> createMover(CellMessage envelop, PoolIoFileMessage message) thro
if (message instanceof PoolAcceptFileMessage) {
List<StickyRecord> stickyRecords =
_replicaStatePolicy.getStickyRecords(attributes);
EntryState targetState =
ReplicaState targetState =
_replicaStatePolicy.getTargetState(attributes);
handle = _repository.createEntry(attributes,
EntryState.FROM_CLIENT,
targetState,
stickyRecords,
EnumSet.of(Repository.OpenFlags.CREATEFILE));
ReplicaState.FROM_CLIENT,
targetState,
stickyRecords,
EnumSet.of(Repository.OpenFlags.CREATEFILE));
} else {
Set<Repository.OpenFlags> openFlags =
message.isPool2Pool()
Expand Down Expand Up @@ -798,10 +798,10 @@ private class ReplicationHandler
@Override
public void stateChanged(StateChangeEvent event)
{
EntryState from = event.getOldState();
EntryState to = event.getNewState();
ReplicaState from = event.getOldState();
ReplicaState to = event.getNewState();

if (to == EntryState.CACHED || to == EntryState.PRECIOUS) {
if (to == ReplicaState.CACHED || to == ReplicaState.PRECIOUS) {
switch (from) {
case FROM_CLIENT:
initiateReplication(event.getPnfsId(), "write");
Expand Down Expand Up @@ -1037,15 +1037,15 @@ public DelayedReply messageArrived(Pool2PoolTransferMsg msg)
CompanionFileAvailableCallback callback =
new CompanionFileAvailableCallback(msg);

EntryState targetState = EntryState.CACHED;
ReplicaState targetState = ReplicaState.CACHED;
int fileMode = msg.getDestinationFileStatus();
if (fileMode != Pool2PoolTransferMsg.UNDETERMINED) {
if (fileMode == Pool2PoolTransferMsg.PRECIOUS) {
targetState = EntryState.PRECIOUS;
targetState = ReplicaState.PRECIOUS;
}
} else if (!_hasTapeBackend && !_isVolatile
&& (_p2pFileMode == P2P_PRECIOUS)) {
targetState = EntryState.PRECIOUS;
targetState = ReplicaState.PRECIOUS;
}

List<StickyRecord> stickyRecords = Collections.emptyList();
Expand Down Expand Up @@ -1175,11 +1175,11 @@ public PoolRemoveFilesMessage messageArrived(PoolRemoveFilesMessage msg)
try {
PnfsId pnfsId = new PnfsId(fileList[i]);
if (!_cleanPreciousFiles && _hasTapeBackend
&& (_repository.getState(pnfsId) == EntryState.PRECIOUS)) {
&& (_repository.getState(pnfsId) == ReplicaState.PRECIOUS)) {
counter++;
_log.error("Replica " + fileList[i] + " kept (precious)");
} else {
_repository.setState(pnfsId, EntryState.REMOVED);
_repository.setState(pnfsId, ReplicaState.REMOVED);
fileList[i] = null;
}
} catch (IllegalTransitionException e) {
Expand Down Expand Up @@ -1211,14 +1211,14 @@ public PoolRemoveFilesMessage messageArrived(PoolRemoveFilesMessage msg)
switch (_repository.getState(pnfsId)) {
case PRECIOUS:
if (msg.isCached()) {
_repository.setState(pnfsId, EntryState.CACHED);
_repository.setState(pnfsId, ReplicaState.CACHED);
}
msg.setSucceeded();
break;

case CACHED:
if (msg.isPrecious()) {
_repository.setState(pnfsId, EntryState.PRECIOUS);
_repository.setState(pnfsId, ReplicaState.PRECIOUS);
}
msg.setSucceeded();
break;
Expand Down Expand Up @@ -1597,7 +1597,7 @@ private void addCacheLocation(PnfsId id)
_pnfs.addCacheLocation(id);
} catch (FileNotFoundCacheException e) {
try {
_repository.setState(id, EntryState.REMOVED);
_repository.setState(id, ReplicaState.REMOVED);
_log.info("File not found in PNFS; removed " + id);
} catch (InterruptedException | CacheException f) {
_log.error("File not found in PNFS, but failed to remove "
Expand Down
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.StickyRecord;
import org.dcache.vehicles.FileAttributes;

Expand All @@ -14,5 +14,5 @@
public interface ReplicaStatePolicy
{
List<StickyRecord> getStickyRecords(FileAttributes fileAttributes);
EntryState getTargetState(FileAttributes fileAttributes);
ReplicaState getTargetState(FileAttributes fileAttributes);
}
Expand Up @@ -31,7 +31,7 @@
import org.dcache.pool.repository.Account;
import org.dcache.pool.repository.CacheEntry;
import org.dcache.pool.repository.EntryChangeEvent;
import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.IllegalTransitionException;
import org.dcache.pool.repository.Repository;
import org.dcache.pool.repository.SpaceSweeperPolicy;
Expand Down Expand Up @@ -93,7 +93,7 @@ public void stop() throws InterruptedException
@Override
public boolean isRemovable(CacheEntry entry)
{
return entry.getState() == EntryState.CACHED && !entry.isSticky();
return entry.getState() == ReplicaState.CACHED && !entry.isSticky();
}

/**
Expand Down Expand Up @@ -356,7 +356,7 @@ private long reclaim(long amount)

long size = entry.getReplicaSize();
_log.debug("Sweeper removes {}.", id);
_repository.setState(id, EntryState.REMOVED);
_repository.setState(id, ReplicaState.REMOVED);
deleted += size;
} catch (IllegalTransitionException | FileNotInCacheException e) {
/* Normal if file got removed just as we wanted to
Expand Down
Expand Up @@ -3,7 +3,7 @@
import java.util.Collections;
import java.util.List;

import org.dcache.pool.repository.EntryState;
import org.dcache.pool.repository.ReplicaState;
import org.dcache.pool.repository.StickyRecord;
import org.dcache.vehicles.FileAttributes;

Expand All @@ -20,8 +20,8 @@ public List<StickyRecord> getStickyRecords(FileAttributes fileAttributes)
}

@Override
public EntryState getTargetState(FileAttributes fileAttributes)
public ReplicaState getTargetState(FileAttributes fileAttributes)
{
return EntryState.CACHED;
return ReplicaState.CACHED;
}
}

0 comments on commit 5a9db09

Please sign in to comment.