-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* align with the s3 url handler (you can only set one per JVM) * lots of internal refactorings
- Loading branch information
Showing
38 changed files
with
606 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ Thumbs.db | |
.cache-main | ||
.cache-tests | ||
bin | ||
hadoop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package apoc.util; | ||
|
||
import java.net.URLStreamHandler; | ||
import java.net.URLStreamHandlerFactory; | ||
|
||
public class ApocUrlStreamHandlerFactory implements URLStreamHandlerFactory { | ||
|
||
private static URLStreamHandlerFactory s3StreamHandlerFactory = Util.createInstanceOrNull("apoc.util.s3.S3UrlStreamHandlerFactory"); | ||
private static URLStreamHandlerFactory hdfsStreamHandlerFactory = Util.createInstanceOrNull("org.apache.hadoop.fs.FsUrlStreamHandlerFactory"); | ||
|
||
@Override | ||
public URLStreamHandler createURLStreamHandler(String protocol) { | ||
if (FileUtils.S3_ENABLED && FileUtils.S3_PROTOCOL.equalsIgnoreCase(protocol)) { | ||
return s3StreamHandlerFactory.createURLStreamHandler(protocol); | ||
} | ||
if (FileUtils.HDFS_ENABLED && FileUtils.HDFS_PROTOCOL.equalsIgnoreCase(protocol)) { | ||
return hdfsStreamHandlerFactory.createURLStreamHandler(protocol); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package apoc.util; | ||
|
||
import apoc.export.util.CountingInputStream; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URLConnection; | ||
|
||
/** | ||
* @author mh | ||
* @since 26.01.18 | ||
*/ | ||
public interface StreamConnection { | ||
InputStream getInputStream() throws IOException; | ||
String getEncoding(); | ||
long getLength(); | ||
default CountingInputStream toCountingInputStream() throws IOException { | ||
return new CountingInputStream(getInputStream(),getLength()); | ||
} | ||
|
||
static class UrlStreamConnection implements StreamConnection { | ||
private final URLConnection con; | ||
|
||
public UrlStreamConnection(URLConnection con) { | ||
this.con = con; | ||
} | ||
|
||
@Override | ||
public InputStream getInputStream() throws IOException { | ||
return con.getInputStream(); | ||
} | ||
|
||
@Override | ||
public String getEncoding() { | ||
return con.getContentEncoding(); | ||
} | ||
|
||
@Override | ||
public long getLength() { | ||
return con.getContentLength(); | ||
} | ||
} | ||
} |
Oops, something went wrong.