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

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

                Author: ASF GitHub Bot
            Created on: 21/Apr/21 22:30
            Start Date: 21/Apr/21 22:30
    Worklog Time Spent: 10m 
      Work Description: tvalentyn commented on a change in pull request #14607:
URL: https://github.com/apache/beam/pull/14607#discussion_r617934115



##########
File path: 
runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/SdkComponents.java
##########
@@ -309,13 +315,38 @@ public String registerEnvironment(Environment env) {
     return environmentId;
   }
 
-  public String getOnlyEnvironmentId() {
+  public String getEnvironmentIdFor(ResourceHints resourceHints) {
+    if (!environmentIdsByResourceHints.containsKey(resourceHints)) {
+      String baseEnvironmentId = getOnlyEnvironmentId();
+      if (resourceHints.hints().size() == 0) {
+        environmentIdsByResourceHints.put(resourceHints, baseEnvironmentId);
+      } else {
+        Environment env =
+            componentsBuilder
+                .getEnvironmentsMap()
+                .get(baseEnvironmentId)
+                .toBuilder()
+                .putAllResourceHints(
+                    Maps.transformValues(
+                        resourceHints.hints(), hint -> 
ByteString.copyFrom(hint.toBytes())))
+                .build();
+        String name = uniqify(env.getUrn(), environmentIds.values());
+        environmentIds.put(env, name);
+        componentsBuilder.putEnvironments(name, env);
+        environmentIdsByResourceHints.put(resourceHints, name);
+      }
+    }
+    return environmentIdsByResourceHints.get(resourceHints);
+  }
+
+  @VisibleForTesting
+  /*package*/ String getOnlyEnvironmentId() {

Review comment:
       For my education, why is this prefixed 'getOnly' ? Does this imply that 
there is only 1 environment, otherwise this call should fail?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 586940)
    Time Spent: 33h 50m  (was: 33h 40m)

> Transforms could give hints to runners on resource requirements
> ---------------------------------------------------------------
>
>                 Key: BEAM-2085
>                 URL: https://issues.apache.org/jira/browse/BEAM-2085
>             Project: Beam
>          Issue Type: Improvement
>          Components: beam-model, runner-core, sdk-java-core
>    Affects Versions: Not applicable
>            Reporter: Ismaël Mejía
>            Assignee: Valentyn Tymofieiev
>            Priority: P3
>              Labels: Clarified
>          Time Spent: 33h 50m
>  Remaining Estimate: 0h
>
> As discussed in BEAM-673 runners can allocate workers to accomplish their 
> work in a better way if they can take into account some hints from the 
> transforms, e.g. a source can hint data locality and with this information 
> the runner can allocate the workers in an better way, this can also be the 
> case with a particular transform that can suggest to the runner to be 
> executed in a worker with a specific resource, e.g. GPU.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to