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];}'

Nov 15, 2013

Jenkins Git Plugin fails with NullPointerException

When I ran Jenkins job to build project, I got the following error message.


I found the answer from here.

1. Uninstall git client plugin
2. Restart, it would be automatically executed
3. Install git plugin, not git client. Git client is installed automatically too.
4. Confirm git is available and name it "default" on Manage Jenkins > Configure System

Enjoy!

Nov 14, 2013

[memo] this parser does not support specification null version null digester

java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"
at javax.xml.parsers.SAXParserFactory.setXIncludeAware(SAXParserFactory.java:448)
at org.apache.commons.digester.Digester.getFactory(Digester.java:534)

Update your xercesImpl.jar!!! old xercesImpl.jar can not handle setXIncludeAware method.
2.9.1 helps you.

Thank you Coding in Color!!!


Jul 24, 2013

Continuous Delivery Using Jenkins

Let me introduce our Jenkins jobs. If Jenkins was not exist, we would suffer from HARD HARD build and deploy jobs.

First of all, we made our server list file. Because this is very often used by Jenkins deploy and restart jobs.
Add your Jenkins user key to my_name/.ssh/authorized_key on each server.
-Jenkins Server List Configure Job-


Next step, we build our project and make backup too.
-Jenkins Build Job-
Build our project by running maven.
  clean release:clean release:prepare package -P prd

And make backup directory.


And run deploy job. Don't forget set post-build Actions. We set Build other projects(Jenkins Restart Job)
-Jenkins Deploy Job-


-Jenkins Restart Job-


Sometimes we need to revert our service. We use this job. Don't forget to set Build other projects(Jenkins Deploy Job) that it will execute Jenkins Restart Job.
-Jenkins Roll Back Job-

Jul 22, 2013

[memo] jmagick 6.4.0 configure problem

I had to install jmagick 6.4.0. And I tried to install as the following.



Jmagick dose not care "--with-java-home=/opt/java/". It just uses "/usr/bin/java javac javah jar".
So you need to link them to /usr/bin

#ln -s /opt/java/bin/java /usr/bin/java


[memo] svc: warning: unable to control file does not exist.

I solved this problem here.

The key is the following command.
# svscanboot &

Jul 9, 2013

[memo] How to add many nodes to Chef Server

I created my node.json file with jackson. And I need to add 100 over nodes to Chef server.
I uploaded to Chef server's tmp directory my nodes files and ran the following script.


It is simple!

Jun 7, 2013

maven scala java mixed project

I develop my product with Java and have test code written by Scala(Specs2). I wanted run test cases on my PC and Jenkins.
I have got some problems and solved by the following pom.xml. It works well. I hope this helps you.

Don't forget add "@RunWith(classOf[JUnitRunner])" to your xxxSpec class.



May 29, 2013

error: src refspec master does not match any.

When I executed the following command, I got an error.
#] git push origin env-properites
  error: src refspec env-properites does not match any.
  error: failed to push some refs to 'http://localhost/mygit/firsttest.git'

I can solve this problem by doing as here is written. It is easy!
Just modify unnecessary file like .gitignore.
And add & commit.
Run the above command again.

You can see the following message.
  Compressing objects: 100% (8/8), done.   Writing objects: 100% (12/12), 1.82 KiB, done.   Total 12 (delta 2), reused 0 (delta 0)   To http://localhost/mygit/firsttest.git    * [new branch]      env-properties -> env-properties

May 16, 2013

com.aerospike.client.AerospikeException: Error Code 13: Record too big

Recently I am trying to verify Aerospike can satisfy our requirements -
1. Persistent Cache for images
2. Time To Live(TTL)
3. Eviction
4. Remove all of related data by a key
5. Scale Out easily

I am testing it with YCSB to check performance. When I tried 256KB data size test, YCSB just stopped. As you know, YCSB is not kind. It doesn't show me any error message. So I ran the following code.

You can find out how to use Aerospike client here.


The result was "Record too big".


What? I already ran same test case on AWS and had no problem. They say "The size of the object or record is exceeding the limit, currently at 1MB". I just ran 256KB and 456KB. Something is wrong. I tried applying several data size files to find out MAX_SIZE. MAX_SIZE was 128KB. Finally I got a hint to solve this problem.

