@Test public void shouldDecreaseLoadOfMainDatabaseIfUnusedAfterFirstMeasurement() { int periodWhenUnused = 2; int backOffMultiplier = 3; State s = createInitialLocalState(periodWhenUnused, backOffMultiplier); s.updateLocalStateWithNewExecTimes(emptyLogPrefix, high1, low1); assertState(s, false, true, true, backOffMultiplier, normalPeriod, 1, 0); }
public State updateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix, long mainDbStmtExecTimeNanos, long failoverDbStmtExecTimeNanos) { State copy = clone(); try { copy.doUpdateLocalStateWithNewExecTimes( logPrefix, mainDbStmtExecTimeNanos, failoverDbStmtExecTimeNanos ); } catch (RuntimeException e) { logger.error(logPrefix + "exception (shown below) while updating state - " + "reverted all changes made during this operation", e); return this.clone(); } return updateLocalStateWithNewExecTimes(copy); }
State implements Serializable, Cloneable { public State updateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix, long mainDbStmtExecTimeNanos, long failoverDbStmtExecTimeNanos) { State copy = clone(); try { copy.doUpdateLocalStateWithNewExecTimes( logPrefix, mainDbStmtExecTimeNanos, failoverDbStmtExecTimeNanos ); } catch (RuntimeException e) { logger.error(logPrefix + "exception (shown below) while updating state - " + "reverted all changes made during this operation", e); return this.clone(); } return updateLocalStateWithNewExecTimes(copy); } }
State implements Serializable, Cloneable { public State updateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix, long mainDbStmtExecTimeNanos, long failoverDbStmtExecTimeNanos) { State copy = clone(); try { copy.doUpdateLocalStateWithNewExecTimes( logPrefix, mainDbStmtExecTimeNanos, failoverDbStmtExecTimeNanos ); } catch (RuntimeException e) { logger.error(logPrefix + "exception (shown below) while updating state - " + "reverted all changes made during this operation", e); return this.clone(); } return updateLocalStateWithNewExecTimes(copy); } State(SqlTimeBasedLoadFactory loadFactory,
                 String host,
                 String repoId,
                 int sqlTimesIncludedInAverage,
                 boolean exceptionsIgnoredAfterRecovery,
                 boolean recoveryErasesHistoryIfExceptionsIgnoredAfterRecovery,
                 int currentToUnusedRatio,
                 int backOffMultiplier,
                 int backOffMaxRatio,
                 String mainDbName,
                 String failoverDbName);  State(String host,
                 String repoId,
                 long modifyTimeMillis,
                 boolean failover,
                 long lastMainQueryTimeNanos,
                 long lastFailoverQueryTimeNanos); }
State implements Serializable, Cloneable { public State updateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix, long mainDbStmtExecTimeNanos, long failoverDbStmtExecTimeNanos) { State copy = clone(); try { copy.doUpdateLocalStateWithNewExecTimes( logPrefix, mainDbStmtExecTimeNanos, failoverDbStmtExecTimeNanos ); } catch (RuntimeException e) { logger.error(logPrefix + "exception (shown below) while updating state - " + "reverted all changes made during this operation", e); return this.clone(); } return updateLocalStateWithNewExecTimes(copy); } State(SqlTimeBasedLoadFactory loadFactory,
                 String host,
                 String repoId,
                 int sqlTimesIncludedInAverage,
                 boolean exceptionsIgnoredAfterRecovery,
                 boolean recoveryErasesHistoryIfExceptionsIgnoredAfterRecovery,
                 int currentToUnusedRatio,
                 int backOffMultiplier,
                 int backOffMaxRatio,
                 String mainDbName,
                 String failoverDbName);  State(String host,
                 String repoId,
                 long modifyTimeMillis,
                 boolean failover,
                 long lastMainQueryTimeNanos,
                 long lastFailoverQueryTimeNanos); @Override State clone(); long getModifyTimeMillis(); Average getAvg(); Average getAvgFailover(); MachineState getMachineState(); String getHost(); String getRepoId(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); State updateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix,
                                                  long mainDbStmtExecTimeNanos,
                                                  long failoverDbStmtExecTimeNanos); void doUpdateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix,
                                                   long mainDbStmtExecTimeNanos,
                                                   long failoverDbStmtExecTimeNanos); State copyFrom(MonitorRunLogPrefix logPrefixIfLocalState, State localOrRemote); boolean sqlTimeIsMeasuredInThisCycle(boolean failover); boolean sqlTimeIsMeasuredInThisCycle(MonitorRunLogPrefix logPrefix, boolean failover); int getPeriod(boolean failover); int getCycleModuloPeriod(boolean failover); Load getLoadAfterLastMeasurement(); String getDesc(boolean failover); }
State implements Serializable, Cloneable { public State updateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix, long mainDbStmtExecTimeNanos, long failoverDbStmtExecTimeNanos) { State copy = clone(); try { copy.doUpdateLocalStateWithNewExecTimes( logPrefix, mainDbStmtExecTimeNanos, failoverDbStmtExecTimeNanos ); } catch (RuntimeException e) { logger.error(logPrefix + "exception (shown below) while updating state - " + "reverted all changes made during this operation", e); return this.clone(); } return updateLocalStateWithNewExecTimes(copy); } State(SqlTimeBasedLoadFactory loadFactory,
                 String host,
                 String repoId,
                 int sqlTimesIncludedInAverage,
                 boolean exceptionsIgnoredAfterRecovery,
                 boolean recoveryErasesHistoryIfExceptionsIgnoredAfterRecovery,
                 int currentToUnusedRatio,
                 int backOffMultiplier,
                 int backOffMaxRatio,
                 String mainDbName,
                 String failoverDbName);  State(String host,
                 String repoId,
                 long modifyTimeMillis,
                 boolean failover,
                 long lastMainQueryTimeNanos,
                 long lastFailoverQueryTimeNanos); @Override State clone(); long getModifyTimeMillis(); Average getAvg(); Average getAvgFailover(); MachineState getMachineState(); String getHost(); String getRepoId(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); State updateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix,
                                                  long mainDbStmtExecTimeNanos,
                                                  long failoverDbStmtExecTimeNanos); void doUpdateLocalStateWithNewExecTimes(MonitorRunLogPrefix logPrefix,
                                                   long mainDbStmtExecTimeNanos,
                                                   long failoverDbStmtExecTimeNanos); State copyFrom(MonitorRunLogPrefix logPrefixIfLocalState, State localOrRemote); boolean sqlTimeIsMeasuredInThisCycle(boolean failover); boolean sqlTimeIsMeasuredInThisCycle(MonitorRunLogPrefix logPrefix, boolean failover); int getPeriod(boolean failover); int getCycleModuloPeriod(boolean failover); Load getLoadAfterLastMeasurement(); String getDesc(boolean failover); final static long notMeasuredInThisCycle; }