锘??xml version="1.0" encoding="utf-8" standalone="yes"?>麻豆狠色伊人亚洲综合网站,亚洲AV成人一区二区三区观看,亚洲精品伦理熟女国产一区二区http://www.tkk7.com/mstar/榛戠伒鐨勬病鍟ユ妧鏈惈閲忕殑鎶鏈崥瀹? -> http://zjumty.iteye.comzh-cnSun, 23 Mar 2025 22:05:22 GMTSun, 23 Mar 2025 22:05:22 GMT60鍦ㄤ紶杈撳眰涓婂帇緙¦ebService鐨勮姹傚拰鍝嶅簲 http://www.tkk7.com/mstar/archive/2013/06/23/400884.html榛戠伒榛戠伒Sun, 23 Jun 2013 13:45:00 GMThttp://www.tkk7.com/mstar/archive/2013/06/23/400884.htmlhttp://www.tkk7.com/mstar/comments/400884.htmlhttp://www.tkk7.com/mstar/archive/2013/06/23/400884.html#Feedback1http://www.tkk7.com/mstar/comments/commentRss/400884.htmlhttp://www.tkk7.com/mstar/services/trackbacks/400884.html闃呰鍏ㄦ枃

榛戠伒 2013-06-23 21:45 鍙戣〃璇勮
]]>
鍦∕ongoDB閲屽疄鐜板驚鐜簭鍒楀姛鑳?http://www.tkk7.com/mstar/archive/2013/04/26/398469.html榛戠伒榛戠伒Fri, 26 Apr 2013 14:57:00 GMThttp://www.tkk7.com/mstar/archive/2013/04/26/398469.htmlhttp://www.tkk7.com/mstar/comments/398469.htmlhttp://www.tkk7.com/mstar/archive/2013/04/26/398469.html#Feedback1http://www.tkk7.com/mstar/comments/commentRss/398469.htmlhttp://www.tkk7.com/mstar/services/trackbacks/398469.html

鐜鏄繖鏍風殑錛氭湇鍔″櫒鏄敤Java鍋氱殑錛?鏁版嵁搴撴槸MongoDB

 

闇姹傛槸榪欐牱鐨勶細鎴戜滑鐨勭郴緇熼噷瑕佺敓鎴愪竴涓敮涓ID錛屽墠闈㈢殑閮ㄥ垎鏈変竴瀹氱殑鏍煎紡錛屽茍鍜屾椂闂村叧鑱旓紝 綺劇‘鍒板井縐掞紝鑰冭檻鍒板悓涓寰鍐呮湁鍙兘瀛樺湪騫跺彂鎯呭喌錛? 鎵浠ュ悗闈㈠湪鍔犱袱浣嶅簭鍒楀彿錛?緋葷粺闇瑕佸畾涔変負1姣鍐呯殑騫跺彂灝忎簬100涓紝鎵浠ュ悗闈袱浣嶅氨澶熺敤浜嗐? Java鏈嶅姟鍣ㄧ鏈夊鍙版満鍣ㄩ兘鍙互鐢ㄦ潵鐢熸垚榪欎釜鍞竴ID錛屾墍浠ラ渶瑕佸湪涓嶅悓鐨勬満鍣ㄤ笂涓嶈兘鐢熸垚鐩稿悓鐨勫簭鍒楀彿錛屾墍浠ラ渶瑕佸湪鏌愪竴鐐逛笂鍋氬叏灞鐨勮寖鍥村悓姝ユ潵淇濆瓨榪欏簭鍒? 鍙風殑鍞竴鎬с?鍏跺疄濡傛灉涓嶈冭檻闇姹傞噷鐨勫敮涓ID鏄湁涓瀹氭剰涔夌殑鏍煎紡鐨勶紝 鐢║UID鎴朚ongoDB鐨凮bjectId閮芥槸鏇村ソ鐨勯夋嫨錛屽畬鍏ㄤ笉闇瑕佸湪鏌愪竴鐐逛笂榪涜鍚屾錛屾ц兘浼氭洿濂姐?/p>

 

榪欎釜鍙互鐢熸垚搴忓垪鍙風殑鐐癸紝 鎴戜滑鍙互鍋氫竴涓簭鍒楀彿鐢熸垚鏈嶅姟鍣ㄦ潵瀵瑰簲錛?涔熷彲浠ョ敤鏁版嵁搴撴潵瀵瑰簲銆? 鍗曞崟涓鴻繖涓畝鍗曠殑鍔熻兘鍑嗗涓涓湇鍔″櫒鏉ュ仛鏄劇劧涓嶅悎閫傘?浣嗘槸鎴戜滑鐢ㄧ殑MongoDB騫舵病鏈夌被浼間簬MySQL鎴朞racle涓殑SELECT FOR UPDATE榪欐牱鐨勯攣鏈哄埗銆?鎵浠ユ病鏈夊姙娉曠畝鍗曠殑瀵硅繖涓簭鍒楀彿鍋氬師瀛愭搷浣溿? 浣嗘槸MongoDB鐨勫鍗曚釜document榪涜update鎿嶄綔涓湁寰堟槸鍏鋒湁鍘熷瓙鎬х殑錛?渚嬪

  • $set
  • $unset
  • $inc
  • $push
  • $pushAll
  • $pull
  • $pullAll

鎴戜滑鍙互鍒╃敤榪欎簺鍘熷瓙鎿嶄綔錛屽湪鏁版嵁搴撳眰浠ヤ箰瑙傞攣鐨勫艦寮忔潵瀹炵幇寰幆搴忓垪瀛楁銆備負浜嗘柟渚胯皟鐢ㄦ垜鎶婅繖孌甸昏緫鍋氭垚鏁版嵁搴撲腑鐨凧avascript鍑芥暟銆?綾諱技涓嶮ySQL涓殑瀛樺偍榪囩▼銆?/p>

 

棣栧厛鎴戜滑闇瑕佷竴涓猚ollection鏉ュ瓨鏀懼簭鍒楀彿錛屽茍瀵歸渶瑕佺殑闇瑕佺殑搴忓垪鍙瘋繘琛屽垵濮嬪寲銆傛垜浠彨瀹僣ounters銆?/p>

Js浠g爜  鏀惰棌浠g爜
  1. db.counters.save({_id:"SerialNo1", val:0, maxval:99})  

 

鐒跺悗鎴戜滑鎯硈ystem.js閲屾坊鍔犱竴涓狫avascript鍑芥暟

Js浠g爜  鏀惰棌浠g爜
  1. db.system.js.save({_id:"getNextUniqueSeq",  
  2. value:function (keyName) {  
  3.     var seqObj = db.counters.findOne({_id:keyName});  
  4.     if (seqObj == null) {  
  5.         print("can not find record with key: " + keyName);  
  6.         return -1;  
  7.     }  
  8.       
  9.     // the max value of sequence  
  10.     var maxVal = seqObj.maxval;  
  11.     // the current value of sequence  
  12.     var curVal = seqObj.val;  
  13.       
  14.     while(true){  
  15.         // if curVal reach max, reset it  
  16.         if(curVal >= maxVal){  
  17.             db.counters.update({_id : keyName, val : curVal}, { $set : { val : 0 }}, falsefalse);  
  18.             var err = db.getLastErrorObj();  
  19.             if( err && err.code ) {  
  20.                 print( "unexpected error reset data: " + tojson( err ) );  
  21.                 return -2;  
  22.             } else if (err.n == 0){  
  23.                 // fail to reset value, may be reseted by others  
  24.                 print("fail to reset value: ");  
  25.             }   
  26.   
  27.             // get current value again.  
  28.             seqObj = db.counters.findOne({_id:keyName});  
  29.             maxVal = seqObj.maxval;  
  30.             curVal = seqObj.val;  
  31.             continue;  
  32.         }   
  33.           
  34.         // if curVal not reach the max, inc it;  
  35.         // increase   
  36.         db.counters.update({_id : keyName, val : curVal}, { $inc : { val : 1 }}, falsefalse);  
  37.         var err = db.getLastErrorObj();  
  38.         if( err && err.code ) {  
  39.             print( "unexpected error inc val: " + tojson( err ) );  
  40.                return -3;  
  41.         } else if (err.n == 0){  
  42.             // fail to reset value, may be increased by others  
  43.             print("fail to inc value: ");  
  44.               
  45.             // get current value again.  
  46.             seqObj = db.counters.findOne({_id:keyName});  
  47.             maxVal = seqObj.maxval;  
  48.             curVal = seqObj.val;  
  49.             continue;  
  50.         } else {  
  51.             var retVal = curVal + 1;  
  52.             print("success to get seq : " + retVal);  
  53.             // increase successful  
  54.             return retVal;  
  55.         }  
  56.     }  
  57. }  
  58. });  

涓婇潰榪欐浼氭妸鎸囧畾鐨勫簭鍒楀彿鐨剉al鍊?1錛屽鏋渧al杈懼埌涓婇檺鍒欎粠0寮濮嬨傛墍浠ュ彨寰幆搴忓垪銆?/p>

 

鍏跺疄涓婇潰鐨勫疄鐜板湪鍘熺悊涓婂拰Java閲岀殑AtomicInteger緋誨垪鐨勫姛鑳藉疄鐜版槸綾諱技鐨勶紝鍒╃敤寰幆閲嶈瘯鍜屽師瀛愭х殑CAS鏉ュ疄鐜般傝繖縐嶅疄鐜版柟寮忓湪澶氱嚎紼嬬殑鐜閲岀敱浜庨攣錛圡onitor錛夌殑鑼冨洿寰堝皬錛屾墍浠ュ茍鍙戞т笂姣旀帓浠栭攣瑕佸ソ涓浜涖?/p>

 

涓嬮潰鎴戜滑鐢↗ava鏉ユ祴璇曚竴涓嬭繖涓嚱鏁扮殑姝g‘鎬с?鍗沖湪澶氱嚎紼嬬殑鎯呭喌涓嬩細涓嶄細寰楀埌閲嶅鐨勫簭鍒楀彿銆?/p>

 

絎竴涓祴璇曪紝val=0錛?maxval=2000錛?Java绔?0涓嚎紼嬫瘡涓嚎紼嬪驚鐜皟鐢?00嬈°?鍏?000嬈°?鎵浠ユ紜殑鎯呭喌涓嬶紝浠?鍒?999搴旇姣忎釜鏁板瓧鍙嚭鐜頒竴嬈°?/p>

 

Java浠g爜  鏀惰棌浠g爜
  1. @Test  
  2. public void testGetNextUniqueSeq1() throws Exception {  
  3.   
  4.     final int THREAD_COUNT = 20;  
  5.     final int LOOP_COUNT = 100;  
  6.   
  7.     Mongo mongoClient = new Mongo("172.17.2.100"27017);  
  8.     DB db = mongoClient.getDB("im");  
  9.     db.authenticate("imadmin""imadmin".toCharArray());  
  10.     BasicDBObject q = new BasicDBObject();  
  11.     q.put("_id""UNIQUE_KEY");  
  12.   
  13.     BasicDBObject upd = new BasicDBObject();  
  14.     BasicDBObject set = new BasicDBObject();  
  15.     set.put("val"0);  
  16.     set.put("maxval", THREAD_COUNT * LOOP_COUNT);  
  17.     upd.put("$set", set);  
  18.   
  19.     db.getCollection("counters").update(q, upd);  
  20.   
  21.     Thread[] threads = new Thread[THREAD_COUNT];  
  22.     final int[][] results = new int[THREAD_COUNT][LOOP_COUNT];  
  23.     for (int i = 0; i < THREAD_COUNT; i++) {  
  24.         final int temp_i = i;  
  25.         threads[i] = new Thread("" + i) {  
  26.             @Override  
  27.             public void run() {  
  28.                 try {  
  29.                     Mongo mongoClient = new Mongo("172.17.2.100"27017);  
  30.                     DB db = mongoClient.getDB("im");  
  31.                     db.authenticate("imadmin""imadmin".toCharArray());  
  32.                     for (int j = 0; j < LOOP_COUNT; j++) {  
  33.                         Object result = db.eval("getNextUniqueSeq(\"UNIQUE_KEY\")");  
  34.                         System.out.printf("Thread %s, seq=%d\n", Thread.currentThread().getName(), ((Double) result).intValue());  
  35.                         results[temp_i][j] = ((Double) result).intValue();  
  36.                     }  
  37.                 } catch (UnknownHostException e) {  
  38.                     e.printStackTrace();  
  39.                 }  
  40.             }  
  41.         };  
  42.     }  
  43.   
  44.     for (Thread thread : threads) {  
  45.         thread.start();  
  46.     }  
  47.   
  48.     for (Thread thread : threads) {  
  49.         thread.join();  
  50.     }  
  51.   
  52.     for (int num = 1; num <= LOOP_COUNT * THREAD_COUNT; num++) {  
  53.         // every number appear 1 times only!  
  54.         int times = 0;  
  55.         for (int j = 0; j < THREAD_COUNT; j++) {  
  56.             for (int k = 0; k < LOOP_COUNT; k++) {  
  57.                 if (results[j][k] == num)  
  58.                     times++;  
  59.             }  
  60.         }  
  61.   
  62.         assertEquals(1, times);  
  63.     }  
  64. }  

 

鐒跺悗鎴戜滑鍐嶆祴璇曚竴涓嬪驚鐜殑鎯呭喌銆?val=0, maxval=99銆?鍚屾牱鏄疛ava绔?0涓嚎紼嬫瘡涓嚎紼嬪驚鐜皟鐢?00嬈°?鍏?000嬈°傝繖嬈′粠0鍒?9鐨勬暟瀛楁瘡涓簲璇ュ彇寰?0嬈°?/p>

 

Java浠g爜  鏀惰棌浠g爜
  1. @Test  
  2. public void testGetNextUniqueSeq2() throws Exception {  
  3.   
  4.     final int THREAD_COUNT = 20;  
  5.     final int LOOP_COUNT = 100;  
  6.   
  7.     Mongo mongoClient = new Mongo("172.17.2.100"27017);  
  8.     DB db = mongoClient.getDB("im");  
  9.     db.authenticate("imadmin""imadmin".toCharArray());  
  10.     BasicDBObject q = new BasicDBObject();  
  11.     q.put("_id""UNIQUE_KEY");  
  12.   
  13.     BasicDBObject upd = new BasicDBObject();  
  14.     BasicDBObject set = new BasicDBObject();  
  15.     set.put("val"0);  
  16.     set.put("maxval", LOOP_COUNT);  
  17.     upd.put("$set", set);  
  18.   
  19.     db.getCollection("counters").update(q, upd);  
  20.   
  21.     Thread[] threads = new Thread[THREAD_COUNT];  
  22.     final int[][] results = new int[THREAD_COUNT][LOOP_COUNT];  
  23.     for (int i = 0; i < THREAD_COUNT; i++) {  
  24.         final int temp_i = i;  
  25.         threads[i] = new Thread("" + i) {  
  26.             @Override  
  27.             public void run() {  
  28.                 try {  
  29.                     Mongo mongoClient = new Mongo("172.17.2.100"27017);  
  30.                     DB db = mongoClient.getDB("im");  
  31.                     db.authenticate("imadmin""imadmin".toCharArray());  
  32.                     for (int j = 0; j < LOOP_COUNT; j++) {  
  33.                         Object result = db.eval("getNextUniqueSeq(\"UNIQUE_KEY\")");  
  34.                         System.out.printf("Thread %s, seq=%d\n", Thread.currentThread().getName(), ((Double) result).intValue());  
  35.                         results[temp_i][j] = ((Double) result).intValue();  
  36.                     }  
  37.                 } catch (UnknownHostException e) {  
  38.                     e.printStackTrace();  
  39.                 }  
  40.             }  
  41.         };  
  42.     }  
  43.   
  44.     for (Thread thread : threads) {  
  45.         thread.start();  
  46.     }  
  47.   
  48.     for (Thread thread : threads) {  
  49.         thread.join();  
  50.     }  
  51.   
  52.     for (int num = 1; num <= LOOP_COUNT; num++) {  
  53.         // every number appear 20 times only!  
  54.         int times = 0;  
  55.         for (int j = 0; j < THREAD_COUNT; j++) {  
  56.             for (int k = 0; k < LOOP_COUNT; k++) {  
  57.                 if (results[j][k] == num)  
  58.                     times++;  
  59.             }  
  60.         }  
  61.   
  62.         assertEquals(20, times);  
  63.     }  
  64. }  

 

榪欎釜嫻嬭瘯璺戜簡鍑犳閮芥槸姝g‘鐨勩?/p>

 

鐢變簬娌℃湁鍙互榪涜瀵規(guī)瘮鍏朵粬鐨勫疄鐜版柟寮忥紙渚嬪鎺掍粬閿侊級鎵浠ユ病鏈夊仛鎬ц兘嫻嬭瘯銆?/p>

 

鍐欏湪鏈鍚庛?铏界劧MongoDB鏀寔綾諱技浜庡瓨鍌ㄨ繃紼嬬殑Stored Javascript錛屼絾鏄叾瀹炰笉寤鴻浣跨敤榪欎釜鏉ヨВ鍐沖鏉傞棶棰樸備富瑕佸師鍥犳槸娌℃硶璋冭瘯錛岀淮鎶よ搗鏉ュお涓嶆柟渚褲傝屼笖鍦?.4涔嬪墠MongoDB瀵規(guī)湇鍔$ Javascript鏀寔騫朵笉鏄緢濂斤紝 涓涓猰ongod榪涚▼鍚屾椂鍙兘鎵ц涓孌礘avascript銆傚鏋滆兘鍦ㄥ簲鐢ㄥ眰瑙e喅鎺夎繕鏄湪搴旂敤灞傞噷瀹炵幇閫昏緫姣旇緝濂姐?/p>



榛戠伒 2013-04-26 22:57 鍙戣〃璇勮
]]>
杈撳嚭debug淇℃伅鍒皃ostfix鐨刲oghttp://www.tkk7.com/mstar/archive/2013/04/26/398459.html榛戠伒榛戠伒Fri, 26 Apr 2013 11:25:00 GMThttp://www.tkk7.com/mstar/archive/2013/04/26/398459.htmlhttp://www.tkk7.com/mstar/comments/398459.htmlhttp://www.tkk7.com/mstar/archive/2013/04/26/398459.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/398459.htmlhttp://www.tkk7.com/mstar/services/trackbacks/398459.html
/etc/postfix/main.cf

debug_peer_list = example.com
debug_peer_level = 2

/etc/postfix/master.cf
smtp      inet  n       -       n       -       -       smtpd -v


榛戠伒 2013-04-26 19:25 鍙戣〃璇勮
]]>
Java閲岀殑CompareAndSet(CAS)http://www.tkk7.com/mstar/archive/2013/04/24/398351.html榛戠伒榛戠伒Wed, 24 Apr 2013 09:20:00 GMThttp://www.tkk7.com/mstar/archive/2013/04/24/398351.htmlhttp://www.tkk7.com/mstar/comments/398351.htmlhttp://www.tkk7.com/mstar/archive/2013/04/24/398351.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/398351.htmlhttp://www.tkk7.com/mstar/services/trackbacks/398351.html Atomic 浠嶫DK5寮濮? java.util.concurrent鍖呴噷鎻愪緵浜嗗緢澶氶潰鍚戝茍鍙戠紪紼嬬殑綾? 浣跨敤榪欎簺綾誨湪澶氭牳CPU鐨勬満鍣ㄤ笂浼氭湁姣旇緝濂界殑鎬ц兘.
涓昏鍘熷洜鏄繖浜涚被閲岄潰澶у浣跨敤(澶辮觸-閲嶈瘯鏂瑰紡鐨?涔愯閿佽屼笉鏄痵ynchronized鏂瑰紡鐨勬?zhèn)茶閿?

浠婂ぉ鏈夋椂闂磋窡韙簡涓涓婣tomicInteger鐨刬ncrementAndGet鐨勫疄鐜?
鏈漢瀵瑰茍鍙戠紪紼嬩篃涓嶆槸鐗瑰埆浜嗚В, 鍦ㄨ繖閲屽氨鏄仛涓瑪璁? 鏂逛究浠ュ悗鍐嶆繁鍏ョ爺絀?

