DefaultKeeperConfig extends AbstractCoreConfig implements KeeperConfig { @Override public long getReplicationStoreMaxCommandsToTransferBeforeCreateRdb() { return getLongProperty(KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, 100L); } DefaultKeeperConfig(); @Override int getMetaServerConnectTimeout(); @Override int getMetaServerReadTimeout(); @Override int getMetaRefreshIntervalMillis(); @Override String getMetaServerAddress(); @Override int getReplicationStoreGcIntervalSeconds(); @Override int getReplicationStoreCommandFileSize(); @Override int getReplicationStoreCommandFileNumToKeep(); @Override long getReplicationStoreMaxCommandsToTransferBeforeCreateRdb(); @Override int getRdbDumpMinIntervalMilli(); @Override int getReplicationStoreMinTimeMilliToGcAfterCreate(); @Override long getCommandReaderFlyingThreshold(); @Override int getDelayLogLimitMicro(); @Override long getTrafficReportIntervalMillis(); @Override long getReplicationTrafficHighWaterMark(); @Override long getReplicationTrafficLowWaterMark(); @Override int getLeakyBucketInitSize(); @Override int getPartialSyncTrafficMonitorIntervalTimes(); @Override int getMaxPartialSyncKeepTokenRounds(); @Override boolean isKeeperRateLimitOpen(); @Override long getReplDownSafeIntervalMilli(); static final String KEY_REPLICATION_STORE_GC_INTERVAL_SECONDS; static final String KEY_REPLICATION_STORE_COMMANDFILE_SIZE; static final String KEY_REPLICATION_STORE_COMMANDFILE_NUM_KEEP; static final String KEY_REPLICATION_STORE_MINITIME_GC_AFTERCREATE; static final String KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB; static final String KEY_COMMAND_READER_FLYING_THRESHOLD; static final String KEY_RDB_DUMP_MIN_INTERVAL; static final String KEY_DELAY_LOG_LIMIT_MICRO; }
@Test public void testReplicationStoreMaxCommandsToTransferBeforeCreateRdb(){ KeeperConfig keeperConfig = new DefaultKeeperConfig(); long value = 10L * (1<<30); System.setProperty(DefaultKeeperConfig.KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, String.valueOf(value)); logger.info("[testReplicationStoreMaxCommandsToTransferBeforeCreateRdb]{}", value); Assert.assertEquals(value, keeperConfig.getReplicationStoreMaxCommandsToTransferBeforeCreateRdb()); }
@Ignore @Test public void testGetLongProperty() { KeeperConfig keeperConfig = new DefaultKeeperConfig(); long value = 10L * (1<<30); System.setProperty(DefaultKeeperConfig.KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, String.valueOf(value)); for(int i = 0; i < 100; i++) { Assert.assertEquals(value, keeperConfig.getReplicationStoreMaxCommandsToTransferBeforeCreateRdb()); } long preValue = value; value = 10L * (1<<10); System.setProperty(DefaultKeeperConfig.KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, String.valueOf(value)); ((DefaultKeeperConfig) keeperConfig) .onChange(DefaultKeeperConfig.KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, String.valueOf(preValue), String.valueOf(value)); for(int i = 0; i < 100; i++) { Assert.assertEquals(value, keeperConfig.getReplicationStoreMaxCommandsToTransferBeforeCreateRdb()); } }
@Ignore @Test public void testGetLongPropertyMultiThread() { KeeperConfig keeperConfig = new DefaultKeeperConfig(); AtomicLong value = new AtomicLong(randomInt()); System.setProperty(DefaultKeeperConfig.KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, String.valueOf(value.get())); for(int i = 0; i < 100; i++) executors.execute(new AbstractExceptionLogTask() { @Override protected void doRun() throws Exception { while(!Thread.currentThread().isInterrupted()) { Assert.assertEquals(value.get(), keeperConfig.getReplicationStoreMaxCommandsToTransferBeforeCreateRdb()); sleep(100); } } }); new Thread(){ @Override public void run() { while(!Thread.currentThread().isInterrupted()) { try { sleep(1000 * 10); } catch (InterruptedException e) { e.printStackTrace(); } ((DefaultKeeperConfig) keeperConfig) .onChange(DefaultKeeperConfig.KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, String.valueOf(value.getAndSet(randomInt())), String.valueOf(value)); System.setProperty(DefaultKeeperConfig.KEY_REPLICATION_STORE_MAX_COMMANDS_TO_TRANSFER_BEFORE_CREATE_RDB, String.valueOf(value.get())); } } }.start(); sleep(1000 * 60); }
@Test public void testNullPointExceptionWhenNoValueSet() { KeeperConfig keeperConfig = new DefaultKeeperConfig(); keeperConfig.getReplicationStoreMaxCommandsToTransferBeforeCreateRdb(); }