public class SparkConf
extends Object
implements scala.Cloneable, org.apache.spark.internal.Logging, scala.Serializable
Most of the time, you would create a SparkConf object with new SparkConf()
, which will load
values from any spark.*
Java system properties set in your application as well. In this case,
parameters you set directly on the SparkConf
object take priority over system properties.
For unit tests, you can also call new SparkConf(false)
to skip loading external settings and
get the same configuration no matter what the system properties are.
All setter methods in this class support chaining. For example, you can write
new SparkConf().setMaster("local").setAppName("My app")
.
param: loadDefaults whether to also load values from Java system properties
Constructor and Description |
---|
SparkConf()
Create a SparkConf that loads defaults from system properties and the classpath
|
SparkConf(boolean loadDefaults) |
Modifier and Type | Method and Description |
---|---|
SparkConf |
clone()
Copy this object
|
boolean |
contains(String key)
Does the configuration contain a given parameter?
|
String |
get(String key)
Get a parameter; throws a NoSuchElementException if it's not set
|
String |
get(String key,
String defaultValue)
Get a parameter, falling back to a default if not set
|
scala.Tuple2<String,String>[] |
getAll()
Get all parameters as a list of pairs
|
scala.Tuple2<String,String>[] |
getAllWithPrefix(String prefix)
Get all parameters that start with
prefix |
String |
getAppId()
Returns the Spark application id, valid in the Driver after TaskScheduler registration and
from the start in the Executor.
|
scala.collection.immutable.Map<Object,String> |
getAvroSchema()
Gets all the avro schemas in the configuration used in the generic Avro record serializer
|
boolean |
getBoolean(String key,
boolean defaultValue)
Get a parameter as a boolean, falling back to a default if not set
|
static scala.Option<String> |
getDeprecatedConfig(String key,
java.util.Map<String,String> conf)
Looks for available deprecated keys for the given config option, and return the first
value available.
|
double |
getDouble(String key,
double defaultValue)
Get a parameter as a double, falling back to a default if not ste
|
scala.collection.Seq<scala.Tuple2<String,String>> |
getExecutorEnv()
Get all executor environment variables set on this SparkConf
|
int |
getInt(String key,
int defaultValue)
Get a parameter as an integer, falling back to a default if not set
|
long |
getLong(String key,
long defaultValue)
Get a parameter as a long, falling back to a default if not set
|
scala.Option<String> |
getOption(String key)
Get a parameter as an Option
|
long |
getSizeAsBytes(String key)
Get a size parameter as bytes; throws a NoSuchElementException if it's not set.
|
long |
getSizeAsBytes(String key,
long defaultValue)
Get a size parameter as bytes, falling back to a default if not set.
|
long |
getSizeAsBytes(String key,
String defaultValue)
Get a size parameter as bytes, falling back to a default if not set.
|
long |
getSizeAsGb(String key)
Get a size parameter as Gibibytes; throws a NoSuchElementException if it's not set.
|
long |
getSizeAsGb(String key,
String defaultValue)
Get a size parameter as Gibibytes, falling back to a default if not set.
|
long |
getSizeAsKb(String key)
Get a size parameter as Kibibytes; throws a NoSuchElementException if it's not set.
|
long |
getSizeAsKb(String key,
String defaultValue)
Get a size parameter as Kibibytes, falling back to a default if not set.
|
long |
getSizeAsMb(String key)
Get a size parameter as Mebibytes; throws a NoSuchElementException if it's not set.
|
long |
getSizeAsMb(String key,
String defaultValue)
Get a size parameter as Mebibytes, falling back to a default if not set.
|
long |
getTimeAsMs(String key)
Get a time parameter as milliseconds; throws a NoSuchElementException if it's not set.
|
long |
getTimeAsMs(String key,
String defaultValue)
Get a time parameter as milliseconds, falling back to a default if not set.
|
long |
getTimeAsSeconds(String key)
Get a time parameter as seconds; throws a NoSuchElementException if it's not set.
|
long |
getTimeAsSeconds(String key,
String defaultValue)
Get a time parameter as seconds, falling back to a default if not set.
|
static boolean |
isExecutorStartupConf(String name)
Return whether the given config should be passed to an executor on start-up.
|
static boolean |
isSparkPortConf(String name)
Return true if the given config matches either
spark.*.port or spark.port.* . |
static void |
logDeprecationWarning(String key)
Logs a warning message if the given config key is deprecated.
|
static void |
org$apache$spark$internal$Logging$$log__$eq(org.slf4j.Logger x$1) |
static org.slf4j.Logger |
org$apache$spark$internal$Logging$$log_() |
SparkConf |
registerAvroSchemas(scala.collection.Seq<org.apache.avro.Schema> schemas)
Use Kryo serialization and register the given set of Avro schemas so that the generic
record serializer can decrease network IO
|
SparkConf |
registerKryoClasses(Class<?>[] classes)
Use Kryo serialization and register the given set of classes with Kryo.
|
SparkConf |
remove(String key)
Remove a parameter from the configuration
|
SparkConf |
set(String key,
String value)
Set a configuration variable.
|
SparkConf |
setAll(scala.collection.Iterable<scala.Tuple2<String,String>> settings)
Set multiple parameters together
|
SparkConf |
setAll(scala.collection.Traversable<scala.Tuple2<String,String>> settings)
Deprecated.
Use setAll(Iterable) instead. Since 3.0.0.
|
SparkConf |
setAppName(String name)
Set a name for your application.
|
SparkConf |
setExecutorEnv(scala.collection.Seq<scala.Tuple2<String,String>> variables)
Set multiple environment variables to be used when launching executors.
|
SparkConf |
setExecutorEnv(String variable,
String value)
Set an environment variable to be used when launching executors for this application.
|
SparkConf |
setExecutorEnv(scala.Tuple2<String,String>[] variables)
Set multiple environment variables to be used when launching executors.
|
SparkConf |
setIfMissing(String key,
String value)
Set a parameter if it isn't already configured
|
SparkConf |
setJars(scala.collection.Seq<String> jars)
Set JAR files to distribute to the cluster.
|
SparkConf |
setJars(String[] jars)
Set JAR files to distribute to the cluster.
|
SparkConf |
setMaster(String master)
The master URL to connect to, such as "local" to run locally with one thread, "local[4]" to
run locally with 4 cores, or "spark://master:7077" to run on a Spark standalone cluster.
|
SparkConf |
setSparkHome(String home)
Set the location where Spark is installed on worker nodes.
|
String |
toDebugString()
Return a string listing all keys and values, one per line.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
$init$, initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, initLock, isTraceEnabled, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning, org$apache$spark$internal$Logging$$log__$eq, org$apache$spark$internal$Logging$$log_, uninitialize
public SparkConf(boolean loadDefaults)
public SparkConf()
public static boolean isExecutorStartupConf(String name)
Certain authentication configs are required from the executor when it connects to the scheduler, while the rest of the spark configs can be inherited from the driver later.
name
- (undocumented)public static boolean isSparkPortConf(String name)
spark.*.port
or spark.port.*
.name
- (undocumented)public static scala.Option<String> getDeprecatedConfig(String key, java.util.Map<String,String> conf)
key
- (undocumented)conf
- (undocumented)public static void logDeprecationWarning(String key)
key
- (undocumented)public static org.slf4j.Logger org$apache$spark$internal$Logging$$log_()
public static void org$apache$spark$internal$Logging$$log__$eq(org.slf4j.Logger x$1)
public SparkConf set(String key, String value)
public SparkConf setMaster(String master)
master
- (undocumented)public SparkConf setAppName(String name)
public SparkConf setJars(scala.collection.Seq<String> jars)
public SparkConf setJars(String[] jars)
public SparkConf setExecutorEnv(String variable, String value)
variable
- (undocumented)value
- (undocumented)public SparkConf setExecutorEnv(scala.collection.Seq<scala.Tuple2<String,String>> variables)
variables
- (undocumented)public SparkConf setExecutorEnv(scala.Tuple2<String,String>[] variables)
variables
- (undocumented)public SparkConf setSparkHome(String home)
home
- (undocumented)public SparkConf setAll(scala.collection.Iterable<scala.Tuple2<String,String>> settings)
public SparkConf setAll(scala.collection.Traversable<scala.Tuple2<String,String>> settings)
settings
- (undocumented)public SparkConf setIfMissing(String key, String value)
public SparkConf registerKryoClasses(Class<?>[] classes)
classes
- (undocumented)public SparkConf registerAvroSchemas(scala.collection.Seq<org.apache.avro.Schema> schemas)
schemas
- (undocumented)public scala.collection.immutable.Map<Object,String> getAvroSchema()
public SparkConf remove(String key)
public String get(String key)
public String get(String key, String defaultValue)
public long getTimeAsSeconds(String key)
key
- (undocumented)java.util.NoSuchElementException
- If the time parameter is not setNumberFormatException
- If the value cannot be interpreted as secondspublic long getTimeAsSeconds(String key, String defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as secondspublic long getTimeAsMs(String key)
key
- (undocumented)java.util.NoSuchElementException
- If the time parameter is not setNumberFormatException
- If the value cannot be interpreted as millisecondspublic long getTimeAsMs(String key, String defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as millisecondspublic long getSizeAsBytes(String key)
key
- (undocumented)java.util.NoSuchElementException
- If the size parameter is not setNumberFormatException
- If the value cannot be interpreted as bytespublic long getSizeAsBytes(String key, String defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as bytespublic long getSizeAsBytes(String key, long defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as bytespublic long getSizeAsKb(String key)
key
- (undocumented)java.util.NoSuchElementException
- If the size parameter is not setNumberFormatException
- If the value cannot be interpreted as Kibibytespublic long getSizeAsKb(String key, String defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as Kibibytespublic long getSizeAsMb(String key)
key
- (undocumented)java.util.NoSuchElementException
- If the size parameter is not setNumberFormatException
- If the value cannot be interpreted as Mebibytespublic long getSizeAsMb(String key, String defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as Mebibytespublic long getSizeAsGb(String key)
key
- (undocumented)java.util.NoSuchElementException
- If the size parameter is not setNumberFormatException
- If the value cannot be interpreted as Gibibytespublic long getSizeAsGb(String key, String defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as Gibibytespublic scala.Option<String> getOption(String key)
public scala.Tuple2<String,String>[] getAll()
public scala.Tuple2<String,String>[] getAllWithPrefix(String prefix)
prefix
prefix
- (undocumented)public int getInt(String key, int defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as an integerpublic long getLong(String key, long defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as a longpublic double getDouble(String key, double defaultValue)
key
- (undocumented)defaultValue
- (undocumented)NumberFormatException
- If the value cannot be interpreted as a doublepublic boolean getBoolean(String key, boolean defaultValue)
key
- (undocumented)defaultValue
- (undocumented)IllegalArgumentException
- If the value cannot be interpreted as a booleanpublic scala.collection.Seq<scala.Tuple2<String,String>> getExecutorEnv()
public String getAppId()
public boolean contains(String key)
public SparkConf clone()
clone
in class Object
public String toDebugString()