citrusleaf.conf

I am using data file because server was already configured RAID 10 with 4 SSDs and I did not want to go far far our data center. :) Anyway the reason was [write-block-size]. It makes limitation on using data file. When I use raw device([device]), I had no problem. I removed it and could run my test case.

You know what?  The max size of our images is 10MB. orz... 


Apr 18, 2013

java: invalid flag: -target=1.6 intellij idea

When I ran my test cases, I got this message "error: java: invalid flag: -target=1.6". I search this -"target=1.6" phrase in my project. So I re installed Intellij idea and removed .idea directory and .iml file. But I got same messages.
Finally I solved this problem by removing Additional command line parameters of java compiler.


Apr 11, 2013

How to add new node to an existing Aerospike Cluster - Using multicast

Modify /etc/citrusleaf/citrusleaf.conf as my example.

After modifying just start new node, it will be added an existing cluster automatically. You can confirm it on /var/log/citrusleaf.log with the following message.


Tip(?).
I changed ip address to 172.28.206.73 - it's wrong address -,  after I got succeeded with above configuration. So I fixed it to 172.28.206.72 and restarted node. But I got some non normal message.
I issued the command and failed to get expected result - ClusterSize 2 -.

I fixed this event by restarting all nodes.

Install and Run Aerospike Community Edition on CentOS 6.2

This installation is just for CentOS 6.2. If you use other OS like Ubuntu, please see Aerospike Standard Installation.

Step 1. Download Aerospike Database Server rpm packages
You can download here.

Step 2. Untar file


Step 3. Install the Aerospike Server


Step 4. Run the Aerospike Server for Testing

Oops! I got a error message. It means "CLD is stopped!".  Let me see the log.

Aha! Aerospike can't get ip address by eth, bond, wlan. Wait! my network interface name is "bond0.2032". If they use regular expression, it would be solved. But I can't fix it, so I changed my configuration file - /etc/citrusleaf/citrusleaf.conf - as blow. I just added network-interface-name item.

......

