Chapter 32. Remote Task Execution


Tasks, or business logic, may be executed directly on JBoss Data Grid servers, allowing this logic to be executed close to the data and using the resources of all nodes in the cluster. These tasks may be bundled in java executables which are deployed to the server instances, and once deployed the tasks may be executed programmatically.

32.1. Creating a Remote Task

To create a task for remote execution a .jar file must be created containing a class that implements org.infinispan.tasks.ServerTask. This interface contains the following methods that must be implemented:
  • void setTaskContext(TaskContext taskContext) - sets the task context; should be used to access caches and other resources necessary.
  • String getName() - provides a unique name for the task. This is the name that will be used for execution by the TaskManager.
In addition to the above the following may be implemented; however, these are not required for execution:
  • TaskExecutionMethod getExecutionMode() - Determines if the task is executed on one node, TaskExecutionMode.ONE_NODE, or on all nodes, TaskExecutionMode.ALL_NODES. Execution on one node is enabled by default.
  • Optional<String> getAllowedRole() - Sets the role that may execute this task. By default no role is provided, indicating that no additional role is required for execution. Additional information on executing tasks is found in Section 32.4, “Running Remote Tasks”.
  • Set<String> getParameters() - A collection of named parameters for use with the task.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.