??xml version="1.0" encoding="utf-8" standalone="yes"?>日韩欧美极品在线观看,精品视频在线免费看,中文一区一区三区免费http://www.aygfsteel.com/cdredfox/一个小程序员的信口开?/description>zh-cnSun, 06 Jul 2025 10:01:48 GMTSun, 06 Jul 2025 10:01:48 GMT60AMQP与QPID?/title><link>http://www.aygfsteel.com/cdredfox/archive/2012/01/02/367727.html</link><dc:creator>永恒瞬间</dc:creator><author>永恒瞬间</author><pubDate>Mon, 02 Jan 2012 09:18:00 GMT</pubDate><guid>http://www.aygfsteel.com/cdredfox/archive/2012/01/02/367727.html</guid><wfw:comment>http://www.aygfsteel.com/cdredfox/comments/367727.html</wfw:comment><comments>http://www.aygfsteel.com/cdredfox/archive/2012/01/02/367727.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/cdredfox/comments/commentRss/367727.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/cdredfox/services/trackbacks/367727.html</trackback:ping><description><![CDATA[<div><div style="line-height: 1.4; height: 100%; width: 100%; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; overflow-x: auto; overflow-y: auto; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; cursor: text; word-wrap: break-word; font-family: arial, 'Microsoft YaHei', 微Y雅黑, simsun, 宋体; color: #333333; text-align: left; "><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">自已整理的一些零散的知识?br /></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><strong style="line-height: 1.4; ">?/strong></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">AMQPQ消息队列协议,Advanced Message Queuing ProtocolQ是一U消息协?Q等同于JMSQ但是JMS只是javaq_的方案,AMQP是一个跨语言的协议?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">AMQP 不分语言q_,最初来自JPMorgon,因ؓ业务需要而滋生,很快从金融界推广到整个计机界流行v来?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">AMQP 目前q是一个草案,最新版本是Q?.10</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><br style="line-height: 1.4; " /></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Publisher --->Exchange ---> MessageQueue --->Consumer</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">整个q程是异步的.Publisher,Consumer怺不知道对方的存在</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Exchange负责交换/路由Q依靠Routing Key,每个消息者有一个Routing Key</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">每个Binding自已感兴趣的RoutingKey告诉Exchange,以便Exchange相关的</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">消息转发l相应的Queue</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><br style="line-height: 1.4; " /></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><strong style="line-height: 1.4; ">几个概念</strong></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Producer,Routing Key,Exchange,Binding,Queue,Consumer.</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Producer: 消息的创,消息的发送?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Routing KeyQ唯一用来映射消息该进入哪个队列的标识</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">ExchangeQ负责消息的路由Q交?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Binding:定义Queue和Exchange的映关p?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">QueueQ消息队?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">ConsumerQ消息的使用?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><br style="line-height: 1.4; " /></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><strong style="line-height: 1.4; ">Exchangecd</strong></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Fan-Out:cM于广播方式,不管RoutingKey</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Direct:ҎRoutingKey,q行兌投寄 </p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Topic:cM于Direct,但是支持多个Key兌Q以l的方式投寄?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">      key?来定义界限。类gusea.news,usea.weather.q两个消息是一l的?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><br style="line-height: 1.4; " /></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><strong style="line-height: 1.4; ">QPID</strong></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">QPID是AMQP的一个实玎ͼ提供C++QJAVA版本的broker,支持多种语言客户端?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">基本功能外提供以下特性:</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">采用 Corosync(?)来保证集环境下的Fault-tolerant(?) Ҏ?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">支持XML的Exchange,消息为XMLӞ彩用Xqueryqo</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">支持plugin</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">提供安全认证Q可对producer/consumer提供w䆾认证</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">qpidd --port --no-data-dir --auth</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">port:端口</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">--no-data-dir:不指定数据目?/p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">--authQ不启用安全w䆾认证</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><br style="line-height: 1.4; " /></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">启动后自动创Z些Exchange,amp.topic,amp.direct,amp.fanout</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">tools:</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Qpid-config:l护Queue,Exchange,内部配置 </p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Qpid-route:配置broker Federation(联盟Q集?)</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">Qpid-tool:监控</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><br style="line-height: 1.4; " /></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">参考:</p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">关于AMQP更多信息可参考: <a target="_blank" rel="nofollow" style="line-height: 1.4; color: #7594b3; ">http://www.openamq.org/doc:amqp-background</a></p><p style="line-height: 1.4; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">关于QPID的更多和使用可参考:<a target="_blank" rel="nofollow" style="line-height: 1.4; color: #7594b3; ">http://qpid.apache.org/</a></p></div></div><img src ="http://www.aygfsteel.com/cdredfox/aggbug/367727.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/cdredfox/" target="_blank">永恒瞬间</a> 2012-01-02 17:18 <a href="http://www.aygfsteel.com/cdredfox/archive/2012/01/02/367727.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>分布式事务简q?/title><link>http://www.aygfsteel.com/cdredfox/archive/2011/08/21/356970.html</link><dc:creator>永恒瞬间</dc:creator><author>永恒瞬间</author><pubDate>Sat, 20 Aug 2011 16:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/cdredfox/archive/2011/08/21/356970.html</guid><wfw:comment>http://www.aygfsteel.com/cdredfox/comments/356970.html</wfw:comment><comments>http://www.aygfsteel.com/cdredfox/archive/2011/08/21/356970.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/cdredfox/comments/commentRss/356970.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/cdredfox/services/trackbacks/356970.html</trackback:ping><description><![CDATA[  随着pȝ来大Q不断的模块化和SOA化,你的pȝ可能被分散于不同的机器上Q这时候,你原先的单机本地事务可能已经无法满你的需求,你可能要跨系l跨资源的去使用事务。这是分布式事务?br /> <strong> 事务有四个特性:</strong><br /><ol><li>   原子?/li><li>   一致?/li><li>   隔离?/li><li>   持久?/li></ol>  具体׃多介l了Q相信大安能明白ACIDҎ的基本含义?br /><br /><strong>事务模型<br /></strong><br />而一个具体的事务需要涉及到的模型(无论哪种模型Q一般由下面几部分组成:<br /><ol><li>AP 应用E序</li><li>RM 资源理?/li><li>TM 事务理?/li></ol>q里的资源管理器一般指数据库资源,而事务管理器Q大多是由数据库厂商提供?br />那么其实在分布式事务中,也应该符合以上事务的Ҏ和模型Q只是资源管理器(RM)变得多了h.<br /><br /><strong>分布式事务介l?br /></strong><br />分布式事务最大的问题在于<strong>如何定资源的状态,以及保证一致性,原子?/strong>?br />一般来说分布事务由 <br /><ol><li>原子提交协议 </li><li>协调?/li><li>参与?/li><li>事务恢复?/li><li>死锁器</li></ol> 五部分组成?br /><br /><strong>原子提交协议</strong>指的是如何保证原子提交,一般分?strong>单阶D原子提交协?/strong>Q?strong>两阶D原子提交协?/strong>Q?strong>三阶D原子提交协?/strong>?br /><br /><strong>对于单阶D原子提交协?/strong>来说Q根本没有办法保证分布式事务的原子性,所以不适用于分布式事务中?br /><br /><strong>两阶D原子提交协议则</strong>是各U分布式事务实现中用最q泛的一U原子提交协议:它主要是交事务提交的q程分ؓ二阶D,投票和最l提交。事务由协调者发起一个事务,参与者加入到事务中后Q第一阶段时候,所有的参与者准备资源,q将资源hold住,协调者询问所有的参与者是否可以提交?所有的参与者向协调者响应结果YES/NO,当所有的协调者都响应YES的时候,协调者才会发L二阶D,向所有的参与者通知提交事务Q当所有的参与者都提交认会会再通知协调者。至此事务处理完毕?br /><br /><strong>三阶D|交协?/strong>׃协调者与参与者多ơ进行沟通所以代价很大,一般不会用。但是它能羃事务处?#8220;不确?#8221;状态的延迟旉?br /><br />所?#8220;不确?#8221;状态就是指当参与者向协调者反馈可以提交的时候,长时间没有收到协调者的通知Q这时候参与者没有办法确定事务最l需要如何处理,所以状态ؓ不确定状态?br /><br /><strong>协调者,参与者一般通过如下动作来进行通信Q?/strong><br /><ol><li>join:由协调者提供,用来注册新的参与?/li><li>canCommitQ协调者询问参与者是否能够提?/li><li>doCommit Q协调者通知参与者提交事?/li><li>doAbortQ协调者通知参与者放弃事?/li><li>haveCommitQ参与者向协调者确认已l提交事?/li><li>getDecisionQ当处于“不确?#8221;状态时Q参与者用来询问协调者事务的目前状态?/li></ol>对于haveCommit特别说明一下,是当W一阶段的时候,协调者发现长旉参与者没有向协调者反馈事务状态,则协调者会d调用该接口事务的情况Q如果仍然无响应Q则会通知所有的参与者放弃该事务?br /><br />M事情都会有意外生,特别是对于跨pȝ间的通信更容易生问题,比如|络异常Q机器down机,q个时候就需要事务恢复器来作相应的处理?br /><strong><br />对于处于W一阶段的事务,</strong>如果参与者发生意外,则协调者会通知所有的参与者进行事务放弃,但是如果协调者出生故障时Q就必须要能 够就行事务恢复,所以协调者必d开始事务的时候,产生唯一的事务ID,q且对事务进行持久化Q在协调者恢复的时候,参够让h参与者l进行事务?br /><strong><br />而对于第二阶D出现的故障Q?/strong>׃W一阶段q行了资源的个决Q则事务认ؓ是必然能成功的,q个事候,如果q个时候参与者发生故障,则协调者需要一套重试机Ӟ让参与者在恢复q来后,能够事务进行完成或者h工介入?br /><br />关于死锁器q里׃多描qCQ以后有Z再描q?br /><br /><strong>语言l织能力比较差,太久没有写东西,凑合着写给自已看吧?/strong><img src ="http://www.aygfsteel.com/cdredfox/aggbug/356970.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/cdredfox/" target="_blank">永恒瞬间</a> 2011-08-21 00:02 <a href="http://www.aygfsteel.com/cdredfox/archive/2011/08/21/356970.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>分布式系l领域经典论文翻译集http://www.aygfsteel.com/cdredfox/archive/2011/08/16/356622.html永恒瞬间永恒瞬间Tue, 16 Aug 2011 04:20:00 GMThttp://www.aygfsteel.com/cdredfox/archive/2011/08/16/356622.htmlhttp://www.aygfsteel.com/cdredfox/comments/356622.htmlhttp://www.aygfsteel.com/cdredfox/archive/2011/08/16/356622.html#Feedback1http://www.aygfsteel.com/cdredfox/comments/commentRss/356622.htmlhttp://www.aygfsteel.com/cdredfox/services/trackbacks/356622.html阅读全文

