use of com.hazelcast.core.QueueStore in project hazelcast by hazelcast.
the class QueueStoreTest method testQueueStoreFactoryIsNotInitialized_whenDisabledInQueueStoreConfig.
@Test
public void testQueueStoreFactoryIsNotInitialized_whenDisabledInQueueStoreConfig() {
String queueName = randomString();
Config config = new Config();
QueueConfig queueConfig = config.getQueueConfig(queueName);
QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
queueStoreConfig.setEnabled(false);
QueueStoreFactory queueStoreFactory = new SimpleQueueStoreFactory();
queueStoreConfig.setFactoryImplementation(queueStoreFactory);
queueConfig.setQueueStoreConfig(queueStoreConfig);
HazelcastInstance instance = createHazelcastInstance(config);
IQueue<Integer> queue = instance.getQueue(queueName);
queue.add(1);
QueueStore queueStore = queueStoreFactory.newQueueStore(queueName, null);
TestQueueStore testQueueStore = (TestQueueStore) queueStore;
int size = testQueueStore.store.size();
assertEquals("Expected not queue store operation" + " since we disabled it in QueueStoreConfig but found initialized ", 0, size);
}
use of com.hazelcast.core.QueueStore in project hazelcast by hazelcast.
the class QueueStoreWrapper method create.
/**
* Factory method that creates a {@link QueueStoreWrapper}
*
* @param name queue name
* @param storeConfig store config of queue
* @param serializationService serialization service.
* @return returns a new instance of {@link QueueStoreWrapper}
*/
public static QueueStoreWrapper create(String name, QueueStoreConfig storeConfig, SerializationService serializationService, ClassLoader classLoader) {
checkNotNull(name, "name should not be null");
checkNotNull(serializationService, "serializationService should not be null");
final QueueStoreWrapper storeWrapper = new QueueStoreWrapper(name);
storeWrapper.setSerializationService(serializationService);
if (storeConfig == null || !storeConfig.isEnabled()) {
return storeWrapper;
}
// create queue store.
final QueueStore queueStore = createQueueStore(name, storeConfig, classLoader);
if (queueStore != null) {
storeWrapper.setEnabled(storeConfig.isEnabled());
storeWrapper.setBinary(Boolean.parseBoolean(storeConfig.getProperty(STORE_BINARY)));
storeWrapper.setMemoryLimit(parseInt(STORE_MEMORY_LIMIT, DEFAULT_MEMORY_LIMIT, storeConfig));
storeWrapper.setBulkLoad(parseInt(STORE_BULK_LOAD, DEFAULT_BULK_LOAD, storeConfig));
storeWrapper.setStore(queueStore);
}
return storeWrapper;
}
use of com.hazelcast.core.QueueStore in project hazelcast by hazelcast.
the class LatencyTrackingQueueStoreTest method setup.
@Before
public void setup() {
hz = createHazelcastInstance();
plugin = new StoreLatencyPlugin(getNodeEngineImpl(hz));
delegate = mock(QueueStore.class);
queueStore = new LatencyTrackingQueueStore<String>(delegate, plugin, NAME);
}
use of com.hazelcast.core.QueueStore in project hazelcast by hazelcast.
the class QueueStoreTest method testQueueStoreFactory.
@Test
public void testQueueStoreFactory() {
String queueName = randomString();
Config config = new Config();
QueueConfig queueConfig = config.getQueueConfig(queueName);
QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
queueStoreConfig.setEnabled(true);
QueueStoreFactory queueStoreFactory = new SimpleQueueStoreFactory();
queueStoreConfig.setFactoryImplementation(queueStoreFactory);
queueConfig.setQueueStoreConfig(queueStoreConfig);
HazelcastInstance instance = createHazelcastInstance(config);
IQueue<Integer> queue = instance.getQueue(queueName);
queue.add(1);
QueueStore queueStore = queueStoreFactory.newQueueStore(queueName, null);
TestQueueStore testQueueStore = (TestQueueStore) queueStore;
int size = testQueueStore.store.size();
assertEquals("Queue store size should be 1 but found " + size, 1, size);
}
Aggregations