|
@@ -78,45 +78,45 @@ public class TestSnapshotMetrics {
|
|
|
*/
|
|
|
@Test
|
|
|
public void testSnapshottableDirs() throws Exception {
|
|
|
- assertGauge("SnapshottableDirectories", 0L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("SnapshottableDirectories", 0, getMetrics(NS_METRICS));
|
|
|
assertCounter("AllowSnapshotOps", 0L, getMetrics(NN_METRICS));
|
|
|
assertCounter("DisallowSnapshotOps", 0L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// Allow snapshots for directories, and check the metrics
|
|
|
hdfs.allowSnapshot(sub1.toString());
|
|
|
- assertGauge("SnapshottableDirectories", 1L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("SnapshottableDirectories", 1, getMetrics(NS_METRICS));
|
|
|
assertCounter("AllowSnapshotOps", 1L, getMetrics(NN_METRICS));
|
|
|
|
|
|
Path sub2 = new Path(dir, "sub2");
|
|
|
Path file = new Path(sub2, "file");
|
|
|
DFSTestUtil.createFile(hdfs, file, 1024, REPLICATION, seed);
|
|
|
hdfs.allowSnapshot(sub2.toString());
|
|
|
- assertGauge("SnapshottableDirectories", 2L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("SnapshottableDirectories", 2, getMetrics(NS_METRICS));
|
|
|
assertCounter("AllowSnapshotOps", 2L, getMetrics(NN_METRICS));
|
|
|
|
|
|
Path subsub1 = new Path(sub1, "sub1sub1");
|
|
|
Path subfile = new Path(subsub1, "file");
|
|
|
DFSTestUtil.createFile(hdfs, subfile, 1024, REPLICATION, seed);
|
|
|
hdfs.allowSnapshot(subsub1.toString());
|
|
|
- assertGauge("SnapshottableDirectories", 3L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("SnapshottableDirectories", 3, getMetrics(NS_METRICS));
|
|
|
assertCounter("AllowSnapshotOps", 3L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// Set an already snapshottable directory to snapshottable, should not
|
|
|
// change the metrics
|
|
|
hdfs.allowSnapshot(sub1.toString());
|
|
|
- assertGauge("SnapshottableDirectories", 3L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("SnapshottableDirectories", 3, getMetrics(NS_METRICS));
|
|
|
// But the number of allowSnapshot operations still increases
|
|
|
assertCounter("AllowSnapshotOps", 4L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// Disallow the snapshot for snapshottable directories, then check the
|
|
|
// metrics again
|
|
|
hdfs.disallowSnapshot(sub1.toString());
|
|
|
- assertGauge("SnapshottableDirectories", 2L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("SnapshottableDirectories", 2, getMetrics(NS_METRICS));
|
|
|
assertCounter("DisallowSnapshotOps", 1L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// delete subsub1, snapshottable directories should be 1
|
|
|
hdfs.delete(subsub1, true);
|
|
|
- assertGauge("SnapshottableDirectories", 1L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("SnapshottableDirectories", 1, getMetrics(NS_METRICS));
|
|
|
|
|
|
// list all the snapshottable directories
|
|
|
SnapshottableDirectoryStatus[] status = hdfs.getSnapshottableDirListing();
|
|
@@ -130,7 +130,7 @@ public class TestSnapshotMetrics {
|
|
|
*/
|
|
|
@Test
|
|
|
public void testSnapshots() throws Exception {
|
|
|
- assertGauge("Snapshots", 0L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("Snapshots", 0, getMetrics(NS_METRICS));
|
|
|
assertCounter("CreateSnapshotOps", 0L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// Create a snapshot for a non-snapshottable directory, thus should not
|
|
@@ -138,16 +138,16 @@ public class TestSnapshotMetrics {
|
|
|
try {
|
|
|
hdfs.createSnapshot(sub1, "s1");
|
|
|
} catch (Exception e) {}
|
|
|
- assertGauge("Snapshots", 0L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("Snapshots", 0, getMetrics(NS_METRICS));
|
|
|
assertCounter("CreateSnapshotOps", 1L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// Create snapshot for sub1
|
|
|
hdfs.allowSnapshot(sub1.toString());
|
|
|
hdfs.createSnapshot(sub1, "s1");
|
|
|
- assertGauge("Snapshots", 1L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("Snapshots", 1, getMetrics(NS_METRICS));
|
|
|
assertCounter("CreateSnapshotOps", 2L, getMetrics(NN_METRICS));
|
|
|
hdfs.createSnapshot(sub1, "s2");
|
|
|
- assertGauge("Snapshots", 2L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("Snapshots", 2, getMetrics(NS_METRICS));
|
|
|
assertCounter("CreateSnapshotOps", 3L, getMetrics(NN_METRICS));
|
|
|
hdfs.getSnapshotDiffReport(sub1, "s1", "s2");
|
|
|
assertCounter("SnapshotDiffReportOps", 1L, getMetrics(NN_METRICS));
|
|
@@ -158,17 +158,17 @@ public class TestSnapshotMetrics {
|
|
|
DFSTestUtil.createFile(hdfs, subfile, 1024, REPLICATION, seed);
|
|
|
hdfs.allowSnapshot(subsub1.toString());
|
|
|
hdfs.createSnapshot(subsub1, "s11");
|
|
|
- assertGauge("Snapshots", 3L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("Snapshots", 3, getMetrics(NS_METRICS));
|
|
|
assertCounter("CreateSnapshotOps", 4L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// delete snapshot
|
|
|
hdfs.deleteSnapshot(sub1, "s2");
|
|
|
- assertGauge("Snapshots", 2L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("Snapshots", 2, getMetrics(NS_METRICS));
|
|
|
assertCounter("DeleteSnapshotOps", 1L, getMetrics(NN_METRICS));
|
|
|
|
|
|
// rename snapshot
|
|
|
hdfs.renameSnapshot(sub1, "s1", "NewS1");
|
|
|
- assertGauge("Snapshots", 2L, getMetrics(NS_METRICS));
|
|
|
+ assertGauge("Snapshots", 2, getMetrics(NS_METRICS));
|
|
|
assertCounter("RenameSnapshotOps", 1L, getMetrics(NN_METRICS));
|
|
|
}
|
|
|
}
|