public class SparkConnection extends Attribute
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
StringParameter |
connectionName
The name of the connection.
|
static java.lang.String |
DEFAULT_DRIVER_MEMORY
The default amount of memory for the Spark driver.
|
static int |
DEFAULT_MASTER_PORT
Default port for the master.
|
static int |
DEFAULT_NUM_LOCAL_WORKERS
The default number of local workers.
|
StringParameter |
driverMemory
The amount of memory to use in the Spark driver.
|
Parameter |
numLocalWorkers
The number of workers when running Spark locally.
|
StringParameter |
serverName
The host name of the Spark server.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
SparkConnection(NamedObj container,
java.lang.String name)
Create a new SparkConnection with the specified name.
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
java.lang.String |
getConnectionName()
Get the name used for this attribute.
|
org.apache.spark.api.java.JavaSparkContext |
getContext()
Get the context using the parameters of this SparkConnection
(serverName, driverMemory, numLocalWorkers, etc.).
|
static org.apache.spark.api.java.JavaSparkContext |
getContext(java.lang.String masterNameAndPortStr,
int numLocalWorkersVal,
java.lang.String driverMemoryStr,
java.lang.String connectionNameStr)
Get the context for a specific master.
|
static org.apache.spark.api.java.JavaSparkContext |
getDefaultContext()
Get the default context.
|
static java.net.InetSocketAddress |
getDefaultMasterSocketAddress()
Get the default Spark master socket address.
|
static java.net.InetSocketAddress |
getMasterAndPortAddress(java.lang.String masterHostAndPortStr)
Parse a string containing the master host and port and return the
socket address.
|
static java.lang.String |
parseOutputFromStartingServer(java.io.InputStream input)
Parse the output from starting the server using start-myspark.sh
|
static void |
releaseContext() |
static void |
shutdown()
Stop any contexts that were started.
|
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public StringParameter connectionName
public StringParameter serverName
public Parameter numLocalWorkers
public StringParameter driverMemory
public static final int DEFAULT_NUM_LOCAL_WORKERS
public static final java.lang.String DEFAULT_DRIVER_MEMORY
public static final int DEFAULT_MASTER_PORT
public SparkConnection(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
public void attributeChanged(Attribute attribute) throws IllegalActionException
NamedObj
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public java.lang.String getConnectionName() throws IllegalActionException
IllegalActionException
public org.apache.spark.api.java.JavaSparkContext getContext() throws IllegalActionException
IllegalActionException
public static org.apache.spark.api.java.JavaSparkContext getContext(java.lang.String masterNameAndPortStr, int numLocalWorkersVal, java.lang.String driverMemoryStr, java.lang.String connectionNameStr) throws IllegalActionException
masterNameAndPortStr
- The master host and port. If empty,
then environment variables MASTER, SPARK_MASTER_IP, and SPARK_LOCAL_IP
are checked for the master. If these are empty, then try to connect
to a master running on localhost. If the connection fails, then a
local master is used (runs in same JVM).numLocalWorkersVal
- The number of workers to use for a
local master.driverMemoryStr
- The amount of memory in the driver.connectionNameStr
- The connecting name string.IllegalActionException
public static org.apache.spark.api.java.JavaSparkContext getDefaultContext() throws IllegalActionException
IllegalActionException
public static java.net.InetSocketAddress getDefaultMasterSocketAddress() throws IllegalActionException
IllegalActionException
public static java.net.InetSocketAddress getMasterAndPortAddress(java.lang.String masterHostAndPortStr) throws IllegalActionException
IllegalActionException
public static java.lang.String parseOutputFromStartingServer(java.io.InputStream input) throws java.io.IOException, IllegalActionException
java.io.IOException
IllegalActionException
public static void releaseContext()
public static void shutdown()