network {
        service {
                address any
                port 3000
                reuse-address
                network-interface-name bond0.2032

......

I ran it again and got succeeded.


Step 5. Verify Installation
I used the Aerospike command line interface tool to verity installation. It is installed as /opt/citrusleaf/bin/cli and lined in /usr/bin/cli. So you can use it normally.


It's simple, right?

Apr 10, 2013

How to install Jenkins and plugins offline.

I tried to the following commands that are introduced on Installing Jenkins on Red Hat distributions.


But I got failed. This server is not connected to internet. So I downloaded rpm package from RedHat Linux RPM packages for Jenkins and git, git-client plugins from Jenkins plugins download site to my MBA. And I uploaded them to the server and executed as blow.





Mar 18, 2013

No runnable methods junit 4.11

I am implementing Swift(OpenStack Object Storage) Client to use Swift simply. I ran each of test cases successfully on IDE, but I ran test cases with Class. It throws the following exception messages.



Here is my code.


I googled and searched several pages.

http://stackoverflow.com/questions/15383387/no-runnable-methods-on-junit-with-custom-annotation-and-all-tests-filtered

It says
You get this error due to the validation performed in validateInstanceMethods since computeTestMethods() returns an empty List: 

He suggested override or remove List size validation. I couldn't agree with him. Cause I have run my test cases with no problem on other projects. I read my code and error message again.

at swift.client.SwiftConfigTest.suite(SwiftConfigTest.java:17)

I felt it weird.  Because I don't need to run suite method. I removed suite method and ran all tests successfully.
Here is my right source code.

Feb 7, 2013

[memo] Kill all process by uid in Linux

Sometimes flunetd porecess is not stopped by "/etc/init.d/td-agent stop".
So I executed the following command.

Feb 5, 2013

bash while loopの変数が初期化される問題

業務上処理件数を調べる必要があったため軽くスクリプトを書くつもりが変数が初期化される現象に遭遇してはまった。

最初書いたスクリプトはこちらです。

特に問題ないように見えますが、最後のecho文の結果が0(zero)になります。

Google先生に聞くと下記のサイトを教えて下れました。
http://www.edwardawebb.com/linux/scope-issue-bash-loops

それで修正したスクリプトがこちら。正しくカウントできました。


ではなぜこの現象が起きるかというとパイプ(|)からのstdinはいつもsubshellを使うそうです。なのでループの中のcountはループ内の変数になってしまいます。
while文前パイプを使った場合よく起きるそうです。w

上で修正したスクリプトは自分のスタイルではないので下記のように見やすく修正しました。

Dec 7, 2012

how to remove remote branch in git(github)

It's simple to delete your remote branch.

  git push origin :

Deleting your local branch is simple too.

  git branch -d

You need to be on another branch. If you execute the command above on , you will see error message.

error: Cannot delete the branch '' which you are currently on.




Dec 6, 2012

How to make IntelliJ IDEA dark(Darcula)

If you use previous version (under 12), please import setting of Ted Wise. You can download this theme from the following URL.

http://tedwise.com/2009/02/26/dark-pastels-theme-for-intellij-idea/

If you just started IntelliJ IDEA 12,
1. Choose IntelliJ IDEA -> Preferences on Menu
2. Choose Editor -> Colors & fonts -> Scheme name
3. Choose Darcula! It's done.

Look it's beautiful!


Dec 5, 2012

Configuration of maven files to deploy to Nexus(Sonatype Nexus)

When I make a new Jenkins server, I always get a trouble with deploying module to Nexus. This memo  is just for me from future. Because I know I will search it again.

You need to write your Nexus repository information as the following.


ID is defined at pom.xml as below.

Nov 17, 2012

error: Setup script exited with error: command 'gcc' failed with exit status 1

I get the following error message when I tried to install tomahawk as following process of "How to install tomahawk"

Python's version is 2.4.3. tomahawk requires upper 2.4. My environments meets requirements.

Suddenly I remember that gcc troubles was solved by installing xxx-devel package.

I ran the following command.
  #]yum install python-devel

I could install tomahawk!

Oct 12, 2012

failed to flush the buffer, retrying. error="no nodes are available" fluentd

I got other error message from fluentd.
  failed to flush the buffer, retrying. error="no nodes are available"

The detail message is the following.


The reason
flunetd uses UDP for health check. But my target servers are on staging environment and collecting server is on production environment. They are on different segment. UDP is prohibited by our network policy.

The solution
Configure your Fire Wall to permit UDP over different segment.

fluentd unexpected error error="Address already in use - bind(2)"

When I started fluentd, I got the error message like the following.

2012-10-12 14:52:07 +0900: unexpected error error="Address already in use - bind(2)"

I searched which program was using this port. Yes, as you see it was td-agent(fluentd).
td-agent is supposed to use 24224 port. It's natural behavior.


But I forgot that I booted it by /usr/sbin/td-agent command before.
Yes it's absolutely my mistake. I killed this process and restart fluentd.

Aug 23, 2012

How to add cron job by Chef

Thanks to Chef, I have could save my time. Because I'm responsible for over 70 servers. I installed Middleware, configured user and ssh and OS environment variables by Chef 4 months ago. It just took half a day. Thanks Chef!

As you know, the LOGs became monsters when we have been satisfied. My application dumped out 4.4GB monsters for 4 months. I need to hunt them. So I reused Chef!

Here is my Chef recipe.


Here is my shell hunts monsters.


After run Chef client, you can confirm cron job is activated.


If you want to configure detail level of cron, please look around the following URL.
http://wiki.opscode.com/display/chef/Resources#Resources-Cron

Aug 9, 2012

How to get thread dump in Tomcat


#ps -ef | grep tomcat
30012    32470     1  6 15:06 ?        00:02:29 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -server -Dcom.sun.management.jmxremote -XX:MaxPermSize=256m -XX:PermSize=256m -XX:SurvivorRatio=2 -Xmn2048m -Xmx4096m -Xms4096m -Dweblogic.corba.client.bidir=true -XX:+PrintGCDetails -Xloggc:/usr/local/tomcat/logs/gc.log.20120809-1506 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start

#kill -3 32470

Thread dump would be recorded on /usr/local/tomcat/logs/catalina.out
Thread dump starts with "TP-Proccesor".

Aug 7, 2012

error: src refspec master does not match any. error: failed to push some refs to 'git@github.com:.git'

If you are a github newbie as like me, it will help you.
Here is what I got message from git after I made new repository.
error: src refspec master does not match any.
error: failed to push some refs to 'git@github ... .git'
I googled and found this solution. It works for me.

$ touch README
$ git add README
$ git add *
$ git commit -m 'my first commit'
$ git push origin master --force

Jul 23, 2012

IntelliJ : java.util.ResourceBundle.throwMissingResourceException


java.util.MissingResourceException: Can't find bundle for base name voldemort
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
When I run my program on IntellJ IDEA, this error message shown up on console window. Do I miss something? Yes, I know. It's a kind of class path thing. Here are my solutions.
1. Move properties under sr/main/java/
2. Write attributes on your codes.
3. Just do the following.
 Select root directory of your project.
 Right Click.
 Choose "Mark Directory at" to "Source Root".
 
Don't choose 1 or 2. Your reviewers would be happy to have a chance to give you a lot of feedback.
It's a secret that I selected 2 for a test. :)
Here is my code.
    private StoreClientFactory storeClientFactory() {
        Properties p = new Properties();
        ResourceBundle rb = ResourceBundle.getBundle(VOLDEMORT_PROPERTY);
        for(String key:rb.keySet()) {
            p.setProperty(key, rb.getString(key));
        }
        return new SocketStoreClientFactory(new ClientConfig(p));
    }

Jun 19, 2012

Configuration for using post-review command on Mac

The memo for using post-review command on Mac

#easy_install -U RBTools
#brew update
#brew install svn  // It would stop on "make" step like following message. Don't worry about it. You just run it again. It will be installed.


==> Installing subversion
==> Downloading http://www.apache.org/dyn/closer.cgi?path=subversion/subversion-1.7.5.tar.bz2
==> Best Mirror http://ftp.meisei-u.ac.jp/mirror/apache/dist/subversion/subversion-1.7.5.tar.bz2
######################################################################## 100.0%
==> ./configure --disable-debug --prefix=/usr/local/Cellar/subversion/1.7.5 --with-ssl --with-zlib=/usr --with-sqlite=/usr/local --disable-neon-version-check --disable-mod-activation --withou
==> make

But you may have some problem yet. Because your built in svn(/usr/bin/svn) is prior to installed svn(/usr/local/bin/svn). You can change your path by using this command.

export PATH=new_path //copy your original path and exchange /usr/bin and /usr/local/bin

 or

Use /usr/local/bin/svn propset reviewboard:url http://reviewboard.example.com .

And make .reviewboardrc file in your check out directory.
#vim .reviewboardrc
REPOSITORY = "http://localhost/svn/myproject/trunk/"
REVIEWBOARD_URL = "http://localhost/reviewboard"

Finally you can use post-review for review board!
#post-review  // in your work directory = check out and modified directory.

reference:
http://www.reviewboard.org/docs/manual/dev/users/tools/post-review/

Warning:
If you use svn1.7.x, post-review command is unable on Review Board 1.6.9.
http://code.google.com/p/reviewboard/issues/detail?id=2359




Jun 18, 2012

Installing ReviewBoard on Ubuntu

I'm following this URL
http://www.reviewboard.org/docs/manual/dev/admin/installation/linux/

#sudo apt-get update
#sudo apt-get upgrade  //It takes time
#sudo apt-get install sqlite3
#sudo apt-get install apache2 libapache2-mod-wsgi
#sudo apt-get install python-setuptools
#sudo apt-get install python-dev

#sudo apt-get install memcached
#sudo easy_install python-memcached
#sudo apt-get install patch
#sudo easy_install ReviewBoard //If you failed here, please use pip. You may see this error message "error: Setup script exited with error: command 'gcc' failed with exit
status 1"
#sudo easy_install pip
#sudo pip install ReviewBoard
#sudo easy_install RbTools  //Don't forget this!!!

If you forget the last command, you will see "Review Board is taking a nap" message.


Install ldap modules
#sudo apt-get install libldap2-dev libsasl2-dev

#sudo easy_install python-ldap


Now you are ready to create Review Board site. Come on just run command. Choose options to fit your environment.


# rb-site install /var/www/rb


Finally we're the last step.



# sudo chown www-data -R /var/www/reviewboard/
# cp /var/www/reviewboard/conf/apache-wsgi.conf /etc/apache2/sites-enabled/000-default

Trouble with mysql-python gcc failed

I'm installing Reviewboard. I followed installing on Linux(Cent OS 5.4). I don't have any problem except the following command.

easy_install mysql-python


/usr/include/python2.4/pyconfig.h:6 から include されたファイル中,
                 /usr/include/python2.4/Python.h:8 から,
                 pymemcompat.h:10 から,
                 _mysql.c:29 から:
/usr/include/python2.4/pyconfig-64.h:648:1: 警告: ここが以前の宣言がある位置です

Googling gave me the answer about this.http://blog.eflow.org/archives/54
Actually the writer couldn't fix this problem but Olivier Biot has the answer.
Thx Olivier! The answer is here.

yum install MySQL-python

It works perfectly.

Jun 12, 2012

Mac keyboard symbol

I've just started MacBook Air a month ago. Yes I'm a newbie. So sometime I'm confused what this symbol( like ⎋) means when I started IntelliJ Idea. Here is the list of mac keyboard symbol. I hope it to help you.


  • ⎋ esc
  • ⇧ shift
  • ⌥ alt option
  • ⌘ command
  • ⌃ control
  • ⌫ delete

Jun 6, 2012

How to scan/fetch all of keys in Voldemort

I'm supposed to provide a list that shows all of data in Voldemort. At first, I look around voldemort.client.StroreClient class. It has #getAll() method but this method has a parameter that is collections of key. Now I want to know all of keys!

Next step, I searched "getAll", "scan" and "fetch" that heats what I want. I found voldemort.client.protocol.admin.AdminClient#fetchKeys(). But it fetches all keys on a particular node. As you know I want all of keys in Voldemort cluster. Let me do coding little bit.

Here is my code. Forgive me for my dirty code. I just wrote this in an instant.
 


    private List getAllKeys() {
        String bootstrapUrl = "tcp://localhost:6666";
        StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
        AdminClient adminClient = new AdminClient(bootstrapUrl, new AdminClientConfig());

        Collection nodes = adminClient.getAdminClientCluster().getNodes();
        List list = new ArrayList();
        int count = 0;
        for (Node node : nodes) {
            if (!factory.getFailureDetector().isAvailable(node))
            {
                System.out.println("Oops Node " + node.getId() + " is unavailable");
                continue;
            }
            List partitionIds = node.getPartitionIds();
            Iterator iter = adminClient.fetchKeys(node.getId(), "tabe_name", partitionIds, null, true);
            while (iter.hasNext()) {
                String key = new String(iter.next().get());
                list.add(key);
                count++;
                System.out.println("Node id:" + node.getId() + " key: " + key);
            }
        }

        System.out.println(count);
        return list;
    }



May 29, 2012

Install Scala on Mac

It's simple if you installed home brew already.
Type the following. That's all. Now you can use Scala. Welcome to Scala world.




$ brew install scala sbt maven giter8

Apr 17, 2012

Basic knowledge for coding interview


  • Data Structures 
    • Linked List
    • Binary Trees
    • Tries
    • Stacks
    • Queues
    • Vectors/ ArrayLists
    • Hash Tables
  • Algorithms
    • Breadth First Search
    • Depth First Search
    • Binary Search
    • Merge Sort
    • Quick Sort
    • Tree Insert/ Find
  • Concepts
    • Bit Manipulation
    • Singleton Design Pattern
    • Factory Design Pattern
    • Memory(Stack vs. Heap)
    • Recursion
    • Big-O Time
quotes from Cracking the Coding Interview: 150 Programming Questions and Solutions

Mar 29, 2012

Bash script : cacti add graph to tree

I had to add much graph to graph trees on cacti over 80 nodes.
So I made the following script. I hope this will help you.

Please edit awk pattern phrases like "/host pattern/" as your situation.

#!/bin/bash
#
#   CopyLeft 2012 Joongjin, Bae
#
#

CACTI_CLI_DIR=/var/www/cacti/cli

cd $CACTI_CLI_DIR

HOST_ID_LIST=`php -q add_tree.php --list-hosts | awk '/host pattern/ { print $1}'`
TREE_ID=`php -q add_tree.php --list-trees | awk '/graph tree name/ { print $1}'`
PARENT_ID_LIST=`php -q add_tree.php --list-nodes --tree-id=$TREE_ID | awk '/^Header/ {print $0}' | awk '/graph tree header node pattern/ {print $2}'`
TARGET_GRAPH_ID_LIST=()

for host_id in $HOST_ID_LIST
do
  TARGET_GRAPH_ID_LIST=("${TARGET_GRAPH_ID_LIST[@]}" "`php -q add_tree.php --list-graphs --host-id=$host_id | awk '/add target graph pattern/ { print $1 "\n"}'`")
done

idx=0

for parent_id in $PARENT_ID_LIST
do
  for graph_id in ${TARGET_GRAPH_ID_LIST[$idx]}
  do
    php -q add_tree.php --type=node --node-type=graph --tree-id=$TREE_ID --parent-node=$parent_id --graph-id=$graph_id
  done
  idx=$((idx+1))
done

echo Mission Completed!

Feb 3, 2012

how to change language in netbeans


First of all, Let me show you my environment.
Windows 7 Professional 64bit
NetBeans7.1 64bit
Java 1.6 64bit

Now, I just changed my job and need to prepare new development environment. So I downloaded and installed NetBeans 7.1 English ver. But you know what I'm in Japan. So smart IDE, NetBeans, shows Japanese menu for me. It's cool But I'm Korean and I prefer to use it in English. As you know Java supports all of languages int the world.(It may be not.) Anyway, I asked Google Sensei.

Fortunately, I got one shot. Read the following URL.

It tells me use locale option like following.

  • "C:\Program Files\NetBeans 7.1\bin\netbeans.exe" --locale en:US



I just add this option to shortcut property. OK. It works. But I want another way. Because I want to write Blog. :) I asked G Sensei again in Japanese. Sensei shows me other ways. Here is my solution.

Add language option to netbeans.conf file. This file is located in ↓ if you installed it in default path

  • C:\Program Files\NetBeans 7.1\etc


Open it just add user.language=en to netbeans_default_options item. I show you my configuration.
(I don't change locale, cause I live in Japan ^^)

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-Duser.language=en"

It is for English. kr for Korean ja for Japanese and cn for Chinese, Sorry since don't know other languages I can't show you other options. Anyway now you got another option to change language in NetBeans. If you are smart(I BELIEVE YOU ARE), you can change language in other IDE like Eclipse, IntelliJ and etc.

YOU WANT Japanese page? Just click the following URL.

Jan 5, 2012

The New Year Resolutions

Yes, I know that New Year already started 5 days ago.
I already decided my resolutions last year.
But I want to make it public and detail.
I hope publishing to force me achieve my resolutions.

OK, here are my resolutions.


  1. Promotion to Manager.
  2. Study of Computer Science and Statics in College.
  3. Buying my home.


1. I will be a manager. That's it.

2. I want to study computer science, statics and business. Big Data Analyst(he/she understands business) will be in high demand in 5 years. And analysis is fun.

3. My Home is My Dream.


------
Written on Jan. 4th 2022.

1. I was promoted to an engineering manager in 2016. But I was promoted to a team lead in 2012.
2. I started to study Stastics from 2012. But I finished my course in 2018.
3. I bought a house in 2013.

Dec 13, 2011

Eclipse: java.lang.UnsupportedClassVersionError: Bad version number in .class file

Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported. from Java 6 API

When I checked out project source, the project didn't have .project and .classpath files.
(I'm using Eclipse 3.7.)
So I added Project Facets Java as 1.6 and used JRE1.4 for JRE System Library.
My project is supposed to work on Java 1.4.
But I compiled it with Java 1.6 because Project Facets is Java 1.6.

I fixed Project Facets and Java Compiler version and have no problem.

Sep 27, 2011

How to reboot Solaris

Just type the following commands. bash-3.00$shutdown -y -i6 -g0 or bash-3.00$reboot

Aug 29, 2011

org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z reason

org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z

Reason : It occurs when xercesImpl-X.X.X.jar doesn't exist in the class path.
Solution : Just replace xerces-X.X-X.jar to xercesImpl-X.X.X.jar.

You can download xercesImpl-X.X.X.jar the following URL.
http://mirrors.ibiblio.org/pub/mirrors/maven/mule/dependencies/maven2/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar

Jul 8, 2011

IE9 frameset tag issue

I've got a problem with IE9.
My web page doesn't show on IE9 document mode.
Because I used frameset tag, I thought my web page failed to satisfy HTML5 standard.
But my another page doesn't have any problem, even using same frameset tag.

I started to find why it happened. There is not answer on the net.
Master Google couldn't help me.(Also Bing and Yahoo)
So I quit searching it on the net and started finding the reason my self with developer tool of IE.

1. miss of javascript code -> deleted every javascript code, but it was same.
2. a bug of Tomcat 5.5 -> changed to 6.0, but it was same.
3. jsp -> quit using jsp, but...
4. 5. 6. ... 100. 101. ...
Finally, I found the reason after 4 days.

The reason was CSS. After I deleted the following line, My web page started working well.
<link href="/css/style.css" rel="stylesheet" type="text/css"/link>

May 12, 2011

How to get ORACLE_HOME by SQL

I had to get Oracle alert log file path by SQL on 9i, 10g.
Because I didn't want to force a user input it.

First I tried the following SQL sentence.
SQL> select * from sysman.mgmt$software_homes;

win2k3svrvminst OraHome92 ORACLE_HOME D:\oracle\ora92

win2k3svrvminst OraDb10g_home1 ORACLE_HOME F:\oracle\product\10.2.0\db_1
win2k3svrvminst Independent Products INDEPENDENT N/A
(copied on SQL Developer)

I didn't know which ORACLE_HOME is proper one.

I should keep searching and tried this.


SQL>select substr(file_spec,   1,   instr(file_spec,   '\',   -1,   2) -1) ORACLE_HOME
from dba_libraries
where library_name = 'DBMS_SUMADV_LIB';
(On Unix, substitute with '/'  )

This SQL showed me ORACLE_HOME, C:\oracle\product\10.2.0\db_1, but it required me as sysdba on 10g.

Because my application can't get sysdba's id and password, I had to keep searching.


SQL> set autopri on
SQL> var oracle_home varchar2(255)
SQL> exec dbms_system.get_env('ORACLE_HOME',:ORACLE_HOME)

It works too, but I don't want to use PL/SQL procedure.

Finally, I quited searching.
But this article can help some people who want to know  "How to get ORACLE_HOME by using SQL".

May 10, 2011

How to know Oracle DB log files' path

ALERT LOG

Oracle writes the alert.log file to the directory as specified by BACKGROUND_DUMP_DEST parameter.
If it is not set, the alert.log will be created in the ORACLE_HOME/rdbms/trace directory.

SQL> show parameter BACKGROUND_DUMP_DEST


NAME                                 TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
background_dump_dest                 string
/u01/app/oracle/diag/rdbms/trace


LISTNER LOG

Oracle writes listener.log file to ORACLE_HOME/NETWORK/log directory in usual.
You can confirm the path of listner.log file using "lsnrctl status" command.


[oracle@helium ~]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-5月 -2011 14:55:15

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

LSNRCTLへようこそ。詳細は"help"と入力してください。

LSNRCTL> status
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))に接続中
リスナーのステータス
------------------------
別名                      LISTENER
バージョン                TNSLSNR for Linux: Version 11.2.0.1.0 - Production
開始日                    13-4月 -2011 15:47:37
稼働時間                  26 日 23 時間 7 分 41 秒
トレース・レベル          off
セキュリティ              ON: Local OS Authentication
SNMP                      OFF
パラメータ・ファイル      /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
ログ・ファイル            /u01/app/oracle/diag/tnslsnr/helium/listener/alert/log.xml
リスニング・エンドポイントのサマリー...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=helium.workslan)(PORT=1521)))
サービスのサマリー...
サービス"kiban.workslan"には、1件のインスタンスがあります。
  インスタンス"kiban"、状態READYには、このサービスに対する1件のハンドラがあります...
