From dev-return-54818-apmail-drill-dev-archive=drill.apache.org@drill.apache.org Sun Jun 28 16:19:20 2020 Return-Path: X-Original-To: apmail-drill-dev-archive@www.apache.org Delivered-To: apmail-drill-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id 28A7419CC9 for ; Sun, 28 Jun 2020 16:19:19 +0000 (UTC) Received: (qmail 64698 invoked by uid 500); 28 Jun 2020 16:19:18 -0000 Delivered-To: apmail-drill-dev-archive@drill.apache.org Received: (qmail 64585 invoked by uid 500); 28 Jun 2020 16:19:17 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 64395 invoked by uid 99); 28 Jun 2020 16:19:17 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Jun 2020 16:19:17 +0000 From: =?utf-8?q?GitBox?= To: dev@drill.apache.org Subject: =?utf-8?q?=5BGitHub=5D_=5Bdrill=5D_dbw9580_commented_on_a_change_in_pull_req?= =?utf-8?q?uest_=232084=3A_DRILL-7745=3A_Add_storage_plugin_for_IPFS?= Message-ID: <159336115744.8807.16132098458393299513.asfpy@gitbox.apache.org> Date: Sun, 28 Jun 2020 16:19:17 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit In-Reply-To: References: dbw9580 commented on a change in pull request #2084: URL: https://github.com/apache/drill/pull/2084#discussion_r446669668 ########## File path: contrib/storage-ipfs/src/main/java/org/apache/drill/exec/store/ipfs/IPFSStoragePluginConfig.java ########## @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2018-2020 Bowen Ding, Yuedong Xu, Liang Wang + * + * 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.shaded.guava.com.google.common.collect.ImmutableMap; +import org.apache.drill.common.logical.FormatPluginConfig; +import org.apache.drill.common.logical.StoragePluginConfigBase; + +import java.security.InvalidParameterException; +import java.util.Map; + +@JsonTypeName(IPFSStoragePluginConfig.NAME) +public class IPFSStoragePluginConfig extends StoragePluginConfigBase{ + static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(IPFSStoragePluginConfig.class); + + public static final String NAME = "ipfs"; + + private final String host; + private final int port; + + @JsonProperty("max-nodes-per-leaf") + private final int maxNodesPerLeaf; + + //TODO add more specific timeout configs fot different operations in IPFS, + // eg. provider resolution, data read, etc. + @JsonProperty("ipfs-timeouts") + private final Map ipfsTimeouts; + + @JsonIgnore + private static final Map 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 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 formats; + + @JsonCreator + public IPFSStoragePluginConfig( + @JsonProperty("host") String host, + @JsonProperty("port") int port, + @JsonProperty("max-nodes-per-leaf") int maxNodesPerLeaf, + @JsonProperty("ipfs-timeouts") Map ipfsTimeouts, + @JsonProperty("groupscan-worker-threads") int numWorkerThreads, + @JsonProperty("formats") Map formats) { + this.host = host; + this.port = port; + this.maxNodesPerLeaf = maxNodesPerLeaf > 0 ? maxNodesPerLeaf : 1; + //TODO Jackson failed to deserialize the ipfsTimeouts map causing NPE + if (ipfsTimeouts != null) { Review comment: Hmm, it seems that this comment was made very early in development, and the issue it describes no longer exists. I deleted the comment in 282a89d. ---------------------------------------------------------------- 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