use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method newPropagator.
private TransactionPropagator newPropagator(int slaveCount, int replication, SlavePriority slavePriority, boolean... failingSlaves) throws Exception {
slaves = instantiateSlaves(slaveCount, failingSlaves);
Config config = Config.embeddedDefaults(MapUtil.stringMap(HaSettings.tx_push_factor.name(), "" + replication, ClusterSettings.server_id.name(), "" + MasterServerId));
Neo4jJobScheduler scheduler = cleanup.add(new Neo4jJobScheduler());
TransactionPropagator result = new TransactionPropagator(TransactionPropagator.from(config, slavePriority), NullLog.getInstance(), new Slaves() {
@Override
public Iterable<Slave> getSlaves() {
return slaves;
}
}, new CommitPusher(scheduler));
// Life
try {
scheduler.init();
scheduler.start();
result.init();
result.start();
} catch (Throwable e) {
throw Exceptions.launderedException(e);
}
return result;
}
use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.
the class ConnectionInfoIT method hzTest.
@Test
public void hzTest() throws Throwable {
// given
testSocket = bindPort("0.0.0.0", 4243);
//when
AssertableLogProvider logProvider = new AssertableLogProvider();
AssertableLogProvider userLogProvider = new AssertableLogProvider();
HazelcastDiscoveryServiceFactory hzFactory = new HazelcastDiscoveryServiceFactory();
Config config = embeddedDefaults(stringMap(discovery_listen_address.name(), ":" + testSocket.getLocalPort(), CausalClusteringSettings.initial_discovery_members.name(), "localhost:" + testSocket.getLocalPort(), new BoltConnector("bolt").enabled.name(), "true", new HttpConnector("http").enabled.name(), "true"));
Neo4jJobScheduler jobScheduler = new Neo4jJobScheduler();
jobScheduler.init();
CoreTopologyService coreTopologyService = hzFactory.coreTopologyService(config, new MemberId(UUID.randomUUID()), jobScheduler, logProvider, userLogProvider);
try {
coreTopologyService.init();
coreTopologyService.start();
}//then
catch (Throwable throwable) {
//expected
}
logProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
userLogProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
}
use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.
the class ContinuousJobTest method shouldTerminateOnStop.
@Test
public void shouldTerminateOnStop() throws Exception {
// given: this task is gonna take >20 ms total
Semaphore semaphore = new Semaphore(-20);
Runnable task = () -> {
// 1 ms
LockSupport.parkNanos(1_000_000);
semaphore.release();
};
Neo4jJobScheduler scheduler = new Neo4jJobScheduler();
ContinuousJob continuousJob = new ContinuousJob(scheduler, jobGroup, task, NullLogProvider.getInstance());
// when
long startTime = System.currentTimeMillis();
try (Lifespan ignored = new Lifespan(scheduler, continuousJob)) {
semaphore.acquireUninterruptibly();
}
long runningTime = System.currentTimeMillis() - startTime;
// then
assertThat(runningTime, lessThan(DEFAULT_TIMEOUT_MS));
//noinspection StatementWithEmptyBody
while (semaphore.tryAcquire()) {
// consume all outstanding permits
}
// no more permits should be granted
semaphore.tryAcquire(10, MILLISECONDS);
}
use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.
the class ContinuousJobTest method shouldRunJobContinuously.
@Test
public void shouldRunJobContinuously() throws Throwable {
// given
CountDownLatch latch = new CountDownLatch(10);
Runnable task = latch::countDown;
Neo4jJobScheduler scheduler = new Neo4jJobScheduler();
ContinuousJob continuousJob = new ContinuousJob(scheduler, jobGroup, task, NullLogProvider.getInstance());
// when
try (Lifespan ignored = new Lifespan(scheduler, continuousJob)) {
//then
assertTrue(latch.await(DEFAULT_TIMEOUT_MS, MILLISECONDS));
}
}
use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.
the class SharedDiscoveryServiceIT method createDiscoveryJob.
private Callable<Void> createDiscoveryJob(MemberId member, DiscoveryServiceFactory disoveryServiceFactory, Set<MemberId> expectedTargetSet) throws ExecutionException, InterruptedException {
Neo4jJobScheduler jobScheduler = new Neo4jJobScheduler();
jobScheduler.init();
CoreTopologyService topologyService = disoveryServiceFactory.coreTopologyService(config(), member, jobScheduler, logProvider, userLogProvider);
return sharedClientStarter(topologyService, expectedTargetSet);
}
Aggregations