This document includes some useful information for how to integrate and automate some JobServer functions within your IT tools and environment
JobServer exposes some of its user and admin functions through a lightweight web services API. This can allow developers to integrate external tools and applications with JobServer. There are currently several operations that are available and they include.
JobServer uses the Hessian framework for accessing web services controls over the
JobServer environment. This is a Java binary web services
API that is very easy to use and integrate with. It allows building a simple application
using a simple Java API. All you need to do is compile your app with
the hessian.jar and jobserver-webservice.jar. You can locate these
jars in your JobServer instalaltion at jobserver/sys/lib/sdk.
Here the Java interface to use
in your Java client to access JobServer web services:
/**
* JobServer interfaces exposed via light-weight Hessian web services.
*
* @author Grand Logic, Inc.
*/
public interface JobServerOpenService {
/**
* Return the status of the JobServer engine.
*
* @return Return code:
* 1 Server NOT running: Container available
* 2 Server running: scheduler/queue enabled
* 3 Server running: scheduler/queue disabled
* 4 Server running: queue enabled & scheduler diabled
* 5 Server running: in graceful shutdown mode
* 6 Server running: in immediate shutdown mode
* 7 Server NOT running: Container NOT available
*/
public int jobserverContainerStatus();
/**
* Check if web server is alive and responding. If request is successful
* it indicates JobServer's web server is running.
*/
public void webserverHeartBeat();
/**
* Trigger job to run immediately.
*
* @param username User must have rights to access and run this job.
* @param password
* @param jobid Job to run
*
* @return 0 went well
* -1 JobServer not running
* -2 Job not found
* -3 invalid user/pass or job rights
* -4 some internal problem
*/
public int triggerJob(String username, String password, long jobid);
/**
* Trigger job to run immediately.
*
* @param username User must have rights to access and run this job.
* @param password
* @param jobid Job to run
* @param properties A Map of properties (name/value pairs) passed to the
JobContext when job is run.
*
* @return 0 went well
* -1 JobServer not running
* -2 Job not found
* -3 invalid user/pass or job rights
* -4 some internal problem
*/
public int triggerJob(String username, String password, long jobid,
Map properties);
/**
* Trigger job to run immediately.
*
* @param username User must have rights to access and run this job.
* @param password
* @param jobid Job to run
* @param properties A Map of properties (name/value pairs) passed to the JobContext
when job is run.
* @param startTime Optional start time marker to pass to job wen it runs. Set null
if not used.
* @param endTime Optional end time marker to pass to job when it runs. Set null if
not used.
*
* @return 0 went well
* -1 JobServer not running
* -2 Job not found
* -3 invalid user/pass or job rights
* -4 some internal problem
*/
public int triggerJob(String username, String password, long jobid, Map properties,
Calendar startTime, Calendar endTime);
/**
* Suspending job scheduling on a dependency rule will prevent a job,
* that is associated to this dependency rule, from being scheduled regardless
* of what the jobs schedule.
*
* @param username User must have rights to the job
* @param password
* @param dependencyRuleName
*
* @return 0 successful
* -1 rule name not found (not yet implemented)
* -2 invalid user/pass
* -3 some internal problem
*/
public int setJobSchedulingSuspended(String username, String password, String dependencyRuleName);
/**
* Allowing job scheduling on a dependency rule will allow a job,
* that is associated to this dependency rule, to run normally. In this
* state the dependency rule does not impact the job's schedule in
* any way.
*
* @param username User must have rights to the job
* @param password
* @param dependencyRuleName
*
* @return 0 successful
* -1 rule name not found (not yet implemented)
* -2 invalid user/pass
* -3 some internal problem
*/
public int setJobSchedulingAllowed(String username, String password, String dependencyRuleName);
/**
* Allowing job scheduling on a dependency rule will allow a job,
* that is associated to this dependency rule, to run normally only
* within the start and end time ranges provided. Outside these
* start/end time ranges the job will be prevented from being
* scheduled.
*
* @param username User must have rights to the job
* @param password
* @param dependencyRuleName
* @param start the start date at which the rule will
* allow for a job to be scheduled. null
* means start date range extends infinitly into the past.
*
* @param end the end date at which the rule will
* allow for a job to be scheduled. null
* means expire date range extends infinitly into the future.
*
* @return 0 successful
* -1 rule name not found (not yet implemented)
* -2 invalid user/pass
* -3 some internal problem
*/
public int setJobSchedulingAllowed(String username, String password, String dependencyRuleName,
Calendar start, Calendar end);
}
Below is a simple example of a simple Java
standalone application that can make web services calls to JobServer. The URI to access the web services is
http://<HOSTNAME>:<WEB_PORT>/jobserver/simplesoa.
.
.
.
String hostname="myserver";
int jobserverWebPort=8020;
String sturl = "http://" + hostname + ":" + jobserverWebPort + "/jobserver/simplesoa";
HessianProxyFactory factory = new HessianProxyFactory();
JobServerService service = (JobServerService) factory.create(JobServerService.class, sturl);
service.webserverHeartBeat();
.
.
.
This simple example shows you easy it is use JobServer's web services Hessian interfaces. Include
this code in any Java server or client and you can access any method/service available from the
JobServerOpenService interface.