Last active
December 15, 2015 11:09
-
-
Save kongliangzhong/5251142 to your computer and use it in GitHub Desktop.
stractch text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java compile error: illegal character: \65279 | |
save file without BOM can fix this problem. | |
in emacs, just open the file and run: M-x set-buffer-file-coding-system, and save the file. | |
thrift | |
1) download thrift | |
2) cd $thrift-home | |
3) ./configure --with-ruby=no | |
4) make install | |
5) the thrift binary file will be found under /usr/local/bin if install successed. | |
svn | |
1) svn merge -c n1,n2... URL | |
2) svn info | |
3) svn log -l limitNum | |
4) svn blame file | |
sbt: | |
1) provided: the jar is included in the compile classpath of the compiler. and not resloved by sbt. also, you can do provided yourself with: | |
unmanagedClasspath in Compile <++= baseDirectory map {base => (base / "lib" / "provided" / "jars" ** "*.jar").classpath} . but the jars may only included in compile scope, not included in test and run scopes. | |
slf4j: | |
1) simple usage: | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class HelloWorld { | |
public static void main(String[] args) { | |
Logger logger = LoggerFactory.getLogger(HelloWorld.class); | |
logger.info("Hello World"); | |
} | |
} | |
2) load log4j config file: | |
you need three jar files in your project's classpath: | |
slf4j-api-1.6.1.jar // the slf4j API | |
slf4j-log4j12-1.6.1.jar // log4j bindings for slf4j | |
log4j-1.2.15.jar // log4j itself | |
org.apache.log4j.xml.DOMConfigurator.configure("log4j.xml"); | |
Git: | |
1) sudo apt-get install git-core git-doc git-gui | |
2) ssh-keygen -t rsa -C "xxxxx..." | |
3) git config --global user.name "xxx" | |
4) git config --global user.email "xxx@xxx" | |
5) git config --global github.user "xxx" | |
6) git config --global github.token "############" | |
7) git init | |
8) git add . | |
9) git commit | |
10) git remote add <name> git@github.com:kongliangzhong/<repo-name>.git | |
11) git push -u <name> master | |
## pull a repository from git to local directory: | |
1) mkdir proj-name | |
2) cd proj-name | |
3) git init | |
4) git pull https://github.com/twitter/finagle.git | |
maven2: | |
1) adding local jars to maven project: | |
If you don't have the JAR in your repository you can however install it. | |
mvn install:install-file | |
-Dfile= | |
-DgroupId= | |
-DartifactId= | |
-Dversion= | |
-Dpackaging= | |
-DgeneratePom=true | |
e.g. | |
mvn install:install-file -Dfile="./portal-service.jar" -DgroupId="com.liferay.portal" -DartifactId="portal-service" -Dversion="6.0.6" -Dpackaging="jar" | |
2) mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"] ... | |
3) maven run main class in src/test/java : | |
mvn exec:java -Dexec.mainClass="com.yunrang.wj.thriftclient.test.JavaClient" -Dexec.classpathScope="test" | |
4) run multiple tasks once: | |
mvn clean compile test-compile ... | |
mvn test-compile : will also do compile. so equals with mvn compile test-compile | |
5) mvn install skip test: mvn install -DskipTests or mvn install -Dmaven.test.skip=true | |
6) mvn help plugin: | |
mvn help:describe -Dplugin=install -Ddetail | |
mvn help:describe -Dplugin=help | |
1) java maven project: | |
ERROR: SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8] | |
slove: | |
mvn dependency:tree | |
[INFO] [dependency:tree {execution: default-cli}] | |
[INFO] com.yunrang.wj:wjthriftclient:jar:1.0-SNAPSHOT | |
[INFO] +- com.yunrang.wj:wjcommon:jar:1.0.1-SNAPSHOT:compile | |
[INFO] | +- commons-configuration:commons-configuration:jar:1.7:compile | |
[INFO] | | +- commons-logging:commons-logging:jar:1.1.1:compile | |
[INFO] | | \- commons-digester:commons-digester:jar:1.8.1:compile | |
[INFO] | +- commons-httpclient:commons-httpclient:jar:3.1:compile | |
[INFO] | +- commons-io:commons-io:jar:2.0.1:compile | |
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.3:compile | |
[INFO] | +- commons-lang:commons-lang:jar:2.6:compile | |
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile | |
[INFO] | +- commons-codec:commons-codec:jar:1.6:compile | |
[INFO] | +- ch.qos.logback:logback-classic:jar:1.0.3:compile | |
[INFO] | | \- ch.qos.logback:logback-core:jar:1.0.3:compile | |
[INFO] | +- ch.qos.logback:logback-access:jar:1.0.3:compile | |
[INFO] | +- org.slf4j:log4j-over-slf4j:jar:1.6.4:compile | |
[INFO] | +- org.mortbay.jetty:jetty:jar:6.1.25:compile | |
[INFO] | | +- org.mortbay.jetty:jetty-util:jar:6.1.25:compile | |
[INFO] | | \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile | |
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile | |
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile | |
[INFO] | \- jaxen:jaxen:jar:1.1.1:compile | |
[INFO] | +- jdom:jdom:jar:1.0:compile | |
[INFO] | \- xom:xom:jar:1.0:compile | |
[INFO] | +- xerces:xmlParserAPIs:jar:2.6.2:compile | |
[INFO] | +- xalan:xalan:jar:2.6.0:compile | |
[INFO] | \- com.ibm.icu:icu4j:jar:2.6.1:compile | |
[INFO] +- org.apache.thrift:libthrift:jar:0.8.0:compile | |
[INFO] | +- org.slf4j:slf4j-api:jar:1.5.8:compile | |
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile | |
[INFO] | \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile | |
[INFO] +- junit:junit:jar:4.10:test | |
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.1:test | |
[INFO] \- commons-pool:commons-pool:jar:1.5.1:compile | |
可以看到在thrift_0.8.0的jar包中包含了不兼容的slf4j的包。去掉此jar包。修改pom中的thrift的dependency: | |
<dependency> | |
<groupId>org.apache.thrift</groupId> | |
<artifactId>libthrift</artifactId> | |
<version>0.8.0</version> | |
<exclusions> | |
<exclusion> | |
<groupId>org.slf4j</groupId> | |
<artifactId>slf4j-api</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
2) maven Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.4.1: | |
try this simple task: | |
tracert( or traceroute) repo1.maven.org | |
someone has inserted an intervening proxy between you and maven.org | |
go to $M2_HOME/conf/settings.xml and configure access to maven.ord thru this proxy (which should look something like) | |
<!-- proxies | |
| This is a list of proxies which can be used on this machine to connect to the network. | |
| Unless otherwise specified (by system property or command-line switch), the first proxy | |
| specification in this list marked as active will be used. | |
|--> | |
<proxies> | |
<!-- proxy | |
| Specification for one proxy, to be used in connecting to the network. | |
| | |
<proxy> | |
<id>optional</id> | |
<active>true</active> | |
<protocol>http</protocol> | |
<username>proxyuser</username> | |
<password>proxypass</password> | |
<host>proxy.host.net</host> | |
<port>80</port> | |
<nonProxyHosts>local.net,some.host.com</nonProxyHosts> | |
</proxy> | |
--> | |
</proxies> | |
wjthriftclient: | |
thrift error: | |
org.apache.thrift.TApplicationException: Search failed: out of sequence response | |
... | |
org.apache.thrift.transport.TTransportException: Read a negative frame size (-2147418109)! | |
... | |
org.apache.thrift.transport.TTransportException: Frame size (825373488) larger than max length (16384000)! | |
经分析,这是使用了无效的thrift connection导致的错误。具体原因是在 client调用完成之前就将 thrift connection 返回给连接池,而且又继续的使用了这些连接,而导致这些错误。 | |
解决方案: 确保client调用完成后,才释放connection到连接池。 | |
// ascending sort. | |
static void sort_array(char ** string_array, int array_len) { | |
char * temp; | |
temp = *string_array; | |
*string_array = *(string_array + array_len - 1); | |
*(string_array + array_len - 1) = temp; | |
for(int i = 1; i < array_len; i++) { | |
for ( int j = i + 1; j < array_len; j ++) { | |
if (cmp_string(*(string_array + j), *(string_array + i)) < 0) { | |
char * temp2 = *(string_array + j); | |
*(string_array + j) = *(string_array + i); | |
*(string_array + i) = temp2; | |
} | |
} | |
} | |
} | |
static char[] rules = {'j', 'a', 'G', 'g', '8', 'r', 'D', 'f', 'U', 'b', 'W'}; | |
static int get_index_in_rules(int ch) { | |
int index = -1; | |
for (int i = 0; i < rules.length; i++) { | |
if (rules[i] == ch) { | |
index = i; | |
break; | |
} | |
} | |
return index; | |
} | |
/* if ch1 equals with ch2, return 0; | |
else if ch1 greater than ch2, will return a positive number, | |
else return a negitive number. | |
*/ | |
static int cmp_ch(int ch1, int ch2) { | |
return get_index_in_rules(ch1) - get_index_in_rules(ch2); | |
} | |
#define MAX_STRING_LEN 2 | |
/* if string s1 equals with s2, return 0; | |
else if s1 greater than s2, will return a positive number, | |
else return a negitive number. | |
*/ | |
static int cmp_string(char * s1, char * s2) { | |
for (int i = 0; i < MAX_STRING_LEN, i++) { | |
if(*(s1+i) || *(s2+i)) return 0; | |
int cmp = cmp_ch(*(s1+i), *(s2+i)); | |
if (cmp) return cmp; | |
} | |
} | |
################# old work log ################### | |
worklog kongliangzhong | |
2012/3/8 | |
1) read comitium code | |
2) write some experimental code on twitter/ostrich | |
2012/3/21 | |
1) write some test code on scala-redis client. | |
2) backup emacs config to github. | |
//TODO: review刷数据改进:对于titile相同的topic_ids, 只保留num_followers最大的那一个topic_id。 | |
2012/5/23 | |
mongomonitor bug list: | |
1) can not delete docs on collection after detect. | |
2) drop collection mongomonitor , if exist, while execute shardMonitorColl.sh. | |
3) get primary only once. cache the result. | |
4) add config changed detect. | |
2012/6/12 | |
thrift connection pool impl: | |
2012/6/27 | |
1) pre-research: liftray | |
2) wj portal platform architecture | |
2012/07/05 | |
1) build liferay developement environment. | |
maven | |
create a portalet | |
deploy portalet | |
Todo list: | |
2012/8/8 | |
contiune study on pluto, check if it supports the following features: | |
1) support spring mvn portlet. | |
2) front page go into the portlet page, navigation. | |
3) use portlet in portlet project. and page layout. | |
2012/5/23 todo-list | |
1) merge mailer2 to newest version. and cl by xichen. | |
2) mongomonitor bugfix and add negios notification. | |
2012/5/24 | |
check comitium stats: yr/java/shared_deploy_scripts/misc/check_servers.sh | |
2012/6/6 | |
Search interface: | |
GeneralServlet RPC: | |
indexing/proto/general_servlet_rpc.thrift | |
MergedDoc: | |
indexing/proto/mergeddoc.thrift | |
Attachment: | |
indexing/proto/attachment.proto | |
Building interface: | |
indexing/building/interface/ | |
attachment_processor.h | |
doc_building_processor.h | |
Retrieval interface: | |
indexing/retrieval/interface/ | |
Snippet serving interface: | |
indexing/serving/interface/ | |
新办公地址: | |
北京市海淀区北三环西路43号5区21A楼,国际研发中心3层。 | |
trunk https://sourcer/svn/yr/trunk/ | |
merge指定的cl serving_20120412/yr$ svn merge -c 81341,81671,81673 https://sourcer/svn/yr/trunk/ | |
merge到最新版本 path_to_server$ svn merge https://sourcer/svn/yr/trunk/path/to/server | |
svn log -l 10 | |
send email: yunyun_prod@yunrang.com, jianma@yunrang.com | |
手工merge: | |
1) svn up under trunk | |
2) meld branch and trunk, merge maually | |
2012/06/11 | |
todo-list: | |
1) thriftclient(thread pool support) implement | |
2) 代码重写和重构 | |
3) 门户基础架构。 | |
merge and push comitium: | |
cl: 87878,88691 | |
1) /usr/local/kongliangzhong/branches/yr$ svn merge -c 87878,88691 https://sourcer/svn/yr/trunk | |
2) COMPILE AND RUN TESTS: /usr/local/kongliangzhong/branches/yr$ svn merge -c 87878,88691 https://sourcer/svn/yr/trunk | |
test java thrift rpc call. | |
check if the java thrift api use the connection pool or not. | |
restart service maually on yy_servers: | |
1) sudo -u yrservice bin/yy_prod.sh restart | |
http://user.qzone.qq.com/372888025/photo/V10iDHA43MDj8V#!app=4&via=QZ.HashRefresh | |
select t2.iata_code as iata_code from | |
( select city_id from tz_flight.tb_airport tmp where tmp.iata_code = #{airport}) t1 | |
inner join tz_core.tb_city_compare t2 | |
on t1.city_id = t2.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment