Google Cloud Dataflow SDK for Java, version 1.9.1
Class PipelineOptionsFactory
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory
-
public class PipelineOptionsFactory extends Object
Constructs aPipelineOptions
or any derived interface that is composable to any other derived interface ofPipelineOptions
via thePipelineOptions.as(java.lang.Class<T>)
method. Being able to compose one derived interface ofPipelineOptions
to another has the following restrictions:- Any property with the same name must have the same return type for all derived interfaces
of
PipelineOptions
. - Every bean property of any interface derived from
PipelineOptions
must have a getter and setter method. - Every method must conform to being a getter or setter for a JavaBean.
- The derived interface of
PipelineOptions
must be composable with every interface registered with this factory.
See the JavaBeans specification for more details as to what constitutes a property.
- Any property with the same name must have the same return type for all derived interfaces
of
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
PipelineOptionsFactory.Builder
A fluentPipelineOptions
builder.
-
Constructor Summary
Constructors Constructor and Description PipelineOptionsFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description static <T extends PipelineOptions>
Tas(Class<T> klass)
Creates and returns an object that implements<T>
.static PipelineOptions
create()
Creates and returns an object that implementsPipelineOptions
.static DataflowWorkerHarnessOptions
createFromSystemProperties()
Deprecated.for internal use onlystatic DataflowWorkerHarnessOptions
createFromSystemPropertiesInternal()
Creates a set of Dataflow worker harness options based of a set of known system properties.static PipelineOptionsFactory.Builder
fromArgs(String[] args)
Sets the command line arguments to parse when constructing thePipelineOptions
.static Set<Class<? extends PipelineOptions>>
getRegisteredOptions()
static void
printHelp(PrintStream out)
Outputs the set of registered options with the PipelineOptionsFactory with a description for each one if available to the output stream.static void
printHelp(PrintStream out, Class<? extends PipelineOptions> iface)
Outputs the set of options available to be set for the passed inPipelineOptions
interface.static void
register(Class<? extends PipelineOptions> iface)
This registers the interface with this factory.PipelineOptionsFactory.Builder
withValidation()
After creation we will validate that<T>
conforms to all the validation criteria.
-
-
-
Method Detail
-
create
public static PipelineOptions create()
Creates and returns an object that implementsPipelineOptions
. This sets the"appName"
to the callingclasses simple name
.- Returns:
- An object that implements
PipelineOptions
.
-
as
public static <T extends PipelineOptions> T as(Class<T> klass)
Creates and returns an object that implements<T>
. This sets the"appName"
to the callingclasses simple name
.Note that
<T>
must be composable with every registered interface with this factory. SeevalidateWellFormed(Class, Set)
for more details.- Returns:
- An object that implements
<T>
.
-
fromArgs
public static PipelineOptionsFactory.Builder fromArgs(String[] args)
Sets the command line arguments to parse when constructing thePipelineOptions
.Example GNU style command line arguments:
--project=MyProject (simple property, will set the "project" property to "MyProject") --readOnly=true (for boolean properties, will set the "readOnly" property to "true") --readOnly (shorthand for boolean properties, will set the "readOnly" property to "true") --x=1 --x=2 --x=3 (list style simple property, will set the "x" property to [1, 2, 3]) --x=1,2,3 (shorthand list style simple property, will set the "x" property to [1, 2, 3]) --complexObject='{"key1":"value1",...} (JSON format for all other complex types)
Simple properties are able to bound to
String
,Class
, enums and Java primitivesboolean
,byte
,short
,int
,long
,float
,double
and their primitive wrapper classes.Simple list style properties are able to be bound to
boolean[]
,char[]
,short[]
,int[]
,long[]
,float[]
,double[]
,Class[]
, enum arrays,String[]
, andList<String>
.JSON format is required for all other types.
By default, strict parsing is enabled and arguments must conform to be either
--booleanArgName
or--argName=argValue
. Strict parsing can be disabled withPipelineOptionsFactory.Builder.withoutStrictParsing()
. Empty or null arguments will be ignored whether or not strict parsing is enabled.Help information can be output to
System.out
by specifying--help
as an argument. After help is printed, the application will exit. Specifying only--help
will print out the list ofregistered options
by invokingprintHelp(PrintStream)
. Specifying--help=PipelineOptionsClassName
will print out detailed usage information about the specifically requested PipelineOptions by invokingprintHelp(PrintStream, Class)
.
-
withValidation
public PipelineOptionsFactory.Builder withValidation()
After creation we will validate that<T>
conforms to all the validation criteria. SeePipelineOptionsValidator.validate(Class, PipelineOptions)
for more details about validation.
-
register
public static void register(Class<? extends PipelineOptions> iface)
This registers the interface with this factory. This interface must conform to the following restrictions:- Any property with the same name must have the same return type for all derived
interfaces of
PipelineOptions
. - Every bean property of any interface derived from
PipelineOptions
must have a getter and setter method. - Every method must conform to being a getter or setter for a JavaBean.
- The derived interface of
PipelineOptions
must be composable with every interface registered with this factory.
- Parameters:
iface
- The interface object to manually register.
- Any property with the same name must have the same return type for all derived
interfaces of
-
getRegisteredOptions
public static Set<Class<? extends PipelineOptions>> getRegisteredOptions()
-
printHelp
public static void printHelp(PrintStream out)
Outputs the set of registered options with the PipelineOptionsFactory with a description for each one if available to the output stream. This output is pretty printed and meant to be human readable. This method will attempt to format its output to be compatible with a terminal window.
-
printHelp
public static void printHelp(PrintStream out, Class<? extends PipelineOptions> iface)
Outputs the set of options available to be set for the passed inPipelineOptions
interface. The output is in a human readable format. The format is:OptionGroup: ... option group description ... --option1=
This method will attempt to format its output to be compatible with a terminal window.<type>
or list of valid enum choices Default: value (if available, seeDefault
) ... option description ... (if available, seeDescription
) Required groups (if available, seeValidation.Required
) --option2=<type>
or list of valid enum choices Default: value (if available, seeDefault
) ... option description ... (if available, seeDescription
) Required groups (if available, seeValidation.Required
)
-
createFromSystemPropertiesInternal
public static DataflowWorkerHarnessOptions createFromSystemPropertiesInternal() throws IOException
Creates a set of Dataflow worker harness options based of a set of known system properties. This is meant to only be used from the Dataflow worker harness as a method to bootstrap the worker harness.For internal use only.
- Returns:
- A
DataflowWorkerHarnessOptions
object configured for the Dataflow worker harness. - Throws:
IOException
-
createFromSystemProperties
@Deprecated public static DataflowWorkerHarnessOptions createFromSystemProperties() throws IOException
Deprecated. for internal use onlyCreates a set ofDataflowWorkerHarnessOptions
based of a set of known system properties. This is meant to only be used from the Dataflow worker harness as a method to bootstrap the worker harness.- Returns:
- A
DataflowWorkerHarnessOptions
object configured for the Dataflow worker harness. - Throws:
IOException
-
-