use of alluxio.proto.journal.File.AddSyncPointEntry 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);
}
}
}
use of alluxio.proto.journal.File.AddSyncPointEntry in project alluxio by Alluxio.
the class ActiveSyncManager method getSyncPathIterator.
private Iterator<Journal.JournalEntry> getSyncPathIterator() {
final Iterator<AlluxioURI> it = mSyncPathList.iterator();
return new Iterator<Journal.JournalEntry>() {
private AlluxioURI mEntry = null;
@Override
public boolean hasNext() {
if (mEntry != null) {
return true;
}
if (it.hasNext()) {
mEntry = it.next();
return true;
}
return false;
}
@Override
public Journal.JournalEntry next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
String syncPointPath = mEntry.getPath();
long mountId = -1;
while (mountId == -1) {
try {
syncPointPath = mEntry.getPath();
String mountPoint = mMountTable.getMountPoint(mEntry);
MountInfo mountInfo = mMountTable.getMountTable().get(mountPoint);
mountId = mountInfo.getMountId();
} catch (InvalidPathException e) {
LOG.info("Path resolution failed for {}, exception {}", syncPointPath, e);
mEntry = null;
if (!hasNext()) {
throw new NoSuchElementException();
}
}
}
mEntry = null;
File.AddSyncPointEntry addSyncPointEntry = File.AddSyncPointEntry.newBuilder().setSyncpointPath(syncPointPath).setMountId(mountId).build();
return Journal.JournalEntry.newBuilder().setAddSyncPoint(addSyncPointEntry).build();
}
@Override
public void remove() {
throw new UnsupportedOperationException("ActiveSyncManager#Iterator#remove is not supported.");
}
};
}
use of alluxio.proto.journal.File.AddSyncPointEntry 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;
}
}
}
Aggregations