@Override // NameNode protected void initialize(Configuration conf) throws IOException { // async edit logs are incompatible with backup node due to race // conditions resulting from laxer synchronization conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_EDITS_ASYNC_LOGGING, false); // Trash is disabled in BackupNameNode, // but should be turned back on if it ever becomes active. conf.setLong(CommonConfigurationKeys.FS_TRASH_INTERVAL_KEY, CommonConfigurationKeys.FS_TRASH_INTERVAL_DEFAULT); NamespaceInfo nsInfo = handshake(conf); super.initialize(conf); namesystem.setBlockPoolId(nsInfo.getBlockPoolID()); if (false == namesystem.isInSafeMode()) { namesystem.setSafeMode(SafeModeAction.SAFEMODE_ENTER); } // Backup node should never do lease recovery, // therefore lease hard limit should never expire. namesystem.leaseManager.setLeasePeriod( HdfsConstants.LEASE_SOFTLIMIT_PERIOD, Long.MAX_VALUE); // register with the active name-node registerWith(nsInfo); // Checkpoint daemon should start after the rpc server started runCheckpointDaemon(conf); InetSocketAddress addr = getHttpAddress(); if (addr != null) { conf.set(BN_HTTP_ADDRESS_NAME_KEY, NetUtils.getHostPortString(getHttpAddress())); } }
/** * Set the softLimit and hardLimit of client lease periods */ void setLeasePeriod(long soft, long hard) { final FSNamesystem namesystem = getNamesystem(); namesystem.leaseManager.setLeasePeriod(soft, hard); namesystem.lmthread.interrupt(); }
long softLeaseLimit = conf.getLong(FSConstants.DFS_SOFT_LEASE_KEY, FSConstants.LEASE_SOFTLIMIT_PERIOD); this.leaseManager.setLeasePeriod( Math.min(hardLeaseLimit, softLeaseLimit), hardLeaseLimit);
/** Set the softLimit and hardLimit of client lease periods. */ public static void setLeasePeriod(final FSNamesystem namesystem, long soft, long hard) { getLeaseManager(namesystem).setLeasePeriod(soft, hard); namesystem.leaseManager.triggerMonitorCheckNow(); }
@Override // NameNode protected void initialize(Configuration conf) throws IOException { // Trash is disabled in BackupNameNode, // but should be turned back on if it ever becomes active. conf.setLong(CommonConfigurationKeys.FS_TRASH_INTERVAL_KEY, CommonConfigurationKeys.FS_TRASH_INTERVAL_DEFAULT); NamespaceInfo nsInfo = handshake(conf); super.initialize(conf); namesystem.setBlockPoolId(nsInfo.getBlockPoolID()); if (false == namesystem.isInSafeMode()) { namesystem.setSafeMode(SafeModeAction.SAFEMODE_ENTER); } // Backup node should never do lease recovery, // therefore lease hard limit should never expire. namesystem.leaseManager.setLeasePeriod( HdfsConstants.LEASE_SOFTLIMIT_PERIOD, Long.MAX_VALUE); // register with the active name-node registerWith(nsInfo); // Checkpoint daemon should start after the rpc server started runCheckpointDaemon(conf); InetSocketAddress addr = getHttpAddress(); if (addr != null) { conf.set(BN_HTTP_ADDRESS_NAME_KEY, NetUtils.getHostPortString(getHttpAddress())); } }
@Override // NameNode protected void initialize(Configuration conf) throws IOException { // Trash is disabled in BackupNameNode, // but should be turned back on if it ever becomes active. conf.setLong(CommonConfigurationKeys.FS_TRASH_INTERVAL_KEY, CommonConfigurationKeys.FS_TRASH_INTERVAL_DEFAULT); NamespaceInfo nsInfo = handshake(conf); super.initialize(conf); namesystem.setBlockPoolId(nsInfo.getBlockPoolID()); if (false == namesystem.isInSafeMode()) { namesystem.setSafeMode(SafeModeAction.SAFEMODE_ENTER); } // Backup node should never do lease recovery, // therefore lease hard limit should never expire. namesystem.leaseManager.setLeasePeriod( HdfsConstants.LEASE_SOFTLIMIT_PERIOD, Long.MAX_VALUE); // register with the active name-node registerWith(nsInfo); // Checkpoint daemon should start after the rpc server started runCheckpointDaemon(conf); InetSocketAddress addr = getHttpAddress(); if (addr != null) { conf.set(BN_HTTP_ADDRESS_NAME_KEY, NetUtils.getHostPortString(getHttpAddress())); } }
/** Check that even if LeaseManager.checkLease is not able to relinquish * leases, the Namenode does't enter an infinite loop while holding the FSN * write lock and thus become unresponsive */ @Test (timeout=1000) public void testCheckLeaseNotInfiniteLoop() { FSDirectory dir = Mockito.mock(FSDirectory.class); FSNamesystem fsn = Mockito.mock(FSNamesystem.class); Mockito.when(fsn.isRunning()).thenReturn(true); Mockito.when(fsn.hasWriteLock()).thenReturn(true); Mockito.when(fsn.getFSDirectory()).thenReturn(dir); LeaseManager lm = new LeaseManager(fsn); //Make sure the leases we are going to add exceed the hard limit lm.setLeasePeriod(0,0); //Add some leases to the LeaseManager lm.addLease("holder1", "src1"); lm.addLease("holder2", "src2"); lm.addLease("holder3", "src3"); assertEquals(lm.getNumSortedLeases(), 3); //Initiate a call to checkLease. This should exit within the test timeout lm.checkLeases(); }
.setLeasePeriod(LOW_SOFTLIMIT, LOW_HARDLIMIT); .setLeasePeriod(HdfsConstants.LEASE_SOFTLIMIT_PERIOD, HdfsConstants.LEASE_HARDLIMIT_PERIOD);