随笔-77  评论-5  文章-2  trackbacks-0
  2011年11月2日
class Square{
public:
 Square(int x ) :value(x*x){
 }

Square(const Square& other) = delete;//rule 1

const Square & operator = (const Square& other) == delete;//rule 2
const Square & operator = (Square&& other) = delete;//rule3 

..
}

Square s = 9; //因为s没有初始化,会先用9 调用构造函数 Square(int x ) , 然后调用Square(const Square& other),和rule1 违背
Square s2(8);
 s= s2;//对应rule 2
 s= Square(9);//对应 rule3 
posted @ 2019-12-31 21:11 huohuo 阅读(1041) | 评论 (0)编辑 收藏
其实一直想学ruby,总是拖拖拉拉推了几年。 很多ruby的教材要么老厚一本 要么是东一榔头西一斧头,逻辑性不清楚 ruby语法还没说清楚就上rails了 这个教材挺好。 今天才发现argument 是实参,parameter是形参
posted @ 2014-07-07 22:20 huohuo 阅读(230) | 评论 (0)编辑 收藏
小新看到妈妈用订书机订了一个盒子,他就从打印机上面拿了几张a4纸,钉了一个像盒子的东西,当作他的百宝箱,把他的一些零零碎碎的东西放到他的百宝箱中。 有一天他看到了妈妈的首饰盒,他觉得很漂亮,就和妈妈说:妈妈,我把你这个盒子里面的东西放到我的那个百宝箱里面,你这个盒子给我当百宝箱吧。 妈妈当然不同意。小新很希望要个百宝箱,爸爸就问他:“你需要一个多大的百宝箱?” 小新比划了一个大小,他希望大一点,能装很多东西。爸爸问他是不是希望箱子能有很多分隔? 小新说不要分隔,但是百宝箱要有锁。 爸爸明白了---你就是要个能锁住的箱子嘛,我给你找个皮箱,带密码锁的。 第二天,爸爸上班回来,发现他平时用的笔记本电脑被小新锁在他的"新百宝箱"----密码锁皮箱里面了,密码是小新设的。 爸爸不知道密码,打不开皮箱,爸爸就和小新说:"帮爸爸把电脑拿出来,爸爸要给你查一个睡觉前讲的故事,不然今天就没故事听了"。 小新说:“你用手机也可以查的嘛,别以为我不知道”
posted @ 2014-01-20 21:49 huohuo 阅读(209) | 评论 (0)编辑 收藏
1 解析utf-8的中文字符问题,我修改了 ReportTask类里面的一个方法,增加了一个getJava().setVmArgs("-Dfile.encoding=utf-8")
2.覆盖率出不了数据   一方面注意制定datafile,把cubertura-instrument和cobertura-report的datafile设置为一个,另外junit里面也要设置一个系统属性,制定cubertura的datafile属性.  不制定datafile时,可能生成文件在当前运行ant的目录.但是我们ant任务中的junit测试任务,可能会使用不同的目录来作工作路径.这样会导致datafile不一致.

另外一个是要记得将javac 任务的debug="yes" ,因为只有debug =yes时,编译的代码才带有行信息,能显示覆盖.  当然常见的问题是junit的classpath中的instrument class目录放到原来被测class之前.




posted @ 2013-08-18 22:37 huohuo 阅读(479) | 评论 (0)编辑 收藏
下载putty的安装版本,安装之后有一个plink pscp程序。
plink程序负责调用ssh命令
pscp负责上传文件。

plink -l user -pw pass   hostname

但是因为plink会提示是否要保存密码,不能保证自动批处理运行,此时利用管道的能力来输入提示的结果

echo Y >yes.txt
plink -l user -pw pass   hostname <yes.txt
posted @ 2012-03-04 06:31 huohuo 阅读(583) | 评论 (0)编辑 收藏
/Files/lijinglin/storm.pdf
posted @ 2011-12-21 01:27 huohuo 阅读(277) | 评论 (0)编辑 收藏
/Files/lijinglin/zookeeper.ppt
posted @ 2011-12-21 00:33 huohuo 阅读(314) | 评论 (0)编辑 收藏
kafka pdf

/Files/lijinglin/F_1330_Narkhede_Kafka.pptx
posted @ 2011-12-20 22:53 huohuo 阅读(304) | 评论 (0)编辑 收藏
/Files/lijinglin/stormsrc.rar
posted @ 2011-12-19 02:15 huohuo 阅读(234) | 评论 (0)编辑 收藏

zookeeper集群安装

测试环境redhat5.5:
vmware建两台虚拟机(btw,似乎双核系统只能建俩,3个就死掉了)
192.168.229.129
192.168.229.130


