JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   On Github   Forums 

Job Metadata

From JPPF 5.1 Documentation

Jump to: navigation, search
Main Page > Development guide > Job Metadata


It is possible to attach user-defined metadata to a job, to describe the characteristics of the job and its tasks. This additional data can then be reused by customized load-balancing algorithms, to perform load balancing based on knowledge about the jobs. For instance, the metadata could provide information about the memory footprint of the tasks and about their duration, which can be critical data for the server, in order to determine on which nodes the job or tasks should be executed.

The job metadata is encapsulated in a specific class: JobMetadata, and can be accessed from the job as follows:

JPPFJob job = ...;
JobMetadata metaData = job.getMetadata();

JobMetadata is defined as follows:

public interface JobMetadata extends Metadata {
}

As for the data provider, the API is actually defined by the Metadata interface:

public interface Metadata extends Serializable {
  // Set a parameter in the metadata
  public void setParameter(Object key, Object value)
  // Retrieve a parameter in the metadata
  public Object getParameter(Object key)
  // Retrieve a parameter in the metadata
  public Object getParameter(Object key, Object defaultValue)
  // Remove a parameter from the metadata
  public Object removeParameter(Object key)
  // Get a the metadata map
  public Map<Object, Object> getAll()
  // Clear all the the metadata
  void clear();
}

Here is an example use:

JPPFJob job = ...;
JobMetadata metaData = job.getMetadata();
// set the memory footprint of each task to 10 KB
metaData.setParameter("task.footprint", "" + (10 * 1024));
// set the duration of each task to 80 milliseconds
metaData.setParameter("task.duration", "80");

Related sample: Custom Load Balancer.

Main Page > Development guide > Job Metadata

JPPF Copyright © 2005-2020 JPPF.org Powered by MediaWiki