org.apache.oozie.service
Class JobsConcurrencyService

java.lang.Object
  extended by org.apache.oozie.service.JobsConcurrencyService
All Implemented Interfaces:
Service, Instrumentable
Direct Known Subclasses:
ZKJobsConcurrencyService

public class JobsConcurrencyService
extends Object
implements Service, Instrumentable

This Service helps coordinate other Services to prevent duplicate processing of Jobs if there are multiple Oozie Servers. This implementation assumes that there are NO other Oozie Servers (i.e. not HA). The ZKJobsConcurrencyService provides a more meaningful implementation.


Field Summary
 
Fields inherited from interface org.apache.oozie.service.Service
CONF_PREFIX, DEFAULT_LOCK_TIMEOUT, lockTimeout, USE_XCOMMAND
 
Constructor Summary
JobsConcurrencyService()
           
 
Method Summary
 void destroy()
          Destroy the jobs concurrency service.
 Class<? extends Service> getInterface()
          Return the public interface for the jobs concurrency services
 List<String> getJobIdsForThisServer(List<String> ids)
          Filter out any job ids that should not be processed by this server.
 Map<String,String> getOtherServerUrls()
          Return a map of instance id to other Oozie servers URL in HA.
 Map<String,String> getServerUrls()
          Return a map of instance id to Oozie server URL.
 void init(Services services)
          Initialize the jobs concurrency service
 void instrument(Instrumentation instr)
          Instruments the jobs concurrency service.
 boolean isAllServerRequest(Map<String,String[]> params)
          Checks if rest request is for all server.
 boolean isHighlyAvailableMode()
          Check if it is running in HA mode
 boolean isJobIdForThisServer(String jobId)
          Check to see if jobId should be processed by this server.
 boolean isLeader()
          Check to see if this server is the first server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobsConcurrencyService

public JobsConcurrencyService()
Method Detail

init

public void init(Services services)
          throws ServiceException
Initialize the jobs concurrency service

Specified by:
init in interface Service
Parameters:
services - services instance.
Throws:
ServiceException - thrown if the service could not initialize.

destroy

public void destroy()
Destroy the jobs concurrency service.

Specified by:
destroy in interface Service

getInterface

public Class<? extends Service> getInterface()
Return the public interface for the jobs concurrency services

Specified by:
getInterface in interface Service
Returns:
JobsConcurrencyService.

instrument

public void instrument(Instrumentation instr)
Instruments the jobs concurrency service.

Specified by:
instrument in interface Instrumentable
Parameters:
instr - instance to instrument the jobs concurrency service to.

isLeader

public boolean isLeader()
Check to see if this server is the first server. This implementation always returns true.

Returns:
true

isJobIdForThisServer

public boolean isJobIdForThisServer(String jobId)
Check to see if jobId should be processed by this server. This implementation always returns true.

Parameters:
jobId - The jobId to check
Returns:
true

getJobIdsForThisServer

public List<String> getJobIdsForThisServer(List<String> ids)
Filter out any job ids that should not be processed by this server. This implementation always returns an unmodified list.

Parameters:
ids - The list of job ids to check
Returns:
ids

getServerUrls

public Map<String,String> getServerUrls()
Return a map of instance id to Oozie server URL. This implementation always returns a map with a single entry where the key is the OOZIE_INSTANCE_ID env var and the value is the URL (of this Oozie server).

Returns:
A map of Oozie instance ids and URLs
Throws:
Exception

getOtherServerUrls

public Map<String,String> getOtherServerUrls()
Return a map of instance id to other Oozie servers URL in HA. This implementation always returns a empty map.

Returns:
A map of Oozie instance ids and URLs
Throws:
Exception

isAllServerRequest

public boolean isAllServerRequest(Map<String,String[]> params)
Checks if rest request is for all server. This function always return false;

Parameters:
params - the HttpRequest param
Returns:
false.

isHighlyAvailableMode

public boolean isHighlyAvailableMode()
Check if it is running in HA mode

Returns:
false


Copyright © 2015 Apache Software Foundation. All Rights Reserved.