@Override void runCmd() throws Exception { if (Utils.isFunctionPackageUrlSupported(this.sourceConfig.getArchive())) { admin.functions().createFunctionWithUrl(SourceConfigUtils.convert(sourceConfig), sourceConfig.getArchive()); } else { admin.functions().createFunction(SourceConfigUtils.convert(sourceConfig), sourceConfig.getArchive()); } print("Created successfully"); } }
@Override void runCmd() throws Exception { if (Utils.isFunctionPackageUrlSupported(sourceConfig.getArchive())) { admin.functions().updateFunctionWithUrl(SourceConfigUtils.convert(sourceConfig), sourceConfig.getArchive()); } else { admin.functions().updateFunction(SourceConfigUtils.convert(sourceConfig), sourceConfig.getArchive()); } print("Updated successfully"); } }
protected void validateSourceConfigs(SourceConfig sourceConfig) { if (StringUtils.isBlank(sourceConfig.getArchive())) { throw new ParameterException("Source archive not specfied"); boolean isConnectorBuiltin = sourceConfig.getArchive().startsWith(Utils.BUILTIN); boolean isArchivePathUrl = Utils.isFunctionPackageUrlSupported(sourceConfig.getArchive()); if(sourceConfig.getArchive().startsWith(Utils.HTTP)) { File tempPkgFile = null; try { tempPkgFile = downloadFromHttpUrl(sourceConfig.getArchive(), sourceConfig.getName()); archivePath = tempPkgFile.getAbsolutePath(); } catch(Exception e) { tempPkgFile.deleteOnExit(); throw new ParameterException("Failed to download archive from " + sourceConfig.getArchive() + ", due to =" + e.getMessage()); archivePath = sourceConfig.getArchive();
@Override public void validateField(String name, Object o, ClassLoader classLoader) { SourceConfig sourceConfig = (SourceConfig) o; if (sourceConfig.getArchive().startsWith(Utils.BUILTIN)) { // We don't have to check the archive, since it's provided on the worker itself return; } String sourceClassName; try { sourceClassName = ConnectorUtils.getIOSourceClass(sourceConfig.getArchive()); } catch (IOException e1) { throw new IllegalArgumentException("Failed to extract source class from archive", e1); } Class<?> typeArg = getSourceType(sourceClassName, classLoader); // Only one of serdeClassName or schemaType should be set if (sourceConfig.getSerdeClassName() != null && !sourceConfig.getSerdeClassName().isEmpty() && sourceConfig.getSchemaType() != null && !sourceConfig.getSchemaType().isEmpty()) { throw new IllegalArgumentException("Only one of serdeClassName or schemaType should be set"); } if (sourceConfig.getSerdeClassName() != null && !sourceConfig.getSerdeClassName().isEmpty()) { FunctionConfigValidator.validateSerde(sourceConfig.getSerdeClassName(),typeArg, name, classLoader, false); } if (sourceConfig.getSchemaType() != null && !sourceConfig.getSchemaType().isEmpty()) { FunctionConfigValidator.validateSchema(sourceConfig.getSchemaType(), typeArg, name, classLoader, false); } } }
@Override void runCmd() throws Exception { // merge deprecated args with new args mergeArgs(); CmdFunctions.startLocalRun(createSourceConfigProto2(sourceConfig), sourceConfig.getParallelism(), 0, brokerServiceUrl, null, AuthenticationConfig.builder().clientAuthenticationPlugin(clientAuthPlugin) .clientAuthenticationParameters(clientAuthParams).useTls(useTls) .tlsAllowInsecureConnection(tlsAllowInsecureConnection) .tlsHostnameVerificationEnable(tlsHostNameVerificationEnabled) .tlsTrustCertsFilePath(tlsTrustCertFilePath).build(), sourceConfig.getArchive(), admin); }
boolean isBuiltin = sourceConfig.getArchive().startsWith(Utils.BUILTIN); if (sourceConfig.getArchive().startsWith(Utils.FILE)) { if (org.apache.commons.lang3.StringUtils.isBlank(sourceConfig.getClassName())) { throw new IllegalArgumentException("Class-name must be present for archive with file-url"); sourceClassName = ConnectorUtils.getIOSourceClass(sourceConfig.getArchive()); try (NarClassLoader ncl = NarClassLoader.getFromArchive(new File(sourceConfig.getArchive()), Collections.emptySet())) { typeArg = getSourceType(sourceClassName, ncl).getName(); String builtin = sourceConfig.getArchive().replaceFirst("^builtin://", ""); sourceSpecBuilder.setBuiltin(builtin);