1. incrementAndGet鐨勫疄鐜?br />
聽聽聽聽publicfinalint聽incrementAndGet()聽{
聽聽聽聽聽聽聽聽
for聽(;;)聽{
聽聽聽聽聽聽聽聽聽聽聽聽
int聽current聽=聽get();
聽聽聽聽聽聽聽聽聽聽聽聽
int聽next聽=聽current聽+1;
聽聽聽聽聽聽聽聽聽聽聽聽
if聽(compareAndSet(current,聽next))
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return聽next;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

棣栧厛鍙互鐪嬪埌浠栨槸閫氳繃涓涓棤闄愬驚鐜?spin)鐩村埌increment鎴愬姛涓烘.聽
寰幆鐨勫唴瀹規(guī)槸
1.鍙栧緱褰撳墠鍊?br />2.璁$畻+1鍚庣殑鍊?br />3.濡傛灉褰撳墠鍊艱繕鏈夋晥(娌℃湁琚?鐨勮瘽璁劇疆閭d釜+1鍚庣殑鍊?br />4.濡傛灉璁劇疆娌℃垚鍔?褰撳墠鍊煎凡緇忔棤鏁堜簡鍗寵鍒殑綰跨▼鏀硅繃浜?, 鍐嶄粠1寮濮?

2. compareAndSet鐨勫疄鐜?br />
聽聽聽聽publicfinalboolean聽compareAndSet(int聽expect,聽int聽update)聽{
聽聽聽聽聽聽聽聽
return聽unsafe.compareAndSwapInt(this,聽valueOffset,聽expect,聽update);
聽聽聽聽}

鐩存帴璋冪敤鐨勬槸UnSafe榪欎釜綾葷殑
compareAndSwapInt鏂規(guī)硶
鍏ㄧО鏄?/span>
sun.misc.Unsafe. 榪欎釜綾繪槸Oracle(Sun)鎻愪緵鐨勫疄鐜? 鍙互鍦ㄥ埆鐨勫叕鍙哥殑JDK閲屽氨涓嶆槸榪欎釜綾諱簡

3.
compareAndSwapInt鐨勫疄鐜?br />
聽聽聽聽/**
聽聽聽聽聽*聽Atomically聽update聽Java聽variable聽to聽<tt>x</tt>聽if聽it聽is聽currently
聽聽聽聽聽*聽holding聽<tt>expected</tt>.
聽聽聽聽聽*聽
@return聽<tt>true</tt>聽if聽successful
聽聽聽聽聽
*/
聽聽聽聽
publicfinalnativeboolean聽compareAndSwapInt(Object聽o,聽long聽offset,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽expected,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽x);

鍙互鐪嬪埌, 涓嶆槸鐢↗ava瀹炵幇鐨? 鑰屾槸閫氳繃JNI璋冪敤鎿嶄綔緋葷粺鐨勫師鐢熺▼搴?

4.
compareAndSwapInt鐨刵ative瀹炵幇
濡傛灉浣犱笅杞戒簡OpenJDK鐨勬簮浠g爜鐨勮瘽鍦╤otspot\src\share\vm\prims\鐩綍涓嬪彲浠ユ壘鍒皍nsafe.cpp
UNSAFE_ENTRY(jboolean,聽Unsafe_CompareAndSwapInt(JNIEnv聽*env,聽jobject聽unsafe,聽jobject聽obj,聽jlong聽offset,聽jint聽e,聽jint聽x))
聽聽UnsafeWrapper(
"Unsafe_CompareAndSwapInt");
聽聽oop聽p聽
=聽JNIHandles::resolve(obj);
聽聽jint
*聽addr聽=聽(jint聽*)聽index_oop_from_field_offset_long(p,聽offset);
聽聽
return聽(jint)(Atomic::cmpxchg(x,聽addr,聽e))聽==聽e;
UNSAFE_END

鍙互鐪嬪埌瀹為檯涓婅皟鐢?/span>
Atomic綾葷殑cmpxchg鏂規(guī)硶.

5.
Atomic鐨?/span>cmpxchg
榪欎釜綾葷殑瀹炵幇鏄窡鎿嶄綔緋葷粺鏈夊叧, 璺烠PU鏋舵瀯涔熸湁鍏? 濡傛灉鏄痺indows涓媥86鐨勬灦鏋?br />瀹炵幇鍦╤otspot\src\os_cpu\windows_x86\vm\鐩綍鐨刟tomic_windows_x86.inline.hpp鏂囦歡閲?br />
inline聽jint聽聽聽聽聽Atomic::cmpxchg聽聽聽聽(jint聽聽聽聽聽exchange_value,聽volatile聽jint*聽聽聽聽聽dest,聽jint聽聽聽聽聽compare_value)聽{
聽聽
//聽alternative聽for聽InterlockedCompareExchange
聽聽int聽mp聽=聽os::is_MP();
聽聽__asm聽{
聽聽聽聽mov聽edx,聽dest
聽聽聽聽mov聽ecx,聽exchange_value
聽聽聽聽mov聽eax,聽compare_value
聽聽聽聽LOCK_IF_MP(mp)
聽聽聽聽cmpxchg聽dword聽ptr聽[edx],聽ecx
聽聽}
}

鍦ㄨ繖閲屽彲浠ョ湅鍒版槸鐢ㄥ祵鍏ョ殑姹囩紪瀹炵幇鐨? 鍏抽敭CPU鎸囦護鏄?/span>
cmpxchg
鍒拌繖閲屾病娉曞啀寰涓嬫壘浠g爜浜? 涔熷氨鏄CAS鐨勫師瀛愭у疄闄呬笂鏄疌PU瀹炵幇鐨? 鍏跺疄鍦ㄨ繖涓鐐逛笂榪樻槸鏈夋帓浠栭攣鐨? 鍙槸姣旇搗鐢╯ynchronized, 榪欓噷鐨勬帓浠栨椂闂磋鐭殑澶? 鎵浠ュ湪澶氱嚎紼嬫儏鍐典笅鎬ц兘浼氭瘮杈冨ソ.

浠g爜閲屾湁涓?/span>
alternative聽for聽InterlockedCompareExchange
榪欎釜
InterlockedCompareExchange鏄疻INAPI閲岀殑涓涓嚱鏁? 鍋氱殑浜嬫儏鍜屼笂闈㈣繖孌墊眹緙栨槸涓鏍風殑
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683560%28v=vs.85%29.aspx

6. 鏈鍚庡啀璐翠竴涓媥86鐨刢mpxchg鎸囧畾

Opcode CMPXCHG


CPU: I486+
Type of Instruction: User

Instruction: CMPXCHG dest, src

Description: Compares the accumulator with dest. If equal the "dest"
is loaded with "src", otherwise the accumulator is loaded
with "dest".

Flags Affected: AF, CF, OF, PF, SF, ZF

CPU mode: RM,PM,VM,SMM
+++++++++++++++++++++++
Clocks:
CMPXCHG reg, reg 6
CMPXCHG mem, reg 7 (10 if compartion fails)




榛戠伒 2013-04-24 17:20 鍙戣〃璇勮
]]>
Apache Mina 涓枃鏂囨。緲昏瘧 - 鐗規(guī)?/title><link>http://www.tkk7.com/mstar/archive/2013/04/23/398309.html</link><dc:creator>榛戠伒</dc:creator><author>榛戠伒</author><pubDate>Tue, 23 Apr 2013 14:02:00 GMT</pubDate><guid>http://www.tkk7.com/mstar/archive/2013/04/23/398309.html</guid><wfw:comment>http://www.tkk7.com/mstar/comments/398309.html</wfw:comment><comments>http://www.tkk7.com/mstar/archive/2013/04/23/398309.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/mstar/comments/commentRss/398309.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/mstar/services/trackbacks/398309.html</trackback:ping><description><![CDATA[鐗規(guī)?br />http://mina.apache.org/mina-project/features.html<br /><br />MINA鏄竴涓畝鍗曠殑鍗存湁鍔熻兘涓板瘜鐨勭綉緇滃簲鐢ㄧ▼搴忔鏋訛紝 瀹冩彁渚涘涓嬬壒鎬э細<br /><ul><li>涓哄悇縐嶄紶杈撶被鍨嬫彁渚涗竴濂楃粺涓鐨凙PI</li></ul><blockquote><ul><li>閫氳繃Java NIO瀹炵幇 TCP/IP & UPD/IP閫氫俊</li></ul></blockquote><blockquote><ul><li>閫氳繃RXTX瀹炵幇涓插彛閫氫俊錛圧S232錛?/li></ul></blockquote><blockquote><ul><li>VM鍐呴儴綆¢亾閫氫俊</li></ul></blockquote><blockquote><ul><li>浣犲彲浠ュ疄鐜拌嚜宸辯殑閫氫俊鏂瑰紡</li></ul></blockquote><ul><li>閫氳繃Filter鎺ュ彛瀹炵幇鎵╁睍鐐癸紱綾諱技涓嶴ervlet鐨凢ilter</li></ul><ul><li>浣庣駭鍜岄珮綰х殑API</li></ul><blockquote><ul><li>浣庣駭錛氫嬌鐢˙yteBuffer</li></ul></blockquote><blockquote><ul><li>楂樼駭錛氱敤鎴瘋嚜瀹氫箟鐨勬秷鎭璞″拰緙栫爜</li></ul></blockquote><ul><li>鍙互鑷敱瀹氬埗鐨勭嚎紼嬫ā鍨?/li></ul><blockquote><ul><li>鍗曠嚎紼?/li></ul></blockquote><blockquote><ul><li>涓涓嚎紼嬫睜</li></ul></blockquote><blockquote><ul><li>澶氫釜綰跨▼姹狅紙渚嬪 <a target="_blank" title="SEDA" >SEDA</a>錛?/li></ul></blockquote><ul><li>鍒╃敤Java5鐨凷SLEngine瀹炵幇鐨勫紑綆卞嵆鐢ㄧ殑SSL,TLS, StartTLS鍔熻兘</li></ul><ul><li>榪囪澆淇濇姢 鍜?甯﹀闄愬埗</li></ul><ul><li>閫氳繃Mock瀵硅薄鍙互榪涜鍗曚綋嫻嬭瘯</li></ul><ul><li>閫氳繃JMX綆$悊鏈嶅姟鍣?/li></ul><ul><li>閫氳繃StreamIoHandler鏀寔鍩轟簬嫻佺殑I/O</li></ul><ul><li>鍙互鏁村悎榪汸icoContainer鍜孲pring絳夊父鐢ㄥ鍣?/li></ul><ul><li>寰堝鏄撲粠Netty榪佺Щ榪囨潵銆?/li></ul><br /><img src ="http://www.tkk7.com/mstar/aggbug/398309.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/mstar/" target="_blank">榛戠伒</a> 2013-04-23 22:02 <a href="http://www.tkk7.com/mstar/archive/2013/04/23/398309.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Apache Mina 涓枃鏂囨。緲昏瘧 - 姒傝堪http://www.tkk7.com/mstar/archive/2013/04/22/398241.html榛戠伒榛戠伒Mon, 22 Apr 2013 15:13:00 GMThttp://www.tkk7.com/mstar/archive/2013/04/22/398241.htmlhttp://www.tkk7.com/mstar/comments/398241.htmlhttp://www.tkk7.com/mstar/archive/2013/04/22/398241.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/398241.htmlhttp://www.tkk7.com/mstar/services/trackbacks/398241.html鍘熸枃閾炬帴錛歨ttp://mina.apache.org/mina-project/index.html

