use of java.util.function.BooleanSupplier in project elasticsearch by elastic.
the class IndicesLifecycleListenerIT method assertShardStatesMatch.
private static void assertShardStatesMatch(final IndexShardStateChangeListener stateChangeListener, final int numShards, final IndexShardState... shardStates) throws InterruptedException {
BooleanSupplier waitPredicate = () -> {
if (stateChangeListener.shardStates.size() != numShards) {
return false;
}
for (List<IndexShardState> indexShardStates : stateChangeListener.shardStates.values()) {
if (indexShardStates == null || indexShardStates.size() != shardStates.length) {
return false;
}
for (int i = 0; i < shardStates.length; i++) {
if (indexShardStates.get(i) != shardStates[i]) {
return false;
}
}
}
return true;
};
if (!awaitBusy(waitPredicate, 1, TimeUnit.MINUTES)) {
fail("failed to observe expect shard states\n" + "expected: [" + numShards + "] shards with states: " + Strings.arrayToCommaDelimitedString(shardStates) + "\n" + "observed:\n" + stateChangeListener);
}
stateChangeListener.shardStates.clear();
}
use of java.util.function.BooleanSupplier in project neo4j by neo4j.
the class CatchupStoreCopyInteractionStressTesting method shouldBehaveCorrectlyUnderStress.
@Test
public void shouldBehaveCorrectlyUnderStress() throws Exception {
int numberOfCores = parseInt(fromEnv("CATCHUP_STORE_COPY_INTERACTION_STRESS_NUMBER_OF_CORES", DEFAULT_NUMBER_OF_CORES));
int numberOfEdges = parseInt(fromEnv("CATCHUP_STORE_COPY_INTERACTION_STRESS_NUMBER_OF_EDGES", DEFAULT_NUMBER_OF_EDGES));
long durationInMinutes = parseLong(fromEnv("CATCHUP_STORE_COPY_INTERACTION_STRESS_DURATION", DEFAULT_DURATION_IN_MINUTES));
String workingDirectory = fromEnv("CATCHUP_STORE_COPY_INTERACTION_STRESS_WORKING_DIRECTORY", DEFAULT_WORKING_DIR);
boolean enableIndexes = parseBoolean(fromEnv("CATCHUP_STORE_COPY_INTERACTION_STRESS_ENABLE_INDEXES", DEFAULT_ENABLE_INDEXES));
String txPrune = fromEnv("CATCHUP_STORE_COPY_INTERACTION_STRESS_TX_PRUNE", DEFAULT_TX_PRUNE);
File clusterDirectory = ensureExistsAndEmpty(new File(workingDirectory, "cluster"));
Map<String, String> coreParams = enableRaftMessageLogging(configureRaftLogRotationAndPruning(configureTxLogRotationAndPruning(new HashMap<>(), txPrune)));
Map<String, String> edgeParams = configureTxLogRotationAndPruning(new HashMap<>(), txPrune);
HazelcastDiscoveryServiceFactory discoveryServiceFactory = new HazelcastDiscoveryServiceFactory();
Cluster cluster = new Cluster(clusterDirectory, numberOfCores, numberOfEdges, discoveryServiceFactory, coreParams, emptyMap(), edgeParams, emptyMap(), Standard.LATEST_NAME);
AtomicBoolean stopTheWorld = new AtomicBoolean();
BooleanSupplier notExpired = untilTimeExpired(durationInMinutes, MINUTES);
BooleanSupplier keepGoing = () -> !stopTheWorld.get() && notExpired.getAsBoolean();
Runnable onFailure = () -> stopTheWorld.set(true);
ExecutorService service = Executors.newCachedThreadPool();
try {
cluster.start();
if (enableIndexes) {
Workload.setupIndexes(cluster);
}
Future<Throwable> workload = service.submit(new Workload(keepGoing, onFailure, cluster));
Future<Throwable> startStopWorker = service.submit(new StartStopLoad(fs, pageCache, keepGoing, onFailure, cluster, numberOfCores, numberOfEdges));
Future<Throwable> catchUpWorker = service.submit(new CatchUpLoad(keepGoing, onFailure, cluster));
long timeout = durationInMinutes + 5;
assertNull(Exceptions.stringify(workload.get()), workload.get(timeout, MINUTES));
assertNull(Exceptions.stringify(startStopWorker.get()), startStopWorker.get(timeout, MINUTES));
assertNull(Exceptions.stringify(catchUpWorker.get()), catchUpWorker.get(timeout, MINUTES));
} finally {
cluster.shutdown();
service.shutdown();
}
// let's cleanup disk space when everything went well
FileUtils.deleteRecursively(clusterDirectory);
}
use of java.util.function.BooleanSupplier in project RecurrentComplex by Ivorforce.
the class TableCellMultiBuilder method build.
@Nonnull
public TableCellDefault build() {
List<TableCellButton> cells = new ArrayList<>();
for (int i = 0; i < this.cells.size(); i++) {
TableCellButton cell = this.cells.get(i).get();
cell.setId("action." + i);
cell.actionID = "action." + i;
BooleanSupplier enabled = enabledSuppliers.get(i);
if (enabled != null)
cell.setEnabled(enabled.getAsBoolean());
cells.add(cell);
}
return new TableCellMulti(cells);
}
Aggregations