com.hazelcast.core

## Class Hazelcast

- java.lang.Object
- - com.hazelcast.core.Hazelcast

-     public final class Hazelcast
      extends Object

  Factory for `HazelcastInstance`'s, a node in a cluster.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Set<HazelcastInstance>` | `getAllHazelcastInstances()` Returns all active/running HazelcastInstances on this JVM.
    `static HazelcastInstance` | `getHazelcastInstanceByName(String instanceName)` Returns an existing HazelcastInstance with instanceName.
    `static HazelcastInstance` | `getOrCreateHazelcastInstance()` Gets or creates a HazelcastInstance with the default XML configuration looked up in: System property: Hazelcast will first check if "hazelcast.config" system property is set to a file or a `classpath:...` path.
    `static HazelcastInstance` | `getOrCreateHazelcastInstance(Config config)` Gets or creates the HazelcastInstance with a certain name.
    `static HazelcastInstance` | `newHazelcastInstance()` Creates a new HazelcastInstance (a new node in a cluster).
    `static HazelcastInstance` | `newHazelcastInstance(Config config)` Creates a new HazelcastInstance (a new node in a cluster).
    `static void` | `setOutOfMemoryHandler(OutOfMemoryHandler outOfMemoryHandler)` Sets `OutOfMemoryHandler` to be used when an `OutOfMemoryError` is caught by Hazelcast threads.
    `static void` | `shutdownAll()` Shuts down all member `HazelcastInstance`s running on this JVM.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### shutdownAll

          public static void shutdownAll()

      Shuts down all member `HazelcastInstance`s running on this JVM. It doesn't shutdown all members of the cluster but just the ones running on this JVM.
      See Also:
        `newHazelcastInstance(Config)`

    - #### newHazelcastInstance

          public static HazelcastInstance newHazelcastInstance(Config config)

      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()`.
      Parameters:
        `config` - Configuration for the new HazelcastInstance (member)
      Returns:
        the new HazelcastInstance
      See Also:
        `shutdownAll()`, `getHazelcastInstanceByName(String)`

    - #### newHazelcastInstance

          public static HazelcastInstance 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.
      Returns:
        the new HazelcastInstance
      See Also:
        `shutdownAll()`, `getHazelcastInstanceByName(String)`

    - #### getHazelcastInstanceByName

          public static HazelcastInstance getHazelcastInstanceByName(String instanceName)

      Returns an existing HazelcastInstance with instanceName.

      To shutdown all running HazelcastInstances (all members on this JVM) call `shutdownAll()`.
      Parameters:
        `instanceName` - Name of the HazelcastInstance (member)
      Returns:
        an existing HazelcastInstance
      See Also:
        `newHazelcastInstance(Config)`, `shutdownAll()`

    - #### getOrCreateHazelcastInstance

          public static HazelcastInstance getOrCreateHazelcastInstance()

      Gets or creates a HazelcastInstance with the default XML configuration looked up in:
      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 a configuration file is not located, an `IllegalArgumentException` will be thrown. If a Hazelcast instance with the same name as the configuration exists, then it is returned, otherwise it is created.
      Returns:
        the HazelcastInstance
      Throws:
        `IllegalArgumentException` - if the instance name of the config is null or empty or if no config file can be located.

    - #### getOrCreateHazelcastInstance

          public static HazelcastInstance getOrCreateHazelcastInstance(Config config)

      Gets or creates the HazelcastInstance with a certain name. If a Hazelcast instance with the same name as the configuration exists, then it is returned, otherwise it is created. If `config` is `null`, then an XML configuration file is looked up in the following order:
      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.
      Parameters:
        `config` - the Config.
      Returns:
        the HazelcastInstance
      Throws:
        `IllegalArgumentException` - if the instance name of the config is null or empty or if no config file can be located.

    - #### getAllHazelcastInstances

          public static Set<HazelcastInstance> getAllHazelcastInstances()

      Returns all active/running HazelcastInstances on this JVM.

      To shutdown all running HazelcastInstances (all members on this JVM) call `shutdownAll()`.
      Returns:
        all active/running HazelcastInstances on this JVM
      See Also:
        `newHazelcastInstance(Config)`, `getHazelcastInstanceByName(String)`, `shutdownAll()`

    - #### setOutOfMemoryHandler

          public static void setOutOfMemoryHandler(OutOfMemoryHandler outOfMemoryHandler)

      Sets `OutOfMemoryHandler` to be used when an `OutOfMemoryError` is caught by Hazelcast threads.

      Warning: `OutOfMemoryHandler` may not be called although JVM throws `OutOfMemoryError`. Because error may be thrown from an external (user thread) thread and Hazelcast may not be informed about `OutOfMemoryError`.

      Parameters:
        `outOfMemoryHandler` - set when an `OutOfMemoryError` is caught by Hazelcast threads
      See Also:
        `OutOfMemoryError`, `OutOfMemoryHandler`

Copyright © 2018. All rights reserved.