Class ScopeEventingFunctionManager

java.lang.Object
com.couchbase.client.java.manager.eventing.ScopeEventingFunctionManager

@Volatile public class ScopeEventingFunctionManager extends Object
Performs management operations on EventingFunctions.
  • Constructor Details

  • Method Details

    • upsertFunction

      public void upsertFunction(EventingFunction function)
      Inserts or replaces a EventingFunction.

      The eventing management API defines that if a function is stored which name does not exist yet, it will be inserted. If the name already exists, the function will be replaced with its new equivalent and the properties changed.

      Operations which change the runtime-state of a function (i.e. deploy / undeploy / pause / resume) should not be modified through this method, but rather by using those methods directly (i.e. deployFunction(String)).

      Parameters:
      function - the function to be inserted or replaced.
      Throws:
      com.couchbase.client.core.error.EventingFunctionCompilationFailureException - if the function body cannot be compiled.
      com.couchbase.client.core.error.CollectionNotFoundException - if the specified collection or scope does not exist.
      com.couchbase.client.core.error.BucketNotFoundException - if the specified bucket does not exist.
      com.couchbase.client.core.error.EventingFunctionIdenticalKeyspaceException - if the source and metadata keyspace are the same.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • upsertFunction

      public void upsertFunction(EventingFunction function, UpsertFunctionOptions options)
      Inserts or replaces a EventingFunction with custom options.

      The eventing management API defines that if a function is stored which name does not exist yet, it will be inserted. If the name already exists, the function will be replaced with its new equivalent and the properties changed.

      Operations which change the runtime-state of a function (i.e. deploy / undeploy / pause / resume) should not be modified through this method, but rather by using those methods directly (i.e. deployFunction(String)).

      Parameters:
      function - the function to be inserted or replaced.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.EventingFunctionCompilationFailureException - if the function body cannot be compiled.
      com.couchbase.client.core.error.CollectionNotFoundException - if the specified collection or scope does not exist.
      com.couchbase.client.core.error.BucketNotFoundException - if the specified bucket does not exist.
      com.couchbase.client.core.error.EventingFunctionIdenticalKeyspaceException - if the source and metadata keyspace are the same.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getFunction

      public EventingFunction getFunction(String name)
      Retrieves a EventingFunction by its name.
      Parameters:
      name - the name of the function to retrieve.
      Returns:
      the eventing function found.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getFunction

      public EventingFunction getFunction(String name, GetFunctionOptions options)
      Retrieves a EventingFunction by its name with custom options.
      Parameters:
      name - the name of the function to retrieve.
      options - the custom options to apply.
      Returns:
      the eventing function found.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getAllFunctions

      public List<EventingFunction> getAllFunctions()
      Retrieves all EventingFunctions currently stored on the server.

      If no functions are found, an empty list is returned.

      Returns:
      eventing functions found or an empty list.
      Throws:
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • getAllFunctions

      public List<EventingFunction> getAllFunctions(GetAllFunctionsOptions options)
      Retrieves all EventingFunctions currently stored on the server with custom options.

      If no functions are found, an empty list is returned.

      Parameters:
      options - the custom options to apply.
      Returns:
      eventing functions found or an empty list.
      Throws:
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • dropFunction

      public void dropFunction(String name)
      Removes a EventingFunction by its name if it exists.

      Note that due to a bug on the server, depending on which version is used, both a EventingFunctionNotFoundException or a EventingFunctionNotDeployedException can be thrown if a function does not exist.

      Parameters:
      name - the name of the function to drop.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotDeployedException - if the function is not found on the server (see above).
      com.couchbase.client.core.error.EventingFunctionDeployedException - if the function is currently deployed (undeploy first).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • dropFunction

      public void dropFunction(String name, DropFunctionOptions options)
      Removes a EventingFunction by its name if it exists with custom options.

      Note that due to a bug on the server, depending on which version is used, both a EventingFunctionNotFoundException or a EventingFunctionNotDeployedException can be thrown if a function does not exist.

      Parameters:
      name - the name of the function to drop.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotDeployedException - if the function is not found on the server (see above).
      com.couchbase.client.core.error.EventingFunctionDeployedException - if the function is currently deployed (undeploy first).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • deployFunction

      public void deployFunction(String name)
      Deploys an EventingFunction identified by its name.

      Calling this method effectively moves the function from state EventingFunctionDeploymentStatus.UNDEPLOYED to state EventingFunctionDeploymentStatus.DEPLOYED.

      Parameters:
      name - the name of the function to deploy.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotBootstrappedException - if the function is not bootstrapped yet (after creating it).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • deployFunction

      public void deployFunction(String name, DeployFunctionOptions options)
      Deploys an EventingFunction identified by its name with custom options.

      Calling this method effectively moves the function from state EventingFunctionDeploymentStatus.UNDEPLOYED to state EventingFunctionDeploymentStatus.DEPLOYED.

      Parameters:
      name - the name of the function to deploy.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotBootstrappedException - if the function is not bootstrapped yet (after creating it).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • undeployFunction

      public void undeployFunction(String name)
      Undeploys an EventingFunction identified by its name.

      Calling this method effectively moves the function from state EventingFunctionDeploymentStatus.DEPLOYED to state EventingFunctionDeploymentStatus.UNDEPLOYED.

      Note that due to a bug on the server, depending on which version is used, both a EventingFunctionNotFoundException or a EventingFunctionNotDeployedException can be thrown if a function does not exist.

      Parameters:
      name - the name of the function to undeploy.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotDeployedException - if the function is not found on the server (see above).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • undeployFunction

      public void undeployFunction(String name, UndeployFunctionOptions options)
      Undeploys an EventingFunction identified by its name with custom options.

      Calling this method effectively moves the function from state EventingFunctionDeploymentStatus.DEPLOYED to state EventingFunctionDeploymentStatus.UNDEPLOYED.

      Note that due to a bug on the server, depending on which version is used, both a EventingFunctionNotFoundException or a EventingFunctionNotDeployedException can be thrown if a function does not exist.

      Parameters:
      name - the name of the function to undeploy.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotDeployedException - if the function is not found on the server (see above).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • pauseFunction

      public void pauseFunction(String name)
      Pauses an EventingFunction identified by its name.

      Calling this method effectively moves the function from state EventingFunctionProcessingStatus.RUNNING to state EventingFunctionProcessingStatus.PAUSED.

      Parameters:
      name - the name of the function to pause.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotBootstrappedException - if the function is not bootstrapped yet (after creating it).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • pauseFunction

      public void pauseFunction(String name, PauseFunctionOptions options)
      Pauses an EventingFunction identified by its name with custom options.

      Calling this method effectively moves the function from state EventingFunctionProcessingStatus.RUNNING to state EventingFunctionProcessingStatus.PAUSED.

      Parameters:
      name - the name of the function to pause.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotBootstrappedException - if the function is not bootstrapped yet (after creating it).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • resumeFunction

      public void resumeFunction(String name)
      Resumes an EventingFunction identified by its name.

      Calling this method effectively moves the function from state EventingFunctionProcessingStatus.PAUSED to state EventingFunctionProcessingStatus.RUNNING.

      Note that due to a bug on the server, depending on which version is used, both a EventingFunctionNotFoundException or a EventingFunctionNotDeployedException can be thrown if a function does not exist.

      Parameters:
      name - the name of the function to resume.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotDeployedException - if the function is not found on the server (see above).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • resumeFunction

      public void resumeFunction(String name, ResumeFunctionOptions options)
      Resumes an EventingFunction identified by its name with custom options.

      Calling this method effectively moves the function from state EventingFunctionProcessingStatus.PAUSED to state EventingFunctionProcessingStatus.RUNNING.

      Note that due to a bug on the server, depending on which version is used, both a EventingFunctionNotFoundException or a EventingFunctionNotDeployedException can be thrown if a function does not exist.

      Parameters:
      name - the name of the function to resume.
      options - the custom options to apply.
      Throws:
      com.couchbase.client.core.error.EventingFunctionNotFoundException - if the function is not found on the server.
      com.couchbase.client.core.error.EventingFunctionNotDeployedException - if the function is not found on the server (see above).
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • functionsStatus

      public EventingStatus functionsStatus()
      Retrieves helpful status information about all functions currently created on the cluster.
      Returns:
      the eventing status.
      Throws:
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.
    • functionsStatus

      public EventingStatus functionsStatus(FunctionsStatusOptions options)
      Retrieves helpful status information about all functions currently created on the cluster with custom options.
      Parameters:
      options - the custom options to apply.
      Returns:
      the eventing status.
      Throws:
      com.couchbase.client.core.error.CouchbaseException - if any other generic unhandled/unexpected errors.