永恒瞬间 2011-08-16 12:20 发表评论
]]>
Clojure Collections 集合cd要介l?/title><link>http://www.aygfsteel.com/cdredfox/archive/2011/07/30/355375.html</link><dc:creator>永恒瞬间</dc:creator><author>永恒瞬间</author><pubDate>Fri, 29 Jul 2011 17:01:00 GMT</pubDate><guid>http://www.aygfsteel.com/cdredfox/archive/2011/07/30/355375.html</guid><wfw:comment>http://www.aygfsteel.com/cdredfox/comments/355375.html</wfw:comment><comments>http://www.aygfsteel.com/cdredfox/archive/2011/07/30/355375.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/cdredfox/comments/commentRss/355375.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/cdredfox/services/trackbacks/355375.html</trackback:ping><description><![CDATA[<div>    Clojure语言本n自已有提供了四种集合cdQList,Vector,Set,Map.同时它也可以使用Java的集合类型砂Q但是这U方式目前ƈ不推荐用,因ؓClojure集合cd和Java语言的集合类型还是有很大区别的,主要体现?集合内容不可改变Q集合的内容可以多种cd以及持久化。持久化意味着当你在对一个集合的操作都会产生一个新的集合对象(如:插入Q删?.....)Q而老的集合对象依然是存在的?br /><br /><strong>   List</strong><br />   List的可以用如下方式定?<br />     (def list1 '("aa" "bb" "cc"))<br />     (def list1 (list "aa" "bb" "cc"))<br />     (def list1 (quote ("aa" "bb" "cc")))<br />   以上三种方式都可以定义一个List,和Java中一样List是有序的?br /><br /><strong>   Vector</strong><br />   vector可以使用如下方式定义Q?br />     (def v ["v1" "v2"])<br />     (def v (vector "v1" "v2"))<br />   同样vector也是有序的,在Clojure的方法参数定义就是用的Vector,比如定义一个类以于Java的public void say(String name)用Clojure则用如下的方式<br />(defn say [name])<br />    <br /><strong>   Set</strong><br />   set可以使用如下方式定义:<br />   (def s {"aa" "bb" "cc"})<br />   (def s #{"aa" "bb" "cc"})<br />   (def s (hash-set "aa" "bb" "cc"))<br /> <br />    Set分可有序set和无序set,上面CZ中的"hash-set"是代表 无序set,而有序set则可?sorted-set来定?<br />    可以用函?contains? 来检一个set中是否存在某个元?(contains? s "aa") 如果s中存?aa"元素Q则q回true,否则q回false.<br />    contains?函数可以使用在Set和Map无素上?br />    同Java中一栗Set中的元素是唯一的?br /><br /><strong>    Map</strong><br />    map可以使用如下方式定义:<br />    (def m {"k1" "v1","k2" "v2"})<br />    (def m (hash-map "k1" "v1","k2" "v2"))<br />    同样Qmap也分为有序和无序的,如果想申明有序的map则?sorted-map卛_?br />    可以使用函数keys,vals得到键集合和值集?(keys m)<br />    get函数可以Ҏkey取得相应的val倹{?get m "k1") q回的是"v1"<br />    get也可以用?其它的集合中Q比如从Vector中取元素的?(get v 1) 代表取出集合v中的W?个无素。注意,集合的编h?开始的?br /><br /><br />   本部分主要简单介l了一下Clojure中的集合的基本用法。后l会l箋介绍更多的一些东ѝ?br /><br /> <br />  </div><img src ="http://www.aygfsteel.com/cdredfox/aggbug/355375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/cdredfox/" target="_blank">永恒瞬间</a> 2011-07-30 01:01 <a href="http://www.aygfsteel.com/cdredfox/archive/2011/07/30/355375.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一则多U程死锁案例解析http://www.aygfsteel.com/cdredfox/archive/2011/07/26/355050.html永恒瞬间永恒瞬间Tue, 26 Jul 2011 04:44:00 GMThttp://www.aygfsteel.com/cdredfox/archive/2011/07/26/355050.htmlhttp://www.aygfsteel.com/cdredfox/comments/355050.htmlhttp://www.aygfsteel.com/cdredfox/archive/2011/07/26/355050.html#Feedback1http://www.aygfsteel.com/cdredfox/comments/commentRss/355050.htmlhttp://www.aygfsteel.com/cdredfox/services/trackbacks/355050.html上周Q我们有几个pȝ发生了线E死锁,Dpȝ的请求被挂住Q无法响应请求。后面查了一下该问题Q原来是我厂一个基lg中用的锁对象不一致而导致了死锁?/span>
public class SimpleStore {
 
     
private Map sessions = Collections.synchronizedMap(new HashMap());
 
     
synchronized public void remove(String sessionID) { //A1
         sessions.put(sessionID, ""); //A2
         sessions.remove(sessionID);
         System.out.println(
"remove " + sessionID);
     }
 
     
public void commit(Map attrs, String sessionID, StatusHolder statusHolder) {
         System.out.println(
"commit " + sessionID);
         
synchronized (sessions) { //B1
             remove(sessionID); // B2
         }
     }
 }
