Search in sources :

Example 11 with RestException

use of org.apache.pulsar.common.util.RestException in project pulsar by apache.

the class FunctionApiV3ResourceTest method testRegisterFunctionUploadFailure.

@Test(expectedExceptions = RestException.class, expectedExceptionsMessageRegExp = "upload failure")
public void testRegisterFunctionUploadFailure() throws Exception {
    try {
        mockWorkerUtils(ctx -> {
            ctx.when(() -> {
                WorkerUtils.uploadFileToBookkeeper(anyString(), any(File.class), any(Namespace.class));
            }).thenThrow(new IOException("upload failure"));
            ;
        });
        when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(function))).thenReturn(false);
        registerDefaultFunction();
    } catch (RestException re) {
        assertEquals(re.getResponse().getStatusInfo(), Response.Status.INTERNAL_SERVER_ERROR);
        throw re;
    }
}
Also used : RestException(org.apache.pulsar.common.util.RestException) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 12 with RestException

use of org.apache.pulsar.common.util.RestException in project pulsar by apache.

the class SinksImpl method getSinkInfo.

@Override
public SinkConfig getSinkInfo(final String tenant, final String namespace, final String componentName) {
    if (!isWorkerServiceAvailable()) {
        throwUnavailableException();
    }
    // validate parameters
    try {
        validateGetFunctionRequestParams(tenant, namespace, componentName, componentType);
    } catch (IllegalArgumentException e) {
        log.error("Invalid get {} request @ /{}/{}/{}", ComponentTypeUtils.toString(componentType), tenant, namespace, componentName, e);
        throw new RestException(Response.Status.BAD_REQUEST, e.getMessage());
    }
    FunctionMetaDataManager functionMetaDataManager = worker().getFunctionMetaDataManager();
    if (!functionMetaDataManager.containsFunction(tenant, namespace, componentName)) {
        log.error("{} does not exist @ /{}/{}/{}", ComponentTypeUtils.toString(componentType), tenant, namespace, componentName);
        throw new RestException(Response.Status.NOT_FOUND, String.format(ComponentTypeUtils.toString(componentType) + " %s doesn't exist", componentName));
    }
    Function.FunctionMetaData functionMetaData = functionMetaDataManager.getFunctionMetaData(tenant, namespace, componentName);
    if (!InstanceUtils.calculateSubjectType(functionMetaData.getFunctionDetails()).equals(componentType)) {
        log.error("{}/{}/{} is not a {}", tenant, namespace, componentName, ComponentTypeUtils.toString(componentType));
        throw new RestException(Response.Status.NOT_FOUND, String.format(ComponentTypeUtils.toString(componentType) + " %s doesn't exist", componentName));
    }
    SinkConfig config = SinkConfigUtils.convertFromDetails(functionMetaData.getFunctionDetails());
    return config;
}
Also used : Function(org.apache.pulsar.functions.proto.Function) SinkConfig(org.apache.pulsar.common.io.SinkConfig) FunctionMetaDataManager(org.apache.pulsar.functions.worker.FunctionMetaDataManager) RestException(org.apache.pulsar.common.util.RestException)

Example 13 with RestException

use of org.apache.pulsar.common.util.RestException in project pulsar by apache.

the class SinksImpl method registerSink.

