Package com.hazelcast.config

Examples of com.hazelcast.config.Config


     *
     * @return
     */
    public Config getHazelcastConfig() {
        System.setProperty("hazelcast.config", xmlConfigLocation);
        Config config = new XmlConfigBuilder().build();
        if (discoveredMemberSet != null) {
            TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
            tcpIpConfig.getMembers().addAll(discoveredMemberSet);
        }
        return config;
    }
View Full Code Here


    private Map<Long,Long> registryCache;

    public HazelcastCacheManager(KiWiConfiguration configuration) {
        this.configuration = configuration;

        hcConfiguration = new Config();
        if(configuration.isClustered()) {
            hcConfiguration.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
            hcConfiguration.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(configuration.getClusterPort());
            hcConfiguration.getNetworkConfig().getJoin().getMulticastConfig().setMulticastGroup(configuration.getClusterAddress());
        } else {
View Full Code Here

            }
        }
    }

    private void initHazelcastInstance() {
        Config config = getHazelcastConfig();

        // do this when theres a way to have adders be the key owners
        // config.getMapConfig(configURI.getDomainName() + "/Endpoints").setBackupCount(0);

        // this caches reads locally
        config.getMapConfig("default").setNearCacheConfig(new NearCacheConfig(0, 0, "NONE", 0, true));

        // Disable the Hazelcast shutdown hook as Tuscany has its own and with both there are race conditions
        config.setProperty("hazelcast.shutdownhook.enabled",
                           // GroupProperties.PROP_SHUTDOWNHOOK_ENABLED,
                           "false");
       
        // By default this is 5 seconds, not sure what the implications are but dropping it down to 1 makes
        // things like the samples look much faster
        config.setProperty("hazelcast.wait.seconds.before.join",
                           // GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN,
                           "1");

        this.hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    }
View Full Code Here

        this.hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    }

    protected Config getHazelcastConfig() {
        Config config;
        this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
        String configFile = properties.getProperty("hazelcastConfig");
        if (configFile != null) {
            try {
                config = new XmlConfigBuilder(configFile).build();
            } catch (FileNotFoundException e) {
                throw new IllegalArgumentException(configFile, e);
            }
        } else {
            config = new XmlConfigBuilder().build();
            RegistryConfig rc = new RegistryConfig(properties);
            config.setPort(rc.getBindPort());
            //config.setPortAutoIncrement(false);

            if (!rc.getBindAddress().equals("*")) {
                config.getNetworkConfig().getInterfaces().setEnabled(true);
                config.getNetworkConfig().getInterfaces().clear();
                config.getNetworkConfig().getInterfaces().addInterface(rc.getBindAddress());
            }

            config.getGroupConfig().setName(rc.getUserid());
            config.getGroupConfig().setPassword(rc.getPassword());

            if (rc.isMulticastDisabled()) {
                config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
            } else {
                config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
                config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(rc.getMulticastPort());
                config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastGroup(rc.getMulticastAddress());
            }
           
            if (rc.getWKAs().size() > 0) {
                TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
                tcpconfig.setEnabled(true);
                List<Address> lsMembers = tcpconfig.getAddresses();
                lsMembers.clear();
                for (String addr : rc.getWKAs()) {
                    String[] ipNPort = addr.split(":");
View Full Code Here

//        Assert.assertEquals("bla1", h6map.get("key1"));

    }

    private HazelcastInstance create(String multicast, int listenPort, int... connectPorts) throws UnknownHostException {
        Config config = new XmlConfigBuilder().build();
        config.setPort(listenPort);
        config.setPortAutoIncrement(false);

        // declare the interface Hazelcast should bind to
        config.getNetworkConfig().getInterfaces().clear();
        config.getNetworkConfig().getInterfaces().addInterface(InetAddress.getLocalHost().getHostAddress());
        config.getNetworkConfig().getInterfaces().setEnabled(true);

        if ("false".equals(multicast)) {
            config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        } else {
            config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(Integer.parseInt(multicast));
        }
       
        if (connectPorts.length > 0) {
            TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
            tcpconfig.setEnabled(true);

            List<Address> lsMembers = tcpconfig.getAddresses();
            lsMembers.clear();
            for (int p : connectPorts) {
View Full Code Here

    else {
      if (logger.isDebugEnabled()) {
        logger.debug("Normal start of new HazelcastInstance");
      }
      // create the instance
      Config cfg = new Config();
      cfg.setPort(E3Constant.HAZELCAST_PORT);
      cfg.setPortAutoIncrement(true);
     
      cfg.setInstanceName(E3Constant.HAZELCAST_NAME);

      cfg.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);

      setHazelcastInstance(Hazelcast.newHazelcastInstance(cfg));

      if (logger.isDebugEnabled()) {
        logger.debug("Normal start: done.");
View Full Code Here

  @Test
  public void testStandaloneMode() {

    // Start 2 standalone hazelcast instances
    Config cfg = new Config();
    cfg.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(cfg);
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance(cfg);
   
    // Add a new key/value in the 1st instance
    Map<Integer, String> map1 = h1.getMap("testmap");
View Full Code Here

  }

  @Test
  public void testHazelcastJavaClient() throws UnknownHostException {

    Config cfg = new Config();
    cfg.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(cfg);

    // Connect a client to the cluster
    ClientConfig clientConfig = new ClientConfig() ;
    InetSocketAddress localMemberAddress = h1.getCluster().getLocalMember().getInetSocketAddress();
View Full Code Here

    MapConfig mapConfig = new MapConfig();
    mapConfig.setName(mapName);
    mapConfig.setMaxSizeConfig(maxSizeConfig);
    mapConfig.setEvictionPolicy("LRU");
   
    Config config = new Config();
    Map <String, MapConfig> mapConfigs = new HashMap<String, MapConfig>();
    mapConfigs.put(mapName, mapConfig);
    config.setMapConfigs(mapConfigs);
   
    // Start a new cluster of Hazelcast isntances
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);

    IMap<String, String> map = h1.getMap(mapName);
View Full Code Here

   
    MapConfig mapConfig = new MapConfig();
    mapConfig.setName(mapName);
    mapConfig.setMapStoreConfig(mapStoreConfig);
   
    Config config = new Config();
    Map <String, MapConfig> mapConfigs = new HashMap<String, MapConfig>();
    mapConfigs.put(mapName, mapConfig);
    config.setMapConfigs(mapConfigs);

    // Initialize the store with 3 key/value pairs
    MockDataStore.internalStore = new HashMap<Object, Object>();
    MockDataStore.internalStore.put("key1", "value1");
    MockDataStore.internalStore.put("key2", "value2");
View Full Code Here

TOP

Related Classes of com.hazelcast.config.Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.