@Test public void call_fail1() throws Exception { Mockito.when(roTx.read(ArgumentMatchers.any(), ArgumentMatchers.<InstanceIdentifier<Topology>>any())) .thenReturn(FluentFutures.immediateFluentFuture(Optional.empty())) .thenReturn(FluentFutures.immediateFluentFuture(Optional.empty())); Assert.assertTrue("Expected healthy cluster, got condition", task.call()); Assert.assertFalse("Expected isolated cluster, got healthy one", task.call()); }
@Override public Boolean call() throws Exception { LOG.debug("Timer tick: check for cluster health"); Preconditions.checkState(datastoreConsequentFailCounter < consequentFailLimit, "Last tick detected cluster isolated condition"); boolean datastoreFailed = false; try { datastoreFailed = Objects.isNull(datastoreAccess.readSynchronous(NodeIdentityListener.SUBSCRIBED_PATH, LogicalDatastoreType.CONFIGURATION)); } catch (IllegalStateException e) { datastoreFailed = true; } if (datastoreFailed) { datastoreConsequentFailCounter++; } else { datastoreConsequentFailCounter = 0; } return datastoreConsequentFailCounter < consequentFailLimit; }
FollowerSyncStatusTask extends SxpTimerTask<Boolean> { @Override public Boolean call() throws Exception { LOG.debug("Timer tick: check for cluster health"); Preconditions.checkState(datastoreConsequentFailCounter < consequentFailLimit, "Last tick detected cluster isolated condition"); boolean datastoreFailed = false; try { datastoreFailed = Objects.isNull(datastoreAccess.readSynchronous(NodeIdentityListener.SUBSCRIBED_PATH, LogicalDatastoreType.CONFIGURATION)); } catch (IllegalStateException e) { datastoreFailed = true; } if (datastoreFailed) { datastoreConsequentFailCounter++; } else { datastoreConsequentFailCounter = 0; } return datastoreConsequentFailCounter < consequentFailLimit; } }
FollowerSyncStatusTask extends SxpTimerTask<Boolean> { @Override public Boolean call() throws Exception { LOG.debug("Timer tick: check for cluster health"); Preconditions.checkState(datastoreConsequentFailCounter < consequentFailLimit, "Last tick detected cluster isolated condition"); boolean datastoreFailed = false; try { datastoreFailed = Objects.isNull(datastoreAccess.readSynchronous(NodeIdentityListener.SUBSCRIBED_PATH, LogicalDatastoreType.CONFIGURATION)); } catch (IllegalStateException e) { datastoreFailed = true; } if (datastoreFailed) { datastoreConsequentFailCounter++; } else { datastoreConsequentFailCounter = 0; } return datastoreConsequentFailCounter < consequentFailLimit; } protected  FollowerSyncStatusTask(int period, final DatastoreAccess datastoreAccess, final int consequentFailLimit); }
FollowerSyncStatusTask extends SxpTimerTask<Boolean> { @Override public Boolean call() throws Exception { LOG.debug("Timer tick: check for cluster health"); Preconditions.checkState(datastoreConsequentFailCounter < consequentFailLimit, "Last tick detected cluster isolated condition"); boolean datastoreFailed = false; try { datastoreFailed = Objects.isNull(datastoreAccess.readSynchronous(NodeIdentityListener.SUBSCRIBED_PATH, LogicalDatastoreType.CONFIGURATION)); } catch (IllegalStateException e) { datastoreFailed = true; } if (datastoreFailed) { datastoreConsequentFailCounter++; } else { datastoreConsequentFailCounter = 0; } return datastoreConsequentFailCounter < consequentFailLimit; } protected  FollowerSyncStatusTask(int period, final DatastoreAccess datastoreAccess, final int consequentFailLimit); @Override Boolean call(); @Override int getPeriod(); }
FollowerSyncStatusTask extends SxpTimerTask<Boolean> { @Override public Boolean call() throws Exception { LOG.debug("Timer tick: check for cluster health"); Preconditions.checkState(datastoreConsequentFailCounter < consequentFailLimit, "Last tick detected cluster isolated condition"); boolean datastoreFailed = false; try { datastoreFailed = Objects.isNull(datastoreAccess.readSynchronous(NodeIdentityListener.SUBSCRIBED_PATH, LogicalDatastoreType.CONFIGURATION)); } catch (IllegalStateException e) { datastoreFailed = true; } if (datastoreFailed) { datastoreConsequentFailCounter++; } else { datastoreConsequentFailCounter = 0; } return datastoreConsequentFailCounter < consequentFailLimit; } protected  FollowerSyncStatusTask(int period, final DatastoreAccess datastoreAccess, final int consequentFailLimit); @Override Boolean call(); @Override int getPeriod();  }