private void applyProperties(Properties prop) { Boolean debug = Boolean.parseBoolean(getValue(KEY_DEBUG, DEFAULT_DEBUG, prop)); tx.debug(debug); tx.bootStrapMode(ReactiveAudit.BootStrapMode.valueOf(getValue(KEY_BOOTSTRAP_MODE, DEFAULT_BOOTSTRAP_MODE, prop).toUpperCase())); tx.bootStrapCPUDelay(Long.parseLong(getValue(KEY_BOOTSTRAP_CPUDELAY, DEFAULT_BOOTSTRAP_CPUDELAY, prop))); tx.bootStrapDelay(Long.parseLong(getValue(KEY_BOOTSTRAP_DELAY, DEFAULT_BOOTSTRAP_DELAY, prop))); tx.throwExceptions(Boolean.parseBoolean(getValue(KEY_THROW_EXCEPTIONS, DEFAULT_THROW_EXCEPTIONS, prop))); tx.latencyFile(getValue(KEY_FILE_LATENCY, DEFAULT_FILE_LATENCY, prop)); tx.latencyNetwork(getValue(KEY_NETWORK_LATENCY, DEFAULT_NETWORK_LATENCY, prop)); tx.latencyCPU(getValue(KEY_CPU_LATENCY, DEFAULT_CPU_LATENCY, prop)); tx.logOutput(getValue(KEY_LOG_OUTPUT, DEFAULT_LOG_OUTPUT, prop), getValue(KEY_LOG_FORMAT, DEFAULT_LOG_FORMAT, prop), getValue(KEY_LOG_SIZE, DEFAULT_LOG_SIZE, prop)); String threadPattern = getValue(KEY_THREAD_PATTERN, DEFAULT_THREAD_PATTERN, prop); if (threadPattern.length() == 0) // Empty is not allowed threadPattern = "(^.*$)"; tx.threadPattern(threadPattern); tx.commit(); }
/** * @return Return a transaction with the current value. */ private Transaction current() { return new Transaction() .throwExceptions(throwExceptions) .threadPattern(threadPattern.toString()) .bootStrapDelay(bootstrapDelay); }
.threadPattern(".*") .latencyFile("LOW") .throwExceptions(false) .commit();
.latencyFile("") .commit(); try .latencyFile("LOW") .commit(); try .latencyFile("MEDIUM") .commit(); try .latencyFile("HIGH") .commit(); try
.throwExceptions(true) .threadPattern("") .latencyFile("high") .latencyNetwork("medium") .latencyCPU("low") .bootStrapDelay(10) .commit(); assertEquals(true, config.isThrow()); assertEquals("", config.getThreadPattern()); assertEquals(10, config.getBootstrapDelay()); config.begin() .throwExceptions(false) .threadPattern("abc") .latencyFile("") .latencyNetwork("") .latencyCPU("") .bootStrapDelay(0) .commit(); assertEquals(false, config.isThrow()); assertEquals("abc", config.getThreadPattern());
@Test public void logIfNewLoop() { config.reset(); config.begin() .threadPattern(".*") .logOutput(LoadParams.DEFAULT_LOG_OUTPUT,LoadParams.DEFAULT_LOG_FORMAT,LoadParams.DEFAULT_LOG_SIZE) .latencyFile("LOW") .throwExceptions(false) .commit(); try { addHandler(); for (int i = 0; i < 5; ++i) { log[0] = 0; latencyCall1(); if (i == 0) assertEquals(1, log[0]); else assertEquals(0, log[0]); } } finally { removeHandler(); } }
/** * Begin a transaction to update the parameters. * Call commit() to apply. * * @return The transaction. */ public Transaction begin() { return new Transaction(); }