@Public public class ParameterTool extends org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters implements Serializable, Cloneable
| 限定符和类型 | 字段和说明 |
|---|---|
protected Map<String,String> |
data |
protected static String |
DEFAULT_UNDEFINED |
protected Map<String,String> |
defaultData |
protected static String |
NO_VALUE_KEY |
protected Set<String> |
unrequestedParameters |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
addToDefaults(String key,
String value) |
protected Object |
clone() |
void |
createPropertiesFile(String pathToFile)
Create a properties file with all the known parameters (call after the last get*() call).
|
void |
createPropertiesFile(String pathToFile,
boolean overwrite)
Create a properties file with all the known parameters (call after the last get*() call).
|
boolean |
equals(Object o) |
static ParameterTool |
fromArgs(String[] args)
Returns
ParameterTool for the given arguments. |
static ParameterTool |
fromMap(Map<String,String> map)
Returns
ParameterTool for the given map. |
static ParameterTool |
fromPropertiesFile(File file)
Returns
ParameterTool for the given Properties file. |
static ParameterTool |
fromPropertiesFile(InputStream inputStream)
Returns
ParameterTool for the given InputStream from Properties file. |
static ParameterTool |
fromPropertiesFile(String path)
Returns
ParameterTool for the given Properties file. |
static ParameterTool |
fromSystemProperties()
Returns
ParameterTool from the system properties. |
String |
get(String key)
Returns the String value for the given key.
|
String |
get(String key,
String defaultValue)
Returns the String value for the given key.
|
boolean |
getBoolean(String key)
Returns the Boolean value for the given key.
|
boolean |
getBoolean(String key,
boolean defaultValue)
Returns the Boolean value for the given key.
|
byte |
getByte(String key)
Returns the Byte value for the given key.
|
byte |
getByte(String key,
byte defaultValue)
Returns the Byte value for the given key.
|
org.apache.flink.configuration.Configuration |
getConfiguration()
Returns a
Configuration object from this ParameterTool. |
double |
getDouble(String key)
Returns the Double value for the given key.
|
double |
getDouble(String key,
double defaultValue)
Returns the Double value for the given key.
|
float |
getFloat(String key)
Returns the Float value for the given key.
|
float |
getFloat(String key,
float defaultValue)
Returns the Float value for the given key.
|
int |
getInt(String key)
Returns the Integer value for the given key.
|
int |
getInt(String key,
int defaultValue)
Returns the Integer value for the given key.
|
long |
getLong(String key)
Returns the Long value for the given key.
|
long |
getLong(String key,
long defaultValue)
Returns the Long value for the given key.
|
int |
getNumberOfParameters()
Returns number of parameters in
ParameterTool. |
Properties |
getProperties()
Returns a
Properties object from this ParameterTool. |
String |
getRequired(String key)
Returns the String value for the given key.
|
short |
getShort(String key)
Returns the Short value for the given key.
|
short |
getShort(String key,
short defaultValue)
Returns the Short value for the given key.
|
Set<String> |
getUnrequestedParameters()
Returns the set of parameter names which have not been requested with
has(String) or one of the get methods. |
boolean |
has(String value)
Check if value is set.
|
int |
hashCode() |
ParameterTool |
mergeWith(ParameterTool other)
Merges two
ParameterTool. |
Map<String,String> |
toMap() |
public static ParameterTool fromArgs(String[] args)
ParameterTool for the given arguments. The arguments are keys followed by values.
Keys have to start with '-' or '--'
Example arguments: --key1 value1 --key2 value2 -key3 value3
args - Input array argumentsParameterToolpublic static ParameterTool fromPropertiesFile(String path) throws IOException
ParameterTool for the given Properties file.path - Path to the properties fileParameterToolIOException - If the file does not existPropertiespublic static ParameterTool fromPropertiesFile(File file) throws IOException
ParameterTool for the given Properties file.file - File object to the properties fileParameterToolIOException - If the file does not existPropertiespublic static ParameterTool fromPropertiesFile(InputStream inputStream) throws IOException
ParameterTool for the given InputStream from Properties file.inputStream - InputStream from the properties fileParameterToolIOException - If the file does not existPropertiespublic static ParameterTool fromMap(Map<String,String> map)
ParameterTool for the given map.map - A map of arguments. Both Key and Value have to be StringsParameterToolpublic static ParameterTool fromSystemProperties()
ParameterTool from the system properties.
Example on how to pass system properties:
-Dkey1=value1 -Dkey2=value2ParameterTool@PublicEvolving public Set<String> getUnrequestedParameters()
has(String) or one of the get methods. Access to the
map returned by toMap() is not tracked.public int getNumberOfParameters()
ParameterTool.public String get(String key)
public String getRequired(String key)
RuntimeException.public String get(String key, String defaultValue)
public boolean has(String value)
public int getInt(String key)
public int getInt(String key, int defaultValue)
public long getLong(String key)
public long getLong(String key, long defaultValue)
public float getFloat(String key)
public float getFloat(String key, float defaultValue)
public double getDouble(String key)
public double getDouble(String key, double defaultValue)
public boolean getBoolean(String key)
public boolean getBoolean(String key, boolean defaultValue)
public short getShort(String key)
public short getShort(String key, short defaultValue)
public byte getByte(String key)
public byte getByte(String key, byte defaultValue)
public org.apache.flink.configuration.Configuration getConfiguration()
Configuration object from this ParameterTool.Configurationpublic Properties getProperties()
Properties object from this ParameterTool.Propertiespublic void createPropertiesFile(String pathToFile) throws IOException
Use this method to create a properties file skeleton.
pathToFile - Location of the default properties file.IOExceptionpublic void createPropertiesFile(String pathToFile, boolean overwrite) throws IOException
pathToFile - Location of the default properties file.overwrite - Boolean flag indicating whether or not to overwrite the fileIOException - If overwrite is not allowed and the file existsprotected Object clone() throws CloneNotSupportedException
clone 在类中 ObjectCloneNotSupportedExceptionpublic ParameterTool mergeWith(ParameterTool other)
ParameterTool.other - Other ParameterTool objectParameterToolCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.