Search in sources :

Example 16 with StickyRecord

use of org.dcache.pool.repository.StickyRecord in project dcache by dCache.

the class RepositorySubsystemTest method setUp.

@Before
public void setUp() throws Throwable {
    id1 = new PnfsId("000000000001");
    id2 = new PnfsId("000000000002");
    id3 = new PnfsId("000000000003");
    id4 = new PnfsId("000000000004");
    id5 = new PnfsId("000000000005");
    info1 = new GenericStorageInfo();
    info2 = new GenericStorageInfo();
    info3 = new GenericStorageInfo();
    info4 = new GenericStorageInfo();
    info5 = new GenericStorageInfo();
    attributes1 = createFileAttributes(id1, size1, info1);
    attributes2 = createFileAttributes(id2, size2, info2);
    attributes3 = createFileAttributes(id3, size3, info3);
    attributes4 = createFileAttributes(id4, 0, info4);
    attributes5 = createFileAttributes(id5, size5, info5);
    dataRoot = Jimfs.newFileSystem(Configuration.unix()).getPath("/");
    metaRoot = Files.createTempDirectory("dtest");
    dataDir = dataRoot.resolve("data");
    metaDir = metaRoot.resolve("meta");
    Files.createDirectory(dataDir);
    Files.createDirectory(metaDir);
    cell = new CellEndpointHelper(address);
    pnfs = new PnfsHandler(new CellPath("pnfs"), "pool");
    pnfs.setCellEndpoint(cell);
    /* Create test data. Notice that the repository automatically
         * applies a short lived sticky record if we don't request
         * one. That is fine for normal operation, but for testing it
         * is not what we want. So we explicitly specify an expired
         * sticky record to avoid that the automatic sticky record is
         * created.
         */
    initRepository();
    repository.init();
    repository.load();
    createEntry(attributes1, ReplicaState.PRECIOUS, Arrays.asList(new StickyRecord("system", 0)));
    createEntry(attributes2, ReplicaState.CACHED, Arrays.asList(new StickyRecord("system", 0)));
    createEntry(attributes3, ReplicaState.CACHED, Arrays.asList(new StickyRecord("system", -1)));
    repository.shutdown();
    replicaStore.close();
    /* Create repository.
         */
    initRepository();
    sweeper.setAccount(account);
    sweeper.setRepository(repository);
    sweeper.start();
}
Also used : CellPath(dmg.cells.nucleus.CellPath) StickyRecord(org.dcache.pool.repository.StickyRecord) CellEndpointHelper(org.dcache.tests.cells.CellEndpointHelper) PnfsId(diskCacheV111.util.PnfsId) PnfsHandler(diskCacheV111.util.PnfsHandler) GenericStorageInfo(diskCacheV111.vehicles.GenericStorageInfo) Before(org.junit.Before)

Example 17 with StickyRecord

use of org.dcache.pool.repository.StickyRecord in project dcache by dCache.

the class CacheRepositoryEntryImpl method update.

@Override
public synchronized <T> T update(String why, Update<T> update) throws CacheException {
    AtomicReference<T> result = new AtomicReference<>();
    ReplicaState state = _state;
    ImmutableList<StickyRecord> sticky = _sticky;
    try {
        _repository.run(() -> {
            UpdatableRecordImpl record = new UpdatableRecordImpl();
            result.set(update.apply(record));
            record.save();
        });
    } catch (Exception e) {
        _state = state;
        _sticky = sticky;
        if (e instanceof EnvironmentFailureException && !_repository.isValid()) {
            throw new DiskErrorCacheException("Meta data update failed and a pool restart is required: " + e.getMessage(), e);
        }
        Throwables.propagateIfPossible(e, CacheException.class);
        throw new CacheException("Meta data update failed: " + e.getMessage(), e);
    }
    return result.get();
}
Also used : StickyRecord(org.dcache.pool.repository.StickyRecord) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) CacheException(diskCacheV111.util.CacheException) EnvironmentFailureException(com.sleepycat.je.EnvironmentFailureException) AtomicReference(java.util.concurrent.atomic.AtomicReference) ReplicaState(org.dcache.pool.repository.ReplicaState) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) CacheException(diskCacheV111.util.CacheException) EnvironmentFailureException(com.sleepycat.je.EnvironmentFailureException) IOException(java.io.IOException) OperationFailureException(com.sleepycat.je.OperationFailureException)

Aggregations

StickyRecord (org.dcache.pool.repository.StickyRecord)17 CacheException (diskCacheV111.util.CacheException)6 FileNotInCacheException (diskCacheV111.util.FileNotInCacheException)6 PnfsId (diskCacheV111.util.PnfsId)6 ReplicaState (org.dcache.pool.repository.ReplicaState)4 FileInCacheException (diskCacheV111.util.FileInCacheException)3 CacheEntry (org.dcache.pool.repository.CacheEntry)3 ReplicaDescriptor (org.dcache.pool.repository.ReplicaDescriptor)3 DiskErrorCacheException (diskCacheV111.util.DiskErrorCacheException)2 LockedCacheException (diskCacheV111.util.LockedCacheException)2 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)2 Message (diskCacheV111.vehicles.Message)2 CellPath (dmg.cells.nucleus.CellPath)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 MessageReply (org.dcache.cells.MessageReply)2 OpenFlags (org.dcache.pool.repository.Repository.OpenFlags)2 CellStubHelper (org.dcache.tests.cells.CellStubHelper)2 FileAttributes (org.dcache.vehicles.FileAttributes)2 PnfsSetFileAttributes (org.dcache.vehicles.PnfsSetFileAttributes)2