@Test public void systemProperty() throws IOException { System.setProperty(HazelcastConfigResourceCondition.CONFIG_SYSTEM_PROPERTY, "classpath:org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml"); try { load(); HazelcastInstance hazelcastInstance = this.context .getBean(HazelcastInstance.class); Map<String, QueueConfig> queueConfigs = hazelcastInstance.getConfig() .getQueueConfigs(); assertThat(queueConfigs).hasSize(1).containsKey("foobar"); } finally { System.clearProperty(HazelcastConfigResourceCondition.CONFIG_SYSTEM_PROPERTY); } }
@Test public void systemProperty() throws IOException { System.setProperty(HazelcastConfigResourceCondition.CONFIG_SYSTEM_PROPERTY, "classpath:org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml"); try { load(); HazelcastInstance hazelcastInstance = this.context .getBean(HazelcastInstance.class); Map<String, QueueConfig> queueConfigs = hazelcastInstance.getConfig() .getQueueConfigs(); assertThat(queueConfigs.values(), hasSize(1)); assertThat(queueConfigs, hasKey("foobar")); } finally { System.clearProperty(HazelcastConfigResourceCondition.CONFIG_SYSTEM_PROPERTY); } }
public DistQueueConfig setup(Config cfg, String name, QueueStore<URLInfo> storeImplementation) { QueueConfig qConfig = new QueueConfig(); //TODO: Refactor the configuration entries qConfig.setName(name); qConfig.setBackupCount(1); if(storeImplementation != null) { QueueStoreConfig storeConfig = new QueueStoreConfig(); storeConfig.setStoreImplementation(storeImplementation); storeConfig.setProperty("memory-limit", "30"); qConfig.setQueueStoreConfig(storeConfig); //todo Refactor to Config } cfg.addQueueConfig(qConfig); return this; }
@Test public void configInstanceWithoutName() { load(HazelcastConfigNoName.class, "spring.hazelcast.config=this-is-ignored.xml"); HazelcastInstance hazelcastInstance = this.context .getBean(HazelcastInstance.class); Map<String, QueueConfig> queueConfigs = hazelcastInstance.getConfig() .getQueueConfigs(); assertThat(queueConfigs).hasSize(1).containsKey("another-queue"); }
private void setQueueConfig(Config config) { QueueConfig queue = config.getQueueConfig("cz.eetlite"); queue.setBackupCount(1); queue.setMaxSize(0); queue.setEmptyQueueTtl(0); QueueStoreConfig queueStoreConfig = null; // queue.setQueueStoreConfig(queueStoreConfig); queue.setStatisticsEnabled(true); }
@Test public void configInstanceWithoutName() { load(HazelcastConfigNoName.class, "spring.hazelcast.config=this-is-ignored.xml"); HazelcastInstance hazelcastInstance = this.context .getBean(HazelcastInstance.class); Map<String, QueueConfig> queueConfigs = hazelcastInstance.getConfig() .getQueueConfigs(); assertThat(queueConfigs.values(), hasSize(1)); assertThat(queueConfigs, hasKey("another-queue")); }
private static void run() { Config config = new Config("queueTest"); QueueConfig queueConfig = config.getQueueConfig(QNAME); QueueStoreConfig queueStoreConfig = new QueueStoreConfig(); queueStoreConfig.setEnabled(true); queueStoreConfig.setStoreImplementation(new MockQueueStore()); queueStoreConfig.getProperties().setProperty("memory-limit", "0"); queueConfig.setQueueStoreConfig(queueStoreConfig); HazelcastInstance hzInstance = Hazelcast.newHazelcastInstance(config); IQueue<Integer> queue = hzInstance.getQueue(QNAME); long startTime = System.currentTimeMillis(); int i = 0; while (i++ < 2000000) { if (i % 10000 == 0) { logger.info(Integer.toString(i) + "\t" + String.format("%8.3f", (double) (System.currentTimeMillis() - startTime) / i)); } queue.add(i); } }
private static Config createConfig(String name) { Config config = new Config(name); QueueConfig queueConfig = config.getQueueConfig(QNAME); queueConfig.setBackupCount(0); QueueStoreConfig queueStoreConfig = new QueueStoreConfig(); queueStoreConfig.setEnabled(true); queueStoreConfig.setStoreImplementation(queueStore); queueStoreConfig.getProperties().setProperty("memory-limit", "0"); queueConfig.setQueueStoreConfig(queueStoreConfig); return config; }
private static Config createConfig(String name) { Config config = new Config(name); QueueConfig queueConfig = config.getQueueConfig(QNAME); queueConfig.setBackupCount(0); return config; }
@Bean public Config anotherHazelcastConfig() { Config config = new Config(); config.addQueueConfig(new QueueConfig("another-queue")); return config; }
@JMXAttribute("Config") @JMXDescription("Queue configuration") public String getConfig() { final QueueConfig config = managementService.getInstance().getConfig().getQueueConfig(getName()); return config.toString(); }
private static void run() { Config config = new Config("queueTest"); QueueConfig queueConfig = config.getQueueConfig(QNAME); QueueStoreConfig queueStoreConfig = new QueueStoreConfig(); queueStoreConfig.setEnabled(true); queueStoreConfig.setStoreImplementation(new MockQueueStore()); queueStoreConfig.getProperties().setProperty("memory-limit", "0"); queueConfig.setQueueStoreConfig(queueStoreConfig); HazelcastInstance hzInstance = Hazelcast.newHazelcastInstance(config); long startTime = System.currentTimeMillis(); int i = 0; while (i++ < 2000000) { if (i % 10000 == 0) { logger.info(Integer.toString(i) + "\t" + String.format("%8.3f", (double) (System.currentTimeMillis() - startTime) / i)); } TransactionOptions options = new TransactionOptions().setTransactionType(TransactionOptions.TransactionType.LOCAL); TransactionContext context = hzInstance.newTransactionContext(options); context.beginTransaction(); TransactionalQueue<Integer> queue = context.getQueue(QNAME); queue.offer(i); context.commitTransaction(); } }