Skip to content

Instantly share code, notes, and snippets.

View ndzj081221130's full-sized avatar

zhangjieinnjucs ndzj081221130

View GitHub Profile
如何判断一个链表是否有环?
从根节点开始遍历,记录遍历过的节点,如果有重复节点,那么就存在环。
1 这个可以用昨天提到的“快慢指针”来解决吧?设两个工作指针,一个快一个慢,如果有环的话,它们会必然在某点相遇。
2
c++的虚函数和纯虚函数的区别?
virtual void test() = 0;
纯虚函数的类在其派生类中必须定义自己这个函数的版本,而且纯虚函数是没有实际意义的,他的目的告知编译器派生类将会定义自己的版本。
@ndzj081221130
ndzj081221130 / 阿里笔试
Created March 30, 2014 13:15
阿里笔试题
记人生的第一次笔试
确实挺难的,好多题目都没来得及仔细思考,估计挂的很惨。。。
跳跃链表的概念。
参考数据结构,平均搜索、插入、删除的复杂度都是O(logp(n))
maxLevel= (logp(n)上取整) -1
对于有n个元素的跳表,搜索、插入、删除的时间复杂度O(n+maxLevel)
最坏情况下,只有个1个maxLevel元素,其余都在0层上。
@ndzj081221130
ndzj081221130 / 2014_3_14Memcached
Created March 17, 2014 01:34
2014_3_14_Memcached研究
假设DEA节点来缓存session数据。
我们假设使用Ruby来做缓存。
我们需要一个分布式的缓存。
MemCached是一个强大的分布式高速缓存,并且支持多种语言。
[主页][1]
@ndzj081221130
ndzj081221130 / 2014_3_13 CF session缓存
Created March 14, 2014 03:13
2014_3_13_CF做session保存
CF支持带有Cookie的web应用的部署。
但是没有对session进行缓存
如果是要做实例池的话,第一件事,应该是session同步.
在DEA1接收到请求时,缓存session,
建一个DEA2,也同步DEA1的session?
@ndzj081221130
ndzj081221130 / 2014_3_12_CF部署sessoin
Created March 13, 2014 03:00
2014_3_8_CF_gorouter
测试gorouter对**sticky session**的维护
首先启动两个DEA实例
warden启动成功后,启动dea,file-server,directory-server。
1进入vagrant/warden2/warden目录
@ndzj081221130
ndzj081221130 / 2014_2_28 jboss实体bean
Created March 12, 2014 05:36
2014_2_28_EntityBean
In EJB 3.0, entity beans primarily serve as a persistence data model. They do not provide remote services. Hence, the entity bean clustering service in EJB 3.0 primarily deals with distributed caching and replication, instead of load balancing.
实体Bean不考虑LB,而是考虑分布式缓存和复制。
JBoss EJB 3.0 entity beans are implemented by Hibernate, which has support for a second-level cache. The second- level cache provides the following functionalities:
• Ifyoupersistacache-enabledentitybeaninstancetothedatabaseviatheentitymanager,the entity will be inserted into the cache.
• If you update an entity bean instance, and save the changes to the database via the entity manager, the entity will be updated in the cache.
• Ifyouremoveanentitybeaninstancefromthedatabaseviatheentitymanager,theentitywill be removed from the cache.
• If loading a cached entity from the database via the entity manager, and that entity does not exist in the database, it will be inserted into the cache.
@ndzj081221130
ndzj081221130 / 2014_2_11多个DEA部署
Created March 12, 2014 05:35
部署2个DEA的命令
> Written with [StackEdit](https://stackedit.io/).
>
> cd /vagrant/dea_ng2
bin/dea config/dea.yml
> cd /vagrant/dea_ng2
sudo go/bin/runner -conf config/dea.yml
@ndzj081221130
ndzj081221130 / 在jboss
Created March 10, 2014 01:35
在jboss集群上部署EJB
stateless Bean
只要在Bean的定义加上@Cluster标记。
stateful Bean一样要加@org.jboss.ejb3.annotation.Clustered标记。默认的策略是FirstAvailable,就是随机选一个节点。
验证stateful bean?以下程序,如果是通过客户端调用的话,请求是会转发给两个不同的节点,但是输出结果总是0?这个stateful该如何体现?应该将state设为static?
设为static后,在同一台机器上的state会按序增加,但是,两台机器之间的数据木有关系,那么stateful如何体现?
node1:0,1,2,3,4
node2:0,1,2
@ndzj081221130
ndzj081221130 / 2014_2_28_EntityBean
Created March 8, 2014 01:50
2014_2_28_EntityBean
In EJB 3.0, entity beans primarily serve as a persistence data model. They do not provide remote services. Hence, the entity bean clustering service in EJB 3.0 primarily deals with distributed caching and replication, instead of load balancing.
实体Bean不考虑LB,而是考虑分布式缓存和复制。
JBoss EJB 3.0 entity beans are implemented by Hibernate, which has support for a second-level cache. The second- level cache provides the following functionalities:
• Ifyoupersistacache-enabledentitybeaninstancetothedatabaseviatheentitymanager,the entity will be inserted into the cache.
• If you update an entity bean instance, and save the changes to the database via the entity manager, the entity will be updated in the cache.
• Ifyouremoveanentitybeaninstancefromthedatabaseviatheentitymanager,theentitywill be removed from the cache.
• If loading a cached entity from the database via the entity manager, and that entity does not exist in the database, it will be inserted into the cache.
@ndzj081221130
ndzj081221130 / 2014_2_25_JBossClustering
Created February 27, 2014 12:33
2014_2_25_JBossClustering概念
开会,ppt,jboss clustering
##1 deep learning:
###1.1 Farm服务,是不是简单的文件同步?
A:应该是。
due to an implementation weakness, the farm deployment service only works for 1) **archives located in the farm/ directory of the first node** to join the cluster or 2) hot-deployed archives.
###1.2 集群的客户端拦截器架构解释: