Skip to content

Instantly share code, notes, and snippets.

@sheimi
Created November 9, 2014 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheimi/02efd04e63ff1f427bb1 to your computer and use it in GitHub Desktop.
Save sheimi/02efd04e63ff1f427bb1 to your computer and use it in GitHub Desktop.
code in blog.sheimi.me: 2012-05-17-source-code-02 (3) injector
public static void install(JobConf job, Path crawlDb) throws IOException {
Path newCrawlDb = FileOutputFormat.getOutputPath(job);
FileSystem fs = new JobClient(job).getFs();
Path old = new Path(crawlDb, "old");
Path current = new Path(crawlDb, CURRENT_NAME);
if (fs.exists(current)) {
if (fs.exists(old)) fs.delete(old, true);
fs.rename(current, old);
}
fs.mkdirs(crawlDb);
fs.rename(newCrawlDb, current);
if (fs.exists(old)) fs.delete(old, true);
Path lock = new Path(crawlDb, LOCK_NAME);
LockUtil.removeLockFile(fs, lock);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment