robertwb commented on a change in pull request #14607:
URL: https://github.com/apache/beam/pull/14607#discussion_r617962077
##########
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:
Yeah, java assumes there is only one environment in play. (Here we're
generalizing that to "one environment type" and this method is not only used
for tests; perhaps it'd be worth renaming but I don't see that as critical.)
--
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]