サービス"kibanXDB.workslan"には、1件のインスタンスがあります。
  インスタンス"kiban"、状態READYには、このサービスに対する1件のハンドラがあります...
コマンドは正常に終了しました。

May 2, 2011

How to log(write) facility and priority to syslog on Linux(RedHat)

On RHEL 5 or higher version.(CentOS 5 or higher ver.), logging the syslog facility and priority is possible.


Add -S or -SS to SYSLOGD_OPTIONS in /etc/sysconfig/syslog and restart the syslog service for the change to take effect.


example)

  $ cat /etc/sysconfig/syslog
  # Options to syslogd
  # -m 0 disables 'MARK' messages.
  # -r enables logging from remote machines
  # -x disables DNS lookups on messages recieved with -r
  # See syslogd(8) for more details
  SYSLOGD_OPTIONS="-m 0 -SS -r"
  $ service syslog restart



Now you can confirm the facility and priority in your syslog.
  $ cat /var/log messages

  May  1 04:02:02 helium syslogd 1.4.1: restart.
  May  2 13:09:55 helium kernel: Kernel logging (proc) stopped.
  May  2 13:09:55 helium kernel: Kernel log daemon terminating.
  May  2 13:09:57 helium exiting on signal 15 <-- before 
  May  2 13:09:57 helium syslogd 1.4.1: restart (remote reception). <-- after
  May  2 13:09:57 helium kernel: klogd 1.4.1, log source = /proc/kmsg started.

