Class JetConfig
public class JetConfig extends Object
- Since:
- 3.0
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_CLUSTER_NAME
The default cluster name for a Jet cluster.static int
DEFAULT_JET_MULTICAST_PORT
The default port number for the cluster auto-discovery mechanism's multicast communication. -
Constructor Summary
Constructors Constructor Description JetConfig()
Creates a new, emptyJetConfig
with the default configuration. -
Method Summary
Modifier and Type Method Description JetConfig
configureHazelcast(Consumer<Config> configConsumer)
Convenience method for for configuring underlying Hazelcast IMDG instance.EdgeConfig
getDefaultEdgeConfig()
Returns the default DAG edge configuration.Config
getHazelcastConfig()
Returns the configuration object for the underlying Hazelcast IMDG instance.InstanceConfig
getInstanceConfig()
Returns the Jet instance config.Properties
getProperties()
Returns the Jet-specific configuration properties.static JetConfig
loadDefault()
Loads JetConfig using the default lookup mechanism to locate the configuration file.static JetConfig
loadDefault(Properties properties)
Loads JetConfig using the built-inlookup mechanism
to locate the configuration file.static JetConfig
loadFromClasspath(ClassLoader classLoader, String resource)
Creates a JetConfig which is loaded from a classpath resource.static JetConfig
loadFromClasspath(ClassLoader classLoader, String resource, Properties properties)
Creates a JetConfig which is loaded from a classpath resource.static JetConfig
loadFromClasspath(String resource)
Deprecated.static JetConfig
loadFromClasspath(String resource, Properties properties)
Deprecated.static JetConfig
loadFromFile(File configFile)
Creates a JetConfig based on a Hazelcast Jet configuration file (XML or YAML) and uses the System.properties to resolve variables in the file.static JetConfig
loadFromFile(File configFile, Properties properties)
Creates a JetConfig based on a Hazelcast Jet configuration file (XML or YAML).static JetConfig
loadFromStream(InputStream configStream)
Deprecated.static JetConfig
loadFromStream(InputStream configStream, Properties properties)
static JetConfig
loadXmlFromStream(InputStream configStream)
Loads JetConfig from the supplied input stream.static JetConfig
loadXmlFromStream(InputStream configStream, Properties properties)
Loads JetConfig from the supplied input stream.static JetConfig
loadXmlFromString(String xml)
Creates a JetConfig from the provided XML string and uses the System.properties to resolve variables in the XML.static JetConfig
loadXmlFromString(String xml, Properties properties)
Creates a JetConfig from the provided XML string and properties to resolve the variables in the XML.static JetConfig
loadYamlFromStream(InputStream configStream)
Loads JetConfig from the supplied input stream.static JetConfig
loadYamlFromStream(InputStream configStream, Properties properties)
Loads JetConfig from the supplied input stream.static JetConfig
loadYamlFromString(String yaml)
Creates a JetConfig from the provided YAML string and uses the System.properties to resolve variables in the YAML.static JetConfig
loadYamlFromString(String yaml, Properties properties)
Creates a JetConfig from the provided YAML string and properties to resolve the variables in the YAML.JetConfig
setDefaultEdgeConfig(EdgeConfig defaultEdgeConfig)
Sets the configuration object that specifies the defaults to use for a DAG edge configuration.JetConfig
setHazelcastConfig(Config config)
Sets the underlying Hazelcast IMDG instance's configuration object.JetConfig
setInstanceConfig(InstanceConfig instanceConfig)
Sets the Jet instance config.JetConfig
setProperties(Properties properties)
Sets the Jet-specific configuration properties.JetConfig
setProperty(String name, String value)
Sets the value of the specified property.
-
Field Details
-
DEFAULT_JET_MULTICAST_PORT
public static final int DEFAULT_JET_MULTICAST_PORTThe default port number for the cluster auto-discovery mechanism's multicast communication.- See Also:
- Constant Field Values
-
DEFAULT_CLUSTER_NAME
The default cluster name for a Jet cluster.- See Also:
- Constant Field Values
-
-
Constructor Details
-
JetConfig
public JetConfig()Creates a new, emptyJetConfig
with the default configuration. Doesn't consider any configuration XML files.
-
-
Method Details
-
loadDefault
Loads JetConfig using the default lookup mechanism to locate the configuration file. Loads the nested Hazelcast config also by using its default lookup mechanism. UsesSystem.getProperties()
to resolve the variables in the XML or YAML.This is the lookup mechanism for the Jet configuration:
-
Read the system property
hazelcast.jet.config
. If it starts withclasspath:
, treat it as a classpath resource, otherwise it's a file pathname. If it's defined but Jet can't find the file it specifies, startup fails. -
Look for
hazelcast-jet.xml
in the working directory. -
Look for
hazelcast-jet.xml
in the classpath. -
Look for
hazelcast-jet.yaml
in the working directory. -
Look for
hazelcast-jet.yaml
in the classpath. - Load the default XML configuration packaged in Jet's JAR.
hazelcast.config
system property. -
Read the system property
-
loadDefault
Loads JetConfig using the built-inlookup mechanism
to locate the configuration file. Loads the nested Hazelcast config also by using the lookup mechanism. Uses the givenproperties
to resolve the variables in the XML or YAML. -
loadFromClasspath
Creates a JetConfig which is loaded from a classpath resource. The System.properties are used to resolve variables in the configuration file.- Parameters:
classLoader
- the ClassLoader used to load the resourceresource
- the resource, an XML or YAML configuration file from the classpath, without the "classpath:" prefix- Throws:
IllegalArgumentException
- if classLoader or resource isnull
, or if the resource is not foundInvalidConfigurationException
- if the resource content is invalid
-
loadFromClasspath
@Nonnull public static JetConfig loadFromClasspath(ClassLoader classLoader, String resource, Properties properties)Creates a JetConfig which is loaded from a classpath resource. Uses the givenproperties
to resolve the variables in the resource.- Parameters:
classLoader
- the ClassLoader used to load the resourceresource
- the resource, an XML or YAML configuration file from the classpath, without the "classpath:" prefixproperties
- the properties used to resolve variables in the resource- Throws:
IllegalArgumentException
- if classLoader or resource isnull
, or if the resource is not foundInvalidConfigurationException
- if the resource content is invalid
-
loadFromFile
Creates a JetConfig based on a Hazelcast Jet configuration file (XML or YAML) and uses the System.properties to resolve variables in the file.- Parameters:
configFile
- the path of the Hazelcast Jet configuration file- Throws:
FileNotFoundException
- if the file doesn't existInvalidConfigurationException
- if the file content is invalid
-
loadFromFile
@Nonnull public static JetConfig loadFromFile(File configFile, Properties properties) throws FileNotFoundExceptionCreates a JetConfig based on a Hazelcast Jet configuration file (XML or YAML). Uses the givenproperties
to resolve the variables in the file.- Parameters:
configFile
- the path of the Hazelcast Jet configuration fileproperties
- the Properties to resolve variables in the file- Throws:
IllegalArgumentException
- if configFile or properties isnull
FileNotFoundException
- if the file doesn't existInvalidConfigurationException
- if the file content is invalid
-
loadXmlFromStream
Loads JetConfig from the supplied input stream. UsesSystem.getProperties()
to resolve the variables in the XML.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathXmlConfig
orFileSystemXmlConfig
.- Parameters:
configStream
- the InputStream to load the config from- Throws:
HazelcastException
- if the XML content is invalid
-
loadXmlFromStream
@Nonnull public static JetConfig loadXmlFromStream(@Nonnull InputStream configStream, @Nonnull Properties properties)Loads JetConfig from the supplied input stream. Uses the givenproperties
to resolve the variables in the XML.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathXmlConfig
orFileSystemXmlConfig
.- Parameters:
configStream
- the InputStream to load the config fromproperties
- the properties to resolve variables in the XML- Throws:
HazelcastException
- if the XML content is invalid
-
loadXmlFromString
Creates a JetConfig from the provided XML string and uses the System.properties to resolve variables in the XML.- Parameters:
xml
- the XML content as a Hazelcast Jet XML String- Throws:
IllegalArgumentException
- if the XML is null or emptyInvalidConfigurationException
- if the XML content is invalid
-
loadXmlFromString
Creates a JetConfig from the provided XML string and properties to resolve the variables in the XML.- Parameters:
xml
- the XML content as a Hazelcast Jet XML String- Throws:
IllegalArgumentException
- if the XML is null or empty or if properties is nullInvalidConfigurationException
- if the XML content is invalid
-
loadYamlFromStream
Loads JetConfig from the supplied input stream. UsesSystem.getProperties()
to resolve the variables in the YAML.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathYamlConfig
orFileSystemYamlConfig
.- Parameters:
configStream
- the InputStream to load the config from- Throws:
HazelcastException
- if the YAML content is invalid- Since:
- 3.1
-
loadYamlFromStream
@Nonnull public static JetConfig loadYamlFromStream(@Nonnull InputStream configStream, @Nonnull Properties properties)Loads JetConfig from the supplied input stream. Uses the givenproperties
to resolve the variables in the YAML.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathYamlConfig
orFileSystemYamlConfig
.- Parameters:
configStream
- the InputStream to load the config from- Throws:
HazelcastException
- if the YAML content is invalid- Since:
- 3.1
-
loadYamlFromString
Creates a JetConfig from the provided YAML string and uses the System.properties to resolve variables in the YAML.- Parameters:
yaml
- the YAML content as a Hazelcast Jet YAML String- Throws:
IllegalArgumentException
- if the YAML is null or emptyInvalidConfigurationException
- if the YAML content is invalid- Since:
- 3.1
-
loadYamlFromString
Creates a JetConfig from the provided YAML string and properties to resolve the variables in the YAML.- Parameters:
yaml
- the YAML content as a Hazelcast Jet YAML String- Throws:
IllegalArgumentException
- if the YAML is null or empty or if properties is nullInvalidConfigurationException
- if the YAML content is invalid- Since:
- 3.1
-
loadFromClasspath
Deprecated.Uses the thread's context class loader to load JetConfig from the classpath resource named by the argument. UsesSystem.getProperties()
to resolve the variables in the XML or Yaml.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathXmlConfig
orFileSystemXmlConfig
.- Parameters:
resource
- names the classpath resource containing the XML or Yaml configuration file- Throws:
HazelcastException
- if the XML or Yaml content is invalidIllegalArgumentException
- if classpath resource is not found
-
loadFromClasspath
@Nonnull @Deprecated public static JetConfig loadFromClasspath(@Nonnull String resource, @Nonnull Properties properties)Deprecated.Uses the thread's context class loader to load JetConfig from the classpath resource named by the argument. Uses the givenproperties
to resolve the variables in the XML.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathXmlConfig
orFileSystemXmlConfig
.- Parameters:
resource
- the classpath resource, an XML configuration file on the classpath- Throws:
HazelcastException
- if the XML content is invalidIllegalArgumentException
- if classpath resource is not found
-
loadFromStream
Deprecated.Loads JetConfig from the supplied input stream. UsesSystem.getProperties()
to resolve the variables in the XML.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathXmlConfig
orFileSystemXmlConfig
.- Parameters:
configStream
- the InputStream to load the config from- Throws:
HazelcastException
- if the XML content is invalid
-
loadFromStream
@Nonnull @Deprecated public static JetConfig loadFromStream(@Nonnull InputStream configStream, @Nonnull Properties properties)Deprecated.Loads JetConfig from the supplied input stream. Uses the givenproperties
to resolve the variables in the XML.This method loads the nested Hazelcast config using the built-in
lookup mechanism
, but you can replace it afterwards by callingsetHazelcastConfig()
with, for example,ClasspathXmlConfig
orFileSystemXmlConfig
.- Parameters:
configStream
- the InputStream to load the config fromproperties
- the properties to resolve variables in the XML- Throws:
HazelcastException
- if the XML content is invalid
-
getHazelcastConfig
Returns the configuration object for the underlying Hazelcast IMDG instance. -
configureHazelcast
Convenience method for for configuring underlying Hazelcast IMDG instance. Example:JetConfig config = new JetConfig().configureHazelcast(c -> { c.getNetworkConfig().setPort(8000); c.setClusterName("jet-dev"); }); Jet.newJetInstance(config);
-
setHazelcastConfig
Sets the underlying Hazelcast IMDG instance's configuration object. -
getInstanceConfig
Returns the Jet instance config. -
setInstanceConfig
Sets the Jet instance config. -
getProperties
Returns the Jet-specific configuration properties. -
setProperties
Sets the Jet-specific configuration properties. -
setProperty
Sets the value of the specified property. -
getDefaultEdgeConfig
Returns the default DAG edge configuration. -
setDefaultEdgeConfig
Sets the configuration object that specifies the defaults to use for a DAG edge configuration.
-