public long getFsyncThresholdExceedCount() { return zks.serverStats().getFsyncThresholdExceedCount(); }
public long getFsyncThresholdExceedCount() { return zks.serverStats().getFsyncThresholdExceedCount(); }
private void assertFsyncThresholdExceedCountZero(ServerStats serverStats) { Assert.assertEquals(0L, serverStats.getFsyncThresholdExceedCount()); } }
public void testSyncThresholdExceedCount() throws IOException { // Given ... // Set threshold to -1, as after the first commit it takes 0ms to commit to disk. java.lang.System.setProperty(FileTxnLog.ZOOKEEPER_FSYNC_WARNING_THRESHOLD_MS_PROPERTY, "-1"); ServerStats.Provider providerMock = mock(ServerStats.Provider.class); ServerStats serverStats = new ServerStats(providerMock); File logDir = ClientBase.createTmpDir(); FileTxnLog fileTxnLog = new FileTxnLog(logDir); fileTxnLog.setServerStats(serverStats); // Verify serverStats is 0 before any commit Assert.assertEquals(0L, serverStats.getFsyncThresholdExceedCount()); // When ... for (int i = 0; i < 50; i++) { fileTxnLog.append(new TxnHeader(1, 1, 1, 1, ZooDefs.OpCode.create), new CreateTxn("/testFsyncThresholdCountIncreased", new byte[]{}, ZooDefs.Ids.OPEN_ACL_UNSAFE, false, 0)); fileTxnLog.commit(); // only 1 commit, otherwise it will be flaky // Then ... verify serverStats is updated to the number of commits (as threshold is set to 0) Assert.assertEquals((long) i + 1 , serverStats.getFsyncThresholdExceedCount()); } }
@Test public void testFsyncThresholdExceedMetrics() { // Given ... ServerStats serverStats = new ServerStats(providerMock); int incrementCount = 30; // When increment ... for (int i = 0; i < incrementCount; i++) { serverStats.incrementFsyncThresholdExceedCount(); } // Then ... Assert.assertEquals(incrementCount, serverStats.getFsyncThresholdExceedCount()); // When reset ... serverStats.resetFsyncThresholdExceedCount(); // Then ... assertFsyncThresholdExceedCountZero(serverStats); }
print("fsync_threshold_exceed_count", stats.getFsyncThresholdExceedCount());
print("fsync_threshold_exceed_count", stats.getFsyncThresholdExceedCount());