Apache MINA 鏄竴涓綉緇滃簲鐢ㄦ鏋訛紝 瀹冨彲浠ュ府鍔╀綘綆鍗曞鏄撶殑寮鍙戦珮鎬ц兘錛岄珮鍙墿灞曟х殑緗戠粶搴旂敤紼嬪簭銆侫pache MINA搴曞眰鍒╃敤Java NIO瀹炵幇錛屽湪TCP/IP鍜孶PD/IP絳変紶杈撳眰涓婃彁渚涗竴涓娊璞$殑鍩轟簬浜嬩歡椹卞姩鐨勫紓姝PI銆?br />
Apache MINA涓鑸縐頒負錛?br />
  • 涓涓狽IO妗嗘灦鎴栧簱
  • 瀹㈡埛绔紝鏈嶅姟鍣ㄦ鏋舵垨搴?/li>
  • 涓涓綉緇淪ocket搴?/li>
灝界濡傛錛孉pache MINA瑕佹彁渚涚殑姣斾笂闈㈣鐨勫寰楀銆?浣犲彲浠ョ湅涓涓嬪畠鐨勫姛鑳界壒鎬у垪琛紝 鍒╃敤榪欎簺鐗規(guī)т綘鍙互蹇熷紑鍙戠綉緇滃簲鐢ㄧ▼搴忥紝 浣犺繕鍙互鐪嬩竴涓嬩漢浠槸鎬庝箞璇碝INA鐨勩?璇蜂笅杞組INA鐨勫寘錛屽皾璇曚竴涓嬪揩閫熷紑濮嬫寚鍗楋紝 嫻忚涓涓婩AQ鎴栬呭姞鍏ユ垜浠殑紺懼尯銆?br />
Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.



榛戠伒 2013-04-22 23:13 鍙戣〃璇勮
]]>
Properties.storeToXML鏂規(guī)硶鎶涘嚭絀烘寚閽堝摝!http://www.tkk7.com/mstar/archive/2013/04/19/398100.html榛戠伒榛戠伒Fri, 19 Apr 2013 08:42:00 GMThttp://www.tkk7.com/mstar/archive/2013/04/19/398100.htmlhttp://www.tkk7.com/mstar/comments/398100.htmlhttp://www.tkk7.com/mstar/archive/2013/04/19/398100.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/398100.htmlhttp://www.tkk7.com/mstar/services/trackbacks/398100.html
綾諱技涓嬮潰榪欐浠g爜:
聽聽聽聽@Test(expected聽=聽IOException.class)
聽聽聽聽
publicvoid聽testPropertiesStoreToXml()聽throws聽IOException聽{
聽聽聽聽聽聽聽聽Properties聽props聽
=new聽Properties();
聽聽聽聽聽聽聽聽props.put(
"key1",聽true);
聽聽聽聽聽聽聽聽ByteArrayOutputStream聽baos聽
=new聽ByteArrayOutputStream();
聽聽聽聽聽聽聽聽props.storeToXML(baos,
null);
聽聽聽聽聽聽聽聽String聽xml聽
=new聽String(baos.toByteArray());
聽聽聽聽聽聽聽聽Assert.fail(
"should聽not聽go聽to聽here");
聽聽聽聽}

鍦ㄧ敓鎴怷ML鐨勬椂鍊欎細鎶涘嚭IOException. 瀵艱嚧榪欎釜IOException鐨勬槸鍋歑MLTransform鐨勬椂鍊欏嚭鐜頒簡NullPointerException

鎰熻寰堝鎬? 璋冭瘯榪汸roperties鐨勪唬鐮佺湅浜嗕竴涓?

聽聽聽聽public聽String聽getProperty(String聽key)聽{
聽聽聽聽Object聽oval聽
=super.get(key);
聽聽聽聽String聽sval聽
=聽(oval聽instanceof聽String)聽?聽(String)oval聽:聽null;
聽聽聽聽
return聽((sval聽==null)聽&&聽(defaults聽!=null))聽?聽defaults.getProperty(key)聽:聽sval;
聽聽聽聽}