Apr 11, 2011

bash if grammar or(||) and(&&) (if文の or and条件)

I had to check parameters.
I searched if grammar, but I couldn't get a example of if condition || condition.
So I changed key word for search. It was "condition expressions"
I've got the answer. OR condition is -o and AND condition is -a.
Here is the sample code.

OR condition

if ["$1" == "" -o "$2" == ""] ; then
  exit 1
fi

AND condition

if ["$1" == "" -a "$2" == ""] ; then
  exit 1
fi

Apr 8, 2011

Linux version check

Linuxのバージョンを確認する必要があって調べてみた。


#uname -a
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux

#cat /proc/version
Linux version 2.6.18-194.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Fri Apr 2 14:58:35 EDT 2010

#cat /etc/redhat-release
CentOS release 5.5 (Final)

linux ssh起動メモ

テストに使うLinux サーバにsshで接続できなかったので
忘れないようにメモ

#service sshd start

Apr 7, 2011

Linux ユーザの全てのプロセスをkillするスクリプト

社内のLinuxサーバに無限にプロセスを生成するスクリプトが実行されたので
該当ユーザの全てのプロセスをkillするスクリプトを作ってみた。

#!bin/bash
uid=$1
pids=`ps ax -o uid,pid | grep $uid 2> /dev/null | awk '{print $2}'`
for pid in $pids
do
  if [ $pid != $$ ]; then
    echo "${user}: ${pid} killed"
    kill -KILL $pid
  fi
