pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] congbobo184 commented on a change in pull request #4403: File system offload
Date Fri, 14 Jun 2019 01:43:05 GMT
congbobo184 commented on a change in pull request #4403: File system offload
URL: https://github.com/apache/pulsar/pull/4403#discussion_r293488087
 
 

 ##########
 File path: tiered-storage/file-system/src/main/java/org/apache/bookkeeper/mledger/offload/filesystem/impl/FileSystemManagedLedgerOffloader.java
 ##########
 @@ -0,0 +1,241 @@
+/**
+ * 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.bookkeeper.mledger.offload.filesystem.impl;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableMap;
+import com.google.protobuf.ByteString;
+import org.apache.bookkeeper.client.BookKeeper;
+import org.apache.bookkeeper.client.api.LedgerEntries;
+import org.apache.bookkeeper.client.api.LedgerEntry;
+import org.apache.bookkeeper.client.api.LedgerMetadata;
+import org.apache.bookkeeper.client.api.ReadHandle;
+import org.apache.bookkeeper.common.util.OrderedScheduler;
+import org.apache.bookkeeper.mledger.LedgerOffloader;
+import org.apache.bookkeeper.mledger.offload.filesystem.FileSystemLedgerOffloaderFactory;
+import org.apache.bookkeeper.mledger.offload.filesystem.TieredStorageConfigurationData;
+import org.apache.bookkeeper.net.BookieSocketAddress;
+import org.apache.bookkeeper.proto.DataFormats;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.BytesWritable;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+import java.util.zip.Checksum;
+
+
+public class FileSystemManagedLedgerOffloader implements LedgerOffloader {
+
+    private static final Logger log = LoggerFactory.getLogger(FileSystemManagedLedgerOffloader.class);
+    private static final String STORAGE_BASE_PATH = "storageBasePath";
+    private static final String[] DRIVER_NAMES = {"filesystem"};
+    private final Configuration configuration;
+    private final String driverName;
+    private final String storageBasePath;
+    private final FileSystem fileSystem;
+    private OrderedScheduler scheduler;
+    private static final long ENTRIES_PER_READ = 100;
+    public static boolean driverSupported(String driver) {
+        return Arrays.stream(DRIVER_NAMES).anyMatch(d -> d.equalsIgnoreCase(driver));
+    }
+    @Override
+    public String getOffloadDriverName() {
+        return driverName;
+    }
+
+    public static FileSystemManagedLedgerOffloader create(TieredStorageConfigurationData
conf, OrderedScheduler scheduler) throws IOException {
+        return new FileSystemManagedLedgerOffloader(conf, scheduler);
+    }
+
+    private FileSystemManagedLedgerOffloader(TieredStorageConfigurationData conf, OrderedScheduler
scheduler) throws IOException {
+        this.configuration = new Configuration();
+        if (conf.getFileSystemProfilePath() != null) {
+            String[] paths = conf.getFileSystemProfilePath().split(",");
+            for (int i =0 ; i < paths.length; i++) {
+                configuration.addResource(new Path(paths[i]));
+            }
+        }
+        if (configuration.get("fs.hdfs.impl") == null) {
+            this.configuration.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
+        }
+        this.configuration.setClassLoader(FileSystemLedgerOffloaderFactory.class.getClassLoader());
+        this.driverName = conf.getManagedLedgerOffloadDriver();
+        this.storageBasePath = configuration.get("hadoop.tmp.dir");
 
 Review comment:
   > should we use a different configuration key "pulsar.offloaded.segments.dir"?
   
   if we use a different key, we should get it once, then add it once like
   configuration.get("pulsar.offloaded.segments.dir");
   configuration.set("hadoop.tmp.dir", pulsar.offloaded.segments.dir);
   It feels a little strange

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message