鍘熸潵Properties榪欒揣, 涓嶆槸String鐨勫睘鎬т竴鐮佽壊鐨勮繑鍥濶ULL鍟?

緇撴灉鍦╔MLTransform鐨勬椂鍊? 鐩存帴瀵硅繖涓狽ULL榪涜鏂規(guī)硶璋冪敤.

鍚庢潵鐪嬩簡涓涓婸roperties鏂囨。, Properties緇ф壙鑷矵ashtable, 鎵浠ユ湁put鍜宲utAll涔嬬被鐨勬柟娉? 浣嗘槸涓嶅緩璁嬌鐢?
鍥犱負榪欎簺鏂規(guī)硶涓嶉檺瀹歋tring綾誨瀷. 鎺ㄨ崘浣跨敤setProperty鏂規(guī)硶, 榪欎釜鏂規(guī)硶鐨勫間竴瀹氭槸String.

Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail. Similarly, the call to the propertyNames or list method will fail if it is called on a "compromised" Properties object that contains a non-String key.

OK,鎴戞壙璁ゆ槸鎴戜笉濂藉ソ鐪嬫枃妗e氨鐢ㄤ簡. 浣嗘槸鎴戣剼鐨勫鏋滀綘鎶婇潪String鐨勫艱皟鐢ㄤ竴涓媡oString鍐嶄嬌鐢ㄤ笉鏄洿濂藉悧?



