-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete old /hbase/online-snapshot/abort znodes
- Loading branch information
1 parent
848504e
commit 4dc0c38
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
hbase0.98/hbase-snapshot-0.98/src/main/java/com/kakao/hbase/snapshot/SnapshotUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.kakao.hbase.snapshot; | ||
|
||
public class SnapshotUtil { | ||
static long getSnapshotTimestamp(String snapshotName) { | ||
try { | ||
return Snapshot.DATE_FORMAT_SNAPSHOT.parse(snapshotName.substring(snapshotName.length() - 14)).getTime(); | ||
} catch (Throwable e) { | ||
return 0; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
hbase0.98/hbase-snapshot-0.98/src/test/java/com/kakao/hbase/snapshot/SnapshotUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.kakao.hbase.snapshot; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.text.ParseException; | ||
import java.util.Date; | ||
|
||
public class SnapshotUtilTest { | ||
@Test | ||
public void testGetSnapshotTimestamp() throws ParseException { | ||
String timestampStr = "20180309110025"; | ||
long timestampMS = 1520560825000L; | ||
long snapshotTimestamp = SnapshotUtil.getSnapshotTimestamp("table1_S" + timestampStr); | ||
Date date = Snapshot.DATE_FORMAT_SNAPSHOT.parse(timestampStr); | ||
Assert.assertEquals(date.getTime(), snapshotTimestamp); | ||
Assert.assertEquals(timestampMS, snapshotTimestamp); | ||
} | ||
} |