ic4y commented on code in PR #3637: URL: https://github.com/apache/incubator-seatunnel/pull/3637#discussion_r1039220516
########## seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/mapstore/MapStoreTest.java: ########## @@ -0,0 +1,56 @@ +/* + * 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.seatunnel.engine.server.mapstore; + +import static org.awaitility.Awaitility.await; + +import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest; + +import com.hazelcast.map.IMap; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; + +import java.util.concurrent.TimeUnit; + +@Slf4j +@DisabledOnOs(OS.WINDOWS) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class MapStoreTest extends AbstractSeaTunnelServerTest { + + @Test + public void testMapStore() { Review Comment: Need to add data check after cluster restart ########## seatunnel-engine/seatunnel-engine-common/src/main/resources/hazelcast.yaml: ########## @@ -32,6 +32,18 @@ hazelcast: auto-increment: true port-count: 100 port: 5801 + map: Review Comment: Not all Imaps need to be persistent ########## seatunnel-engine/seatunnel-engine-storage/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/IMapFileStorage.java: ########## @@ -131,6 +131,7 @@ public void initialize(Map<String, Object> configuration) { this.businessRootPath = namespace + DEFAULT_IMAP_FILE_PATH_SPLIT + clusterName + DEFAULT_IMAP_FILE_PATH_SPLIT + businessName + DEFAULT_IMAP_FILE_PATH_SPLIT; try { this.fs = FileSystem.get(hadoopConf); + fs.setWriteChecksum(false); Review Comment: @CalvinKirs PTAL ########## seatunnel-engine/seatunnel-engine-common/src/main/resources/hazelcast.yaml: ########## @@ -32,6 +32,18 @@ hazelcast: auto-increment: true port-count: 100 port: 5801 + map: + supplements: + map-store: + enabled: true + initial-mode: LAZY Review Comment: Suggert initial-mode is EAGER ########## seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java: ########## @@ -17,58 +17,80 @@ package org.apache.seatunnel.engine.server.persistence; +import static org.apache.seatunnel.engine.imap.storage.file.common.FileConstants.FileInitProperties.HDFS_CONFIG_KEY; + +import org.apache.seatunnel.engine.imap.storage.api.IMapStorage; +import org.apache.seatunnel.engine.imap.storage.file.IMapFileStorage; + +import com.google.common.collect.Maps; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.MapLoaderLifecycleSupport; import com.hazelcast.map.MapStore; +import lombok.SneakyThrows; +import org.apache.hadoop.conf.Configuration; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import java.util.Properties; public class FileMapStore implements MapStore<Object, Object>, MapLoaderLifecycleSupport { - //TODO Wait for the file Kv storage development to complete + + private IMapStorage mapStorage; @Override public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) { + // TODO implemented by loading the factory + mapStorage = new IMapFileStorage(); + Map<String, Object> initMap = new HashMap<>(Maps.fromProperties(properties)); + Configuration configuration = new Configuration(); + configuration.set("fs.defaultFS", properties.getProperty("fs.defaultFS")); + properties.put(HDFS_CONFIG_KEY, configuration); + initMap.put(HDFS_CONFIG_KEY, configuration); + mapStorage.initialize(initMap); + } @Override public void destroy() { - + mapStorage.destroy(); } @Override public void store(Object key, Object value) { + mapStorage.store(key, value); } @Override public void storeAll(Map<Object, Object> map) { - + mapStorage.storeAll(map); } @Override public void delete(Object key) { - + mapStorage.delete(key); } @Override public void deleteAll(Collection<Object> keys) { - + mapStorage.deleteAll(keys); } + @SneakyThrows @Override - public String load(Object key) { - return null; + public Object load(Object key) { + return mapStorage.loadAll().get(key); Review Comment: Suggest return null -- 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]
