Package org.apache.storm
Class StormSubmitter
- java.lang.Object
-
- org.apache.storm.StormSubmitter
-
public class StormSubmitter extends Object
Use this class to submit topologies to run on the Storm cluster. You should run your program with the "storm jar" command from the command-line, and then use this class to submit your topologies.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StormSubmitter.ProgressListener
Interface use to track progress of file upload.
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
LOG
static Pattern
zkDigestPattern
-
Constructor Summary
Constructors Constructor Description StormSubmitter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>
prepareZookeeperAuthentication(Map<String,Object> conf)
static boolean
pushCredentials(String name, Map<String,Object> topoConf, Map<String,String> credentials)
Push a new set of credentials to the running topology.static boolean
pushCredentials(String name, Map<String,Object> topoConf, Map<String,String> credentials, String expectedUser)
Push a new set of credentials to the running topology.static String
submitJar(Map<String,Object> conf, String localJar)
Submit jar file.static String
submitJar(Map<String,Object> conf, String localJar, StormSubmitter.ProgressListener listener)
Submit jar file.static String
submitJarAs(Map<String,Object> conf, String localJar, StormSubmitter.ProgressListener listener, String asUser)
static String
submitJarAs(Map<String,Object> conf, String localJar, StormSubmitter.ProgressListener listener, NimbusClient client)
static void
submitTopology(String name, Map<String,Object> topoConf, StormTopology topology)
Submits a topology to run on the cluster.static void
submitTopology(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts)
Submits a topology to run on the cluster.static void
submitTopology(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts, StormSubmitter.ProgressListener progressListener)
Submits a topology to run on the cluster.static void
submitTopologyAs(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts, StormSubmitter.ProgressListener progressListener, String asUser)
Submits a topology to run on the cluster as a particular user.static void
submitTopologyWithProgressBar(String name, Map<String,Object> topoConf, StormTopology topology)
Submits a topology to run on the cluster with a progress bar.static void
submitTopologyWithProgressBar(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts)
Submits a topology to run on the cluster with a progress bar.static boolean
validateZKDigestPayload(String payload)
-
-
-
Field Detail
-
LOG
public static final org.slf4j.Logger LOG
-
zkDigestPattern
public static final Pattern zkDigestPattern
-
-
Method Detail
-
validateZKDigestPayload
public static boolean validateZKDigestPayload(String payload)
-
prepareZookeeperAuthentication
public static Map<String,Object> prepareZookeeperAuthentication(Map<String,Object> conf)
-
pushCredentials
public static boolean pushCredentials(String name, Map<String,Object> topoConf, Map<String,String> credentials) throws AuthorizationException, NotAliveException, InvalidTopologyException
Push a new set of credentials to the running topology.- Parameters:
name
- the name of the topology to push credentials to.topoConf
- the topology-specific configuration, if desired. SeeConfig
.credentials
- the credentials to push.- Returns:
- whether the pushed credential collection is non-empty. Return false if empty.
- Throws:
AuthorizationException
- if you are not authorized ot push credentials.NotAliveException
- if the topology is not aliveInvalidTopologyException
- if any other error happens
-
pushCredentials
public static boolean pushCredentials(String name, Map<String,Object> topoConf, Map<String,String> credentials, String expectedUser) throws AuthorizationException, NotAliveException, InvalidTopologyException
Push a new set of credentials to the running topology. Return false if push Creds map is empty, true otherwise.- Parameters:
name
- the name of the topology to push credentials to.topoConf
- the topology-specific configuration, if desired. SeeConfig
.credentials
- the credentials to push.expectedUser
- the user you expect the topology to be owned by.- Returns:
- whether the pushed credential collection is non-empty. Return false if empty.
- Throws:
AuthorizationException
- if you are not authorized ot push credentials.NotAliveException
- if the topology is not aliveInvalidTopologyException
- if any other error happens
-
submitTopology
public static void submitTopology(String name, Map<String,Object> topoConf, StormTopology topology) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException
Submits a topology to run on the cluster. A topology runs forever or until explicitly killed.- Parameters:
name
- the name of the storm.topoConf
- the topology-specific configuration. SeeConfig
.topology
- the processing to execute.- Throws:
AlreadyAliveException
- if a topology with this name is already runningInvalidTopologyException
- if an invalid topology was submittedAuthorizationException
- if authorization is failedSubmitterHookException
- if any Exception occurs during initialization or invocation of registeredISubmitterHook
-
submitTopology
public static void submitTopology(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException
Submits a topology to run on the cluster. A topology runs forever or until explicitly killed.- Parameters:
name
- the name of the storm.topoConf
- the topology-specific configuration. SeeConfig
.topology
- the processing to execute.opts
- to manipulate the starting of the topology.- Throws:
AlreadyAliveException
- if a topology with this name is already runningInvalidTopologyException
- if an invalid topology was submittedAuthorizationException
- if authorization is failedSubmitterHookException
- if any Exception occurs during initialization or invocation of registeredISubmitterHook
-
submitTopology
public static void submitTopology(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts, StormSubmitter.ProgressListener progressListener) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException
Submits a topology to run on the cluster. A topology runs forever or until explicitly killed.- Parameters:
name
- the name of the storm.topoConf
- the topology-specific configuration. SeeConfig
.topology
- the processing to execute.opts
- to manipulate the starting of the topologyprogressListener
- to track the progress of the jar upload processStormSubmitter.ProgressListener
- Throws:
AlreadyAliveException
- if a topology with this name is already runningInvalidTopologyException
- if an invalid topology was submittedAuthorizationException
- if authorization is failedSubmitterHookException
- if any Exception occurs during initialization or invocation of registeredISubmitterHook
-
submitTopologyAs
public static void submitTopologyAs(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts, StormSubmitter.ProgressListener progressListener, String asUser) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException, IllegalArgumentException
Submits a topology to run on the cluster as a particular user. A topology runs forever or until explicitly killed.- Parameters:
asUser
- The user as which this topology should be submitted.- Throws:
IllegalArgumentException
- thrown if configs will yield an unschedulable topology. validateConfs validates confsSubmitterHookException
- if any Exception occurs during initialization or invocation of registeredISubmitterHook
AlreadyAliveException
InvalidTopologyException
AuthorizationException
-
submitTopologyWithProgressBar
public static void submitTopologyWithProgressBar(String name, Map<String,Object> topoConf, StormTopology topology) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException
Submits a topology to run on the cluster with a progress bar. A topology runs forever or until explicitly killed.- Parameters:
name
- the name of the storm.topoConf
- the topology-specific configuration. SeeConfig
.topology
- the processing to execute.- Throws:
AlreadyAliveException
- if a topology with this name is already runningInvalidTopologyException
- if an invalid topology was submittedAuthorizationException
- if authorization is failed
-
submitTopologyWithProgressBar
public static void submitTopologyWithProgressBar(String name, Map<String,Object> topoConf, StormTopology topology, SubmitOptions opts) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException
Submits a topology to run on the cluster with a progress bar. A topology runs forever or until explicitly killed.- Parameters:
name
- the name of the storm.topoConf
- the topology-specific configuration. SeeConfig
.topology
- the processing to execute.opts
- to manipulate the starting of the topology- Throws:
AlreadyAliveException
- if a topology with this name is already runningInvalidTopologyException
- if an invalid topology was submittedAuthorizationException
- if authorization is failedSubmitterHookException
- if any Exception occurs during initialization or invocation of registeredISubmitterHook
-
submitJar
public static String submitJar(Map<String,Object> conf, String localJar)
Submit jar file.- Parameters:
conf
- the topology-specific configuration. SeeConfig
.localJar
- file path of the jar file to submit- Returns:
- the remote location of the submitted jar
-
submitJar
public static String submitJar(Map<String,Object> conf, String localJar, StormSubmitter.ProgressListener listener)
Submit jar file.- Parameters:
conf
- the topology-specific configuration. SeeConfig
.localJar
- file path of the jar file to submitlistener
- progress listener to track the jar file upload- Returns:
- the remote location of the submitted jar
-
submitJarAs
public static String submitJarAs(Map<String,Object> conf, String localJar, StormSubmitter.ProgressListener listener, NimbusClient client)
-
-