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]