Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong getAllScheduledCount on Scheduled Executor Service #9694

Closed
tkountis opened this issue Jan 19, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@tkountis
Copy link
Contributor

commented Jan 19, 2017

@Danny-Hazelcast reported the following, which I managed to reproduce.

When scheduling on random partitions and trying to get all scheduled tasks from the service, the number of tasks is wrong. The returned figure seems to match num_of_tasks * backup_count.

Reproduce

@Test
    public void scheduleRandomPartitions_getAllScheduled()
            throws ExecutionException, InterruptedException {

        HazelcastInstance[] instances = createClusterWithCount(2);
        IScheduledExecutorService s = getScheduledExecutor(instances, "s");

        int expectedTotal = 11;
        for (int i=0; i < expectedTotal; i++) {
            s.schedule(new PlainCallableTask(), 0, SECONDS);
        }

        Map<Member, List<IScheduledFuture<Double>>> allScheduled = s.getAllScheduledFutures();

        int actualTotal = 0;
        for (Member member : allScheduled.keySet()) {
            actualTotal += allScheduled.get(member).size();
        }

        assertEquals(expectedTotal, actualTotal, 0);
    }

The above fails with:

java.lang.AssertionError: 
Expected :11.0
Actual   :22.0
 <Click to see difference>


	at org.junit.Assert.fail(Assert.java:88)
	at org.junit.Assert.failNotEquals(Assert.java:834)
	at org.junit.Assert.assertEquals(Assert.java:575)
	at org.junit.Assert.assertEquals(Assert.java:700)
	at com.hazelcast.scheduledexecutor.ScheduledExecutorServiceBasicTest.scheduleRandomPartitions_getAllScheduled(ScheduledExecutorServiceBasicTest.java:785)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

@tkountis tkountis added this to the 3.8 milestone Jan 19, 2017

@tkountis tkountis self-assigned this Jan 19, 2017

@tkountis

This comment has been minimized.

Copy link
Contributor Author

commented Jan 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.