skoppu22 commented on code in PR #358:
URL: https://github.com/apache/cassandra-sidecar/pull/358#discussion_r3374713080
##########
server/src/main/java/org/apache/cassandra/sidecar/configmanagement/ConfigurationOverlaySnapshot.java:
##########
@@ -21,34 +21,64 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
+import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Objects;
import io.vertx.core.json.JsonObject;
import org.jetbrains.annotations.NotNull;
/**
- * Represents a snapshot of a configuration overlay with its metadata.
- * The SHA-256 hash is dynamically computed from the overlay contents and
cached.
+ * Represents a snapshot of a configuration with its metadata.
+ * The SHA-256 hash is dynamically computed from the configuration contents
and cached.
*/
public class ConfigurationOverlaySnapshot
{
@NotNull
private final Instant lastModified;
@NotNull
- private final CassandraConfigurationOverlay overlay;
+ private final CassandraConfigurationOverlay configuration;
private volatile String hash;
public ConfigurationOverlaySnapshot(@NotNull Instant lastModified,
- @NotNull CassandraConfigurationOverlay
overlay)
+ @NotNull CassandraConfigurationOverlay
configuration)
{
this.lastModified = Objects.requireNonNull(lastModified, "lastModified
must not be null");
- this.overlay = Objects.requireNonNull(overlay, "overlay must not be
null");
+ this.configuration = Objects.requireNonNull(configuration,
"configuration must not be null");
}
/**
- * Returns the SHA-256 hash of the overlay contents, prefixed with
"sha256:".
+ * Merges another snapshot on top of this one, producing the effective
configuration.
+ * The other snapshot's values take precedence over this snapshot's values.
+ *
+ * <p>Deep-merges {@code cassandraYaml} (nested objects are recursively
merged, all other
+ * types are replaced by the other snapshot's values). Merges {@code
extraJvmOpts} with the
+ * other snapshot's entries overriding this snapshot's entries on key
conflict.
+ *
+ * @param other the overlay snapshot whose values take precedence
+ * @return a new snapshot with the merged configuration and the max of
both lastModified timestamps
+ */
+ @NotNull
+ public ConfigurationOverlaySnapshot overlay(@NotNull
ConfigurationOverlaySnapshot other)
+ {
+ JsonObject mergedYaml =
ConfigUtils.mergeConfigurations(configuration.cassandraYaml(),
+
other.configuration().cassandraYaml());
+
+ Map<String, String> mergedOpts = new
LinkedHashMap<>(configuration.extraJvmOpts());
+ mergedOpts.putAll(other.configuration().extraJvmOpts());
Review Comment:
Don't we need to call validateNoConflictingBooleanOpts on these merged JVM
opts?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]