当前位置: 首页 > 编程日记 > 正文

聊聊jesque的几个dao

为什么80%的码农都做不了架构师?>>>   hot3.png

本文主要聊一下jesque的几个dao

dao列表

  • FailureDAO
  • KeysDAO
  • QueueInfoDAO
  • WorkerInfoDAO

FailureDAO

jesque-2.1.0-sources.jar!/net/greghaines/jesque/meta/dao/FailureDAO.java

/*** FailureDAO provides access to job failures.* * @author Greg Haines*/
public interface FailureDAO {/*** @return total number of failures*/long getCount();/*** @param offset offset into the failures* @param count number of failures to return* @return a sub-list of the failures*/List<JobFailure> getFailures(long offset, long count);/*** Clear the list of failures.*/void clear();/*** Re-queue a job for execution.* @param index the index into the failure list* @return the date the job was re-queued*/Date requeue(long index);/*** Remove a failure from the list.* @param index the index of the failure to remove*/void remove(long index);
}

主要操纵的是namespace:failed,是一个list类型

  • count

使用llen方法获取队列长度

  • clear

使用del删除namespace:failed队列

  • getFailures

使用lrange命令查询

  • requeue

根据index取出failed job,重新设定retry时间,放到入队列中

  • remove

根据index删,使用lrem,这里是先lset一个随机值,再根据这个随机值lrem

KeysDAO

jesque-2.1.0-sources.jar!/net/greghaines/jesque/meta/dao/KeysDAO.java

/*** KeysDAO provides access to available keys.* * @author Greg Haines*/
public interface KeysDAO {/*** Get basic key info.* @param key the key name* @return the key information or null if the key did not exist*/KeyInfo getKeyInfo(String key);/*** Get basic key info plus a sub-list of the array value for the key, if applicable.* @param key the key name* @param offset the offset into the array* @param count the number of values to return* @return the key information or null if the key did not exist*/KeyInfo getKeyInfo(String key, int offset, int count);/*** Get basic info on all keys.* @return a list of key informations*/List<KeyInfo> getKeyInfos();/*** @return information about the backing Redis database*/Map<String, String> getRedisInfo();
}
  • getKeyInfo

使用type获取类型

  • getKeyInfos

使用keys *方法

  • getRedisInfo

使用info

QueueInfoDAO

jesque-2.1.0-sources.jar!/net/greghaines/jesque/meta/dao/QueueInfoDAO.java

/*** QueueInfoDAO provides access to the queues in use by Jesque.* * @author Greg Haines*/
public interface QueueInfoDAO {/*** @return the list of queue names*/List<String> getQueueNames();/*** @return total number of jobs pending in all queues*/long getPendingCount();/*** @return total number of jobs processed*/long getProcessedCount();/*** @return the list of queue informations*/List<QueueInfo> getQueueInfos();/*** @param name the queue name* @param jobOffset the offset into the queue* @param jobCount the number of jobs to return* @return the queue information or null if the queue does not exist*/QueueInfo getQueueInfo(String name, long jobOffset, long jobCount);/*** Delete the given queue.* @param name the name of the queue*/void removeQueue(String name);
}
  • getQueueNames

使用smembers方法操作namespace:queues

  • getPendingCount

对每个queue计算大小,分queue类型

