
2011年10月27日
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; //因?yàn)閟沒(méi)有初始化,會(huì)先用9 調(diào)用構(gòu)造函數(shù)
Square(int x ) , 然后調(diào)用Square(const Square& other),和rule1 違背Square s2(8);
s= s2;//對(duì)應(yīng)rule 2
s= Square(9);//對(duì)應(yīng) rule3
posted @
2019-12-31 21:11 huohuo 閱讀(1060) |
評(píng)論 (0) |
編輯 收藏
其實(shí)一直想學(xué)ruby,總是拖拖拉拉推了幾年。
很多ruby的教材要么老厚一本
要么是東一榔頭西一斧頭,邏輯性不清楚
ruby語(yǔ)法還沒(méi)說(shuō)清楚就上rails了
這個(gè)教材挺好。
今天才發(fā)現(xiàn)argument 是實(shí)參,parameter是形參
小新看到媽媽用訂書(shū)機(jī)訂了一個(gè)盒子,他就從打印機(jī)上面拿了幾張a4紙,釘了一個(gè)像盒子的東西,當(dāng)作他的百寶箱,把他的一些零零碎碎的東西放到他的百寶箱中。 有一天他看到了媽媽的首飾盒,他覺(jué)得很漂亮,就和媽媽說(shuō):媽媽,我把你這個(gè)盒子里面的東西放到我的那個(gè)百寶箱里面,你這個(gè)盒子給我當(dāng)百寶箱吧。 媽媽當(dāng)然不同意。小新很希望要個(gè)百寶箱,爸爸就問(wèn)他:“你需要一個(gè)多大的百寶箱?” 小新比劃了一個(gè)大小,他希望大一點(diǎn),能裝很多東西。爸爸問(wèn)他是不是希望箱子能有很多分隔? 小新說(shuō)不要分隔,但是百寶箱要有鎖。 爸爸明白了---你就是要個(gè)能鎖住的箱子嘛,我給你找個(gè)皮箱,帶密碼鎖的。 第二天,爸爸上班回來(lái),發(fā)現(xiàn)他平時(shí)用的筆記本電腦被小新鎖在他的"新百寶箱"----密碼鎖皮箱里面了,密碼是小新設(shè)的。 爸爸不知道密碼,打不開(kāi)皮箱,爸爸就和小新說(shuō):"幫爸爸把電腦拿出來(lái),爸爸要給你查一個(gè)睡覺(jué)前講的故事,不然今天就沒(méi)故事聽(tīng)了"。 小新說(shuō):“你用手機(jī)也可以查的嘛,別以為我不知道”
1 解析utf-8的中文字符問(wèn)題,我修改了 ReportTask類(lèi)里面的一個(gè)方法,增加了一個(gè)getJava().setVmArgs("-Dfile.encoding=utf-8")
2.覆蓋率出不了數(shù)據(jù) 一方面注意制定datafile,把cubertura-instrument和cobertura-report的datafile設(shè)置為一個(gè),另外junit里面也要設(shè)置一個(gè)系統(tǒng)屬性,制定cubertura的datafile屬性. 不制定datafile時(shí),可能生成文件在當(dāng)前運(yùn)行ant的目錄.但是我們ant任務(wù)中的junit測(cè)試任務(wù),可能會(huì)使用不同的目錄來(lái)作工作路徑.這樣會(huì)導(dǎo)致datafile不一致.
另外一個(gè)是要記得將javac 任務(wù)的debug="yes" ,因?yàn)橹挥衐ebug =yes時(shí),編譯的代碼才帶有行信息,能顯示覆蓋. 當(dāng)然常見(jiàn)的問(wèn)題是junit的classpath中的instrument class目錄放到原來(lái)被測(cè)class之前.
下載putty的安裝版本,安裝之后有一個(gè)plink pscp程序。
plink程序負(fù)責(zé)調(diào)用ssh命令
pscp負(fù)責(zé)上傳文件。
plink -l user -pw pass hostname
但是因?yàn)閜link會(huì)提示是否要保存密碼,不能保證自動(dòng)批處理運(yùn)行,此時(shí)利用管道的能力來(lái)輸入提示的結(jié)果
echo Y >yes.txt
plink -l user -pw pass hostname <yes.txt
/Files/lijinglin/storm.pdf
/Files/lijinglin/zookeeper.ppt
kafka pdf /Files/lijinglin/F_1330_Narkhede_Kafka.pptx
/Files/lijinglin/stormsrc.rar
測(cè)試環(huán)境redhat5.5:
vmware建兩臺(tái)虛擬機(jī)(btw,似乎雙核系統(tǒng)只能建倆,3個(gè)就死掉了)
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
可以把那個(gè)例子考過(guò)來(lái)
- # The number of milliseconds of each tick
- tickTime=2000
- # The number of ticks that the initial
- # synchronization phase can take
- initLimit=10
- # The number of ticks that can pass between
- # sending a request and getting an acknowledgement
- syncLimit=5
- # the directory where the snapshot is stored.
- # do not use /tmp for storage, /tmp here is just
- # example sakes.
- dataDir=/opt/zookeeper-3.4.0/data/zookeeper
- dataLogDir=/opt/zookeeper-3.4.0/data/log
- # the port at which the clients will connect
- clientPort=2181
- #
- # Be sure to read the maintenance section of the
- # administrator guide before turning on autopurge.
- #
- # http:
- #
- # The number of snapshots to retain in dataDir
- #autopurge.snapRetainCount=3
- # Purge task interval in hours
- # Set to "0" to disable auto purge feature
- #autopurge.purgeInterval=1
- server.1=192.168.229.129:2888:3888
- server.2=192.168.229.130:2888:3888
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/zookeeper-3.4.0/data/zookeeper
dataLogDir=/opt/zookeeper-3.4.0/data/log
# the port at which the clients will connect
clientPort=2181
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.229.129:2888:3888
server.2=192.168.229.130:2888:3888
修改/opt/zookeeper-3.4.0/bin/zkServer.sh
- status)
- # -q is necessary on some versions of linux where nc returns too quickly, and no stat result is output
- #STAT=`echo stat | nc -q 1 localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//') 2> /dev/null| grep Mode`
- STAT=`echo stat | nc localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//') 2> /dev/null| grep Mode`
status)
# -q is necessary on some versions of linux where nc returns too quickly, and no stat result is output
#STAT=`echo stat | nc -q 1 localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//') 2> /dev/null| grep Mode`
STAT=`echo stat | nc localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//') 2> /dev/null| grep Mode`
以上這些多臺(tái)機(jī)器一樣
log和data都在dataDir下面
如果找不到log了用大招:
ps -ef|grep zookeeper
ls -l /proc/123123/fd
其中有一個(gè)是log
然后dataDir建立一個(gè)文件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
對(duì)應(yīng)zoo.cfg里面的
注意一定是數(shù)字 然后zkServer.sh start
啟動(dòng)
zkServer.sh status
看狀態(tài)
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 閱讀(1334) |
評(píng)論 (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轉(zhuǎn)換之后的負(fù)數(shù)部分。
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)));
}
/**
* 打印二進(jìn)制數(shù)組
* @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++寫(xiě)好的小端序的int數(shù)據(jù),用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 閱讀(5392) |
評(píng)論 (0) |
編輯 收藏
1.修改當(dāng)前的hostname可以用
hostname myname
此時(shí)只是修改了內(nèi)存內(nèi)部的,下次啟動(dòng)又恢復(fù)了
2.機(jī)器在啟動(dòng)的時(shí)候會(huì)調(diào)用/etc/rc.d/boot.localnet
腳本看后面的附錄,這個(gè)腳本會(huì)判斷當(dāng)前的$HOSTNAME變量是否設(shè)置,沒(méi)有設(shè)置就會(huì)讀取/etc/HOSTNAME
來(lái)設(shè)置主機(jī)名。
3.因此要修改hostname,
3.1 修改/etc/HOSTNAME文件
3.2 修改當(dāng)前的$HOSTNAME變量
3.3 停掉/etc/rc.d/boot.localnet
3.4 啟動(dòng) /etc/rc.d/boot.localnet
因此執(zhí)行腳本如下:
export HOSTNAME=myname
echo $HOSTNAME>/etc/HOSTNAME
/etc/rc.d/boot.localnet stop
/etc/rc.d/boot.localnet start
附錄:/etc/rc.d/boot.localnet
case "$1" in
start)
# clean up old yp bindings
rm -f /var/yp/binding/*.[12]
#
# set hostname and domainname
#
XHOSTNAME=""
test -f /etc/HOSTNAME && {
read XHOSTNAME < /etc/HOSTNAME
}
test -n "$HOSTNAME" -a "$HOSTNAME" != '(none)' && {
echo Using boot-specified hostname \'${HOSTNAME}\'
XHOSTNAME="$HOSTNAME"
}
test -n "$XHOSTNAME" && {
echo -n Setting up hostname \'${XHOSTNAME%%.*}\'
hostname ${XHOSTNAME%%.*}
rc_status -v -r
}
XDOMAINNAME=""
test -f /etc/defaultdomain && {
read XDOMAINNAME < /etc/defaultdomain
}
test -n "$XDOMAINNAME" && {
echo -n Setting up NIS domainname \'$XDOMAINNAME\'
}
domainname "$XDOMAINNAME"
test -n "$XDOMAINNAME" && {
rc_status -v -r
posted @
2011-10-27 22:21 huohuo 閱讀(16394) |
評(píng)論 (3) |
編輯 收藏