done


ちなみにそのユーザはbashのプロセスをずっと生成したので
以下のコマンドでも対応できる。
killall bash

rootユーザなら以下のコマンドで他のユーザの全てのプロセスをkillすることもできる。

killall5

Solarisの vmstat見方メモ

以前AIXのvmstatの見方を説明したが、
今回はSolaris。

$ vmstat 1 3
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr f0 s6 s1 s1   in   sy   cs us sy id
 0 0 0 1013264 74720  4   5 29  3  3  0  0 -0 -0  0  0  434   85   70  2  3 95
 0 3 0 1011328 96624 11  22  0  0  0  0  0  0  0  0  0  449  137   78  1  3 96
 0 0 0 1011328 96624  7   7  0  0  0  0  0  0  0  0  0  407   88   66  0  3 97

主に仕事で必要な情報はメモリ。

AIXと違うのはまず単位がKBであること、
AIXはページ単位だったため4を掛け算する必要があった。
(ページは4KB)

そしてswap項目は使用可能なvirtual memoryサイズ、
AIXはすでに使われた仮想メモリ領域を意味する。

freeはAIXと同じく物理メモリの使用可能サイズを意味する。

Apr 5, 2011

line numbers in eclipse(行番号を表示する設定)

ソースレビューをしていたら自分のEclipseに行番号が表示されないことに気付き設定した。
忘れないためメモ
Windows(ウィンドウ) -> Preferences(設定) -> General(一般) – > Editors(エディター) -> Text Editors(テキスト・エディター)
“Show Line Numbers(行番号の表示)” チェックボックスにチェックを入れる