private long size(final Jedis jedis, final String queueName) {final String key = key(QUEUE, queueName);final long size;if (JedisUtils.isDelayedQueue(jedis, key)) { // If delayed queue, use ZCARDsize = jedis.zcard(key);} else { // Else, use LLENsize = jedis.llen(key);}return size;}

延时队列使用的是zcard操作SortSet 非延时队列使用llen操作list

  • getProcessedCount

直接查询stat的string对象

  • getQueueInfos

顺带计算每个queue的大小

  • removeQueue
public void removeQueue(final String name) {PoolUtils.doWorkInPoolNicely(this.jedisPool, new PoolWork<Jedis, Void>() {/*** {@inheritDoc}*/@Overridepublic Void doWork(final Jedis jedis) throws Exception {jedis.srem(key(QUEUES), name);jedis.del(key(QUEUE, name));return null;}});}

操作了queues以及queue两个对象

WorkerInfoDAO

jesque-2.1.0-sources.jar!/net/greghaines/jesque/meta/dao/WorkerInfoDAO.java

/*** WorkerInfoDAO provides access to information about workers.* * @author Greg Haines*/
public interface WorkerInfoDAO {/*** @return total number of workers known*/long getWorkerCount();/*** @return number of active workers*/long getActiveWorkerCount();/*** @return number of paused workers*/long getPausedWorkerCount();/*** @return information about all active workers*/List<WorkerInfo> getActiveWorkers();/*** @return information about all paused workers*/List<WorkerInfo> getPausedWorkers();/*** @return information about all workers*/List<WorkerInfo> getAllWorkers();/*** @param workerName the name of the worker* @return information about the given worker or null if that worker does not exist*/WorkerInfo getWorker(String workerName);/*** @return a map of worker informations by hostname*/Map<String, List<WorkerInfo>> getWorkerHostMap();/*** Removes the metadata about a worker.* * @param workerName*            The worker name to remove*/void removeWorker(String workerName);
}
  • getAllWorkers

smembers操作namespace:workers

  • getActiveWorkers

smembers操作namespace:workers,然后过来出来state是working的

  • getPausedWorkers

smembers操作namespace:workers,然后过来出来state是paused的

  • getWorkerCount

直接scard操作namespace:workers

  • getActiveWorkerCount

smembers操作namespace:workers,然后过来出来state是working的

  • getPausedWorkerCount

smembers操作namespace:workers,然后过来出来state是paused的

  • getWorkerHostMap

smembers操作namespace:workers,然后按照host来分map 这个基本是万能的,其他的count基本是这个衍生出来

  • removeWorker
public void removeWorker(final String workerName) {PoolUtils.doWorkInPoolNicely(this.jedisPool, new PoolWork<Jedis, Void>() {/*** {@inheritDoc}*/@Overridepublic Void doWork(final Jedis jedis) throws Exception {jedis.srem(key(WORKERS), workerName);jedis.del(key(WORKER, workerName), key(WORKER, workerName, STARTED), key(STAT, FAILED, workerName), key(STAT, PROCESSED, workerName));return null;}});}

操作works以及其他相关的对象

转载于:https://my.oschina.net/go4it/blog/1575699

相关文章:

Proxy与NAT有什么区别

在internet共享上网技术上,一般有两种方式,一种是proxy代理型,一种是NAT网关型,关于两者的区别与原理,身边很多人都不是很明白,下面我来讲讲我的理解,如有不对的,欢迎指正.1.先说应用例子:服务器端,用wingate就是Proxy,用sygate就是NAT客户端,需要在IE中设置代理服务器的就是用…

【转】ubuntu 12.04 下 Vim 插件 YouCompleteMe 的安装

原文网址&#xff1a;http://www.cnblogs.com/jostree/p/4137402.html 作者&#xff1a;jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4137402.html 1.需要保证vim的版本大于7.3.584&#xff0c;否则的话需要更新vim 可以通过第三方源更新&#xff1a; 在终端输入…

「倒计时」2021年移动云 API 应用创新开发大赛,你居然还没报名?!

移动云API应用创新开发大赛自成立举办以来&#xff0c;因赛事覆盖广、规模大、奖励高等、吸引了移动、企业、高校各赛道选手踊跃报名。目前活动火爆呈现白热化状态&#xff0c;截至目前为止&#xff0c;累计报名600人。现距离大赛报名截止仅剩5天&#xff01;&#xff01;&…

snort源码的详细分析

前段时间由于工作关系&#xff0c;对snort入侵检测系统进行了仔细的研究&#xff0c;起初基本都是通过网上找的资料&#xff0c;对于snort系统的应用&#xff0c;原理&#xff0c;架构&#xff0c;配置&#xff0c;源码机构网上都可以找到比较详细的资料&#xff0c;我自己用vs…

TCP/IP四层模型和OSI七层模型

TCP/IP四层模型和OSI七层模型对应表。我们把OSI七层网络模型和Linux TCP/IP四层概念模型对应&#xff0c;然后将各种网络协议归类。 表1-1 TCP/IP四层模型和OSI七层模型对应表 OSI七层网络模型 Linux TCP/IP四层概念模型 对应网络协议 应用层&#xff08;Application&am…

强化学习环境库 Gym 发布首个社区发布版,全面兼容 Python 3.9

作者&#xff1a;肖智清 来源&#xff1a;AI科技大本营 强化学习环境库Gym于2021年8月中旬迎来了首个社区志愿者维护的发布版Gym 0.19。该版本全面兼容Python 3.9&#xff0c;增加了多个新特性。 强化学习环境库的事实标准Gym迎来首个社区发布版 Gym库在强化学习领域可以说是…

SCOM电子书

SCOM电子书介绍转载于:https://blog.51cto.com/286722/1599625

京东二面的几个问题

1. tcp 连接的最大数量&#xff0c;tcp 用什么来标识 2. 多线程时如何避免互斥 3. protected 关键字 4. 动态库和静态库 5. 线程池 6.多继承时的虚表 网络编程需要加强转载于:https://www.cnblogs.com/simplepaul/p/7865777.html

服务器集群负载均衡(F5,LVS,DNS,CDN)区别以及选型

服务器集群负载均衡(F5,LVS,DNS,CDN)区别以及选型 下面是“黑夜路人”的《大型网站架构优化&#xff08;PHP&#xff09;与相关开源软件使用建议》 F5全称: F5-BIG-IP-GTM 全球流量管理器. 是一家叫F5 Networks的公司开发的四~七层交换机,软硬件捆绑. 据说最初用BSD系统,现在是…

linux下SVN不允许空白日志提交

在svn服务端通过hooks在提交时强制要求写日志。1. 在hooks目录里&#xff0c;复制文件pre-commit.tmpl到pre-commit2. 修改pre-commit文件&#xff0c;如下。#!/bin/shREPOS"$1"TXN"$2"SVNLOOK/usr/bin/svnlook #根据你的SVN目录而定LOGMSG$SVNLOOK log -t…

没有熙熙攘攘,百度VR在世界大会的一场奇妙之旅

你可听过玄奘西行的故事&#xff1f;没有猴子和女儿国&#xff0c;也没有鬼怪和妖魔&#xff0c;在那个故事里有的只是人心的善恶和风雨的折磨。相传&#xff0c;在玄奘走到楼兰时&#xff0c;曾被官兵追捕&#xff0c;他机缘巧合才悄悄逃出大狱。那茫茫大漠里&#xff0c;为避…

Ubuntu下搭建postgresql主从服务器(方法1)

Ubuntu下搭建postgresql主从服务器&#xff08;方法1&#xff09; 安装略 postgresql主服务器&#xff1a; $ vi /etc/postgresql/9.1/main/postgresql.conf 按a或i进入编辑模式 listen_addresses ‘*’ &#xff08;默认为注释的&#xff0c;此处不改从postgresql同步时会报…

利用集群技术实现Web服务器的负载均衡

集群(Cluster)所谓集群是指一组独立的计算机系统构成的一个松耦合的多处理器系统&#xff0c;它们之间通过网络实现进程间的通信。应用程序可以通过网络共享内存进行消息传送&#xff0c;实现分布式计算机。 负载均衡(Load Balance)网络的负载均衡是一种动态均衡技术&#xf…

AI EARTH再立功,达摩院包揽遥感AI领域三项冠军

人类赖以生存的地球表面积大约为5.1亿平方公里&#xff0c;而陆地面积仅占29.2%&#xff0c;这些土地历经数十亿年的演变及人类生活的改造&#xff0c;又被分割成耕地、森林、草地、水域及建筑等等&#xff0c;现在&#xff0c;AI正在成为管理陆地资源的新途径。 8月27日&#…

node.js写一个json服务

待续转载于:https://www.cnblogs.com/progfun/p/4212099.html

试过不用循环语句撸代码吗?

译者按&#xff1a; 通过使用数组的reduce、filter以及map方法来避免循环语句。 原文: Coding Tip: Try to Code Without Loops 译者: Fundebug 为了保证可读性&#xff0c;本文采用意译而非直译。另外&#xff0c;本文版权归原作者所有&#xff0c;翻译仅用于学习。 在前一篇博…

Linux 命令 top 学习总结

本文简介 概要: 学习总结 Linux 下的 top 命令 版本: Debian 5(Lenny), top: procps version 3.2.7 日期: 2010-11-17 永久链接: http://sleepycat.org/linux/linuxcommand/top.html I. 概述 学习总结 top 命令。主要学习自 man 手册。 Linux 下 top 命令:# toptop…

android 中改变按钮按下时的颜色

原文出处&#xff1a;http://blog.csdn.net/nmsoftklb/article/details/9087233 a、在开发中大家都会遇到这样情况&#xff0c;在一个xxx.xml文件中如果有两个以上的组件有一样的属性功能时&#xff0c;可以把它们共同的内容抽取出来 放在styles.xml文件来声明。 然后在相应的组…

实战:使用 Mask-RCNN 的停车位检测

作者&#xff1a;小白来源&#xff1a;小白学视觉Q如何使用Mask-RCNN检测停车位可用性?我最近做了一个项目&#xff0c;根据安全摄像头的照片来检测停车位是否可用或被占用。我的工作有局限性&#xff0c;我将进一步详细介绍这些局限性&#xff0c;但一旦这些问题得到解决&…

Microsoft Office Communications Server 2007 R2 RTM 简体中文企业版部署速成篇之二

写文章真是件累人的事情.\(^o^)/~.OCS2007R2中的CWA有很多新特性.今天我们来看看,接着昨天的开始.本篇基于速成篇之一.Go!在一中的环境中多了,一台WIN2008的服务器,并加入域.首先在DNS里面建两条别名,指向CWA服务器!完成后,记得重新启动DNS.然后,子啊功能和角色里面添加必要的组…

F5负载均衡会话保持技术及原理技术白皮书

1&#xff0e;什么是会话保持&#xff1f;在大多数电子商务的应用系统或者需要进行用户身份认证的在线系统中&#xff0c;一个客户与服务器经常经过好几次的交互过程才能完成一笔交易或者是一个请求的完成。由于这几次交互过程是密切相关的&#xff0c;服务器在进行这些交互过程…

一文全览机器学习建模流程(Python代码)

作者&#xff1a;泳鱼 来源&#xff1a;算法进阶引言随着人工智能时代的到来&#xff0c;机器学习已成为解决问题的关键工具&#xff0c;如识别交易是否欺诈、预测降雨量、新闻分类、产品营销推荐。我们接下来会详细介绍机器学习如何应用到实际问题&#xff0c;并概括机器学习应…

CSS Selector 3

转载于:https://www.cnblogs.com/dmdj/p/4213159.html

GSM中时隙、信道、突发序列、帧的解释

刚从论坛中看到有人问GSM中时隙、信道、突发序列、帧知识。今天我们数字通信正好上到这一块&#xff0c;我就根据我知道的和网上搜索的回答&#xff01; 1、时分多路复用技术 FDMA:频分多址 TDMA:时分多址 CDMA:码分多址 为了提高通信道的利用率&#xff0c;使若干彼此独立信号…

网页效率之DNS查找和并行下载

首先&#xff0c;一个页面所需要访问的域名数量为n&#xff0c;那么就需要n次DNS查找&#xff0c;而DNS查找通常是blocking call&#xff0c;就是说在得到结果之后才能继续&#xff0c;所以越多的DNS查找&#xff0c;反应速度就越慢&#xff1b; 雅虎的YSlow插件的规则之一&…

赛门铁克开启“容灾即服务”时代

从本地备份到异地复制再到云容灾&#xff0c;随着云计算技术的快速发展&#xff0c;以及云服务这种模式逐渐被广大企业用户所接受&#xff0c;将数据备份到云已经是一种可行的数据保护解决方案。12 月 16日&#xff0c;赛门铁克公司推出了一款全新的灾难恢复解决方案Symantec D…

再谈“去虚拟化”对深度学习系统的必要性

作者 | 袁进辉上周写了一篇《浅谈GPU虚拟化与分布式深度学习框架的异同》&#xff0c;想不到引起很多关注和讨论。和朋友们讨论之后&#xff0c;觉得这个话题值得再发散一下&#xff1a;首先&#xff0c;文章只讨论了GPU“一分多”这种“狭义”的虚拟化&#xff0c;还存在另外的…

Enable PowerShell script execution policy

Open Windows PowerShell with administrator Run “Set-ExecutionPolicy UnRestricted –Force” 本文转自学海无涯博客51CTO博客&#xff0c;原文链接http://blog.51cto.com/549687/1918870如需转载请自行联系原作者520feng2007

Linux下DNS轮询与Squid反向代理结合

一、安装反向代理服务器 1&#xff0e;下载反向代理服务器软件采用squid&#xff0c;下载地址&#xff1a; http://www.squid-cache.org/Versions/v2/2.2/squid-2.2.STABLE5-src.tar.gz 下载后存放在/usr/local/squid/src目录里&#xff0c;文件名是 squid-2.2.STABLE5 ... 一…

从iOS证书申请到签名文件生成

2019独角兽企业重金招聘Python工程师标准>>> 苹果的应用在发布时&#xff08;无论是Adhoc发布还是AppStore正式发布&#xff09;都需要一个签名文件。这个签名文件是由苹果后台生成的&#xff0c;它把用户生成的证书&#xff0c;注册设备&#xff0c;AppID等统统连在…