上面代码中:
 private Map sessions = Collections.synchronizedMap(new HashMap());

sessionsq个mapx为线E安全的map,则操作map中的MҎӞ都会加锁Qƈ且会锁住sessions对象?/span>  q行代码Q则在外部线E访问removeҎ时会锁住SimpleStoreq个对象?br />

 synchronized public void remove(String sessionID);

可以看到Q目前在同一个类或者方法中Q有两把锁,q且锁对象不是同一个,那下面我们看看线E是怎么被死锁住的:
1, 假设AU程先调用removeҎQ则q时会把simpleStorel锁住,然后执行sessions.put(sessionID, “”)的时候,会尝试锁住sessions
2, 同时BU程调用commitҎQ在 synchronized (sessions) Ӟ会先锁住sessions对象Qƈ且在调用接下来的remove()试,会尝试锁?nbsp;  SimpleStore对象Q至此,U程A和线EBl于成功完成死锁?/span>

 

所以在使用多线E时一定要特别注意Q用锁一定要注意你的锁对象是否一致。要不然有可能死锁了~






永恒瞬间 2011-07-26 12:44 发表评论
]]>
ORA-00257 解决Ҏ以及归档日志存放定w满的解决Ҏhttp://www.aygfsteel.com/cdredfox/archive/2010/09/03/330791.html永恒瞬间永恒瞬间Thu, 02 Sep 2010 23:36:00 GMThttp://www.aygfsteel.com/cdredfox/archive/2010/09/03/330791.htmlhttp://www.aygfsteel.com/cdredfox/comments/330791.htmlhttp://www.aygfsteel.com/cdredfox/archive/2010/09/03/330791.html#Feedback0http://www.aygfsteel.com/cdredfox/comments/commentRss/330791.htmlhttp://www.aygfsteel.com/cdredfox/services/trackbacks/330791.htmlW一U解x式:关闭闪回功能Q可以用如果下语句
alter database flashback off
不徏议在正式环境使用q种ҎQ如果在开发环境则可以试使用q种Ҏ。因为必竟开发环境对于数据的恢复没有什么要求,没有多大的概率用到闪回?/span>
W二U解x式:闪回日志文件的最大容量调高,可以使用如下语句
alter system set DB_RECOVERY_FILE_DEST_SIZE=20g
可以通过如果下语句查看目前闪回文件的大小以及使用情况
select * from v$recovery_file_dest; 


永恒瞬间 2010-09-03 07:36 发表评论
]]>
վ֩ģ壺 ɽ| ¤| | | Դ| ɽ| ǭ| | | | | | п| | | | | ״| ̳| | ľ| | | ԫ| ʡ| | ͨ| ƽ| Դ| | | Ȩ| | | | Ͻ| | ͻȪ| °Ͷ| | |