Java 类com.hazelcast.config.FileSystemXmlConfig 实例源码

项目:hazelcast-wm    文件:AbstractWebFilterTest.java   
protected void ensureInstanceIsUp() throws Exception {
    if (isInstanceNotActive(hz)) {
        hz = Hazelcast.newHazelcastInstance(
                new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
    }
    if (serverXml1 != null) {
        if (server1 == null) {
            serverPort1 = availablePort();
            server1 = getServletContainer(serverPort1, sourceDir, serverXml1);
        } else if (!server1.isRunning()) {
            server1.start();
        }
    }
    if (serverXml2 != null) {
        if (server2 == null) {
            serverPort2 = availablePort();
            server2 = getServletContainer(serverPort2, sourceDir, serverXml2);
        } else if (!server2.isRunning()) {
            server2.start();
        }
    }
}
项目:hazelcast-wm    文件:WebFilterClientFailOverTests.java   
@Test
public void whenClusterIsDown_enabledDeferredWrite() throws Exception {
    CookieStore cookieStore = new BasicCookieStore();
    assertEquals("true", executeRequest("write", serverPort1, cookieStore));
    assertEquals("value", executeRequest("read", serverPort1, cookieStore));
    hz.shutdown();

    assertEquals("value", executeRequest("read", serverPort1, cookieStore));
    assertEquals("true", executeRequest("remove", serverPort1, cookieStore));
    assertEquals("null", executeRequest("read", serverPort1, cookieStore));

    hz = Hazelcast.newHazelcastInstance(
            new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
    assertClusterSizeEventually(1, hz);

    assertEquals("true", executeRequest("write", serverPort1, cookieStore));
    assertEquals("value", executeRequest("read", serverPort1, cookieStore));
}
项目:hazelcast-wm    文件:WebFilterClientFailOverTests.java   
@Test
public void whenClusterIsDownAtBeginning_enabledDeferredWrite() throws Exception {
    hz.shutdown();

    CookieStore cookieStore = new BasicCookieStore();
    assertEquals("true", executeRequest("write", serverPort1, cookieStore));
    assertEquals("value", executeRequest("read", serverPort1, cookieStore));

    assertEquals("value", executeRequest("read", serverPort1, cookieStore));
    assertEquals("true", executeRequest("remove", serverPort1, cookieStore));
    assertEquals("null", executeRequest("read", serverPort1, cookieStore));

    assertEquals("true", executeRequest("write", serverPort1, cookieStore));
    assertEquals("value", executeRequest("read", serverPort1, cookieStore));

    hz = Hazelcast.newHazelcastInstance(
            new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
    assertClusterSizeEventually(1, hz);

    assertEquals("value", executeRequest("read", serverPort1, cookieStore));
    assertEquals("true", executeRequest("remove", serverPort1, cookieStore));
    assertEquals("null", executeRequest("read", serverPort1, cookieStore));

}
项目:hazelcast-wm    文件:WebFilterClientFailOverTests.java   
@Test
public void testWhenClusterIsDownAtBeginningInNonDeferredMode() throws Exception {
    if (!testName.equals("client - not deferred")) {
        return;
    }

    hz.shutdown();
    CookieStore cookieStore = new BasicCookieStore();
    assertEquals("true", executeRequest("write", serverPort1, cookieStore));
    assertEquals("value", executeRequest("read", serverPort1, cookieStore));

    hz = Hazelcast.newHazelcastInstance(
            new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
    assertClusterSizeEventually(1, hz);

    assertEquals("value", executeRequest("read", serverPort1, cookieStore));
    IMap<String, Object> map = hz.getMap(DEFAULT_MAP_NAME);
    assertEquals(1, map.size());
}
项目:hazelcast-wm    文件:WebFilterClientFailOverTests.java   
@Test
public void testWhenClusterIsDownAtBeginningInDeferedMode() throws Exception {
    if (!testName.equals("client - not deferred")) {
        return;
    }

    hz.shutdown();
    CookieStore cookieStore = new BasicCookieStore();
    assertEquals("true", executeRequest("write", serverPort1, cookieStore));
    assertEquals("value", executeRequest("read", serverPort1, cookieStore));

    hz = Hazelcast.newHazelcastInstance(
            new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
    assertClusterSizeEventually(1, hz);
    assertEquals("value", executeRequest("read", serverPort1, cookieStore));

    IMap<String, Object> map = hz.getMap(DEFAULT_MAP_NAME);
    assertEquals(0, map.size());
}
项目:hazelcast-wm    文件:DeferredWriteClusterTest.java   
@Override
protected void ensureInstanceIsUp() throws Exception {
    if (isInstanceNotActive(hz)) {
        hz = Hazelcast.newHazelcastInstance(
                new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
    }
    if (serverXml1 != null) {
        if (server1 == null) {
            serverPort1 = availablePort();
            server1 = getServletContainer(serverPort1, sourceDir, serverXml1);
        } else if (!server1.isRunning()) {
            server1.start();
        }
    }
    if (serverXml2 != null) {
        if (server2 == null) {
            serverPort2 = availablePort();
            server2 = getServletContainer(serverPort2, sourceDir, serverXml2);
        } else if (!server2.isRunning()) {
            server2.start();
        }
    }
}
项目:hazelcast-wm    文件:DeferredFailoverClusterTest.java   
@Override
protected void ensureInstanceIsUp() throws Exception {
    if (isInstanceNotActive(hz)) {
        hz = Hazelcast.newHazelcastInstance(
                new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
    }
    if (serverXml1 != null) {
        if (server1 == null) {
            serverPort1 = availablePort();
            server1 = getServletContainer(serverPort1, sourceDir, serverXml1);
        } else if (!server1.isRunning()) {
            server1.start();
        }
    }
    if (serverXml2 != null) {
        if (server2 == null) {
            serverPort2 = availablePort();
            server2 = getServletContainer(serverPort2, sourceDir, serverXml2);
        } else if (!server2.isRunning()) {
            server2.start();
        }
    }
}
项目:hybridbpm    文件:HazelcastServer.java   
public void start() {
    try {
        logger.info("HazelcastServer starting");
        File configurationFile = new File(CONFIGURATION_DIRECTORY, CONFIGURATION_FILENAME);
        if (!configurationFile.exists()) {
            try (FileOutputStream fos = new FileOutputStream(configurationFile)) {
                fos.write(HybridbpmCoreUtil.getDefaultHazelcastConfig().getBytes());
            }
        }
        configurationFile = new File(CONFIGURATION_DIRECTORY, CONFIGURATION_FILENAME);
        hazelcastInstance = Hazelcast.newHazelcastInstance(new FileSystemXmlConfig(configurationFile));
        logger.info("HazelcastServer started");
    } catch (Exception ex) {
        logger.log(Level.SEVERE, ex.getMessage(), ex);
    }
}
项目:ravikumaran201504    文件:StoreManager.java   
@Activate
public void activate() {
    try {
        File hazelcastFile = new File(HAZELCAST_XML_FILE);
        if (!hazelcastFile.exists()) {
            createDefaultHazelcastFile(hazelcastFile);
        }

        Config config = new FileSystemXmlConfig(HAZELCAST_XML_FILE);

        instance = Hazelcast.newHazelcastInstance(config);
        log.info("Started");
    } catch (FileNotFoundException e) {
        log.error("Unable to configure Hazelcast", e);
    }
}
项目:Gaffer    文件:HazelcastCacheService.java   
private void configureHazelcast(final Properties properties) {
    if (null == hazelcast || !Hazelcast.getAllHazelcastInstances().contains(hazelcast)) {
        String configFile = properties.getProperty(CACHE_CONFIG_FILE);
        if (null == configFile) {
            LOGGER.warn("Config file not set using system property: " + CACHE_CONFIG_FILE
                    + ". Using default settings");

            hazelcast = Hazelcast.newHazelcastInstance();
        } else {
            try {
                final Config config = new FileSystemXmlConfig(configFile);
                hazelcast = Hazelcast.newHazelcastInstance(config);
            } catch (final Exception e) {
                throw new IllegalArgumentException("Could not create cache using config path: " + configFile, e);
            }
        }
    }
}
项目:moquette    文件:Server.java   
private void configureCluster(IConfig config) throws FileNotFoundException {
    LOG.info("Configuring embedded Hazelcast instance");
    String interceptHandlerClassname = config.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
    if (interceptHandlerClassname == null || !HZ_INTERCEPT_HANDLER.equals(interceptHandlerClassname)) {
        LOG.info("There are no Hazelcast intercept handlers. The server won't start a Hazelcast instance.");
        return;
    }
    String hzConfigPath = config.getProperty(BrokerConstants.HAZELCAST_CONFIGURATION);
    if (hzConfigPath != null) {
        boolean isHzConfigOnClasspath = this.getClass().getClassLoader().getResource(hzConfigPath) != null;
        Config hzconfig = isHzConfigOnClasspath
                ? new ClasspathXmlConfig(hzConfigPath)
                : new FileSystemXmlConfig(hzConfigPath);
        LOG.info("Starting Hazelcast instance. ConfigurationFile={}", hzconfig);
        hazelcastInstance = Hazelcast.newHazelcastInstance(hzconfig);
    } else {
        LOG.info("Starting Hazelcast instance with default configuration");
        hazelcastInstance = Hazelcast.newHazelcastInstance();
    }
    listenOnHazelCastMsg();
}
项目:reactive-data    文件:HazelcastInstanceProxy.java   
/**
  * 
  * @param configFile
  * @param entityBasePkg
  * @throws FileNotFoundException
  */
public HazelcastInstanceProxy(File configFile, String entityBasePkg) throws FileNotFoundException
{
  this(new FileSystemXmlConfig(configFile), entityBasePkg);
}