Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Monday, March 2, 2015

Logback config to suppress event by stacktrace element

Log event in file:
[2015-03-02 09:03:14,418] [server] [user] [ajp-bio-8009-exec-33] [Session][] [ERROR] - An exception has been thrown while processing following requests: '[Request[oid=2021,name=updateSelection,args=[ [ [ 2, 3 ], [ 6, 6 ], [ 11, 11 ] ] ]], Request[oid=2019,name=handleEvent,args=[ popupBeforeOpen, beforePopupOpen, [  ] ]]]'.
java.lang.NullPointerException: null
at com.company.View.fillContextMenu(View.java:444) 
at com.company.View.access$500(View.java:107)
at com.company.View$2.beforePopupOpen(View.java:303)
at sun.reflect.GeneratedMethodAccessor791.invoke(Unknown Source) ~[na:na]


to suppress that event following logback configuration for ch.qos.logback.classic.boolex.JaninoEventEvaluator is required:
<included>

   <property name="common.log.date.format" value="{MM/dd HH:mm:ss:SSS}" />
   <property name="common.log.conversionpattern" value="[%d${common.log.date.format}] [%X{username}] [%c{0}] [%marker] [%p]: %m%n" />

   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
      <target>System.out</target>
      <encoder>
         <pattern>${common.log.conversionpattern}</pattern>
      </encoder>
<!-- perform more precise filtering, you can suppress particular messages here -->
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression><![CDATA[
// suppress ERRORs from legacy code
if (level == ERROR
&& logger.contains("Session")
&& message.contains("handleEvent,args=[ popupBeforeOpen, beforePopupOpen, [  ] ]")
&& message.contains("updateSelection")
       && message.contains("An exception has been thrown while processing following requests")
        && throwableProxy != null && "java.lang.NullPointerException".equals(throwableProxy.getClassName())
&& throwableProxy.getStackTraceElementProxyArray()[0].getSTEAsString().contains("com.mycompany.View.fillContextMenu")
) {
return false;
}

return true;
]]></expression>
</evaluator>
<OnMatch>NEUTRAL</OnMatch>
<OnMismatch>DENY</OnMismatch>
</filter>
   </appender>

   <root level="INFO">
      <appender-ref ref="STDOUT" />
   </root>

</included>

Sunday, January 19, 2014

Checkstyle: ULC classes as static variables

Example of AvoidModifiersForTypesCheck in real code validation, implemented in sevntu.checkstyle 1.0.5 .

http://ulc.canoo.com/ulccommunity/Contributions/Extensions/GoodPractices.html

Static variables
Never keep instances of ULC classes in static variables (ULCIcons neither!). They cannot be shared between different sessions.

Post on ULC Canoo site that helps, at forum .

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.

Thursday, September 12, 2013

Scala Lift steps how to compile and run


Lift: http://liftweb.net/download
Examples: https://github.com/dpp/simply_lift

git clone https://github.com/dpp/simply_lift
cd simply_lift/samples/http_rest
./sbt
> update
> jetty-run

But this project use old version of scala and lift and sbt

to do Project from scratch with all explanations: http://cookbook.liftweb.net/#InstallAndRunning
just Rest example: http://simply.liftweb.net/index-5.3.html#toc-Section-5.3

Experiments:
#udpate sbt-launch.jar from http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html to latest version

# remove old file to activate changes
rm project/build.properties

#register eclipse plugin https://github.com/typesafehub/sbteclipse/
echo "addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0")" > simply_lift/samples/http_rest/project/plugins.sbt


Deploy (jetty, tomact ):
#create a war in target folder
sbt package

#deploy war to Java application server (jetty, tomcat, ...)
https://groups.google.com/forum/#!topic/liftweb/503eibvCvV4

#examples of prod configurations
https://www.assembla.com/spaces/liftweb/wiki/Deployment

Scala vs Nodejs: http://blog.nelsonsilva.eu/2010/12/14/go-vs-scala-vs-nodejs/index.html#disqus_thread

Monday, September 9, 2013

How to run scala as script

1. Through interpreter
$ cat script.scala
println("Hello, World!")

Run:
scala script.scala

2. Thought a Scala script

$ cat script.scala
#!/usr/bin/scala!#
println("Hello, World!")

Run as:
$ ./script.scala

3. Compile and then run compiled class
, source.

$ cat script.scala
object Greeting {
    def main(args: Array[String]) = println("Hello world!")
}

Run as:
$ scalac script.scala
$ scala Greeting


Happy scripting!

Monday, November 28, 2011

California DMV Drive Permit written test

1. Preparation.
Official books http://dmv.ca.gov/pubs/pubs.htm

Good summary to read - http://www.theroadtosiliconvalley.com/transport/californian-drivers-license-dmv-techniques/

Official youtube for lazy - http://www.youtube.com/user/californiadmv

Good online test - http://driving-tests.org/california/california-permit-practice-test/
http://dmv.ca.gov/pubs/interactive/tdrive/exam.htm

Review latest examples of tests in youtube - http://www.youtube.com/watch?v=M5mh62xzw0E&feature=related

2. Make an appointment to DMV
http://dmv.ca.gov/foa/welcome.do?localeName=en

3. In DMV come to appointment desk(1), fill form return to (1), receive number and pay at (2), make a photo(3), go to exam boxes(4).
image created at here.

4. My Test:




Driver Instructor - Anatoliy Chechelnitskij  415 652 74 33. 2hours costed me 75$. I took 9 lessons + 1 lesson for exam 1st attempt + 1 lesson for 2nd exam attempt.
1st attempts - failure:

 2nd attempt - success:

Other variant: