Skip to content

Commit

Permalink
priorityPendingCount returns scheduleQueue.prioritySize()
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrinot authored and Tom Bujok committed Oct 14, 2015
1 parent 952aaae commit 9548d87
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
Expand Up @@ -76,7 +76,7 @@ public OperationThread(String name, int threadId, ScheduleQueue scheduleQueue,

@Probe
int priorityPendingCount() {
return scheduleQueue.normalSize();
return scheduleQueue.prioritySize();
}

@Probe
Expand Down
@@ -1,13 +1,14 @@
package com.hazelcast.spi.impl.operationexecutor.classic;

import com.hazelcast.instance.OutOfMemoryErrorDispatcher;
import com.hazelcast.logging.ILogger;
import com.hazelcast.nio.Packet;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.spi.Operation;
import com.hazelcast.spi.impl.operationexecutor.OperationRunner;
import com.hazelcast.spi.impl.operationexecutor.OperationRunnerFactory;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastSerialClassRunner;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.annotation.ParallelTest;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand All @@ -19,8 +20,8 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(HazelcastSerialClassRunner.class)
@Category(QuickTest.class)
@RunWith(HazelcastParallelClassRunner.class)
@Category({QuickTest.class, ParallelTest.class})
public class OperationThreadTest extends AbstractClassicOperationExecutorTest {

@Test
Expand Down Expand Up @@ -49,4 +50,34 @@ public void run() throws Exception {
}
});
}

@Test
public void priorityPendingCount_returnScheduleQueuePrioritySize() {
ScheduleQueue mockScheduleQueue = mock(ScheduleQueue.class);
when(mockScheduleQueue.prioritySize()).thenReturn(Integer.MAX_VALUE);

PartitionOperationThread operationThread = createNewOperationThread(mockScheduleQueue);

int prioritySize = operationThread.priorityPendingCount();
assertEquals(Integer.MAX_VALUE, prioritySize);
}

@Test
public void normalPendingCount_returnScheduleQueueNormalSize() {
ScheduleQueue mockScheduleQueue = mock(ScheduleQueue.class);
when(mockScheduleQueue.normalSize()).thenReturn(Integer.MAX_VALUE);

PartitionOperationThread operationThread = createNewOperationThread(mockScheduleQueue);

int normalSize = operationThread.normalPendingCount();
assertEquals(Integer.MAX_VALUE, normalSize);
}

private PartitionOperationThread createNewOperationThread(ScheduleQueue mockScheduleQueue) {
ILogger mockLogger = mock(ILogger.class);
OperationRunner[] runners = new OperationRunner[0];
PartitionOperationThread thread = new PartitionOperationThread("threadName", 0, mockScheduleQueue, mockLogger, threadGroup, nodeExtension, runners);

return thread;
}
}

0 comments on commit 9548d87

Please sign in to comment.