Thursday, November 28, 2013

Sevntu Checkstyle release 1.10.0

official page: http://sevntu-checkstyle.github.io/sevntu.checkstyle/#1.10.0

New and noteworthy:

New project! sevntu-checkstyle-sonar-plugin -  Project was created as extension to Sonar Checkstyle Plugin for SonarQube, How to use it is described here in detail and pictures, Done by Ruslan Diachenko. More.

New project! sevntu-checkstyle-idea-extension -  Project was created as extension for Checkstyle IDEA plugin for IntelliJ IDEA, How to use it  is described here in details and pictures, Done by Vadim Panasiuk. More.

Bug fixing and improvements in existing Checks: 

CustomDeclarationOrderCheck -  Inner Classes in methods are ignored. Done by Baratali Izmailov. More.

VariableDeclarationUsageDistanceCheck -  Update to ignore raising violation against block constructions/builders and methods with long list arguments, Done by Baratali Izmailov. More.

ConfusingConditionCheck -  Update to skip raising violations on sequential IF, Done by Vadim Panasiuk. More.

NoNullForCollectionReturnCheck -  Fix for NulPointerException, Done by Ilja Dubinin. More.

ForbidCertainImportsCheck -  additional field as Regexp for specifying ignored imports from forbidden, Done by Daniil Yaroslavtsev. More.

Updates in messages -  Done by Baratali Izmailov, Ilja Dubinin, Vadim Panasiuk. More.



General information:
repository: https://github.com/sevntu-checkstyle/sevntu.checkstyle
mail-list: https://groups.google.com/forum/?hl=en#!forum/sevntu-checkstyle

Monday, November 25, 2013

Saturday, November 23, 2013

How to merge github wiki changes from one repository to another


Case:
User forked a repository on GitHub and wiki pages are also forked, user do changes to wiki, but there is no way to send pull request for wiki changes, but Wiki is just another sub repository in GitHub repo, so admin of original repository have to do merge manually.

Example:
source wiki: https://github.com/VadimPanasiuk/sevntu.checkstyle.wiki.git
target/original wiki: https://github.com/sevntu-checkstyle/sevntu.checkstyle.wiki.git

Source of wisdom for massive squash.

Commands:
git clone https://github.com/sevntu-checkstyle/sevntu.checkstyle.wiki.git
cd sevntu.checkstyle.wiki.git
git fetch https://github.com/VadimPanasiuk/sevntu.checkstyle.wiki.git master:master-Vadim
git checkout master-Vadim

#checkout to last non-Vadim's commit  
git reset --hard 34a2f8e627dd6209f4928b6f66a37368789ab492

# do massive squash of all Vadim's changes
git merge --squash HEAD@{1}          
git commit -m "How to use SevNTU Checkstyle in Intellij IDEA (markdown)"
git checkout master

# cherry-pick newly squashed  commit
git cherry-pick cbe1915a65d80769d56f4fbd9a60dd0b88c8c049    

git push


If wiki was forked from latest state of original wiki, you can do it a bit simpler:
git clone https://github.com/sevntu-checkstyle/sevntu.checkstyle.wiki.git
cd sevntu.checkstyle.wiki.git
git pull https://github.com/VadimPanasiuk/sevntu.checkstyle.wiki.git master
# squashing all Vadim's changes in one 
git push origin master

Friday, November 15, 2013

Free API web services

Very concise list of free Web APIs: http://www.programmableweb.com/apis/directory
It is good start for testing REST API calls in your application.

Execute JMX bean method by jolokia wrapper

official site: http://www.jolokia.org/index.html
Reference: http://www.jolokia.org/reference/html/protocol.html#exec

Configuration in your jvisualvm or jconsole:


Example:
[user@server]$ curl localhost:8080/jolokia/exec/my.app:name=my.SyncJob/doSync

Output:
{"timestamp":1384551703,"status":200,"request":{"operation":"doSync","mbean":"my.app:name=my.SyncJob","type":"exec"},"value":null}

Monday, November 11, 2013

Example of orastat usage to find problematic SQL on Oracle server


In Short:
orastat -ser | egrep -v INACT\|BG
# grab PID number of process , for example 9
orastat -sal 9


Here is logs of steps:

[oracle@server ~]$ orastat -ser | egrep -v INACT\|BG
2013/11/07-17:56:50 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-ser arg2=
2013/11/07-17:56:50 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/11.2.0.3 - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:56:50 orastat | Version=3.53 Host=hana Company=some-company
2013/11/07-17:56:50 orastat | -ser: Session Details

Session      Ses    Ses      Wait    Wait       DB     OS                              Session             Last      Last                 +-UserCommits-+ Rollback Program
SID-Ser#     Type   Status   Class / Seq        Userid-Userid-PID-SPID-Term@Server     Start Time          Call ET   SQL    SQL_ID           Count   /Sec    Count Identifier
------------ ------ -------- ------------------ -------------------------------------- ------------------- --------- ------ ------------- -------- ------ -------- ------------------------
9,33801      USER   ACTIVE   User_I/O/51809     SCHEMA2-sb-1234-7525-unknown@other-server.rev 2013/11/07-17:10:05     8_Sec SELECT 1wrbrdf8qrrx8        0      ?        0 JDBC_Thin_Client      
482,56061    USER*  ACTIVE   Network/13         SYS-oracle-14955-14956-?@localhost          2013/11/07-17:56:50     0_Sec SELECT 9d688j2s309du        0      ?        0 sqlplus@localhost_(TNS_V1-V3)

2013/11/07-17:56:50 orastat | Count of USER session(s) in ACTIVE status: 2
2013/11/07-17:56:50 orastat | There are 50 total sessions (mysid=482 - denoted by *)




[oracle@server ~]$ orastat -sal 9
2013/11/07-17:57:23 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-sal arg2=9
2013/11/07-17:57:23 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/11.2.0.3 - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:57:23 orastat | Version=3.53 Host=hana Company=some-company

Session SQL:
--------------------------------------------------------------------------------

SELECT
  cc.company_id  .....
WHERE
  cc.start$ <= sysdate and sysdate < cc.end$

--------------------------------------------------------------------------------

Session Current Wait State:

SID    DB-User          WaitType St WTSeq  Tmr WTTimSec Wait Event Details
------ ---------------- -------- -- ------ --- -------- -------------------------------------
9      SCHEMA2           RealWait  A  51976  -1        1 P1Raw=0000000000000021 P2Raw=00000000000233F5 P3Raw=0000000000000001 db file sequential read WAITED SHORT TIME file# 33 block# 144373 blocks 1

Session Stats:

                                                           ------------------------------------------Session------------------------------------------
SID-Ser#  OS:Userid-PID-Server     DB:User    Program       Hours  CPUTm Commit PFBlks TScans  MemSorts DiskSorts Con+BuGet PhysReads RHRat  LokWaitTm
--------- ------------------------ ---------- ------------ ------ ------ ------ ------ ------ --------- --------- --------- --------- ------ ---------
9,33801   sb-1234-other-server SCHEMA2     JDBCThinClie    0.8 277617      0      0  41609       175         0 118634411     12000  100.0         0

2013/11/07-17:57:25 orastat | orastat | -sal Done






[oracle@server ~]$ orastat -wr
2013/11/07-17:57:48 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-wr arg2=
2013/11/07-17:57:48 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/11.2.0.3 - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:57:48 orastat | Version=3.53 Host=hana Company=some-company
2013/11/07-17:57:48 orastat | -wr: Wait Reasons - By User and Event Type (Idle Waits Excluded)

DB User    Wait Event Type                          Sessions Waiting
---------- ---------------------------------------- ----------------
SCHEMA2     db file sequential read                                 1

2013/11/07-17:57:48 orastat | Total Session(s) Waiting: 1



[oracle@server ~]$ orastat -wr
2013/11/07-17:57:56 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-wr arg2=
2013/11/07-17:57:56 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/11.2.0.3 - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:57:56 orastat | Version=3.53 Host=hana Company=some-company
2013/11/07-17:57:56 orastat | -wr: Wait Reasons - By User and Event Type (Idle Waits Excluded)

DB User    Wait Event Type                          Sessions Waiting
---------- ---------------------------------------- ----------------
SCHEMA2     db file sequential read                                 1

So problem is found, inadequate sequential read that was caused by problems with missed oracle statistics recalculation.

Wednesday, November 6, 2013

Checkstyle idea - require toString() method for Classes

toString() is required for classes that do logging as error to print context of them-self and around.

it might be reasonable to put in toString() only simple types fields that are provided by setXXXXX().

Johua Bloh idea about toString() for classes - Effective Java 2 book - "Item 10: Always override toString" - http://jtechies.blogspot.com/2012/07/item-10-always-override-tostring.html.

Having useful toString() make logging of context during error a simple and pleasant task.

Questions: What criteria we could follow to make a Check that will not force all Classes to have toString() on domains and critical for logging?

Override toString() everywhere is not practical, so we need figure out distinctive characteristics of Classes that have to do it.
- Class that is POJO
- ....

if somebody have ideas please share them on https://groups.google.com/forum/?hl=en#!forum/sevntu-checkstyle or https://groups.google.com/forum/?hl=en#!forum/checkstyle-devel