/** * Updates the checkpoint to the specified URI. * * @param location the location of the new checkpoint */ public void update(URI location) { try { if (mUfs.isFile(mCheckpoint.toString())) { UnderFileSystemUtils.deleteFileIfExists(mUfs, mTempBackupCheckpoint.toString()); UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString()); // Rename in two steps so that we never have identical mCheckpointPath and // mBackupCheckpointPath. This is a concern since UFS may implement rename as copy + delete. mUfs.renameFile(mCheckpoint.toString(), mTempBackupCheckpoint.toString()); mUfs.renameFile(mTempBackupCheckpoint.toString(), mBackupCheckpoint.toString()); LOG.info("Backed up the checkpoint file to {}", mBackupCheckpoint.toString()); } mUfs.renameFile(location.getPath(), mCheckpoint.toString()); LOG.info("Renamed the checkpoint file from {} to {}", location, mCheckpoint.toString()); // The checkpoint already reflects the information in the completed logs. mWriter.deleteCompletedLogs(); UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString()); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public synchronized JournalOutputStream getCheckpointOutputStream(long latestSequenceNumber) throws IOException { if (mCheckpointOutputStream == null) { mCheckpointManager.recover(); LOG.info("Creating tmp checkpoint file: {}", mTempCheckpoint); if (!mUfs.isDirectory(mJournal.getLocation().toString())) { LOG.info("Creating journal folder: {}", mJournal.getLocation()); mUfs.mkdirs(mJournal.getLocation().toString()); } mNextEntrySequenceNumber = latestSequenceNumber + 1; LOG.info("Latest journal sequence number: {} Next journal sequence number: {}", latestSequenceNumber, mNextEntrySequenceNumber); UnderFileSystemUtils.deleteFileIfExists(mUfs, mTempCheckpoint.toString()); mCheckpointOutputStream = new CheckpointOutputStream( new DataOutputStream(mUfs.create(mTempCheckpoint.toString()))); } return mCheckpointOutputStream; }
UnderFileSystemUtils.deleteFileIfExists(mUfs, mCheckpoint.toString()); mUfs.renameFile(mTempBackupCheckpoint.toString(), mCheckpoint.toString());
String ufsBlockPath = alluxio.worker.BlockUtils.getUfsBlockPath(ufsClient, blockId); try (CloseableResource<UnderFileSystem> ufsResource = ufsClient.acquireUfsResource()) { alluxio.util.UnderFileSystemUtils.deleteFileIfExists(ufsResource.get(), ufsBlockPath); } catch (Exception e) { LOG.warn("Failed to clean up staging UFS block file {}", ufsBlockPath, e.getMessage());
/** * Updates the checkpoint to the specified URI. * * @param location the location of the new checkpoint */ public void update(URI location) { try { if (mUfs.isFile(mCheckpoint.toString())) { UnderFileSystemUtils.deleteFileIfExists(mUfs, mTempBackupCheckpoint.toString()); UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString()); // Rename in two steps so that we never have identical mCheckpointPath and // mBackupCheckpointPath. This is a concern since UFS may implement rename as copy + delete. mUfs.renameFile(mCheckpoint.toString(), mTempBackupCheckpoint.toString()); mUfs.renameFile(mTempBackupCheckpoint.toString(), mBackupCheckpoint.toString()); LOG.info("Backed up the checkpoint file to {}", mBackupCheckpoint.toString()); } mUfs.renameFile(location.getPath(), mCheckpoint.toString()); LOG.info("Renamed the checkpoint file from {} to {}", location, mCheckpoint.toString()); // The checkpoint already reflects the information in the completed logs. mWriter.deleteCompletedLogs(); UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString()); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public synchronized JournalOutputStream getCheckpointOutputStream(long latestSequenceNumber) throws IOException { if (mCheckpointOutputStream == null) { mCheckpointManager.recover(); LOG.info("Creating tmp checkpoint file: {}", mTempCheckpoint); if (!mUfs.isDirectory(mJournal.getLocation().toString())) { LOG.info("Creating journal folder: {}", mJournal.getLocation()); mUfs.mkdirs(mJournal.getLocation().toString()); } mNextEntrySequenceNumber = latestSequenceNumber + 1; LOG.info("Latest journal sequence number: {} Next journal sequence number: {}", latestSequenceNumber, mNextEntrySequenceNumber); UnderFileSystemUtils.deleteFileIfExists(mUfs, mTempCheckpoint.toString()); mCheckpointOutputStream = new CheckpointOutputStream( new DataOutputStream(mUfs.create(mTempCheckpoint.toString()))); } return mCheckpointOutputStream; }
UnderFileSystemUtils.deleteFileIfExists(mUfs, mCheckpoint.toString()); mUfs.renameFile(mTempBackupCheckpoint.toString(), mCheckpoint.toString());