@DeveloperApi
public interface PluginContext
An instance of this class is provided to plugins in their initialization method. It is safe for plugins to keep a reference to the instance for later use (for example, to send messages to the plugin's driver component).
Context instances are plugin-specific, so metrics and messages are tied each plugin. It is not possible for a plugin to directly interact with other plugins.
| Modifier and Type | Method and Description |
|---|---|
Object |
ask(Object message)
Send an RPC to the plugin's driver-side component.
|
SparkConf |
conf()
Configuration of the Spark application.
|
String |
executorID()
Executor ID of the process.
|
String |
hostname()
The host name which is being used by the Spark process for communication.
|
com.codahale.metrics.MetricRegistry |
metricRegistry()
Registry where to register metrics published by the plugin associated with this context.
|
java.util.Map<String,ResourceInformation> |
resources()
The custom resources (GPUs, FPGAs, etc) allocated to driver or executor.
|
void |
send(Object message)
Send a message to the plugin's driver-side component.
|
com.codahale.metrics.MetricRegistry metricRegistry()
SparkConf conf()
String executorID()
String hostname()
java.util.Map<String,ResourceInformation> resources()
void send(Object message) throws java.io.IOException
This method sends a message to the driver-side component of the plugin, without expecting a reply. It returns as soon as the message is enqueued for sending.
The message must be serializable.
message - Message to be sent.java.io.IOExceptionObject ask(Object message)
throws Exception
This method sends a message to the driver-side component of the plugin, and blocks until a
reply arrives, or the configured RPC ask timeout (spark.rpc.askTimeout) elapses.
If the driver replies with an error, an exception with the corresponding error will be thrown.
The message must be serializable.
message - Message to be sent.Exception