Pochatkin commented on code in PR #1640:
URL: https://github.com/apache/ignite-3/pull/1640#discussion_r1104133481


##########
modules/runner/src/main/java/org/apache/ignite/internal/configuration/NodeBootstrapConfiguration.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.ignite.internal.configuration;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.atomic.AtomicReference;
+import org.intellij.lang.annotations.Language;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Node bootstrap configuration provider interface.
+ */
+@FunctionalInterface
+public interface NodeBootstrapConfiguration {
+    /**
+     * Path to node configuration file.
+     *
+     * @return Path to node configuration file in HOCON format.
+     */
+    Path config();
+
+
+    /**
+     * Simple config file provider.
+     *
+     * @param configPath path to node bootstrap configuration.
+     * @return Simple implementation with provided configuration file.
+     */
+    static NodeBootstrapConfiguration directFile(@NotNull Path configPath) {
+        return () -> configPath;
+    }
+
+    /**
+     * Return node bootstrap configuration with content from {@param is}.
+     *
+     * @param is configuration content.
+     * @param workDir dir for configuration file location.
+     * @return Node bootstrap configuration with lazy config file creation.
+     */
+    static NodeBootstrapConfiguration inputStream(@Nullable InputStream is, 
Path workDir) {
+        return new NodeBootstrapConfiguration() {
+
+            private final AtomicReference<Path> config = new 
AtomicReference<>();
+
+            @Override
+            public Path config() {
+                if (config.compareAndSet(null, createEmptyConfig(workDir))) {
+                    if (is != null) {
+                        try {
+                            Files.write(config.get(), is.readAllBytes());

Review Comment:
   Yeah, of course you are right but this code used only for tests and should 
be removed after all test migrated to config file usages instead of config 
string providing. Are you sure that it must be bullet-proof file writing method?



-- 
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]

Reply via email to