@Test public void testDownloadFile() throws Exception { String jarHttpUrl = "https: String testDir = FunctionCommonTest.class.getProtectionDomain().getCodeSource().getLocation().getPath(); File pkgFile = new File(testDir, UUID.randomUUID().toString()); FunctionCommon.downloadFromHttpUrl(jarHttpUrl, pkgFile); Assert.assertTrue(pkgFile.exists()); pkgFile.delete(); }
public static void downloadFromHttpUrl(String destPkgUrl, File targetFile) throws IOException { URL website = new URL(destPkgUrl); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); log.info("Downloading function package from {} to {} ...", destPkgUrl, targetFile.getAbsoluteFile()); try (FileOutputStream fos = new FileOutputStream(targetFile)) { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } log.info("Downloading function package from {} to {} completed!", destPkgUrl, targetFile.getAbsoluteFile()); }
FunctionCommon { public static void downloadFromHttpUrl(String destPkgUrl, File targetFile) throws IOException { URL website = new URL(destPkgUrl); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); log.info("Downloading function package from {} to {} ...", destPkgUrl, targetFile.getAbsoluteFile()); try (FileOutputStream fos = new FileOutputStream(targetFile)) { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } log.info("Downloading function package from {} to {} completed!", destPkgUrl, targetFile.getAbsoluteFile()); } }
FunctionCommon { public static void downloadFromHttpUrl(String destPkgUrl, File targetFile) throws IOException { URL website = new URL(destPkgUrl); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); log.info("Downloading function package from {} to {} ...", destPkgUrl, targetFile.getAbsoluteFile()); try (FileOutputStream fos = new FileOutputStream(targetFile)) { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } log.info("Downloading function package from {} to {} completed!", destPkgUrl, targetFile.getAbsoluteFile()); }  }
FunctionCommon { public static void downloadFromHttpUrl(String destPkgUrl, File targetFile) throws IOException { URL website = new URL(destPkgUrl); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); log.info("Downloading function package from {} to {} ...", destPkgUrl, targetFile.getAbsoluteFile()); try (FileOutputStream fos = new FileOutputStream(targetFile)) { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } log.info("Downloading function package from {} to {} completed!", destPkgUrl, targetFile.getAbsoluteFile()); }  static String printJson(MessageOrBuilder msg); static void mergeJson(String json, Builder builder); static int findAvailablePort(); static Class<?>[] getFunctionTypes(FunctionConfig functionConfig, ClassLoader classLoader); static Class<?>[] getFunctionTypes(Class userClass, boolean isWindowConfigPresent); static Object createInstance(String userClassName, ClassLoader classLoader); static Runtime convertRuntime(FunctionConfig.Runtime runtime); static FunctionConfig.Runtime convertRuntime(Runtime runtime); static org.apache.pulsar.functions.proto.Function.ProcessingGuarantees convertProcessingGuarantee(
            FunctionConfig.ProcessingGuarantees processingGuarantees); static FunctionConfig.ProcessingGuarantees convertProcessingGuarantee(
            org.apache.pulsar.functions.proto.Function.ProcessingGuarantees processingGuarantees); static Class<?> getSourceType(String className, ClassLoader classLoader); static Class<?> getSourceType(Class sourceClass); static Class<?> getSinkType(String className, ClassLoader classLoader); static void downloadFromHttpUrl(String destPkgUrl, File targetFile); static ClassLoader extractClassLoader(String destPkgUrl); static File createPkgTempFile(); static File extractFileFromPkgURL(String destPkgUrl); static NarClassLoader extractNarClassLoader(Path archivePath, File packageFile,
                                                       String narExtractionDirectory); static String getFullyQualifiedInstanceId(org.apache.pulsar.functions.proto.Function.Instance instance); static String getFullyQualifiedInstanceId(String tenant, String namespace,
                                                     String functionName, int instanceId); static final long getSequenceId(MessageId messageId); static final MessageId getMessageId(long sequenceId); static byte[] toByteArray(Object obj); static String getUniquePackageName(String packageName); static String getStateNamespace(String tenant, String namespace); static String getFullyQualifiedName(org.apache.pulsar.functions.proto.Function.FunctionDetails FunctionDetails); static String getFullyQualifiedName(String tenant, String namespace, String functionName); static String extractTenantFromFullyQualifiedName(String fqfn); static String extractNamespaceFromFullyQualifiedName(String fqfn); static String extractNameFromFullyQualifiedName(String fqfn); static Class<?> getTypeArg(String className, Class<?> funClass, ClassLoader classLoader); static double roundDecimal(double value, int places); }
FunctionCommon { public static void downloadFromHttpUrl(String destPkgUrl, File targetFile) throws IOException { URL website = new URL(destPkgUrl); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); log.info("Downloading function package from {} to {} ...", destPkgUrl, targetFile.getAbsoluteFile()); try (FileOutputStream fos = new FileOutputStream(targetFile)) { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } log.info("Downloading function package from {} to {} completed!", destPkgUrl, targetFile.getAbsoluteFile()); }  static String printJson(MessageOrBuilder msg); static void mergeJson(String json, Builder builder); static int findAvailablePort(); static Class<?>[] getFunctionTypes(FunctionConfig functionConfig, ClassLoader classLoader); static Class<?>[] getFunctionTypes(Class userClass, boolean isWindowConfigPresent); static Object createInstance(String userClassName, ClassLoader classLoader); static Runtime convertRuntime(FunctionConfig.Runtime runtime); static FunctionConfig.Runtime convertRuntime(Runtime runtime); static org.apache.pulsar.functions.proto.Function.ProcessingGuarantees convertProcessingGuarantee(
            FunctionConfig.ProcessingGuarantees processingGuarantees); static FunctionConfig.ProcessingGuarantees convertProcessingGuarantee(
            org.apache.pulsar.functions.proto.Function.ProcessingGuarantees processingGuarantees); static Class<?> getSourceType(String className, ClassLoader classLoader); static Class<?> getSourceType(Class sourceClass); static Class<?> getSinkType(String className, ClassLoader classLoader); static void downloadFromHttpUrl(String destPkgUrl, File targetFile); static ClassLoader extractClassLoader(String destPkgUrl); static File createPkgTempFile(); static File extractFileFromPkgURL(String destPkgUrl); static NarClassLoader extractNarClassLoader(Path archivePath, File packageFile,
                                                       String narExtractionDirectory); static String getFullyQualifiedInstanceId(org.apache.pulsar.functions.proto.Function.Instance instance); static String getFullyQualifiedInstanceId(String tenant, String namespace,
                                                     String functionName, int instanceId); static final long getSequenceId(MessageId messageId); static final MessageId getMessageId(long sequenceId); static byte[] toByteArray(Object obj); static String getUniquePackageName(String packageName); static String getStateNamespace(String tenant, String namespace); static String getFullyQualifiedName(org.apache.pulsar.functions.proto.Function.FunctionDetails FunctionDetails); static String getFullyQualifiedName(String tenant, String namespace, String functionName); static String extractTenantFromFullyQualifiedName(String fqfn); static String extractNamespaceFromFullyQualifiedName(String fqfn); static String extractNameFromFullyQualifiedName(String fqfn); static Class<?> getTypeArg(String className, Class<?> funClass, ClassLoader classLoader); static double roundDecimal(double value, int places);  }