[ 
https://issues.apache.org/jira/browse/DRILL-7745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17177819#comment-17177819
 ] 

ASF GitHub Bot commented on DRILL-7745:
---------------------------------------

dbw9580 commented on a change in pull request #2084:
URL: https://github.com/apache/drill/pull/2084#discussion_r470681998



##########
File path: 
contrib/storage-ipfs/src/main/java/org/apache/drill/exec/store/ipfs/IPFSStoragePluginConfig.java
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.drill.exec.store.ipfs;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.drill.common.logical.FormatPluginConfig;
+import org.apache.drill.common.logical.StoragePluginConfigBase;
+import org.apache.drill.shaded.guava.com.google.common.base.Objects;
+import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableMap;
+import org.apache.drill.shaded.guava.com.google.common.collect.Maps;
+
+import java.security.InvalidParameterException;
+import java.util.Map;
+
+@JsonTypeName(IPFSStoragePluginConfig.NAME)
+public class IPFSStoragePluginConfig extends StoragePluginConfigBase{
+    public static final String NAME = "ipfs";
+
+    @JsonProperty
+    private final String host;
+
+    @JsonProperty
+    private final int port;
+
+    @JsonProperty("max-nodes-per-leaf")
+    private final int maxNodesPerLeaf;
+
+    @JsonProperty("ipfs-timeouts")
+    private final Map<IPFSTimeOut, Integer> ipfsTimeouts;
+
+    @JsonIgnore
+    private static final Map<IPFSTimeOut, Integer> ipfsTimeoutDefaults = 
ImmutableMap.of(
+        IPFSTimeOut.FIND_PROV, 4,
+        IPFSTimeOut.FIND_PEER_INFO, 4,
+        IPFSTimeOut.FETCH_DATA, 6
+    );
+
+    public enum IPFSTimeOut {
+        @JsonProperty("find-provider")
+        FIND_PROV("find-provider"),
+        @JsonProperty("find-peer-info")
+        FIND_PEER_INFO("find-peer-info"),
+        @JsonProperty("fetch-data")
+        FETCH_DATA("fetch-data");
+
+        @JsonProperty("type")
+        private final String which;
+        IPFSTimeOut(String which) {
+            this.which = which;
+        }
+
+        @JsonCreator
+        public static IPFSTimeOut of(String which) {
+            switch (which) {
+                case "find-provider":
+                    return FIND_PROV;
+                case "find-peer-info":
+                    return FIND_PEER_INFO;
+                case "fetch-data":
+                    return FETCH_DATA;
+                default:
+                    throw new InvalidParameterException("Unknown key for IPFS 
timeout config entry: " + which);
+            }
+        }
+
+        @Override
+        public String toString() {
+            return this.which;
+        }
+    }
+
+    @JsonProperty("groupscan-worker-threads")
+    private final int numWorkerThreads;
+
+    @JsonProperty
+    private final Map<String, FormatPluginConfig> formats;
+
+    @JsonCreator
+    public IPFSStoragePluginConfig(
+        @JsonProperty("host") String host,
+        @JsonProperty("port") int port,
+        @JsonProperty("max-nodes-per-leaf") int maxNodesPerLeaf,
+        @JsonProperty("ipfs-timeouts") Map<IPFSTimeOut, Integer> ipfsTimeouts,
+        @JsonProperty("groupscan-worker-threads") int numWorkerThreads,
+        @JsonProperty("formats") Map<String, FormatPluginConfig> formats) {
+        this.host = host;
+        this.port = port;
+        this.maxNodesPerLeaf = maxNodesPerLeaf > 0 ? maxNodesPerLeaf : 1;
+        if (ipfsTimeouts != null) {
+            this.ipfsTimeouts = Maps.newHashMap();
+            ipfsTimeouts.forEach(this.ipfsTimeouts::put);
+            ipfsTimeoutDefaults.forEach(this.ipfsTimeouts::putIfAbsent);
+        } else {
+            this.ipfsTimeouts = ipfsTimeoutDefaults;
+        }
+        this.numWorkerThreads = numWorkerThreads > 0 ? numWorkerThreads : 1;
+        this.formats = formats;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public int getMaxNodesPerLeaf() {
+        return maxNodesPerLeaf;
+    }
+
+    public int getIpfsTimeout(IPFSTimeOut which) {
+        return ipfsTimeouts.get(which);
+    }
+
+    public Map<IPFSTimeOut, Integer> getIpfsTimeouts() {
+        return ipfsTimeouts;
+    }
+
+    public int getNumWorkerThreads() {
+        return numWorkerThreads;
+    }
+
+    public Map<String, FormatPluginConfig> getFormats() {
+        return formats;
+    }
+
+    @Override
+    public int hashCode() {

Review comment:
       Fixed in 30094a8.




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


> Add storage plugin for IPFS
> ---------------------------
>
>                 Key: DRILL-7745
>                 URL: https://issues.apache.org/jira/browse/DRILL-7745
>             Project: Apache Drill
>          Issue Type: New Feature
>          Components: Storage - Other
>    Affects Versions: 1.18.0
>            Reporter: Bowen Ding
>            Assignee: Bowen Ding
>            Priority: Major
>
> See introduction here: [https://github.com/bdchain/Minerva]
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to