Jan 20, 2017

[memo] How to use jacoco

Here is my configuration of pom.xml







"jacoco-initialize" prepare jacoco-agent before "test" maven lifecycle. And "jacoco-site" export report in "package" maven lifecyccle phase.

mvn clean package
You can see the report in ${your_project_root_directory}/target/site/jacoco/index.html

I learned how to use jacoco from here.
http://www.javaworld.com/article/2074515/core-java/unit-test-code-coverage-with-maven-and-jacoco.html

If you use maven-surefire-plugin and argLine, you would see "Skipping JaCoCo execution due to missing execution data file......" message and failed to create report. Please refer the official document of jacoco.
http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html

If your project already defines VM arguments for test execution, be sure that they will include property defined by JaCoCo.
One of the ways to do this in case of maven-surefire-plugin - is to use syntax for late property evaluation:

org.apache.maven.plugins
maven-surefire-plugin

@{argLine} -your -extra -arguments


Here is my real configuration pom.xml

Oct 5, 2016

[memo] How to check max open files(file descriptors) in Linux

Entire OS

cat /proc/sys/fs/file-max


Max open file number of each process
ps aux | grep glassfish
#find process id(pid)
grep "open files" /proc/10244/limits
Max open files            65535                65535                files

Mar 15, 2016

[memo] How to delete all jobs of jenkins

Delete all jobs

Go to the following URL.
http://your.jenkins.url/script

And input the following script

for(j in jenkins.model.Jenkins.getInstance().getProjects()) {
    j.delete();
}

http://stackoverflow.com/questions/5076246/hudson-ci-how-to-delete-all-jobs

Sep 13, 2015

[memo] How to keep SSH session from disconnection in Mac

Set 5 minutes for interval.

vi ~/.ssh/config
ServerAliveInterval 300
TCPKeepAlive yes

Jun 15, 2015

[memo] How to show only total for each directories

du -csh *

The -c option can be added to provide a grand total for all of the files and directories that are listed.
The -s (for suppress or summarize) option tells du to report only the total disk space occupied by a directory tree and to suppress individual reports for its subdirectories.
The -h (i.e., human readable) can make the output easier to read by displaying it in kilobytes (K), megabytes (M) and gigabytes (G) rather than just in the default kilobytes.

Reference
http://stackoverflow.com/questions/10103604/linux-command-line-du-how-to-make-it-show-only-total-for-each-directories

Dec 9, 2014

[memo] How to change a git URL in all Jenkins jobs

Each job's configuration is saved at config.xml. So you just find old URL and change them to new URL like the below.


Sep 9, 2014

[memo] How to get hostname with logback

Just use ${HOSTNAME} logback can get hostname. Don't set hostname manually. It may make other engineers try to fix problem on other server. It's my experience. :)

Aug 13, 2014

[git] How to split repository by sub directories and retain all branches and tags

Because of Legacy and Enterprise code, I have a very big git repository moved from svn. If I build and deploy a external API's client, other clients are also updated and I should spent time to find why my war file has so many differences between current and new. If I fixed parent pom.xml, I could solve this problem. But I decided to split a big repository into 20 small repositories.

As usual, I Googled I found how to use git subtree to divide a sub directory to new git repository. It is very simple way!
Detach subdirectory into separate Git repository
 But it looses our commit logs and branches.

I asked Google again and found what I want.
git splitting repository by subfolder and retain all old branches
But I missed tags with this answer. Yes I know I should study myself. So I just added one more process to above.

Here is an example with github.

Make new repository on you github.
You can see how to push your project to new repository.
https://github.com/baepiff/test

git clone https://github.com/baepiff/voldemort voldemort
cd voldemort
git checkout --detach 
# delete all branches
git branch | grep --invert-match "*" | xargs git branch -D 
# get all branches
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done 
# confirm you have all branches and tags
git branch
git tag

