com.hazelcast.core.Hazelcast.newHazelcastInstance()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(218)

本文整理了Java中com.hazelcast.core.Hazelcast.newHazelcastInstance()方法的一些代码示例,展示了Hazelcast.newHazelcastInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hazelcast.newHazelcastInstance()方法的具体详情如下:
包路径:com.hazelcast.core.Hazelcast
类名称:Hazelcast
方法名:newHazelcastInstance

Hazelcast.newHazelcastInstance介绍

[英]Creates a new HazelcastInstance (a new node in a cluster). This method allows you to create and run multiple instances of Hazelcast cluster members on the same JVM.

To shutdown all running HazelcastInstances (all members on this JVM) call #shutdownAll(). Hazelcast will look into two places for the configuration file:

  1. System property: Hazelcast will first check if "hazelcast.config" system property is set to a file or a classpath:... path. Examples: -Dhazelcast.config=C:/myhazelcast.xml , -Dhazelcast.config=classpath:the-hazelcast-config.xml , -Dhazelcast.config=classpath:com/mydomain/hazelcast.xml
  2. "hazelcast.xml" file in current working directory
  3. Classpath: Hazelcast will check classpath for hazelcast.xml file.
    If Hazelcast doesn't find any config file, it will start with the default configuration (hazelcast-default.xml) located in hazelcast.jar.
    [中]创建新的HazelcastInstance(群集中的新节点)。此方法允许您在同一JVM上创建和运行Hazelcast集群成员的多个实例。
    要关闭所有正在运行的HazelcastInstances(此JVM上的所有成员),请调用#shutdownAll()。Hazelcast将查看配置文件的两个位置:
    1.系统属性:Hazelcast将首先检查“Hazelcast.config”系统属性是否设置为文件或类路径:。。。路径示例:-Dhazelcast。config=C:/myhazelcast。xml,-Dhazelcast。config=classpath:hazelcast配置。xml,-Dhazelcast。config=classpath:com/mydomain/hazelcast。xml
    1.当前工作目录中的“hazelcast.xml”文件
    1.类路径:Hazelcast将检查Hazelcast的类路径。xml文件。
    如果Hazelcast找不到任何配置文件,它将从位于Hazelcast中的默认配置(Hazelcast default.xml)开始。罐子

代码示例

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, String> map = hz.getMap("map");
    for (Map.Entry<String, String> entry : map.entrySet()) {
      System.out.println(entry.getKey() + " " + entry.getValue());
    }
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, String> map = hz.getMap("map");
    map.put("1", "Tokyo");
    map.put("2", "Paris");
    map.put("3", "New York");
    System.out.println("Finished loading map");
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("Peter", new Person("Peter"));

    Person person = map.get("Peter");
    System.out.println(person);

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("foo", new Person("foo"));
    System.out.println("finished writing");

    System.out.println(map.get("foo"));
    System.out.println("finished reading");

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("Peter", new Person("Peter"));

    Person person = map.get("Peter");
    System.out.println(person);

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    ISet<String> set = hz.getSet("set");
    for (String s : set) {
      System.out.println(s);
    }
    System.out.println("Reading finished!");
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("Peter", new Person("Peter"));

    Person person = map.get("Peter");
    System.out.println(person);

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("Peter", new Person("Peter"));

    Person person = map.get("Peter");
    System.out.println(person);

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) throws Exception {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    IQueue<String> queue = hz.getQueue("q");

    System.out.println("Queue retrieved: " + queue);
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    IList<String> list = hz.getList("list");
    for (String s : list) {
      System.out.println(s);
    }
    System.out.println("Reading finished!");
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("Peter", new Person("Peter"));

    Person person = map.get("Peter");
    System.out.println(person);

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("Peter", new Person("Peter"));

    Person person = map.get("Peter");
    System.out.println(person);

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");

    map.put("Peter", new Person("Peter"));

    Person person = map.get("Peter");
    System.out.println(person);

    Hazelcast.shutdownAll();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
  HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(newConfig());
  Map<String, String> map = hazelcastInstance.getMap("map");
  map.put("1", "Tokyo");
  map.put("2", "Paris");
  map.put("3", "New York");
  System.out.println("Inserted " + map.size() + " entries into maps hd memory");
  hazelcastInstance.shutdown();
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
  HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(newConfig());
  Map<String, String> map = hazelcastInstance.getMap("map");
  for (int i = 0; i < 10 * MAX_ENTRY_COUNT; i++) {
    map.put("key-" + i, "value-" + i);
  }
  System.out.println("Map size is " + map.size() + " and it is below the allowed max entry count " + MAX_ENTRY_COUNT);
  hazelcastInstance.shutdown();
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, String> map = hz.getReplicatedMap("map");

    map.put("1", "Tokyo");
    map.put("2", "Paris");
    map.put("3", "New York");

    System.out.println("Finished loading map");
    hz.shutdown();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, String> map = hz.getReplicatedMap("map");

    for (Map.Entry<String, String> entry : map.entrySet()) {
      System.out.println(entry.getKey() + " " + entry.getValue());
    }

    hz.shutdown();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    ITopic<Date> topic = hz.getTopic("topic");
    topic.publish(new Date());
    System.out.println("Published");
    System.exit(0);
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    IMap<Long, Person> personMap = hz.getMap("personMap");
    Person p = personMap.get(1L);
    System.out.println(p);
    hz.shutdown();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
  HazelcastInstance hz = Hazelcast.newHazelcastInstance();
  IMap<String, String> map = hz.getMap("someMap");
  map.addEntryListener(new MyEntryListener(), true);
  System.out.println("EntryListener registered");
}

相关文章