榛戠伒 2013-04-19 16:42 鍙戣〃璇勮
]]>
鍏充簬spring-mvc鐨処nitBinder娉ㄨВ鐨勫弬鏁?/title><link>http://www.tkk7.com/mstar/archive/2013/04/17/397945.html</link><dc:creator>榛戠伒</dc:creator><author>榛戠伒</author><pubDate>Tue, 16 Apr 2013 16:42:00 GMT</pubDate><guid>http://www.tkk7.com/mstar/archive/2013/04/17/397945.html</guid><wfw:comment>http://www.tkk7.com/mstar/comments/397945.html</wfw:comment><comments>http://www.tkk7.com/mstar/archive/2013/04/17/397945.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.tkk7.com/mstar/comments/commentRss/397945.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/mstar/services/trackbacks/397945.html</trackback:ping><description><![CDATA[閫氳繃Spring-mvc鐨凘InitBinder娉ㄩ噴鐨勬柟娉曞彲浠ュWebDataBinder鍋氫竴浜涘垵濮嬪寲鎿嶄綔銆?br />姣斿璁劇疆Validator銆?<br />鎴戜竴鐩村湪鎯寵兘涓嶈兘涓烘瘡涓猂equest鎴栬呮瘡涓狝ction鏂規(guī)硶鍗曠嫭璁劇疆Validator銆?br />涔熷氨鏄Controller閲屾湁澶氫釜琚獲InitBinder鏍囨敞鐨勬柟娉曘?鍦ㄤ笉鍚岀殑Action鏃惰鍒嗗埆璋冪敤銆?br /><br />鎴戞敞鎰忓埌浜咢InitBinder鐨剉alue鍙傛暟錛?br /><br />api docs閲屾槸榪欐牱鎻忚堪鐨勶細<br />The names of command/form attributes and/or request parameters that this init-binder method is supposed to apply to. <p>Default is to apply to all command/form attributes and all request parameters processed by the annotated handler class. Specifying model attribute names or request parameter names here restricts the init-binder method to those specific attributes/parameters, with different init-binder methods typically applying to different groups of attributes or parameters. <br /></p><p>鏄箮鏄彲浠ラ拡瀵逛笉鍚岀殑Form瀵硅薄鎴栧懡浠よ皟鐢ㄤ笉鍚岀殑InitBinder鏂規(guī)硶銆?/p><p>浜庢槸鎴戝啓浜嗕笅闈㈢殑Controller璇曚簡涓涓?/p><p></p><div style="background-color:#eeeeee;font-size:13px;BORDER:1px solid #CCCCCC;PADDING-RIGHT: 5px;PADDING-BOTTOM: 4px;PADDING-left: 4px;PADDING-TOP: 4px;WIDTH: 98%;word-break:break-all"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000; ">@Controller<br /></span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">聽HomeController聽{<br />聽聽聽聽<br />聽聽聽聽</span><span style="color: #0000FF; ">private</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">static</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">final</span><span style="color: #000000; ">聽Logger聽logger聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽LoggerFactory.getLogger(HomeController.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">);<br />聽聽聽聽<br />聽聽聽聽@InitBinder(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">action1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)<br />聽聽聽聽</span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">聽initBinder1(WebDataBinder聽binder){<br />聽聽聽聽聽聽聽聽logger.info(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">initBinder1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />聽聽聽聽}<br />聽聽聽聽<br />聽聽聽聽@InitBinder(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">action2</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)<br />聽聽聽聽</span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">聽initBinder2(WebDataBinder聽binder){<br />聽聽聽聽聽聽聽聽logger.info(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">initBinder2</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />聽聽聽聽}<br />聽聽聽聽<br />聽聽聽聽</span><span style="color: #008000; ">/**</span><span style="color: #008000; "><br />聽聽聽聽聽*聽Simply聽selects聽the聽home聽view聽to聽render聽by聽returning聽its聽name.<br />聽聽聽聽聽</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br />聽聽聽聽@RequestMapping(value聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽</span><span style="color: #000000; ">"</span><span style="color: #000000; ">/</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,聽method聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽RequestMethod.GET)<br />聽聽聽聽</span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">聽String聽home(Model聽model)聽{聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽Date聽date聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">new</span><span style="color: #000000; ">聽Date();<br />聽聽聽聽聽聽聽聽DateFormat聽dateFormat聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽DateFormat.getDateTimeInstance(DateFormat.LONG,聽DateFormat.LONG);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽String聽formattedDate聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽dateFormat.format(date);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽model.addAttribute(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">serverTime</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,聽formattedDate聽);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">聽</span><span style="color: #000000; ">"</span><span style="color: #000000; ">home</span><span style="color: #000000; ">"</span><span style="color: #000000; ">;<br />聽聽聽聽}<br />聽聽聽聽<br />聽聽聽聽</span><span style="color: #008000; ">/**</span><span style="color: #008000; "><br />聽聽聽聽聽*聽Simply聽selects聽the聽home聽view聽to聽render聽by聽returning聽its聽name.<br />聽聽聽聽聽</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br />聽聽聽聽@RequestMapping(value聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽</span><span style="color: #000000; ">"</span><span style="color: #000000; ">/doit</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,聽method聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽RequestMethod.POST,聽params</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">action1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)<br />聽聽聽聽</span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">聽String聽doit1(@RequestParam(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">value1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)聽</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">聽value1,<br />聽聽聽聽聽聽聽聽聽聽聽聽@RequestParam(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">action1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)聽String聽action,聽Model聽model)聽{聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽logger.info(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">value1={}</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,value1);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽Date聽date聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">new</span><span style="color: #000000; ">聽Date();<br />聽聽聽聽聽聽聽聽DateFormat聽dateFormat聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽DateFormat.getDateTimeInstance(DateFormat.LONG,聽DateFormat.LONG);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽String聽formattedDate聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽dateFormat.format(date);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽model.addAttribute(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">serverTime</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,聽formattedDate聽);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">聽</span><span style="color: #000000; ">"</span><span style="color: #000000; ">home</span><span style="color: #000000; ">"</span><span style="color: #000000; ">;<br />聽聽聽聽}<br />聽聽聽聽<br />聽聽聽聽</span><span style="color: #008000; ">/**</span><span style="color: #008000; "><br />聽聽聽聽聽*聽Simply聽selects聽the聽home聽view聽to聽render聽by聽returning聽its聽name.<br />聽聽聽聽聽</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br />聽聽聽聽@RequestMapping(value聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽</span><span style="color: #000000; ">"</span><span style="color: #000000; ">/doit</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,聽method聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽RequestMethod.POST,聽params</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">action2</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)<br />聽聽聽聽</span><span style="color: #0000FF; ">public</span><span style="color: #000000; ">聽String聽doit2(@RequestParam(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">value1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)聽</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">聽value1,<br />聽聽聽聽聽聽聽聽聽聽聽聽@RequestParam(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">action2</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)聽String聽action,聽Model聽model)聽{聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽logger.info(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">value1={}</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,value1);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽Date聽date聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽</span><span style="color: #0000FF; ">new</span><span style="color: #000000; ">聽Date();<br />聽聽聽聽聽聽聽聽DateFormat聽dateFormat聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽DateFormat.getDateTimeInstance(DateFormat.LONG,聽DateFormat.LONG);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽String聽formattedDate聽</span><span style="color: #000000; ">=</span><span style="color: #000000; ">聽dateFormat.format(date);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽model.addAttribute(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">serverTime</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,聽formattedDate聽);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">聽</span><span style="color: #000000; ">"</span><span style="color: #000000; ">home</span><span style="color: #000000; ">"</span><span style="color: #000000; ">;<br />聽聽聽聽}<br />}<br /></span></div><p>鐢婚潰涓婄殑Form鏄繖鏍風殑</p><p><br /></p><p></p><div style="background-color:#eeeeee;font-size:13px;BORDER:1px solid #CCCCCC;PADDING-RIGHT: 5px;PADDING-BOTTOM: 4px;PADDING-left: 4px;PADDING-TOP: 4px;WIDTH: 98%;word-break:break-all"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000FF; "><</span><span style="color: #800000; ">form聽</span><span style="color: #FF0000; ">action</span><span style="color: #0000FF; ">="doit"</span><span style="color: #FF0000; ">聽method</span><span style="color: #0000FF; ">="post"</span><span style="color: #FF0000; ">聽enctype</span><span style="color: #0000FF; ">="application/x-www-form-urlencoded"</span><span style="color: #0000FF; ">></span><span style="color: #000000; "><br />聽聽聽聽</span><span style="color: #0000FF; "><</span><span style="color: #800000; ">input聽</span><span style="color: #FF0000; ">type</span><span style="color: #0000FF; ">="text"</span><span style="color: #FF0000; ">聽name</span><span style="color: #0000FF; ">="value1"</span><span style="color: #FF0000; ">聽value</span><span style="color: #0000FF; ">="100"</span><span style="color: #0000FF; ">/></span><span style="color: #000000; "><br />聽聽聽聽</span><span style="color: #0000FF; "><</span><span style="color: #800000; ">input聽</span><span style="color: #FF0000; ">type</span><span style="color: #0000FF; ">="submit"</span><span style="color: #FF0000; ">聽name</span><span style="color: #0000FF; ">="action1"</span><span style="color: #FF0000; ">聽value</span><span style="color: #0000FF; ">="Action1"</span><span style="color: #0000FF; ">/></span><span style="color: #000000; "><br />聽聽聽聽</span><span style="color: #0000FF; "><</span><span style="color: #800000; ">input聽</span><span style="color: #FF0000; ">type</span><span style="color: #0000FF; ">="submit"</span><span style="color: #FF0000; ">聽name</span><span style="color: #0000FF; ">="action2"</span><span style="color: #FF0000; ">聽value</span><span style="color: #0000FF; ">="Action2"</span><span style="color: #0000FF; ">/></span><span style="color: #000000; "><br /></span><span style="color: #0000FF; "></</span><span style="color: #800000; ">form</span><span style="color: #0000FF; ">></span></div><br /><p>鎴戠殑鎰忔効鏄鏋滅敾闈笂錛岀偣鍑籥ction1鎸夐挳鎷╄皟鐢╥nitBinder1鏂規(guī)硶銆?濡傛灉鐐瑰嚮action2鎸夐挳鍒欒皟鐢╥nitBinder2鏂規(guī)硶銆?/p><p>瀹為檯涓婁篃紜疄鏄繖鏍風殑銆?<br /></p><p>褰撶偣鍑籥ction1鏃訛紝<span style="color: #000000; ">logger.info(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">initBinder1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">); 浼氭墽琛?/span></p><p>褰撶偣鍑籥ction2鏄紝<span style="color: #000000; ">logger.info(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">initBinder2</span><span style="color: #000000; ">"</span><span style="color: #000000; ">); 浼氭墽琛?/span></p><p>鏄箮鏄彲浠ュ疄鐜扳滄瘡涓狝ction鏂規(guī)硶鍗曠嫭璁劇疆Validator鈥濊繖涓洰鐨勩?/p><p>浣嗘槸鍏跺疄騫朵笉鏄繖鏍風殑銆?/p><p>鎴戣皟寮忚繘鍘諱簡InitBinder鐩稿叧鐨勬簮浠g爜InitBinderDataBinderFactory錛?緇撴灉鍙戠幇瀹冨彧鏄湪瀵筧ction榪欎釜鍙傛暟緇戝畾鐨勬椂鍊欒皟鐢ㄤ簡涓婇潰榪欎釜鏂規(guī)硶錛?瀵箆alue1緇戝畾鐨勬椂鍊欓偅涓柟娉曢兘娌℃湁璋冪敤銆傝屾垜浠父甯歌瑙e喅鐨勬槸瀵瑰悓涓涓弬鏁板浜庝笉鍚岀殑action搴旂敤涓嶅悓鐨刅alidator銆?<br /></p><p>鎵浠ョ洰鍓嶈繕鏄病鏈夊ソ鐨勬柟娉曡兘鐩存帴瑙e喅榪欎釜闂錛?/p><p>涔熻鎴戜滑鍙互鑷繁瀹炵幇涓涓狣ataBinderFactory鏉ヨВ鍐寵繖涓棶棰樸?/p><p><br /></p><img src ="http://www.tkk7.com/mstar/aggbug/397945.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/mstar/" target="_blank">榛戠伒</a> 2013-04-17 00:42 <a href="http://www.tkk7.com/mstar/archive/2013/04/17/397945.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>KMP綆楁硶閲岀殑next鍑芥暟鏄庝箞寰楀埌鐨勶紵http://www.tkk7.com/mstar/archive/2013/04/14/397824.html榛戠伒榛戠伒Sun, 14 Apr 2013 15:24:00 GMThttp://www.tkk7.com/mstar/archive/2013/04/14/397824.htmlhttp://www.tkk7.com/mstar/comments/397824.htmlhttp://www.tkk7.com/mstar/archive/2013/04/14/397824.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/397824.htmlhttp://www.tkk7.com/mstar/services/trackbacks/397824.html涔熷氨鏄繖涓?p鈶?p鈶?p鈶垛?.p(k-1錛夆?= ' p(j-k+1錛塸(j-k+2錛夆︹(j-1錛夆欍?涓轟粈涔堟壘鍒拌繖涓猭浠ュ悗鐢╧鐨勫厓绱犳瘮杈冨瓧絎︿覆涓璱灝辮浜嗐?br />
鐜板湪鎵懼埌涓涓渶鎺ヨ繎鏄庣櫧鐨勫氨鏄櫨搴︾櫨縐戜笂鐨?br />
鍋囪
涓諱覆錛歴: 鈥榮鈶?s鈶?s鈶?鈥︹(n錛夆?;
妯″紡涓?錛歱: 鈥榩鈶?p鈶?p鈶垛?.p(m錛夆?br />鎶婅鏈笂鐨勮繖涓孌電湅瀹屽悗錛岀戶緇?br />鐜板湪鎴戜滑鍋囪 涓諱覆絎琲涓瓧絎︿笌妯″紡涓茬殑絎琷(j<=m錛変釜瀛楃鈥樺け閰嶁欏悗錛屼富涓茬i涓瓧絎︿笌妯″紡涓茬殑絎琸(k<j錛変釜瀛楃緇х畫姣旇緝
姝ゆ椂錛宻(i錛夆墵p(j錛夛紝鏈?br />涓諱覆錛歴鈶粹︹?s(i-j+1錛夆︹?s(i-1錛?s(i) 鈥︹︹︹?
|| 錛堢浉閰嶏級 || 鈮狅紙澶遍厤錛?br />鍖歸厤涓詫細p鈶?...........p(j-1錛?p(j)
鐢辨錛屾垜浠緱鍒板叧緋誨紡錛?br />鈥榩鈶?p鈶?p鈶垛?.p(j-1錛夆?= 鈥?s(i-j+1錛夆︹(i-1錛夆?br />鐢變簬s(i錛夆墵p(j錛夛紝鎺ヤ笅鏉(i錛夊皢涓巔(k錛夌戶緇瘮杈冿紝鍒欐ā寮忎覆涓殑鍓嶏紙k-1錛変釜瀛楃鐨勫瓙涓插繀欏繪弧瓚充笅鍒楀叧緋誨紡錛屽茍涓斾笉鍙兘瀛樺湪 k鈥?gt;k 婊¤凍涓嬪垪鍏崇郴寮忥細錛坘<j),
鈥榩鈶?p鈶?p鈶垛?.p(k-1錛夆?= 鈥?s(i-k+1錛塻(i-k+2錛夆︹(i-1錛夆?br />鍗籌細
涓諱覆錛歴鈶粹︹(i-k +1錛?s(i-k +2錛?鈥︹(i-1錛?s(i) 鈥︹︹︹?
|| 錛堢浉閰嶏級 || ||錛堟湁寰呮瘮杈冿級
鍖歸厤涓詫細p鈶?p鈶?鈥︹?.... p(k-1錛?p(k)
鐜板湪鎴戜滑鎶婂墠闈㈡葷粨鐨勫叧緋葷患鍚堜竴涓?br />鏈夛細
s鈶粹(i-j +1錛夆?s(i-k +1錛?s(i-k +2錛?鈥︹?s(i-1錛?s(i) 鈥︹?br />|| 錛堢浉閰嶏級 || || || 鈮狅紙澶遍厤錛?br />p鈶?鈥︹(j-k+1錛?p(j-k+2錛?鈥?..... p(j-1錛?p(j)
|| 錛堢浉閰嶏級 || ||錛堟湁寰呮瘮杈冿級
p鈶?p鈶?鈥︹?..... p(k-1錛?p(k)
鐢變笂錛屾垜浠緱鍒板叧緋伙細
'p鈶?p鈶?p鈶垛?.p(k-1錛夆?= ' p(j-k+1錛塸(j-k+2錛夆︹(j-1錛夆?br />
涓嶇煡閬撴槸浠庡摢涓鏈笂鎶勬潵鐨勩?鍏跺疄榪樻槸涓嶅お鏄庣櫧鏈鍚庝竴姝ャ?br />

榛戠伒 2013-04-14 23:24 鍙戣〃璇勮
]]>
綆鍗曠殑鐩戣鏌愪釜绔彛鐨勮繛鎺ユ暟鐨凩inux鍛戒護http://www.tkk7.com/mstar/archive/2012/10/30/linux_shell_watch_connection.html榛戠伒榛戠伒Tue, 30 Oct 2012 01:38:00 GMThttp://www.tkk7.com/mstar/archive/2012/10/30/linux_shell_watch_connection.htmlhttp://www.tkk7.com/mstar/comments/390432.htmlhttp://www.tkk7.com/mstar/archive/2012/10/30/linux_shell_watch_connection.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/390432.htmlhttp://www.tkk7.com/mstar/services/trackbacks/390432.html
#!/bin/sh
netstat聽
-anp聽|聽grep聽:$1|聽awk聽'{print聽$5}'|聽awk聽-F:聽'{print聽$1}'|聽sort聽|聽uniq聽-c

鐒跺悗鎵ц鍛戒護:

watch -n 1 count_conn 8080

鏈鍚庣殑鍙傛暟灝辨槸浣犺鐩戣鐨勭鍙?



榛戠伒 2012-10-30 09:38 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 在线看片免费不卡人成视频 | 亚洲av无码专区首页| 日本一区二区三区免费高清在线| 两个人看的www免费| 免费看黄视频网站| 欧洲亚洲国产清在高| 亚洲小说图区综合在线| 国产免费人成视频在线播放播| 国产va免费精品观看精品| 亚洲熟女精品中文字幕| 亚洲国产综合精品一区在线播放| 亚洲欧洲日本精品| 国产午夜无码精品免费看动漫| jjzz亚洲亚洲女人| 亚洲av无码一区二区三区天堂| 免费国产综合视频在线看| 日本亚洲精品色婷婷在线影院| 一级毛片免费观看不卡的| 亚洲无码在线播放| 亚欧国产一级在线免费| 免费成人在线观看| 久久免费观看国产99精品| 亚洲中文字幕在线第六区| 美女黄频a美女大全免费皮| 好吊妞788免费视频播放| 亚洲一区二区三区免费视频| 亚洲一级毛片免费在线观看| 久久精品亚洲一区二区三区浴池 | 97在线免费视频| 亚洲成a人片在线不卡| 国产精品亚洲高清一区二区| 免费无遮挡无码视频在线观看| 亚洲av无码成h人动漫无遮挡| 色播在线永久免费视频网站| 亚洲毛片基地4455ww| 国产AV无码专区亚洲AWWW| 青青草免费在线视频| 亚洲中文字幕无码久久| 亚洲啪啪AV无码片| 日本一道综合久久aⅴ免费| 国产精品亚洲综合网站|