# make another local repository
git clone voldemort voldemort2
cd voldemort2
git checkout --detach
git branch | grep --invert-match "*" | xargs git branch -D
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done
git branch
git tag 
# Isolate docs and recreate branches
# --prune-empty removes all commits that do not modify docs
# -- --all updates all existing references, which is all existing branches
git filter-branch --prune-empty --subdirectory-filter docs -- --all

# clean up git log
rm -rf .git/refs/original/*
git reflog expire --all --expire-unreachable=0
git repack -A -d
git prune

# push all branches and tags to new repository
git remote set-url origin https://github.com/baepiff/test
git push --all
git push --tags


I made separated repository shell script. I hope it helps you.
 

Jun 18, 2014

[git] how to change remote repository url

We have some development servers. We build source on the development on these servers. When I executed 'git fetch', git required another guy's password.

git fetch
#Password for 'https://another.guy@git.com':


Of course, I don't know his password. So I decided to change remote repository url. I got found the answer here.


git remote -v
#origin https://another.guy@git.com/scm/xxx.git (fetch)
#origin https://another.guy@git.com/scm/xxx.git (push)

git remote set-url origin https://git.com/scm/xxx.git

git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://git.com/scm/xxx.git (push)

git fetch
#Username for 'https://git.com/': my.user
#Password for 'https://my.user@git.com':


---
git remote set-url origin https://git.com/scm/xxx.git
git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://another.guy@git.com/scm/xxx.git (push)

git remote set-url --push origin https://git.com/scm/xxx.git
git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://git.com/scm/xxx.git (push)

Jun 15, 2014

[git] how to remove remote tag

If you just started to use maven release plug in, you would get some problems with release plug in like failed on prepare due to not exist snapshot version, or failed on prepare because of existing tag. I would like to share how to remove git tag from remote.
It's easy. Just run the following commands. That's it!

git tag -d myapp-0.0.1
git push origin :refs/tags/myapp-0.0.1


Apr 29, 2014

[memo] How to add/delete jvm options for glassfish

I need to modify jvm options of glassfish(2.1). I asked Google and found the following URLs.
http://docs.oracle.com/cd/E19879-01/820-4332/create-jvm-options-1/index.html
http://docs.oracle.com/cd/E19879-01/820-4332/delete-jvm-options-1/index.html

Here is my example.


Current glassfish has NewRatio and SurvivorRatio. So I deleted them and add new options like below.
-XX:NewRatio=1
-XX:SurvivorRatio=4
-Xms1024m
-XX:CMSInitiatingOccupancyFraction=70

Apr 17, 2014

Feb 27, 2014

[memo] How to cut tcpdump file in Linux

# /usr/sbin/tcpslice -t my.tcp.dump
my.tcp.dump       114y02m27d10h20m28s861544u      114y02m27d10h20m37s097574u
# /usr/sbin/tcpslice -w sliced.my.tcp.dump 14y02m27d10h20m35s +10 my.tcp.dump

+10 means 10 seconds. So sliced.my.tcp.dump has tcp dump of 14-02-27 10:20:35 - 45

Feb 18, 2014

[memo] Delete files older than xxx days on Linux

find /opt/myapp/log/ -mtime +120 -type f -exec rm {} \;

http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/

Jan 7, 2014

Dec 24, 2013

[memo] Eclipse proxy configuration

Eclipse 4.2
Window -> Preferences -> search network
Set your Host and Post for HTTP and HTTPS. Do not set SOCKS

Nov 19, 2013

[memo] Maven release:perform DO NOT deploy

As you know web application is not supposed to be uploaded maven repository. I tried to not deploy on the release. Finall I found the answer here.
It took much time.

Nov 17, 2013

[memo] Print file names that contain word and exclude extension.

### command
find ${TARGET_DIR}/*.xml -type f | xargs grep -l ${SEARCH_WORD} | awk '{ num = split($0, array, "/"); print array[num];}' | awk '{ num = split($0, array, "."); print array[1];}'