Google Code Prettify

2013年12月24日 星期二

Apache Shiro Password Hashing

SHA 512 Hash

Sha512Hash s = new Sha512Hash("password", "salt string", 1024);
UsernamePasswordToken token = new UsernamePasswordToken("milla", s.toString());
Subject subject = SecurityUtils.getSubject();
subject.login(token);

Apache Shiro Cryptography Features

http://shiro.apache.org/cryptography-features.html

2013年10月8日 星期二

Apache Shiro Use Cache Server

Apache Shiro 已經有內建 Cache 機制,http://shiro.apache.org/caching.html

但也能自行 implement,整合其它的 Cache Server (JCache, Ehcache, JCS, OSCache, JBossCache, TerraCotta, Coherence, GigaSpaces)

implement 方式,可以參考這個網址
http://www.java2s.com/Open-Source/Java/Authentication-Authorization/shrio/org/apache/shiro/cache/ehcache/Catalogehcache.htm


使用時,需在 shiro.ini 增加幾行資料

#Use Infinispan HotRod Cache
cacheManager = com.test.cache.SessionCacheManager
securityManager.cacheManager = $cacheManager
sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
securityManager.sessionManager.sessionDAO = $sessionDAO

Apache Shiro JdbcRealm and RememberMe

僅需要在 shiro.ini 增加幾行資料

#Setting JdbcRealm
jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm

#取得帳號密碼
jdbcRealm.authenticationQuery = select user_pass from users where user_name = ?

#取得Roles資料
jdbcRealm.userRolesQuery = select role_name from user_roles where user_name = ?

#使用JNDI DataSource
dataSource = org.apache.shiro.jndi.JndiObjectFactory
dataSource.resourceName = java:/comp/env/jdbc/EmployeeDB

jdbcRealm.dataSource = $dataSource
securityManager.realms = $jdbcRealm

#-----------------------------------------------------------------------------------------

#Setting RememberMe
rememberMeManager = org.apache.shiro.web.mgt.CookieRememberMeManager
securityManager.rememberMeManager = $rememberMeManager
securityManager.rememberMeManager.cookie.name = remember_me

#設定cookie.maxAge = blah , cookie會無法正常寫入
#securityManager.rememberMeManager.cookie.maxAge = blah

securityManager.rememberMeManager.cookie.domain = testdomain.com

2013年5月29日 星期三

Cloudera Manager Free 監控

本來想利用別人寫好的  https://github.com/cloudera/cm_api

但安裝時遇到些問題,CentOS 5 的 Python 只有 2.4.3
上面的套件需要 2.5以上 才能使用

只好自己來囉,Cloudera Manager 本身就有提供 API,透過HTTP,即可取得相關資料
文件在 http://unimelb.sportalhosting.com/static/apidocs/tutorial.html

只要先取得 clusters 資料,在依序取得 services 資料就行了

Service的回傳JSON資料,可參考 http://unimelb.sportalhosting.com/static/apidocs/ns0_apiService.html

2013年5月22日 星期三

Hive 備忘錄

HIVE文件存儲格式的測試比較

http://hugh-wangp.iteye.com/blog/1404708


Hive index
http://blog.csdn.net/yfkiss/article/details/7863577


Hive JDBC
https://cwiki.apache.org/Hive/hivejdbcinterface.html
https://cwiki.apache.org/confluence/display/Hive/HiveClient
http://ccfangle.iteye.com/blog/1775936
http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/4.2.0/CDH4-Installation-Guide/cdh4ig_topic_18_2.html


Hive Gzip 壓縮
http://www.ifshall.com/tag/rcfile/


Hive Data Types
https://cwiki.apache.org/Hive/languagemanual-types.html

Hive DML
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML

HBase 大量寫入

Server 在有限的記憶體下,Memstore的控制相當重要

HBase 在大量寫入時,可能會造成 Out Of Memory

盡可能使用批量寫入的方式

參考下列文章

http://blog.linezing.com/2012/03/hbase-performance-optimization

http://www.cnblogs.com/panfeng412/archive/2012/03/08/hbase-performance-tuning-section3.html

HTML5 Canvas Scale Smoothing

Canvas 預設 放大/縮小 會做 Smoothing,但反而造成不必要的模糊

在 Chrome 、 Firefox 提供關閉的方式

ctx.imageSmoothingEnabled = false;

ctx.webkitImageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;

測試網址如下:
http://jsfiddle.net/saviski/pGs4f/12/

http://jsfiddle.net/P36cS/2/

C10M 備忘錄


The C10M problem



解決方式: http://c10m.robertgraham.com/p/blog-page.html

相關文章
    簡中: http://www.open-open.com/lib/view/open1369096743247.html

    原文:http://highscalability.com/blog/2013/5/13/the-secret-to-10-million-concurrent-connections-the-kernel-i.html


C10M Google 論壇
https://groups.google.com/forum/#!topic/mechanical-sympathy/ao44gonVdAY


改善 TCP封包遺失,穩定網路封包的套件
http://www.ntop.org/products/pf_ring/

PF_RING 測試文章
http://www.metaflows.com/technology/pf-ring/

http://codet.net/wordpress/285.html