Skip to content

Commit

Permalink
Revert behavior back to truncating milliseconds in backups last modif…
Browse files Browse the repository at this point in the history
…ied time. (#948)
  • Loading branch information
mattl-netflix authored Jun 8, 2021
1 parent a0795dc commit c313fdd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ private String removeHash(String appNameWithHash) {
*/
private String getV2Location() {
ImmutableList.Builder<String> parts = getV2Prefix();
parts.add(type.toString(), getLastModified().toEpochMilli() + "");
// JDK-8177809 truncate to seconds to ensure consistent behavior with our old method of
// getting lastModified time (File::lastModified) in Java 8.
long lastModified = getLastModified().toEpochMilli() / 1_000L * 1_000L;
parts.add(type.toString(), lastModified + "");
if (BackupFileType.isDataFile(type)) {
parts.add(keyspace, columnFamily);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public void testV2BackupPathSST() {

AbstractBackupPath abstractBackupPath2 = pathFactory.get();
abstractBackupPath2.parseRemote(remotePath);
Assert.assertEquals(now, abstractBackupPath2.getLastModified());
Assert.assertEquals(
now.toEpochMilli() / 1_000L * 1_000L,
abstractBackupPath2.getLastModified().toEpochMilli());
validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2);
}

Expand Down Expand Up @@ -183,7 +185,9 @@ public void testV2BackupPathMeta() {

AbstractBackupPath abstractBackupPath2 = pathFactory.get();
abstractBackupPath2.parseRemote(remotePath);
Assert.assertEquals(now, abstractBackupPath2.getLastModified());
Assert.assertEquals(
now.toEpochMilli() / 1_000L * 1_000L,
abstractBackupPath2.getLastModified().toEpochMilli());
validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2);
}

Expand Down Expand Up @@ -214,15 +218,17 @@ public void testV2BackupPathSecondaryIndex() {
abstractBackupPath.setLastModified(now);
String remotePath = abstractBackupPath.getRemotePath();
logger.info(remotePath);
long correctLastModified = +now.toEpochMilli() / 1_000L * 1_000L;
Assert.assertEquals(
"casstestbackup/1049_fake-app/1808575600/SECONDARY_INDEX_V2/"
+ now.toEpochMilli()
+ correctLastModified
+ "/keyspace1/columnfamily1/.columnfamily1_field1_idx/SNAPPY/PLAINTEXT/mc-1234-Data.db",
remotePath);

AbstractBackupPath abstractBackupPath2 = pathFactory.get();
abstractBackupPath2.parseRemote(remotePath);
Assert.assertEquals(now, abstractBackupPath2.getLastModified());
Assert.assertEquals(
correctLastModified, abstractBackupPath2.getLastModified().toEpochMilli());
validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2);
}

Expand Down Expand Up @@ -254,15 +260,17 @@ public void testV2SnapshotPathSecondaryIndex() {
abstractBackupPath.setLastModified(now);
String remotePath = abstractBackupPath.getRemotePath();
logger.info(remotePath);
long correctLastModified = +now.toEpochMilli() / 1_000L * 1_000L;
Assert.assertEquals(
"casstestbackup/1049_fake-app/1808575600/SECONDARY_INDEX_V2/"
+ now.toEpochMilli()
+ correctLastModified
+ "/keyspace1/columnfamily1/.columnfamily1_field1_idx/SNAPPY/PLAINTEXT/mc-1234-Data.db",
remotePath);

AbstractBackupPath abstractBackupPath2 = pathFactory.get();
abstractBackupPath2.parseRemote(remotePath);
Assert.assertEquals(now, abstractBackupPath2.getLastModified());
Assert.assertEquals(
correctLastModified, abstractBackupPath2.getLastModified().toEpochMilli());
validateAbstractBackupPath(abstractBackupPath, abstractBackupPath2);
}

Expand Down

0 comments on commit c313fdd

Please sign in to comment.