@Test public void heartbeatFilesUnderAndOverReplicated() throws Exception { mFileContext.getOptions().setReplicationMin(2).setReplicationMax(-1); long blockId1 = createBlockHelper(TEST_FILE_1, mFileContext, ""); mFileContext.getOptions().setReplicationMin(0).setReplicationMax(3); long blockId2 = createBlockHelper(TEST_FILE_2, mFileContext, ""); addBlockLocationHelper(blockId1, 1); addBlockLocationHelper(blockId2, 5); mReplicationChecker.heartbeat(); Map<Long, Integer> expected1 = ImmutableMap.of(blockId1, 1); Map<Long, Integer> expected2 = ImmutableMap.of(blockId2, 2); Assert.assertEquals(expected2, mMockReplicationHandler.getEvictRequests()); Assert.assertEquals(expected1, mMockReplicationHandler.getReplicateRequests()); }
@Override public void heartbeat() throws InterruptedException { if (mSafeModeManager.isInSafeMode()) { return; } TimeUnit.SECONDS.sleep(mQuietPeriodSeconds); Set<Long> inodes; inodes = mInodeTree.getPinIdSet(); check(inodes, mReplicationHandler, Mode.REPLICATE); inodes = mInodeTree.getReplicationLimitedFileIds(); check(inodes, mReplicationHandler, Mode.EVICT); inodes = mInodeTree.getPinIdSet(); checkMisreplicated(inodes, mReplicationHandler); }
ReplicationChecker implements HeartbeatExecutor { @Override public void heartbeat() throws InterruptedException { if (mSafeModeManager.isInSafeMode()) { return; } TimeUnit.SECONDS.sleep(mQuietPeriodSeconds); Set<Long> inodes; inodes = mInodeTree.getPinIdSet(); check(inodes, mReplicationHandler, Mode.REPLICATE); inodes = mInodeTree.getReplicationLimitedFileIds(); check(inodes, mReplicationHandler, Mode.EVICT); inodes = mInodeTree.getPinIdSet(); checkMisreplicated(inodes, mReplicationHandler); } }
ReplicationChecker implements HeartbeatExecutor { @Override public void heartbeat() throws InterruptedException { if (mSafeModeManager.isInSafeMode()) { return; } TimeUnit.SECONDS.sleep(mQuietPeriodSeconds); Set<Long> inodes; inodes = mInodeTree.getPinIdSet(); check(inodes, mReplicationHandler, Mode.REPLICATE); inodes = mInodeTree.getReplicationLimitedFileIds(); check(inodes, mReplicationHandler, Mode.EVICT); inodes = mInodeTree.getPinIdSet(); checkMisreplicated(inodes, mReplicationHandler); } ReplicationChecker(InodeTree inodeTree, BlockMaster blockMaster,
      SafeModeManager safeModeManager, JobMasterClientPool jobMasterClientPool);  ReplicationChecker(InodeTree inodeTree, BlockMaster blockMaster,
      SafeModeManager safeModeManager, ReplicationHandler replicationHandler); }
ReplicationChecker implements HeartbeatExecutor { @Override public void heartbeat() throws InterruptedException { if (mSafeModeManager.isInSafeMode()) { return; } TimeUnit.SECONDS.sleep(mQuietPeriodSeconds); Set<Long> inodes; inodes = mInodeTree.getPinIdSet(); check(inodes, mReplicationHandler, Mode.REPLICATE); inodes = mInodeTree.getReplicationLimitedFileIds(); check(inodes, mReplicationHandler, Mode.EVICT); inodes = mInodeTree.getPinIdSet(); checkMisreplicated(inodes, mReplicationHandler); } ReplicationChecker(InodeTree inodeTree, BlockMaster blockMaster,
      SafeModeManager safeModeManager, JobMasterClientPool jobMasterClientPool);  ReplicationChecker(InodeTree inodeTree, BlockMaster blockMaster,
      SafeModeManager safeModeManager, ReplicationHandler replicationHandler); @Override void heartbeat(); @Override void close(); }
ReplicationChecker implements HeartbeatExecutor { @Override public void heartbeat() throws InterruptedException { if (mSafeModeManager.isInSafeMode()) { return; } TimeUnit.SECONDS.sleep(mQuietPeriodSeconds); Set<Long> inodes; inodes = mInodeTree.getPinIdSet(); check(inodes, mReplicationHandler, Mode.REPLICATE); inodes = mInodeTree.getReplicationLimitedFileIds(); check(inodes, mReplicationHandler, Mode.EVICT); inodes = mInodeTree.getPinIdSet(); checkMisreplicated(inodes, mReplicationHandler); } ReplicationChecker(InodeTree inodeTree, BlockMaster blockMaster,
      SafeModeManager safeModeManager, JobMasterClientPool jobMasterClientPool);  ReplicationChecker(InodeTree inodeTree, BlockMaster blockMaster,
      SafeModeManager safeModeManager, ReplicationHandler replicationHandler); @Override void heartbeat(); @Override void close();  }