public class ZKJobsConcurrencyService extends JobsConcurrencyService implements Service, Instrumentable
The distributed locks provided by ZKLocksService
will prevent any concurrency issues from occurring if multiple Oozie
Servers try to process the same job at the same time. However, this will make Oozie slower (more waiting on locks) and will
place additional stress on ZooKeeper and the Database. By "assigning" different Oozie servers to process different jobs, we can
improve this situation. This is particularly necessary for Services like the RecoveryService
, which could duplicate jobs
otherwise. We can assign jobs to servers by doing a mod of the jobs' id and the number of servers.
The leader server is elected by all of the Oozie servers, so there can only be one at a time. This is useful for tasks that require (or are better off) being done by only one server (e.g. database purging). Note that the leader server isn't a "traditional leader" in the sense that it doesn't command or have authority over the other servers. This leader election uses a znode under /oozie.zookeeper.namespace/ZK_BASE_SERVICES_PATH/ZK_LEADER_PATH (default is /oozie/services/concurrencyleader).
CONF_PREFIX, DEFAULT_LOCK_TIMEOUT, lockTimeout
Constructor and Description |
---|
ZKJobsConcurrencyService() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy the zookeeper jobs concurrency service.
|
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 Oozie server URL of other servers.
|
Map<String,String> |
getServerUrls()
Return a map of instance id to Oozie server URL.
|
void |
init(Services services)
Initialize the zookeeper jobs concurrency service
|
void |
instrument(Instrumentation instr)
Instruments the zk jobs concurrency service.
|
boolean |
isAllServerRequest(Map<String,String[]> params)
Checks if rest request is for all server.
|
boolean |
isHighlyAvailableMode()
Return 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 leader server.
|
getInterface
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInterface
public ZKJobsConcurrencyService()
public void init(Services services) throws ServiceException
init
in interface Service
init
in class JobsConcurrencyService
services
- services instance.ServiceException
- thrown if the service could not initialize.public void destroy()
destroy
in interface Service
destroy
in class JobsConcurrencyService
public void instrument(Instrumentation instr)
instrument
in interface Instrumentable
instrument
in class JobsConcurrencyService
instr
- instance to instrument the zookeeper jobs concurrency service to.public boolean isLeader()
isLeader
in class JobsConcurrencyService
public boolean isJobIdForThisServer(String jobId)
isJobIdForThisServer
in class JobsConcurrencyService
jobId
- The jobId to checkpublic List<String> getJobIdsForThisServer(List<String> ids)
getJobIdsForThisServer
in class JobsConcurrencyService
ids
- The list of job ids to checkpublic Map<String,String> getServerUrls()
getServerUrls
in class JobsConcurrencyService
public Map<String,String> getOtherServerUrls()
getOtherServerUrls
in class JobsConcurrencyService
public boolean isAllServerRequest(Map<String,String[]> params)
isAllServerRequest
in class JobsConcurrencyService
params
- the HttpRequest parampublic boolean isHighlyAvailableMode()
isHighlyAvailableMode
in class JobsConcurrencyService
Copyright © 2018 Apache Software Foundation. All rights reserved.