2015-05-06 17:16:10 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2015-05-06 17:16:10 +08:00
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/string.hpp"
|
|
|
|
|
#include "../redis/redis_command.hpp"
|
2015-05-06 17:16:10 +08:00
|
|
|
|
|
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
typedef class redis_client disque_client;
|
|
|
|
|
typedef class redis_client_pool disque_client_pool;
|
|
|
|
|
typedef class redis_client_cluster disque_client_cluster;
|
|
|
|
|
class disque_cond;
|
|
|
|
|
class disque_node;
|
|
|
|
|
class disque_job;
|
|
|
|
|
|
2015-09-08 17:21:04 +08:00
|
|
|
|
/**
|
|
|
|
|
* disque <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2015-05-06 17:16:10 +08:00
|
|
|
|
class ACL_CPP_API disque : virtual public redis_command
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command()
|
|
|
|
|
*/
|
|
|
|
|
disque();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command(redis_client*)
|
|
|
|
|
*/
|
|
|
|
|
disque(redis_client* conn);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command(redis_client_cluster*<EFBFBD><EFBFBD> size_t)
|
|
|
|
|
*/
|
|
|
|
|
disque(redis_client_cluster* cluster, size_t max_conns);
|
|
|
|
|
|
|
|
|
|
virtual ~disque();
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* add a job to the specified queue
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param name {const char*} the name of the specified queue
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param job {const char*} a message to deliver
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param timeout {int} the command timeout in milliseconds
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>еij<EFBFBD>ʱʱ<EFBFBD>䣨<EFBFBD><EFBFBD><EFBFBD>룩
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param args {const std::map<acl::string, int>*} the condition
|
|
|
|
|
* for ADDJOB command, the conditions name include:
|
|
|
|
|
* REPLICATE, DELAY, RETRY, TTL, MAXLEN, ASYNC, if the args was NULL,
|
|
|
|
|
* none condition will be used in this operation
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EF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FBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {const char*} a ID of the job will be returned, NULL will
|
|
|
|
|
* be returned if some error happened.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
const char* addjob(const char* name, const char* job,
|
|
|
|
|
int timeout, const std::map<string, int>* args = NULL);
|
|
|
|
|
const char* addjob(const char* name, const string& job,
|
|
|
|
|
int timeout, const std::map<string, int>* args = NULL);
|
|
|
|
|
const char* addjob(const char* name, const void* job, size_t job_len,
|
|
|
|
|
int timeout, const std::map<string, int>* args = NULL);
|
|
|
|
|
|
|
|
|
|
/**
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* add a job to the specified queue
|
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param name {const char*} the name of the specified queue
|
|
|
|
|
* ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param job {const char*} a message to deliver
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout {int} the command timeout in milliseconds
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>뾫<EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param cond {const acl::disque_cond*} the condition for the ADDJOB
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD> disque_cond
|
|
|
|
|
* @return {const char*} a ID of the job will be returned, NULL will
|
|
|
|
|
* be returned if some error happened.
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
const char* addjob(const char* name, const char* job,
|
|
|
|
|
int timeout, const disque_cond* cond);
|
|
|
|
|
const char* addjob(const char* name, const string& job,
|
|
|
|
|
int timeout, const disque_cond* cond);
|
|
|
|
|
const char* addjob(const char* name, const void* job, size_t job_len,
|
|
|
|
|
int timeout, const disque_cond* cond);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get jobs from the specified queues, or return NULL if the timeout
|
|
|
|
|
* is reached.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>м<EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>ȡָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param names {const std::vector<acl::string>&} the specified queues
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param timeout {int} the command timeout in milliseconds
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>뾫<EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param count {size_t} the max count of the jobs to be got
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* ָ<EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {const std::vector<acl::disque_job*>*} return the jobs,
|
|
|
|
|
* or return NULL if the timeout is reached or some error happens.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
const std::vector<disque_job*>* getjob(const std::vector<string>& names,
|
|
|
|
|
size_t timeout, size_t count);
|
2015-09-08 17:21:04 +08:00
|
|
|
|
const std::vector<disque_job*>* getjob(const char* name,
|
|
|
|
|
size_t timeout, size_t count);
|
2015-05-06 17:16:10 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* acknowledge the execution of one or more jobs via IDs. The node
|
|
|
|
|
* receiving the ACK will replicate it to multiple nodes and will try
|
|
|
|
|
* to garbage collect both the job and the ACKs from the cluster so
|
|
|
|
|
* that memory can be freed.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> ACK <EFBFBD><EFBFBD>Ϣ<EFBFBD>Ľڵ<EFBFBD><EFBFBD>Ὣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㣬 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>Ⱥ<EFBFBD><EFBFBD> ACK <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>Ӷ<EFBFBD><EFBFBD>ͷ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD>ռ<EFBFBD>õ<EFBFBD><EFBFBD>ڴ档
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param job_ids {const std::vector<acl::string>&} the jobs' IDs
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {int} return the number of IDs been ACKed, -1 will be
|
|
|
|
|
* returned if some error happened
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ȷ<EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
int ackjob(const std::vector<string>& job_ids);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* perform a best effort cluster wide detection of the specified
|
|
|
|
|
* job IDs.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŭ<EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>Ⱥ<EFBFBD><EFBFBD>Χ<EFBFBD>ڶԸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EF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D><EFBFBD><EFBFBD> ACKJOB <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD>η<EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param job_ids {const std::vector<acl::string>&} the jobs' IDs
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {int} return the number of IDs been ACKed, -1 will be
|
|
|
|
|
* returned if some error happened
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ȷ<EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
int fastack(const std::vector<string>& job_ids);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* peek some jobs no more than the specified count from the specified
|
|
|
|
|
* queue and remain these jobs in queue.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD>ڲ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD> <EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>淵<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param name {const char*} the specified queue
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* ָ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param count {int} limit the max count of jobs to be got
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {const std::vector<acl::disque_job*>*} return the jobs
|
|
|
|
|
* if the queue isn't empty. NULL will be returned if the queue
|
|
|
|
|
* is empty or some error happened.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
const std::vector<disque_job*>* qpeek(const char* name, int count);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the number of jobs stored in the specified queue
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param name {const char*} the specified queue
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* ָ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {int} return the number of the jobs in queue
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
int qlen(const char* name);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the stat information of the specified job by job id
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param job_id {const char*} the id of the job
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {const acl::disque_job*} return the job's information,
|
|
|
|
|
* return NULL if the job doesn't exist or some error happens.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD> disque_job<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
const disque_job* show(const char* job_id);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* queue jobs if not already queued
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>뵽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param job_ids {const std::vector<acl::string>&} the job IDs
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {int} return the number of jobs been queued, -1 will be
|
|
|
|
|
* returned if some error happens.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
int enqueue(const std::vector<string>& job_ids);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* remove the jobs from the queue
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param job_ids {const std::vector<acl::string>&} the job IDs
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {int} return the number of jobs been removed, -1 will be
|
|
|
|
|
* returned if some error happens.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
int dequeue(const std::vector<string>& job_ids);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* completely delete a job from a node.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD>ڽڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>泹<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FASTACK <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD> Ψһ<EFBFBD>IJ<EFBFBD>ͬ<EFBFBD>ǣ<EFBFBD>
|
|
|
|
|
* DELJOB <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>У<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ὣ DELJOB <EFBFBD><EFBFBD>Ⱥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>cluster bus message<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param job_ids {const std::vector<acl::string>&} the job IDs
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {int} return the number of jobs been deleted, -1 will be
|
|
|
|
|
* returned if some error happens.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
int deljob(const std::vector<string>& job_ids);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* display the information of the disque cluster
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD>Ⱥ<EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>Ϣ
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @param out {std::map<acl::string, acl::string>&} store result
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {bool} if the operation is successful
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
bool info(std::map<string, string>& out);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the information of all the nodes in the cluster
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD>Ⱥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2015-05-06 17:16:10 +08:00
|
|
|
|
* @return {const std::vector<acl::disque_node*>*} all the nodes'
|
|
|
|
|
* information in the cluster, return NULL if some error happened.
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>Ⱥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL<EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD> disque_node
|
2015-05-06 17:16:10 +08:00
|
|
|
|
*/
|
|
|
|
|
const std::vector<disque_node*>* hello();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int jobs_bat(const std::vector<string>& job_ids, const char* cmd);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
disque_job* job_;
|
|
|
|
|
std::vector<disque_job*> jobs_;
|
|
|
|
|
|
|
|
|
|
const std::vector<disque_job*>* get_jobs(const char* name);
|
|
|
|
|
void free_jobs();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int version_;
|
|
|
|
|
string myid_;
|
|
|
|
|
std::vector<disque_node*> nodes_;
|
|
|
|
|
|
|
|
|
|
disque_node* create_node(const redis_result* rr);
|
|
|
|
|
void free_nodes();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|