use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class JetSplitBrainTestSupport method createHazelcastInstanceInBrain.
/**
* Starts a new {@code JetInstance} which is only able to communicate
* with members on one of the two brains.
* @param firstSubCluster jet instances in the first sub cluster
* @param secondSubCluster jet instances in the first sub cluster
* @param createOnFirstSubCluster if true, new instance is created on the first sub cluster.
* @return a HazelcastInstance whose {@code MockJoiner} has blacklisted the other brain's
* members and its connection manager blocks connections to other brain's members
* @see TestHazelcastInstanceFactory#newHazelcastInstance(Address, com.hazelcast.config.Config, Address[])
*/
protected final JetInstance createHazelcastInstanceInBrain(JetInstance[] firstSubCluster, JetInstance[] secondSubCluster, boolean createOnFirstSubCluster) {
Address newMemberAddress = nextAddress();
JetInstance[] instancesToBlock = createOnFirstSubCluster ? secondSubCluster : firstSubCluster;
List<Address> addressesToBlock = new ArrayList<>(instancesToBlock.length);
for (JetInstance anInstancesToBlock : instancesToBlock) {
if (isInstanceActive(anInstancesToBlock)) {
addressesToBlock.add(getAddress(anInstancesToBlock.getHazelcastInstance()));
// block communication from these instances to the new address
FirewallingConnectionManager connectionManager = getFireWalledConnectionManager(anInstancesToBlock.getHazelcastInstance());
connectionManager.blockNewConnection(newMemberAddress);
connectionManager.closeActiveConnection(newMemberAddress);
}
}
// indicate we need to unblacklist addresses from joiner when split-brain will be healed
unblacklistHint = true;
// create a new Hazelcast instance which has blocked addresses blacklisted in its joiner
return createJetMember(createConfig(), addressesToBlock.toArray(new Address[addressesToBlock.size()]));
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class JetSplitBrainTestSupport method healSplitBrain.
private void healSplitBrain(JetInstance[] instances, int firstSubClusterSize) {
applyOnBrains(instances, firstSubClusterSize, SplitBrainTestSupport::unblockCommunicationBetween);
if (unblacklistHint) {
applyOnBrains(instances, firstSubClusterSize, JetSplitBrainTestSupport::unblacklistJoinerBetween);
}
for (JetInstance instance : instances) {
assertClusterSizeEventually(instances.length, instance.getHazelcastInstance());
}
waitAllForSafeState(Stream.of(instances).map(JetInstance::getHazelcastInstance).collect(toList()));
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class JetSplitBrainTestSupport method testSplitBrain.
final void testSplitBrain(int firstSubClusterSize, int secondSubClusterSize, Consumer<JetInstance[]> beforeSplit, BiConsumer<JetInstance[], JetInstance[]> onSplit, Consumer<JetInstance[]> afterMerge) {
checkPositive(firstSubClusterSize, "invalid first sub cluster size: " + firstSubClusterSize);
checkPositive(secondSubClusterSize, "invalid second sub cluster size: " + secondSubClusterSize);
JetConfig config = createConfig();
int clusterSize = firstSubClusterSize + secondSubClusterSize;
JetInstance[] instances = startInitialCluster(config, clusterSize);
if (beforeSplit != null) {
beforeSplit.accept(instances);
}
createSplitBrain(instances, firstSubClusterSize, secondSubClusterSize);
Brains brains = getBrains(instances, firstSubClusterSize, secondSubClusterSize);
if (onSplit != null) {
onSplit.accept(brains.firstSubCluster, brains.secondSubCluster);
}
healSplitBrain(instances, firstSubClusterSize);
if (afterMerge != null) {
afterMerge.accept(instances);
}
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class ManualRestartTest method when_jobIsCompleted_then_isCannotBeRestarted.
@Test(expected = IllegalStateException.class)
public void when_jobIsCompleted_then_isCannotBeRestarted() {
// Given that the job is completed
JetInstance client = createJetClient();
Job job = client.newJob(dag);
job.cancel();
try {
job.join();
fail();
} catch (CancellationException ignored) {
}
// Then, the job cannot restart
job.restart();
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class OperationTimeoutTest method when_slowRunningOperationOnMultipleNodes_doesNotTimeout.
@Test
public void when_slowRunningOperationOnMultipleNodes_doesNotTimeout() throws Throwable {
// Given
JetInstance instance = createJetMember(config);
createJetMember(config);
DAG dag = new DAG();
dag.newVertex("slow", SlowProcessor::new);
// When
executeAndPeel(instance.newJob(dag));
}
Aggregations