Search in sources :

Example 1 with RemoveSyncPointEntry

use of alluxio.proto.journal.File.RemoveSyncPointEntry in project alluxio by Alluxio.

the class ActiveSyncManager method stopSyncAndJournal.

/**
 * Stop active sync on a URI and journal the remove entry.
 *
 * @param rpcContext the master rpc or no-op context
 * @param syncPoint sync point to be stopped
 */
public void stopSyncAndJournal(RpcContext rpcContext, AlluxioURI syncPoint) throws InvalidPathException {
    if (!isSyncPoint(syncPoint)) {
        throw new InvalidPathException(String.format("%s is not a sync point", syncPoint));
    }
    try (LockResource r = new LockResource(mLock)) {
        MountTable.Resolution resolution = mMountTable.resolve(syncPoint);
        LOG.debug("stop syncPoint {}", syncPoint.getPath());
        final long mountId = resolution.getMountId();
        RemoveSyncPointEntry removeSyncPoint = File.RemoveSyncPointEntry.newBuilder().setSyncpointPath(syncPoint.toString()).setMountId(mountId).build();
        applyAndJournal(rpcContext, removeSyncPoint);
        try {
            stopSyncInternal(syncPoint);
        } catch (Throwable e) {
            LOG.warn("Stop sync failed on {}", syncPoint, e);
            // revert state;
            AddSyncPointEntry addSyncPoint = File.AddSyncPointEntry.newBuilder().setSyncpointPath(syncPoint.toString()).build();
            applyAndJournal(rpcContext, addSyncPoint);
            recoverFromStopSync(syncPoint);
        }
    }
}
Also used : LockResource(alluxio.resource.LockResource) AddSyncPointEntry(alluxio.proto.journal.File.AddSyncPointEntry) RemoveSyncPointEntry(alluxio.proto.journal.File.RemoveSyncPointEntry) MountTable(alluxio.master.file.meta.MountTable) InvalidPathException(alluxio.exception.InvalidPathException)

Example 2 with RemoveSyncPointEntry

use of alluxio.proto.journal.File.RemoveSyncPointEntry in project alluxio by Alluxio.

the class ActiveSyncManager method startSyncAndJournal.

/**
 * Start active sync on a URI and journal the add entry.
 *
 * @param rpcContext the master rpc or no-op context
 * @param syncPoint sync point to be start
 */
public void startSyncAndJournal(RpcContext rpcContext, AlluxioURI syncPoint) throws InvalidPathException {
    try (LockResource r = new LockResource(mLock)) {
        MountTable.Resolution resolution = mMountTable.resolve(syncPoint);
        long mountId = resolution.getMountId();
        try (CloseableResource<UnderFileSystem> ufsResource = resolution.acquireUfsResource()) {
            if (!ufsResource.get().supportsActiveSync()) {
                throw new UnsupportedOperationException("Active Syncing is not supported on this UFS type: " + ufsResource.get().getUnderFSType());
            }
        }
        if (isUnderSyncPoint(syncPoint)) {
            throw new InvalidPathException("URI " + syncPoint + " is already a sync point");
        }
        AddSyncPointEntry addSyncPoint = AddSyncPointEntry.newBuilder().setSyncpointPath(syncPoint.toString()).setMountId(mountId).build();
        applyAndJournal(rpcContext, addSyncPoint);
        try {
            startSyncInternal(syncPoint, resolution);
        } catch (Throwable e) {
            LOG.warn("Start sync failed on {}", syncPoint, e);
            // revert state;
            RemoveSyncPointEntry removeSyncPoint = File.RemoveSyncPointEntry.newBuilder().setSyncpointPath(syncPoint.toString()).build();
            applyAndJournal(rpcContext, removeSyncPoint);
            recoverFromStartSync(syncPoint, resolution.getMountId());
            throw e;
        }
    }
}
Also used : LockResource(alluxio.resource.LockResource) AddSyncPointEntry(alluxio.proto.journal.File.AddSyncPointEntry) RemoveSyncPointEntry(alluxio.proto.journal.File.RemoveSyncPointEntry) MountTable(alluxio.master.file.meta.MountTable) UnderFileSystem(alluxio.underfs.UnderFileSystem) InvalidPathException(alluxio.exception.InvalidPathException)

Aggregations

InvalidPathException (alluxio.exception.InvalidPathException)2 MountTable (alluxio.master.file.meta.MountTable)2 AddSyncPointEntry (alluxio.proto.journal.File.AddSyncPointEntry)2 RemoveSyncPointEntry (alluxio.proto.journal.File.RemoveSyncPointEntry)2 LockResource (alluxio.resource.LockResource)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)1