@Override
public void registerSink(final String tenant, final String namespace, final String sinkName, final InputStream uploadedInputStream, final FormDataContentDisposition fileDetail, final String sinkPkgUrl, final SinkConfig sinkConfig, final String clientRole, AuthenticationDataSource clientAuthenticationDataHttps) {
    if (!isWorkerServiceAvailable()) {
        throwUnavailableException();
    }
    if (tenant == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Tenant is not provided");
    }
    if (namespace == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Namespace is not provided");
    }
    if (sinkName == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Sink name is not provided");
    }
    if (sinkConfig == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Sink config is not provided");
    }
    try {
        if (!isAuthorizedRole(tenant, namespace, clientRole, clientAuthenticationDataHttps)) {
            log.warn("{}/{}/{} Client [{}] is not authorized to register {}", tenant, namespace, sinkName, clientRole, ComponentTypeUtils.toString(componentType));
            throw new RestException(Response.Status.UNAUTHORIZED, "Client is not authorized to perform operation");
        }
    } catch (PulsarAdminException e) {
        log.error("{}/{}/{} Failed to authorize [{}]", tenant, namespace, sinkName, e);
        throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
    try {
        // Check tenant exists
        worker().getBrokerAdmin().tenants().getTenantInfo(tenant);
        String qualifiedNamespace = tenant + "/" + namespace;
        List<String> namespaces = worker().getBrokerAdmin().namespaces().getNamespaces(tenant);
        if (namespaces != null && !namespaces.contains(qualifiedNamespace)) {
            String qualifiedNamespaceWithCluster = String.format("%s/%s/%s", tenant, worker().getWorkerConfig().getPulsarFunctionsCluster(), namespace);
            if (namespaces != null && !namespaces.contains(qualifiedNamespaceWithCluster)) {
                log.error("{}/{}/{} Namespace {} does not exist", tenant, namespace, sinkName, namespace);
                throw new RestException(Response.Status.BAD_REQUEST, "Namespace does not exist");
            }
        }
    } catch (PulsarAdminException.NotAuthorizedException e) {
        log.error("{}/{}/{} Client [{}] is not authorized to operate {} on tenant", tenant, namespace, sinkName, clientRole, ComponentTypeUtils.toString(componentType));
        throw new RestException(Response.Status.UNAUTHORIZED, "Client is not authorized to perform operation");
    } catch (PulsarAdminException.NotFoundException e) {
        log.error("{}/{}/{} Tenant {} does not exist", tenant, namespace, sinkName, tenant);
        throw new RestException(Response.Status.BAD_REQUEST, "Tenant does not exist");
    } catch (PulsarAdminException e) {
        log.error("{}/{}/{} Issues getting tenant data", tenant, namespace, sinkName, e);
        throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
    FunctionMetaDataManager functionMetaDataManager = worker().getFunctionMetaDataManager();
    if (functionMetaDataManager.containsFunction(tenant, namespace, sinkName)) {
        log.error("{} {}/{}/{} already exists", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName);
        throw new RestException(Response.Status.BAD_REQUEST, String.format("%s %s already exists", ComponentTypeUtils.toString(componentType), sinkName));
    }
    Function.FunctionDetails functionDetails = null;
    boolean isPkgUrlProvided = isNotBlank(sinkPkgUrl);
    File componentPackageFile = null;
    try {
        // validate parameters
        try {
            if (isPkgUrlProvided) {
                if (Utils.hasPackageTypePrefix(sinkPkgUrl)) {
                    componentPackageFile = downloadPackageFile(sinkPkgUrl);
                } else {
                    if (!Utils.isFunctionPackageUrlSupported(sinkPkgUrl)) {
                        throw new IllegalArgumentException("Function Package url is not valid. supported url (http/https/file)");
                    }
                    try {
                        componentPackageFile = FunctionCommon.extractFileFromPkgURL(sinkPkgUrl);
                    } catch (Exception e) {
                        throw new IllegalArgumentException(String.format("Encountered error \"%s\" when getting %s package from %s", e.getMessage(), ComponentTypeUtils.toString(componentType), sinkPkgUrl));
                    }
                }
                functionDetails = validateUpdateRequestParams(tenant, namespace, sinkName, sinkConfig, componentPackageFile);
            } else {
                if (uploadedInputStream != null) {
                    componentPackageFile = WorkerUtils.dumpToTmpFile(uploadedInputStream);
                }
                functionDetails = validateUpdateRequestParams(tenant, namespace, sinkName, sinkConfig, componentPackageFile);
                if (!isFunctionCodeBuiltin(functionDetails) && (componentPackageFile == null || fileDetail == null)) {
                    throw new IllegalArgumentException(ComponentTypeUtils.toString(componentType) + " Package is not provided");
                }
            }
        } catch (Exception e) {
            log.error("Invalid register {} request @ /{}/{}/{}", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName, e);
            throw new RestException(Response.Status.BAD_REQUEST, e.getMessage());
        }
        try {
            worker().getFunctionRuntimeManager().getRuntimeFactory().doAdmissionChecks(functionDetails);
        } catch (Exception e) {
            log.error("{} {}/{}/{} cannot be admitted by the runtime factory", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName);
            throw new RestException(Response.Status.BAD_REQUEST, String.format("%s %s cannot be admitted:- %s", ComponentTypeUtils.toString(componentType), sinkName, e.getMessage()));
        }
        // function state
        Function.FunctionMetaData.Builder functionMetaDataBuilder = Function.FunctionMetaData.newBuilder().setFunctionDetails(functionDetails).setCreateTime(System.currentTimeMillis()).setVersion(0);
        // cache auth if need
        if (worker().getWorkerConfig().isAuthenticationEnabled()) {
            Function.FunctionDetails finalFunctionDetails = functionDetails;
            worker().getFunctionRuntimeManager().getRuntimeFactory().getAuthProvider().ifPresent(functionAuthProvider -> {
                if (clientAuthenticationDataHttps != null) {
                    try {
                        Optional<FunctionAuthData> functionAuthData = functionAuthProvider.cacheAuthData(finalFunctionDetails, clientAuthenticationDataHttps);
                        functionAuthData.ifPresent(authData -> functionMetaDataBuilder.setFunctionAuthSpec(Function.FunctionAuthenticationSpec.newBuilder().setData(ByteString.copyFrom(authData.getData())).build()));
                    } catch (Exception e) {
                        log.error("Error caching authentication data for {} {}/{}/{}", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName, e);
                        throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, String.format("Error caching authentication data for %s %s:- %s", ComponentTypeUtils.toString(componentType), sinkName, e.getMessage()));
                    }
                }
            });
        }
        Function.PackageLocationMetaData.Builder packageLocationMetaDataBuilder;
        try {
            packageLocationMetaDataBuilder = getFunctionPackageLocation(functionMetaDataBuilder.build(), sinkPkgUrl, fileDetail, componentPackageFile);
        } catch (Exception e) {
            log.error("Failed process {} {}/{}/{} package: ", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName, e);
            throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
        }
        functionMetaDataBuilder.setPackageLocation(packageLocationMetaDataBuilder);
        updateRequest(null, functionMetaDataBuilder.build());
    } finally {
        if (componentPackageFile != null && componentPackageFile.exists()) {
            if (sinkPkgUrl == null || !sinkPkgUrl.startsWith(Utils.FILE)) {
                componentPackageFile.delete();
            }
        }
    }
}
Also used : RestException(org.apache.pulsar.common.util.RestException) ByteString(com.google.protobuf.ByteString) RestUtils.throwUnavailableException(org.apache.pulsar.functions.worker.rest.RestUtils.throwUnavailableException) RestException(org.apache.pulsar.common.util.RestException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) IOException(java.io.IOException) WebApplicationException(javax.ws.rs.WebApplicationException) Function(org.apache.pulsar.functions.proto.Function) FunctionMetaDataManager(org.apache.pulsar.functions.worker.FunctionMetaDataManager) FunctionAuthData(org.apache.pulsar.functions.auth.FunctionAuthData) FunctionAuthUtils.getFunctionAuthData(org.apache.pulsar.functions.auth.FunctionAuthUtils.getFunctionAuthData) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) File(java.io.File)

