You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/06/30 22:13:29 UTC

[GitHub] [kafka] cmccabe commented on a change in pull request #10949: KAFKA-13019: Add MetadataImage and MetadataDelta classes for KRaft Snapshots

cmccabe commented on a change in pull request #10949:
URL: https://github.com/apache/kafka/pull/10949#discussion_r661845115



##########
File path: metadata/src/main/java/org/apache/kafka/image/ConfigurationsImage.java
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.image;
+
+import org.apache.kafka.common.config.ConfigResource;
+import org.apache.kafka.server.common.ApiMessageAndVersion;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+
+/**
+ * Represents the configurations in the metadata image.
+ *
+ * This class is thread-safe.
+ */
+public final class ConfigurationsImage {
+    public static final ConfigurationsImage EMPTY =
+        new ConfigurationsImage(Collections.emptyMap());
+
+    private final Map<ConfigResource, ConfigurationImage> data;
+
+    public ConfigurationsImage(Map<ConfigResource, ConfigurationImage> data) {
+        this.data = data;
+    }
+
+    public boolean isEmpty() {
+        return data.isEmpty();
+    }
+
+    Map<ConfigResource, ConfigurationImage> resourceData() {
+        return data;
+    }
+
+    public Properties configProperties(ConfigResource configResource) {

Review comment:
       Eventually it would be good to transition away from using the `Properties` class, I think. It's a weird old Java 1.0 (or whatever) thing with a lot of odd behaviors. One example is that its default encoding for writing out to a file is ISO-8859-1 (Latin-1), which I guess made sense in the 1990s, but not today. Because of their decision to inherit from HashTable (now deprecated) you can also insert non-string values, which behave in ways that can only be described as "incorrect" (like appearing as null when accessed by `getProperty`).
   
   But, a bunch of other parts of the code use `Properties` for entity configurations, so we have to support it, for now.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org