com.hazelcast.config.ClasspathXmlConfig Java Examples
The following examples show how to use
com.hazelcast.config.ClasspathXmlConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HazelcastReentrantReadWriteLockTest.java From hazelcast-locks with Apache License 2.0 | 6 votes |
@BeforeClass public static void createGrids() { /* Suppress Hazelcast log output to standard error which does not appear to be suppressible via Agent Server's * log4j.xml. */ // ConsoleOutputSuppressor.suppressStandardError(); final Config standardConfig1 = new ClasspathXmlConfig("hazelcast1.xml"), standardConfig2 = new ClasspathXmlConfig("hazelcast2.xml"); standardConfig1.setProperty("hazelcast.operation.call.timeout.millis", "3000"); standardConfig2.setProperty("hazelcast.operation.call.timeout.millis", "3000"); grid1 = Hazelcast.newHazelcastInstance(standardConfig1); grid2 = Hazelcast.newHazelcastInstance(standardConfig2); dataStructureFactory1 = HazelcastDataStructureFactory.getInstance(grid1); dataStructureFactory2 = HazelcastDataStructureFactory.getInstance(grid2); lockService1 = new DistributedLockUtils().new PublicDistributedLockService(dataStructureFactory1); lockService2 = new DistributedLockUtils().new PublicDistributedLockService(dataStructureFactory2); }
Example #2
Source File: HazelcastLocal.java From j2cache with Apache License 2.0 | 5 votes |
public synchronized HazelcastInstance getHazelcast() { if (hazelcast == null) { Config config = new ClasspathXmlConfig("org/j2server/j2cache/cache/hazelcast/hazelcast-cache-config.xml"); config.setInstanceName("j2cache"); hazelcast = Hazelcast.newHazelcastInstance(config); } return hazelcast; }
Example #3
Source File: MapStoreExampleMain.java From hazelcast-demo with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws FileNotFoundException { //加载配置 Config config = new ClasspathXmlConfig("org/palm/hazelcast/map/store/mapStoreConfig.xml"); //创建Hazelcast实力 HazelcastInstance ins = Hazelcast.newHazelcastInstance(config); //获取Map Map<Integer, String> map = ins.getMap("demo"); println(map.get(1));//输出第一条数据 map.put(11, "Moonbrook");//添加一条数据 println(map.get(11));//输出第一条数据 map.remove(11);//移除添加的数据 println(map.get(11));//输出被移除的数据 }
Example #4
Source File: HazelcastConfigSimple.java From hazelcast-demo with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // 从classpath加载配置文件 Config config = new ClasspathXmlConfig("xmlconfig/simple-config.xml"); // 获取网络配置 NetworkConfig netConfig = config.getNetworkConfig(); // 获取用户定义的map配置 MapConfig mapConfigXml = config.getMapConfig("demo.config"); // 获取系统默认的map配置 MapConfig mapConfigDefault = config.getMapConfig("default"); // 输出集群监听的起始端口号 System.out.println("Current port:" + netConfig.getPort()); // 输出监听端口的累加号 System.out.println("Current port count:" + netConfig.getPortCount()); // 输出自定义map的备份副本个数 System.out.println("Config map backup count:" + mapConfigXml.getBackupCount()); // 输出默认map的备份副本个数 System.out.println("Default map backup count:" + mapConfigDefault.getBackupCount()); // 测试创建Hazelcast实例并读写测试数据 HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config); HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config); Map<Integer, String> defaultMap1 = instance1.getMap("defaultMap"); defaultMap1.put(1, "testMap"); Map<Integer, String> configMap1 = instance1.getMap("configMap"); configMap1.put(1, "configMap"); Map<Integer, String> testMap2 = instance2.getMap("defaultMap"); System.out.println("Default map value:" + testMap2.get(1)); Map<Integer, String> configMap2 = instance2.getMap("configMap"); System.out.println("Config map value:" + configMap2.get(1)); }
Example #5
Source File: ApplicationConfig.java From hazelcast-jet-demos with Apache License 2.0 | 4 votes |
@Bean public Config config(Environment environment) { return new ClasspathXmlConfig("hazelcast.xml"); }
Example #6
Source File: RegistratorTestBase.java From hazelcast-consul-discovery-spi with Apache License 2.0 | 4 votes |
public HazelcastInstanceMgr(String hazelcastConfigFile) { this.conf =new ClasspathXmlConfig(hazelcastConfigFile); }
Example #7
Source File: TestDoNothingRegistrator.java From hazelcast-consul-discovery-spi with Apache License 2.0 | 4 votes |
public HazelcastInstanceMgr(String hazelcastConfigFile) { this.conf =new ClasspathXmlConfig(hazelcastConfigFile); }
Example #8
Source File: ManualRunner.java From hazelcast-consul-discovery-spi with Apache License 2.0 | 3 votes |
public static void main(String[] args) throws Exception { Config conf =new ClasspathXmlConfig("hazelcast-consul-discovery-spi-example.xml"); HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(conf); Thread.currentThread().sleep(300000); System.exit(0); }