Example 14 with RestException

use of org.apache.pulsar.common.util.RestException in project pulsar by apache.

the class SinksImpl method getSinkStatus.

@Override
public SinkStatus getSinkStatus(final String tenant, final String namespace, final String componentName, final URI uri, final String clientRole, final AuthenticationDataSource clientAuthenticationDataHttps) {
    // validate parameters
    componentStatusRequestValidate(tenant, namespace, componentName, clientRole, clientAuthenticationDataHttps);
    SinkStatus sinkStatus;
    try {
        sinkStatus = new GetSinkStatus().getComponentStatus(tenant, namespace, componentName, uri);
    } catch (WebApplicationException we) {
        throw we;
    } catch (Exception e) {
        log.error("{}/{}/{} Got Exception Getting Status", tenant, namespace, componentName, e);
        throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
    return sinkStatus;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) RestException(org.apache.pulsar.common.util.RestException) SinkStatus(org.apache.pulsar.common.policies.data.SinkStatus) RestUtils.throwUnavailableException(org.apache.pulsar.functions.worker.rest.RestUtils.throwUnavailableException) RestException(org.apache.pulsar.common.util.RestException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) IOException(java.io.IOException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 15 with RestException

use of org.apache.pulsar.common.util.RestException in project pulsar by apache.

the class SinksImpl method updateSink.

@Override
public void updateSink(final String tenant, final String namespace, final String sinkName, final InputStream uploadedInputStream, final FormDataContentDisposition fileDetail, final String sinkPkgUrl, final SinkConfig sinkConfig, final String clientRole, AuthenticationDataSource clientAuthenticationDataHttps, UpdateOptionsImpl updateOptions) {
    if (!isWorkerServiceAvailable()) {
        throwUnavailableException();
    }
    if (tenant == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Tenant is not provided");
    }
    if (namespace == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Namespace is not provided");
    }
    if (sinkName == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Sink name is not provided");
    }
    if (sinkConfig == null) {
        throw new RestException(Response.Status.BAD_REQUEST, "Sink config is not provided");
    }
    try {
        if (!isAuthorizedRole(tenant, namespace, clientRole, clientAuthenticationDataHttps)) {
            log.warn("{}/{}/{} Client [{}] is not authorized to update {}", tenant, namespace, sinkName, clientRole, ComponentTypeUtils.toString(componentType));
            throw new RestException(Response.Status.UNAUTHORIZED, "Client is not authorized to perform operation");
        }
    } catch (PulsarAdminException e) {
        log.error("{}/{}/{} Failed to authorize [{}]", tenant, namespace, sinkName, e);
        throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
    FunctionMetaDataManager functionMetaDataManager = worker().getFunctionMetaDataManager();
    if (!functionMetaDataManager.containsFunction(tenant, namespace, sinkName)) {
        throw new RestException(Response.Status.BAD_REQUEST, String.format("%s %s doesn't exist", ComponentTypeUtils.toString(componentType), sinkName));
    }
    Function.FunctionMetaData existingComponent = functionMetaDataManager.getFunctionMetaData(tenant, namespace, sinkName);
    if (!InstanceUtils.calculateSubjectType(existingComponent.getFunctionDetails()).equals(componentType)) {
        log.error("{}/{}/{} is not a {}", tenant, namespace, sinkName, ComponentTypeUtils.toString(componentType));
        throw new RestException(Response.Status.NOT_FOUND, String.format("%s %s doesn't exist", ComponentTypeUtils.toString(componentType), sinkName));
    }
    SinkConfig existingSinkConfig = SinkConfigUtils.convertFromDetails(existingComponent.getFunctionDetails());
    // The rest end points take precedence over whatever is there in functionconfig
    sinkConfig.setTenant(tenant);
    sinkConfig.setNamespace(namespace);
    sinkConfig.setName(sinkName);
    SinkConfig mergedConfig;
    try {
        mergedConfig = SinkConfigUtils.validateUpdate(existingSinkConfig, sinkConfig);
    } catch (Exception e) {
        throw new RestException(Response.Status.BAD_REQUEST, e.getMessage());
    }
    if (existingSinkConfig.equals(mergedConfig) && isBlank(sinkPkgUrl) && uploadedInputStream == null) {
        log.error("{}/{}/{} Update contains no changes", tenant, namespace, sinkName);
        throw new RestException(Response.Status.BAD_REQUEST, "Update contains no change");
    }
    Function.FunctionDetails functionDetails = null;
    File componentPackageFile = null;
    try {
        // validate parameters
        try {
            if (isNotBlank(sinkPkgUrl)) {
                if (Utils.hasPackageTypePrefix(sinkPkgUrl)) {
                    componentPackageFile = downloadPackageFile(sinkPkgUrl);
                } else {
                    try {
                        componentPackageFile = FunctionCommon.extractFileFromPkgURL(sinkPkgUrl);
                    } catch (Exception e) {
                        throw new IllegalArgumentException(String.format("Encountered error \"%s\" when getting %s package from %s", e.getMessage(), ComponentTypeUtils.toString(componentType), sinkPkgUrl));
                    }
                }
                functionDetails = validateUpdateRequestParams(tenant, namespace, sinkName, mergedConfig, componentPackageFile);
            } else if (existingComponent.getPackageLocation().getPackagePath().startsWith(Utils.FILE) || existingComponent.getPackageLocation().getPackagePath().startsWith(Utils.HTTP)) {
                try {
                    componentPackageFile = FunctionCommon.extractFileFromPkgURL(existingComponent.getPackageLocation().getPackagePath());
                } catch (Exception e) {
                    throw new IllegalArgumentException(String.format("Encountered error \"%s\" when getting %s package from %s", e.getMessage(), ComponentTypeUtils.toString(componentType), sinkPkgUrl));
                }
                functionDetails = validateUpdateRequestParams(tenant, namespace, sinkName, mergedConfig, componentPackageFile);
            } else if (uploadedInputStream != null) {
                componentPackageFile = WorkerUtils.dumpToTmpFile(uploadedInputStream);
                functionDetails = validateUpdateRequestParams(tenant, namespace, sinkName, mergedConfig, componentPackageFile);
            } else if (existingComponent.getPackageLocation().getPackagePath().startsWith(Utils.BUILTIN)) {
                functionDetails = validateUpdateRequestParams(tenant, namespace, sinkName, mergedConfig, componentPackageFile);
                if (!isFunctionCodeBuiltin(functionDetails) && (componentPackageFile == null || fileDetail == null)) {
                    throw new IllegalArgumentException(ComponentTypeUtils.toString(componentType) + " Package is not provided");
                }
            } else {
                componentPackageFile = FunctionCommon.createPkgTempFile();
                componentPackageFile.deleteOnExit();
                WorkerUtils.downloadFromBookkeeper(worker().getDlogNamespace(), componentPackageFile, existingComponent.getPackageLocation().getPackagePath());
                functionDetails = validateUpdateRequestParams(tenant, namespace, sinkName, mergedConfig, componentPackageFile);
            }
        } catch (Exception e) {
            log.error("Invalid update {} request @ /{}/{}/{}", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName, e);
            throw new RestException(Response.Status.BAD_REQUEST, e.getMessage());
        }
        try {
            worker().getFunctionRuntimeManager().getRuntimeFactory().doAdmissionChecks(functionDetails);
        } catch (Exception e) {
            log.error("Updated {} {}/{}/{} cannot be submitted to runtime factory", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName);
            throw new RestException(Response.Status.BAD_REQUEST, String.format("%s %s cannot be admitted:- %s", ComponentTypeUtils.toString(componentType), sinkName, e.getMessage()));
        }
        // merge from existing metadata
        Function.FunctionMetaData.Builder functionMetaDataBuilder = Function.FunctionMetaData.newBuilder().mergeFrom(existingComponent).setFunctionDetails(functionDetails);
        // update auth data if need
        if (worker().getWorkerConfig().isAuthenticationEnabled()) {
            Function.FunctionDetails finalFunctionDetails = functionDetails;
            worker().getFunctionRuntimeManager().getRuntimeFactory().getAuthProvider().ifPresent(functionAuthProvider -> {
                if (clientAuthenticationDataHttps != null && updateOptions != null && updateOptions.isUpdateAuthData()) {
                    // get existing auth data if it exists
                    Optional<FunctionAuthData> existingFunctionAuthData = Optional.empty();
                    if (functionMetaDataBuilder.hasFunctionAuthSpec()) {
                        existingFunctionAuthData = Optional.ofNullable(getFunctionAuthData(Optional.ofNullable(functionMetaDataBuilder.getFunctionAuthSpec())));
                    }
                    try {
                        Optional<FunctionAuthData> newFunctionAuthData = functionAuthProvider.updateAuthData(finalFunctionDetails, existingFunctionAuthData, clientAuthenticationDataHttps);
                        if (newFunctionAuthData.isPresent()) {
                            functionMetaDataBuilder.setFunctionAuthSpec(Function.FunctionAuthenticationSpec.newBuilder().setData(ByteString.copyFrom(newFunctionAuthData.get().getData())).build());
                        } else {
                            functionMetaDataBuilder.clearFunctionAuthSpec();
                        }
                    } catch (Exception e) {
                        log.error("Error updating authentication data for {} {}/{}/{}", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName, e);
                        throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, String.format("Error caching authentication data for %s %s:- %s", ComponentTypeUtils.toString(componentType), sinkName, e.getMessage()));
                    }
                }
            });
        }
        Function.PackageLocationMetaData.Builder packageLocationMetaDataBuilder;
        if (isNotBlank(sinkPkgUrl) || uploadedInputStream != null) {
            try {
                packageLocationMetaDataBuilder = getFunctionPackageLocation(functionMetaDataBuilder.build(), sinkPkgUrl, fileDetail, componentPackageFile);
            } catch (Exception e) {
                log.error("Failed process {} {}/{}/{} package: ", ComponentTypeUtils.toString(componentType), tenant, namespace, sinkName, e);
                throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
            }
        } else {
            packageLocationMetaDataBuilder = Function.PackageLocationMetaData.newBuilder().mergeFrom(existingComponent.getPackageLocation());
        }
        functionMetaDataBuilder.setPackageLocation(packageLocationMetaDataBuilder);
        updateRequest(existingComponent, functionMetaDataBuilder.build());
    } finally {
        if (componentPackageFile != null && componentPackageFile.exists()) {
            if ((sinkPkgUrl != null && !sinkPkgUrl.startsWith(Utils.FILE)) || uploadedInputStream != null) {
                componentPackageFile.delete();
            }
        }
    }
}
Also used : RestException(org.apache.pulsar.common.util.RestException) RestUtils.throwUnavailableException(org.apache.pulsar.functions.worker.rest.RestUtils.throwUnavailableException) RestException(org.apache.pulsar.common.util.RestException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) IOException(java.io.IOException) WebApplicationException(javax.ws.rs.WebApplicationException) Function(org.apache.pulsar.functions.proto.Function) SinkConfig(org.apache.pulsar.common.io.SinkConfig) FunctionMetaDataManager(org.apache.pulsar.functions.worker.FunctionMetaDataManager) FunctionAuthData(org.apache.pulsar.functions.auth.FunctionAuthData) FunctionAuthUtils.getFunctionAuthData(org.apache.pulsar.functions.auth.FunctionAuthUtils.getFunctionAuthData) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) File(java.io.File)

Aggregations

RestException (org.apache.pulsar.common.util.RestException)178 IOException (java.io.IOException)101 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)101 WebApplicationException (javax.ws.rs.WebApplicationException)66 FunctionMetaDataManager (org.apache.pulsar.functions.worker.FunctionMetaDataManager)65 RestUtils.throwUnavailableException (org.apache.pulsar.functions.worker.rest.RestUtils.throwUnavailableException)54 Test (org.testng.annotations.Test)45 File (java.io.File)41 FunctionMetaData (org.apache.pulsar.functions.proto.Function.FunctionMetaData)36 Function (org.apache.pulsar.functions.proto.Function)33 Namespace (org.apache.distributedlog.api.namespace.Namespace)21 SchemaSerializationException (org.apache.pulsar.client.api.SchemaSerializationException)21 ExecutionException (java.util.concurrent.ExecutionException)18 NamespaceNotFoundException (org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)18 StreamNotFoundException (org.apache.bookkeeper.clients.exceptions.StreamNotFoundException)18 FunctionAuthData (org.apache.pulsar.functions.auth.FunctionAuthData)18 FunctionAuthUtils.getFunctionAuthData (org.apache.pulsar.functions.auth.FunctionAuthUtils.getFunctionAuthData)18 FunctionRuntimeManager (org.apache.pulsar.functions.worker.FunctionRuntimeManager)15 URI (java.net.URI)14 FunctionConfig (org.apache.pulsar.common.functions.FunctionConfig)12