下载2011年12月15日的最新zookeeper
加压到
/opt/zookeeper-3.4.0/
配置/opt/zookeeper-3.4.0/conf/zoo.cfg
可以把那个例子考过来
Java代码 复制代码 收藏代码
  1. # The number of milliseconds of each tick   
  2. tickTime=2000  
  3. # The number of ticks that the initial    
  4. # synchronization phase can take   
  5. initLimit=10  
  6. # The number of ticks that can pass between    
  7. # sending a request and getting an acknowledgement   
  8. syncLimit=5  
  9. # the directory where the snapshot is stored.   
  10. do not use /tmp for storage, /tmp here is just    
  11. # example sakes.   
  12. dataDir=/opt/zookeeper-3.4.0/data/zookeeper   
  13. dataLogDir=/opt/zookeeper-3.4.0/data/log   
  14. # the port at which the clients will connect   
  15. clientPort=2181  
  16. #   
  17. # Be sure to read the maintenance section of the    
  18. # administrator guide before turning on autopurge.   
  19. #   
  20. # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance   
  21. #   
  22. # The number of snapshots to retain in dataDir   
  23. #autopurge.snapRetainCount=3  
  24. # Purge task interval in hours   
  25. # Set to "0" to disable auto purge feature   
  26. #autopurge.purgeInterval=1  
  27. server.1=192.168.229.129:2888:3888  
  28. server.2=192.168.229.130:2888:3888  

修改/opt/zookeeper-3.4.0/bin/zkServer.sh
Java代码 复制代码 收藏代码
  1. status)   
  2.     # -q is necessary on some versions of linux where nc returns too quickly, and no stat result is output   
  3.     #STAT=`echo stat | nc -q 1 localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//'2> /dev/null| grep Mode`   
  4.     STAT=`echo stat | nc localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//'2> /dev/null| grep Mode`  

以上这些多台机器一样

log和data都在dataDir下面
如果找不到log了用大招:
ps -ef|grep zookeeper
ls -l /proc/123123/fd
其中有一个是log
然后dataDir建立一个文件myid
在192.168.229.129上
echo 1 >/opt/zookeeper-3.4.0/data/zookeeper/myid
在192.168.229.130上
echo 2 >/opt/zookeeper-3.4.0/data/zookeeper/myid
对应zoo.cfg里面的
注意一定是数字


然后zkServer.sh start 
启动
zkServer.sh status
看状态
echo ruok|nc localhost 2181         
//are you ok?
echo dump|nc localhost 2181
echo stat|nc localhost 2181
echo srst|nc localhost 2181
zkServer.sh stop
posted @ 2011-12-16 03:48 huohuo 阅读(1318) | 评论 (0)编辑 收藏

 

public class Util {
 final static int LINE_COUNT = 16;
 final static int WORD_COUNT = 2;
 public static StringBuffer toHex(byte b)
 {
  byte factor = 16;
  int v = b & 0xff;//去掉byte转换之后的负数部分。
  byte high = (byte)( v / factor);
  byte low = (byte)(v % factor);
  StringBuffer buf = new StringBuffer();
  buf.append(toHexLow(high)).append(toHexLow(low));
  return buf;
 }
 private static char toHexLow(byte b)
 {
  if(b > 16 || b < 0 )
  {
   throw new IllegalArgumentException("inpt parameter should less than 16 and greater than 0");
  }
  if(b < 10){
   return (char)('0' + (char)b);
  }
  else{
    return (char)('A' + (b-10));

  }
 }
 
 public static StringBuffer toHex(int val)
 {
  StringBuffer buf = toHex((byte)(val >>24 & 0xff)).append(toHex((byte)(val>>16&0xff)));
  return buf.append(toHex((byte)(val>>8&0xff))).append(toHex((byte)(val & 0xff)));
 }
 
 /**
  * 打印二进制数组
  * @param arr
  * @param off
  * @param len
  */
 public static void printBytes(byte [] arr,int off,int len)
 {
  if(arr == null || len <= 0 || off <0 || off + len > arr.length){
   return;
  }
  
  int count = 0;
  
  for(int i = off; count < len; ++i)
  {
   System.out.print(toHex(arr[i]));
   
   ++ count;
   if(count% WORD_COUNT == 0)
   {
    System.out.print(' ');
   }
   if(count % LINE_COUNT == 0)
   {
    System.out.println();
   }
  }
 }
 
 public static void main(String[] args) {
  byte[] arr = new byte[256];
  for(int i = 0; i < 256;++i )
  {
   
   arr[i] = (byte)i;
   
  }
  
  printBytes(arr,0,256);
  printBytes(arr,240,16);
  
  System.out.println(toHex(1));
  System.out.println(toHex(0xffffffff));
  System.out.println(toHex(0xeeffaacc));
 }
}




另外c++写好的小端序的int数据,用java读入如此处理
 private static int convertInt(byte[]  arr)
 {
  if(arr == null || arr.length != 4)
  {
   throw new IllegalArgumentException("bytes array error");
  }
  int val = (arr[0] & 0xff) | (arr[1] & 0xff)<<8 | (arr[2] & 0xff)<<16 | (arr[3]&0xff)<<24;
  return val;
 }


posted @ 2011-11-02 21:36 huohuo 阅读(5370) | 评论 (0)编辑 收藏