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/03/05 23:20:33 UTC

[GitHub] [incubator-pinot] fx19880617 opened a new pull request #5119: Always copy test data out from jar file

fx19880617 opened a new pull request #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119
 
 
   a quick fix for issue of referring to jar uri.
   ```Exception in thread "main" java.lang.IllegalStateException: PinotFS for scheme: jar has not been initialized
   
   at shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:518)
   
   at org.apache.pinot.spi.filesystem.PinotFSFactory.create(PinotFSFactory.java:78)
   
   at
   
   org.apache.pinot.plugin.ingestion.batch.standalone.SegmentGenerationJobRunner.run(SegmentGenerationJobRunner.java:115)
   
   at org.apache.pinot.spi.ingestion.batch.IngestionJobLauncher.kickoffIngestionJob(IngestionJobLauncher.java:96)
   
   at org.apache.pinot.spi.ingestion.batch.IngestionJobLauncher.runIngestionJob(IngestionJobLauncher.java:77)
   
   at org.apache.pinot.tools.admin.command.QuickstartRunner.launchDataIngestionJob(QuickstartRunner.java:183)
   
   at org.apache.pinot.tools.Quickstart.execute(Quickstart.java:154)
   
   at org.apache.pinot.tools.Quickstart.main(Quickstart.java:209)
   ```

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

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


[GitHub] [incubator-pinot] snleee commented on a change in pull request #5119: Always copy test data out from jar file

Posted by GitBox <gi...@apache.org>.
snleee commented on a change in pull request #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119#discussion_r389214127
 
 

 ##########
 File path: pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.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.utils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+
+public class JarUtils {
+  private JarUtils() {
+  } // non-instantiable
+
+  /**
+   * Copies a directory from a jar file to an external directory.
+   */
+  public static void copyResourcesToDirectory(String fromJarFilePath, String jarDir, String destDir)
+      throws IOException {
+    if (fromJarFilePath.startsWith("jar:")) {
+      fromJarFilePath = fromJarFilePath.substring(4);
+    }
+    if (fromJarFilePath.startsWith("file:")) {
 
 Review comment:
   same here

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

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


[GitHub] [incubator-pinot] fx19880617 merged pull request #5119: Always copy test data out from jar file

Posted by GitBox <gi...@apache.org>.
fx19880617 merged pull request #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119
 
 
   

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

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


[GitHub] [incubator-pinot] siddharthteotia commented on issue #5119: Always copy test data out from jar file

Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on issue #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119#issuecomment-596035759
 
 
   Verified this works on Mac. The error reported earlier is not seen anymore.
   
   Thanks @fx19880617  for fixing this.

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

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


[GitHub] [incubator-pinot] snleee commented on a change in pull request #5119: Always copy test data out from jar file

Posted by GitBox <gi...@apache.org>.
snleee commented on a change in pull request #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119#discussion_r389214145
 
 

 ##########
 File path: pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.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.utils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+
+public class JarUtils {
+  private JarUtils() {
+  } // non-instantiable
+
+  /**
+   * Copies a directory from a jar file to an external directory.
+   */
+  public static void copyResourcesToDirectory(String fromJarFilePath, String jarDir, String destDir)
+      throws IOException {
+    if (fromJarFilePath.startsWith("jar:")) {
+      fromJarFilePath = fromJarFilePath.substring(4);
+    }
+    if (fromJarFilePath.startsWith("file:")) {
+      fromJarFilePath = fromJarFilePath.substring(5);
+    }
+    JarFile fromJar = new JarFile(fromJarFilePath);
+    for (Enumeration<JarEntry> entries = fromJar.entries(); entries.hasMoreElements(); ) {
+      JarEntry entry = entries.nextElement();
+      if (entry.getName().startsWith(jarDir + "/") && !entry.isDirectory()) {
+        File dest = new File(destDir + "/" + entry.getName().substring(jarDir.length() + 1));
+        File parent = dest.getParentFile();
+        if (parent != null) {
+          parent.mkdirs();
+        }
+
+        FileOutputStream out = new FileOutputStream(dest);
+        InputStream in = fromJar.getInputStream(entry);
+
+        try {
+          byte[] buffer = new byte[8 * 1024];
+
+          int s = 0;
+          while ((s = in.read(buffer)) > 0) {
+            out.write(buffer, 0, s);
+          }
+        } catch (IOException e) {
+          throw new IOException("Could not copy asset from jar file", e);
+        } finally {
+          try {
+            in.close();
+          } catch (IOException ignored) {
+          }
+          try {
+            out.close();
+          } catch (IOException ignored) {
+          }
+        }
+      }
+    }
+  }
+}
 
 Review comment:
   add line

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

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


[GitHub] [incubator-pinot] snleee commented on issue #5119: Always copy test data out from jar file

Posted by GitBox <gi...@apache.org>.
snleee commented on issue #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119#issuecomment-596029034
 
 
   Verified that `quick-start-batch.sh` is working fine on my mac laptop.

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

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


[GitHub] [incubator-pinot] snleee commented on a change in pull request #5119: Always copy test data out from jar file

Posted by GitBox <gi...@apache.org>.
snleee commented on a change in pull request #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119#discussion_r389214081
 
 

 ##########
 File path: pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.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.utils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+
+public class JarUtils {
+  private JarUtils() {
+  } // non-instantiable
+
+  /**
+   * Copies a directory from a jar file to an external directory.
+   */
+  public static void copyResourcesToDirectory(String fromJarFilePath, String jarDir, String destDir)
+      throws IOException {
+    if (fromJarFilePath.startsWith("jar:")) {
 
 Review comment:
   lets put `private static final String JAR_PREFIX = "jar:"`
   
   

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

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


[GitHub] [incubator-pinot] snleee commented on a change in pull request #5119: Always copy test data out from jar file

Posted by GitBox <gi...@apache.org>.
snleee commented on a change in pull request #5119: Always copy test data out from jar file
URL: https://github.com/apache/incubator-pinot/pull/5119#discussion_r389214114
 
 

 ##########
 File path: pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.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.utils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+
+public class JarUtils {
+  private JarUtils() {
+  } // non-instantiable
+
+  /**
+   * Copies a directory from a jar file to an external directory.
+   */
+  public static void copyResourcesToDirectory(String fromJarFilePath, String jarDir, String destDir)
+      throws IOException {
+    if (fromJarFilePath.startsWith("jar:")) {
+      fromJarFilePath = fromJarFilePath.substring(4);
 
 Review comment:
   substring(JAR_PREFIX.length())

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

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