Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
setTimes doesn't change the modificationTime of a working copy's tag …
Browse files Browse the repository at this point in the history
…file

Summary:
As part of task 1741642, CoronaReleaseManager will change the tag file timestamp for a working copy of a
release so that the working release will not be cleaned when it is used by some job. But somehow, setTime doesn't work.

Test Plan: ant test -Dtestcase=TestReleaseManager

Reviewers: rvadali

Reviewed By: rvadali

Task ID: 1841095
  • Loading branch information
jeanxu authored and Alex Feinberg committed Nov 8, 2012
1 parent 6c7c8b6 commit e504354
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.conf.Configuration;

/**
Expand Down Expand Up @@ -223,9 +224,10 @@ public String getRelease(JobID jobid) {
// update the timestamp
Path donePath = new Path(cr.copiedPath, RELEASE_TAG_FILE);
try {
fs.setTimes(donePath, System.currentTimeMillis(), -1);
FSDataOutputStream fos = fs.create(donePath);
fos.close();
} catch (IOException e) {
LOG.error("Unable to set timestamp for " + donePath);
LOG.error("Unable to recreate " + donePath);
return null;
}
cr.jobids.add(jobid);
Expand Down Expand Up @@ -391,7 +393,8 @@ private boolean copyRelease(Path src, Path dest, boolean isTop) {
if (isTop) {
// create the tag file
Path donePath = new Path(dest, RELEASE_TAG_FILE);
fs.create(donePath);
FSDataOutputStream fos = fs.create(donePath);
fos.close();
}
} catch (IOException ioe) {
LOG.error("IOException when link dir ", ioe);
Expand Down
Expand Up @@ -225,9 +225,30 @@ public void testNoCleanup() throws IOException {
}
}
if (!deleted) {
LOG.info( oldPath + " is not deleted");
LOG.info(oldPath + " is not deleted");
}
assertEquals(deleted, false);
LOG.info("Done with the testing for testNoCleanup");
}

// test when a working release is used, the tag file timestamp is changed
public void testNewTag() throws IOException {
LOG.info("Start testNewTag");
JobID jobid = new JobID("TestJob", 1);
long oldTimeStamp = releaseTimeStamp;
long currentTimeStamp = System.currentTimeMillis();
try {
Thread.sleep(1000);
} catch(InterruptedException e) {
}
String workingPath = getRelease(releaseTimeStamp, jobid);
String workingTag = workingPath + "/RELEASE_COPY_DONE";
FileStatus tagStatus = fs.getFileStatus(new Path(workingTag));
long newTimeStamp = tagStatus.getModificationTime();
LOG.info("Before getRelease, " + workingTag + " timestamp is " + oldTimeStamp);
LOG.info("After getRelease, the timestamp is " + newTimeStamp);
assertEquals(newTimeStamp > currentTimeStamp, true);
assertEquals(newTimeStamp > oldTimeStamp, true);
LOG.info("Done with the testing for testNewTag");
}
}

0 comments on commit e504354

Please sign in to comment.