@Override public boolean isExpired(long timeout) { for (int i = 0; i < measures.length; i++) { if (measures[i].isExpired(timeout)) { return true; } } return false; } }
@Override public boolean isExpired(long timeout) { for (int i = 0; i < measures.length; i++) { if (measures[i].isExpired(timeout)) { return true; } } return false; } }
@Override public boolean isExpired(long timeout) { for (int i = 0; i < measures.length; i++) { if (measures[i].isExpired(timeout)) { return true; } } return false; } }
@Override public boolean isExpired(long timeout) { for (int i = 0; i < measures.length; i++) { if (measures[i].isExpired(timeout)) { return true; } } return false; } }
@Override public boolean isExpired(long timeout) { for (int i = 0; i < measures.length; i++) { if (measures[i].isExpired(timeout)) { return true; } } return false; } }
@Override public boolean isExpired(long timeout) { for (int i = 0; i < measures.length; i++) { if (measures[i].isExpired(timeout)) { return true; } } return false; } }
@Override public boolean isExpired(long timeout) { for (int i = 0; i < measures.length; i++) { if (measures[i].isExpired(timeout)) { return true; } } return false; } }
public void leaveCritical() { if (logger.isTraceEnabled()) { CriticalAnalyzer analyzer = component != null ? component.getCriticalAnalyzer() : null; if (analyzer != null) { long nanoTimeout = analyzer.getTimeoutNanoSeconds(); if (isExpired(nanoTimeout)) { logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("entered")); logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, entered at", traceEnter); } } traceEnter = null; } TIME_LEFT_UPDATER.lazySet(this, System.nanoTime()); }
public void leaveCritical() { if (logger.isTraceEnabled()) { CriticalAnalyzer analyzer = component != null ? component.getCriticalAnalyzer() : null; if (analyzer != null) { long nanoTimeout = analyzer.getTimeoutNanoSeconds(); if (isExpired(nanoTimeout)) { logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("entered")); logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, entered at", traceEnter); } } traceEnter = null; } TIME_LEFT_UPDATER.lazySet(this, System.nanoTime()); }
public void leaveCritical() { if (logger.isTraceEnabled()) { CriticalAnalyzer analyzer = component != null ? component.getCriticalAnalyzer() : null; if (analyzer != null) { long nanoTimeout = analyzer.getTimeoutNanoSeconds(); if (isExpired(nanoTimeout)) { logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("entered")); logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, entered at", traceEnter); } } traceEnter = null; } TIME_LEFT_UPDATER.lazySet(this, System.nanoTime()); }
public void leaveCritical() { if (logger.isTraceEnabled()) { CriticalAnalyzer analyzer = component != null ? component.getCriticalAnalyzer() : null; if (analyzer != null) { long nanoTimeout = analyzer.getTimeoutNanoSeconds(); if (isExpired(nanoTimeout)) { logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("entered")); logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, entered at", traceEnter); } } traceEnter = null; } TIME_LEFT_UPDATER.lazySet(this, System.nanoTime()); }
public void leaveCritical() { if (logger.isTraceEnabled()) { CriticalAnalyzer analyzer = component != null ? component.getCriticalAnalyzer() : null; if (analyzer != null) { long nanoTimeout = analyzer.getTimeoutNanoSeconds(); if (isExpired(nanoTimeout)) { logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("entered")); logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, entered at", traceEnter); } } traceEnter = null; } TIME_LEFT_UPDATER.lazySet(this, System.nanoTime()); }
@Test public void testCriticalMeasure() throws Exception { CriticalMeasure measure = new CriticalMeasure(null, 1); long time = System.nanoTime(); CriticalMeasure.TIME_ENTER_UPDATER.set(measure, time - TimeUnit.MINUTES.toNanos(5)); CriticalMeasure.TIME_LEFT_UPDATER.set(measure, time); Assert.assertFalse(measure.isExpired(TimeUnit.SECONDS.toNanos(30))); }
@Test public void testCriticalMeasureTakingLongButSucceeding() throws Exception { CriticalAnalyzer analyzer = new CriticalAnalyzerImpl(); CriticalComponent component = new CriticalComponentImpl(analyzer, 5); CriticalMeasure measure = new CriticalMeasure(component, 1); long time = System.nanoTime(); CriticalMeasure.TIME_ENTER_UPDATER.set(measure, time - TimeUnit.MINUTES.toNanos(5)); measure.leaveCritical(); Assert.assertFalse(measure.isExpired(TimeUnit.SECONDS.toNanos(30))); }
@Test public void testCriticalFailure() throws Exception { CriticalAnalyzer analyzer = new CriticalAnalyzerImpl(); CriticalComponent component = new CriticalComponentImpl(analyzer, 5); CriticalMeasure measure = new CriticalMeasure(component, 1); long time = System.nanoTime(); measure.enterCritical(); CriticalMeasure.TIME_ENTER_UPDATER.set(measure, time - TimeUnit.MINUTES.toNanos(5)); CriticalMeasure.TIME_LEFT_UPDATER.set(measure, time - TimeUnit.MINUTES.toNanos(10)); Assert.assertTrue(measure.isExpired(TimeUnit.SECONDS.toNanos(30))); measure.leaveCritical(); } }