You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/11/03 13:32:16 UTC

[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #6220: Adding BootstrapTable command to allow bootstrapping a table from an example directory

kishoreg commented on a change in pull request #6220:
URL: https://github.com/apache/incubator-pinot/pull/6220#discussion_r516028639



##########
File path: pinot-tools/src/main/java/org/apache/pinot/tools/GitHubEventsQuickstart.java
##########
@@ -62,7 +62,7 @@ private void startKafka() {
 
   public void execute(String personalAccessToken)
       throws Exception {
-    final File quickStartDataDir = new File("githubEvents" + System.currentTimeMillis());
+    final File quickStartDataDir = new File(new File("githubEvents" + System.currentTimeMillis()), "pullRequestMergedEvents");

Review comment:
       add a - after githubEvents

##########
File path: pinot-tools/src/main/java/org/apache/pinot/tools/BootstrapTableTool.java
##########
@@ -0,0 +1,130 @@
+/**
+ * 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.pinot.tools;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.net.URL;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.spi.ingestion.batch.IngestionJobLauncher;
+import org.apache.pinot.spi.ingestion.batch.spec.SegmentGenerationJobSpec;
+import org.apache.pinot.tools.admin.command.AddTableCommand;
+import org.apache.pinot.tools.admin.command.QuickstartRunner;
+import org.apache.pinot.tools.utils.JarUtils;
+import org.yaml.snakeyaml.Yaml;
+
+
+public class BootstrapTableTool {
+  private final String _controllerHost;
+  private final int _controllerPort;
+  private final String _tableDir;
+
+  public BootstrapTableTool(String controllerHost, int controllerPort, String tableDir) {
+    _controllerHost = controllerHost;
+    _controllerPort = controllerPort;
+    _tableDir = tableDir;
+  }
+
+  public boolean execute()
+      throws Exception {
+    File setupTableTmpDir = new File(FileUtils.getTempDirectory(), String.valueOf(System.currentTimeMillis()));
+
+    File tableDir = new File(_tableDir);
+    String tableName = tableDir.getName();
+    File schemaFile = new File(tableDir, String.format("%s_schema.json", tableName));
+    if (!schemaFile.exists()) {
+      throw new RuntimeException(
+          "Unable to find schema file for table - " + tableName + ", at " + schemaFile.getAbsolutePath());
+    }
+    boolean tableCreationResult = false;
+    File offlineTableConfigFile = new File(tableDir, String.format("%s_offline_table_config.json", tableName));
+    if (offlineTableConfigFile.exists()) {
+      File ingestionJobSpecFile = new File(tableDir, "ingestionJobSpec.yaml");
+      tableCreationResult =
+          bootstrapOfflineTable(setupTableTmpDir, tableName, schemaFile, offlineTableConfigFile, ingestionJobSpecFile);
+    }
+    File realtimeTableConfigFile = new File(tableDir, String.format("%s_realtime_table_config.json", tableName));
+    if (realtimeTableConfigFile.exists()) {
+      tableCreationResult = bootstrapRealtimeTable(tableName, schemaFile, realtimeTableConfigFile);
+    }
+    if (!tableCreationResult) {
+      throw new RuntimeException(String
+          .format("Unable to find config files for table - %s, at location [%s] or [%s].", tableName,
+              offlineTableConfigFile.getAbsolutePath(), realtimeTableConfigFile.getAbsolutePath()));
+    }
+    return true;
+  }
+
+  private boolean bootstrapRealtimeTable(String tableName, File schemaFile, File realtimeTableConfigFile)
+      throws Exception {
+    Quickstart.printStatus(Quickstart.Color.CYAN, String.format("***** Adding %s realtime table *****", tableName));

Review comment:
       better to use logger here so that it can be used in other places?

##########
File path: pinot-tools/src/main/java/org/apache/pinot/tools/BootstrapTableTool.java
##########
@@ -0,0 +1,130 @@
+/**
+ * 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.pinot.tools;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.net.URL;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.spi.ingestion.batch.IngestionJobLauncher;
+import org.apache.pinot.spi.ingestion.batch.spec.SegmentGenerationJobSpec;
+import org.apache.pinot.tools.admin.command.AddTableCommand;
+import org.apache.pinot.tools.admin.command.QuickstartRunner;
+import org.apache.pinot.tools.utils.JarUtils;
+import org.yaml.snakeyaml.Yaml;
+
+
+public class BootstrapTableTool {

Review comment:
       java docs, you can put the same content in the PR description

##########
File path: pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/BootstrapTableCommand.java
##########
@@ -0,0 +1,80 @@
+/**
+ * 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.pinot.tools.admin.command;
+
+import org.apache.pinot.spi.plugin.PluginManager;
+import org.apache.pinot.tools.Command;
+import org.apache.pinot.tools.BootstrapTableTool;
+import org.kohsuke.args4j.Option;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class BootstrapTableCommand extends AbstractBaseAdminCommand implements Command {
+  private static final Logger LOGGER = LoggerFactory.getLogger(BootstrapTableCommand.class.getName());
+
+  @Option(name = "-controllerHost", required = false, metaVar = "<String>", usage = "host name for controller.")
+  private String _controllerHost;
+
+  @Option(name = "-controllerPort", required = false, metaVar = "<int>", usage = "http port for broker.")
+  private final String _controllerPort = DEFAULT_CONTROLLER_PORT;
+
+  @Option(name = "-dir", required = false, aliases = {"-d", "-directory"}, metaVar = "<String>", usage = "The directory contains all the configs and data to bootstrap a table")

Review comment:
       I prefer this mode vs providing too much flexibility. This will allow us to create a lot of simple examples




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org