beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-3702) Support system properties source for pipeline options
Date Fri, 16 Mar 2018 17:57:00 GMT

     [ https://issues.apache.org/jira/browse/BEAM-3702?focusedWorklogId=81290&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-81290
]

ASF GitHub Bot logged work on BEAM-3702:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Mar/18 17:56
            Start Date: 16/Mar/18 17:56
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on a change in pull request #4683: [BEAM-3702]
adding fromJvm to create pipelineoptions from the system properties
URL: https://github.com/apache/beam/pull/4683#discussion_r175168208
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
 ##########
 @@ -1792,4 +1804,82 @@ private synchronized void register(Class<? extends PipelineOptions>
iface) {
       return combinedCache.get(interfaces).getPropertyDescriptors();
     }
   }
+
+  /**
+   * @param prefix a prefix filter on the map keys.
+   * @param options the options to convert to a pipeline options.
+   * @return a pipeline options instance based on the specified configuration.
+   */
+  @Experimental
+  public static PipelineOptions fromMap(final String prefix, final Map<String, String>
options) {
+    checkArgument(prefix != null, "prefix should not be null.");
+    checkArgument(options != null, "options should not be null.");
+    final Map<String, String> filtered = options.entrySet()
+                                        .stream()
+                                        .filter(e -> e.getKey()
+                                                      .startsWith(prefix))
+                                        .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
+    return fromMap(filtered);
+  }
+
+  /**
+   * @param options the options to convert to a pipeline options.
+   * @return a pipeline options instance based on the specified configuration.
+   */
+  public static PipelineOptions fromMap(final Map<String, String> options) {
+    checkArgument(options != null, "options should not be null.");
+    return new Builder().fromMap(options).create();
+  }
+
+  /**
+   * @param properties the properties to use to create the pipeline options instance.
+   * @return a pipeline options instance based on the specified properties.
+   */
+  @Experimental
+  public static PipelineOptions fromProperties(final Properties properties) {
+    checkArgument(properties != null, "properties should not be null.");
+    return fromMap(properties.stringPropertyNames()
+                    .stream()
+                    .collect(toMap(identity(), properties::getProperty)));
+  }
+
+  /**
+   * @param prefix the prefix filter applied on system properties keys.
+   * @param properties the properties to use to create the pipeline options instance.
 
 Review comment:
   Please improve the javadoc to be similar to `fromArgs` explaining the parsing.
   
   It's also important to mention that you filter out non string key/value pairs since many
people may assume that might call toString on everything. Please also mention how prefix is
used.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 81290)
    Time Spent: 9h 10m  (was: 9h)

> Support system properties source for pipeline options
> -----------------------------------------------------
>
>                 Key: BEAM-3702
>                 URL: https://issues.apache.org/jira/browse/BEAM-3702
>             Project: Beam
>          Issue Type: Task
>          Components: sdk-java-core
>            Reporter: Romain Manni-Bucau
>            Assignee: Romain Manni-Bucau
>            Priority: Major
>             Fix For: 2.5.0
>
>          Time Spent: 9h 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message