Posts

Showing posts from 2009

Eclipse project explorer label decorations - Type Icons

There is a simple way to see decorations for Interfaces, Abstract Classes, Enums, etc in the Project Explorer. Goto Window : Preferences Search for decorations Click on General : Appearance : Label Decorations Check Java Type Indicator on and apply You will now see the decorations in the Project Explorer

Is the API RESTful

REST APIs must be hypertext-driven RESTful URI design

Eclipse JBoss/WebLogic debugging and hotswap

How to configure Eclipse debugging and hotswap for JBoss and WebLogic Excerpt: Lastly, tell Eclipse not to erase other files in the output folder every time it builds the project. While still in Preferences navigate to Java | Compiler | Building and uncheck Scrub output folders when cleaning projects. That's it. Now every time you save a Java file, Eclipse will recompile it and JBoss will reload it. WebLogic hot swap

Terracotta vs. Hibernate

After a side-by-side implementation comparison, where ACID Transactions and persistence were not strictly required, utilizing Terracotta required ~1/4 the LOC implementation of a Hibernate implementation. Terracotta required ~5 implementaion files vs. ~14 implementation files for Hibernate - several were related to DDL. Hibernate required DDL, mapping files or annotations, DAOs, dbUnit test data, and integration tests. Terracotta required POJOs and plain unit tests instead of the integration tests necessary for Hibernate. To avoid surprises, it is generally good practice to thoroughly test all Hibernate mappings and test against the target database. Also significant, is the fact that the Terracotta implementation doesn't unnecessarily tax the least scalable component of the system; the database.

Remote windows shutdown/restart

c:> shutdown -? c:> shutdown -r -f -m \\<Computer> -t 1 -c "some message" Restart in 1 second forcing applications to close

Windows Tools

Cygwin howto OpenSSH and X VNC is almost always the wrong solution for connecting to a Linux box. $ ssh -X -C -c blowfish username@linuxbox gnome-panel cygwin sshd install cygwin ssh install RKTools - alternative to cygwin TCPView - Sysinternals Windows Telnet server Telnet client - Java Applet The Java Telnet Application

Favor composition over inheritance

I have take Josh Bloch’s recommendations to heart: • Item 15 minimize mutability • Item 16 favor composition over inheritance • Close/limit the API as much as possible and open/expose it only as necessary • Design for inheritance and document it or disallow it I have created very few class inheritance hierarchies over the years – except when I was heavily doing swing/UI work. I used to create lots of abstract classes for common behavior; however, I have since switched to creating interface inheritance hierarchies and utilizing composition. While it is slightly more work except for testing, I can’t recall any particular situation where composition hasn’t worked. However, there are certainly situations where a class inheritance hierarchy is more ideal and I would still favor it over composition. I have specifically found composition to be excellent for TDD. I can test the parent class fully. Later when I compose, I use a mock and just test the pass-through methods and the new behavior

Exception best practices

Favor RuntimeExceptions over checked exceptions – follow Hibernate’s example. This allows clients to choose what to do. Always declare throws on methods even for runtime exceptions - for clarity, not necessary in tests Always include @throws in the JavaDoc for each exception and state under what circumstances it throws the exceptions Always include the details (state) related to the cause of the exception in the message - this will help others debug the issue (it isn’t really for us the developers, it’s for the poor guys/gals on the front line who have to debug our broken s$*t) – utilize String.format and include what was being processed and all state that might be helpful in understanding the issue – beware of possible NPEs in String.format arg method calls. And yes this takes time and requires thought on how to clearly convey the information; however it is incredibly useful, sometimes even for us developers. Always remember to wrap any source exceptions in your own exception processi

Avoid method chaining

When to use it Just don't!

Use final modifer liberally

The Final Word on the Final Modifier Using final: • Prevents bugs • Ensures thread-safety • Ensures security • Generally improves performance • Enforces better design/implementation - favoring composition over inheritance Final modifier

Windows Loopback adapter for Oracle

Oracle must have primary loopback adapter for DHCP. last installed adapter is primary if add adapter, must uninstall and reinstall loopback for Oracle on Windows Oracle windows loopback adapter install procedure

Filesystem comparison matrix

Wikipedia filesystem comparison matrix

ActiveMQ JMS

ActiveMQ Networks of brokers Distributed queues Other AMQ links http://docs.huihoo.com/javadoc/jboss/4.0.3SP1/jmx/javax/management/MBeanServerInvocationHandler.html http://activemq.apache.org/maven/activemq-core/apidocs/index.html?org/apache/activemq/security/ http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/security/package-summary.html http://code.google.com/p/z-activemq-security-plugin/ http://code.google.com/p/z-activemq-security-plugin/source/browse/#svn/trunk/src/org/ztuffaha/amqsecurity http://activemq.apache.org/clustering.htm Ubuntu autostart: The script already exists. sudo ln -s /home/tcollinsworth/java/apache-activemq-5.3.2/bin/linux-x86-64/activemq /etc/rc2.d/S50activemq Restart on ubuntu linux: sudo /etc/rc2.d/S50activemq Log file location: apache-activemq-5.3.2/data AMQ JMS tests

URI

URI URI scheme URI uri = new URI("schemaElement://pathElement@hostName:1234/pathElement?queryElement#fragmentElement"); System.out.println("getAuthority=" + uri.getAuthority()); System.out.println("getFragment=" + uri.getFragment()); System.out.println("getHost=" + uri.getHost()); System.out.println("getPath=" + uri.getPath()); System.out.println("getPort=" + uri.getPort()); System.out.println("getQuery=" + uri.getQuery()); System.out.println("getScheme=" + uri.getScheme()); System.out.println("getSchemeSpecificPart=" + uri.getSchemeSpecificPart()); Console output: getAuthority=pathElement@hostName:1234 getFragment=fragmentElement getHost=hostName getPath=/pathElement getPort=1234 getQuery=queryElement getScheme=schemaElement getSchemeSpecificPart=//pathElement@hostName:1234/pathElement?queryElement

Titbits

Meritocracy, Technocracy, Nepotism, Democracy

Oracle networking

Oracle instance discovery tool - find instance SIDs on system tnsping - is the listener up

GWT

GWT GWT-Ext most impressive demo Davis Ford - huge table with performance

Ubunto 9.10 nuggets to add after installing

Top things to do after installing Ubuntu Linux 9.10 Karmic Koala

String concatenation vs. StringBuilder

Java String Concatenation and Performance

Cloud Storage

Using Google App Engine and Google distributed BigTable storage Amazon S3 S3 scaling, performance, and retries hadoop HBase Hadoop Database - BigTable Cascading Google BigTable Webservice Terracotta Terracotta EhCache example Nirvanix Storage Delivery Network Mosso Rackspace Sherpa - Yahoo Cloud Storage - CAP theorem Yahoo Developer Network Blog Cloudies Awards apache-cassandra Notes on Distributed Keystores MySQL Project Voldemort LightCloud CouchDB Tokyo Cabinet Google BigTable: One big difference between BigTable and relational databases is how transactions are handled. Row-level transactions are possible in BigTable, but not any other type of transactions. The unsung hero of the day that really makes BigTable shine, however, is Chubby. Chubby is a lock-providing service that is highly available and allows many difficult design decisions to be abstracted away from BigTable. When a BigTable server (master or slave) comes up, it reserves a lock through Chubby with its name and path, a

Java Messaging APIs

Skype4Java Twitter Java APIs SMS Java APIs SNMP AdventNet API SNMP4J RSS Rome RSS ROME JavaWorld HOWTO IRC IM Bots IM Bots imified

Spring links

Spring Introduction Dependency Injection Spring Best Practices Spring Framework Spring tutorial

Hibernate Criterion and functional indexing

Embedding direct SQL into hibernate criterion

Porting to JBoss from Weblogic

Porting to JBoss from Weblogic

JBoss port binding exceptions

Prior to Windows Vista/2008 Server the IANA standards were not adhered to. Windows can grab ports between 1025 and 5000 for its own use. Article Debug Bind Exception

UI Mockup tool

Balsamiq Mockups

Hibernate Spring HSQL testing

Unit Testing Hibernate Mapping Configurations

Convert WinXp physical install to VirtualBox vdi

Create VirtualBox image from hard disk partition Use VMWare and vConverter Some other options

Cloning VBox machine vdi or img

Cloning requires changing the UUID to avoid conflicts befor VirtualBox will allow registering it. Copy img or vdi file to a new location/name Execute VBoxManager internalcommands sethduuid <newName.img|.vdi> In VirtualBox GUI create a new machine When its time to create a new or select existing Virtual Hard Disk select use existing. Click on the folder and then click the Add icon Select the new img or vdi file that you changed the uuid above Complete configuring the machine as typical.

Creating Ubuntu 8.10 VirtualBox VM for Oracle 10g

Oracle 10g linux download is not compatible with Ubuntu Create new VirtualBox Machine Select name and type Insert Ubuntu live CD in drive Mount drive from the machine Start the machine and install Ubuntu To fix the screen resolution follow this HOWTO

Cloudbook

Software development

Database sharding

Shared nothing instances www.codefutures.com highscalability.com

Mocks

Mock Comparison Growing Object-Oriented Software, Guided by Tests jMockit jMock , Mockito EasyMock PowerMock

REST

Restlet Resources Swagger

Java Round Robin Graphing

JRobing-MRTG

JBoss 5

Browse the JNDI tree view In a browser: Connect to http://localhost:8080 or http://localhost:8080/web-console or http://localhost:8080/jmx-console In the Web Console: Open: System : JMX MBeans : jboss : jboss:service=JNDIView In the third/last table click the 'Invoke' button on the list row Or in the JMX Console: Under the jboss section click on the 'service=JNDIView' link In the third/last table click the 'Invoke' button on the list row DO NOT click on jboss.deployment and select 'id="jboss:service=JNDIView",type=Component' It does not have the facilities to list the JNDI tree view. Admin Console http://localhost:8080/admin-console Default username: admin, password: admin Converting to JBoss 5 info: JBoss 5 is strict in validating xml. The persistence.xml needs to be changed from: <?xml version="1.0" encoding="UTF-8"?> <persistence> <persistence-unit name="titan"> . . . TO: <?xml version

JDBC debugging

log4jdbc * P6Spy most well known, not recently updated * Craftsman Spy not recently updated * JAMon (Java Application Monitor) comprehensive app monitor and API, includes JDBC/SQL * JdbcProxy can emulate another JDBC driver to test the app without a database. * LogDriver

Continuous Integration

Hudson

JAXB

Mapping your favorite class

Eclipse

Project .classpath

XML - Russian Doll vs. Salami Slice vs. Venetian Blind

XML Schemas: Best Practices

Hibernate configuration files

hibernate.properties and hibernate.cfg.xml perform the same configuration functions, if hibernate.cfg.xml exists it takes precedence over hibernate.properties. The configurations can include Datastore, SessionFactory, Connection Pool, Transactions, and Cache Provider. Much if not all of this can also be specified in the persistence.xml and the *-ds.xml. Generally the persistence.xml specifies only the persistence unit name, jndi-name, mode (create, drop, etc.) for an EE application and everything in a standalone application. Generally the *-ds.xml specifies the data source connection parameters, jdbc url, driver class, credentials, connection test parameter, provider type (Oracle, MySQL, etc.). Generally the hibernate.cfg.xml specifies the others. hibernate.cfg.xml is placed in WEB-INF/classes persistence.xml is placed in META-INF in jar with entity beans Hibernate Quickly

Eclipse Remote System Explorer Plugin

Like winscp for Eclipse: Remote System Explorer (RSE) • remote file systems through SSH, FTP or dstore agents (seamless editing of remote files including remote search and compare), • remote shell access (compiling with error navigation), • remote process handling through dstore agents, and remote debugging through CDT / gdb /

GC Tuning

Sun's VM Garbage Collection Tuning documentation Sun tuning presentation GC log format Garbage Collector Visualization

Remote JConsole and VisualGC

To connect visualgc remotely you need to be running jstatd on the server to be monitored. Create a jstatd.all.policy containing: grant codebase "file:${java.home}/../lib/tools.jar" { permission java.security.AllPermission; }; Set and export the JAVA_HOME environment property and start jstatd with: nohup jstatd -J-Djava.security.policy=jstatd.all.policy > jstatd.out 2>jstatd.err & The default port is 1099. Either get the pid from the server or start JConsole to get it. In JConsole int Remote process enter server:port and a username and password if you set authentication to true below. Ah yes, you will have to have started the Java process with the following environment (but should be using JConsole for monitoring and debugging anyway): -Dcom.sun.management.jmxremote.port=11099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false When JConsole starts, click on the VM Summary tab. This shows you many details about the

EE5 Web Service - Maven + Eclipse + JBoss 5

In Eclipse Create the project: File : New : Other : Maven Project Uncheck create a simple project (skip archetype selection) Click Next Select Catalog: Internal Double-click maven-archetype-webapp Enter Group Id: com.company.xxx Enter Artifact Id: someName Click Finish Set the Java version: Open the pom.xml Add the following: . . . <build> <finalName>someName</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project> Create the artifacts: Right click on the project name in Package Explorer Select New : Source Folder Enter src/main/java Click Finish Right click on the new source folder src/main/java Select New : Package Enter a new package name or structure Ri

DocBook format

DocBook XML is a library of standard XML tags you can use to write stylesheets for generating other output like HTML, PDF, etc. Build DocBook XML in Eclipse

Diagnosing EE/System problems

Check the following: (order depends on issue) JVM - JConsole (memory, cpu utililzation, threads, deadlocks) - JStack (blocking, locks, what are threads doing) or kill -3 Logs - Load Balancer log - Access Log - Query Log - GC log - been burned by this one twice - Server logs (JBoss, server, error, etc.) - Log4j logging latency - use async appenders Virtualization issues (VMWare) - OS scheduling latency - Network latency - Filesystem latency OS stats - top - ntop - iostats External System Latency - databases - AD - EMail - MOM/JMS - Web Services - network storage - etc.

Import cert into Java keystore

from jdk.X.X.X/jre/lib/security keytool -import -file some.cert -keystore cacerts default password: changeit

Open Office Wiki Publisher

Create documents in Open Office WYSIWYG and publish/update to MediaWiki.

Java Pose

Technical Debt

32 bit Windows and memory above 4 GB

Geoff Chappel's blog

Oracle composite indexes

Composite index examples and explanations

ssh agent to eliminate remote login password prompt

Configure and run the ssh agent to eliminate the need to manually login to a remote system to execute commands. Ubuntu default setup comes with ssh agent automatically - you just need to configure it. 1. Generate a private key: ssh-keygen -t dsa 2. Copy this key to the correct place on the remote machine, usually this is: ~/.ssh/authorized_keys 3. Run ssh-add This require you to enter your local passphrase and your remote password. You can also set up Ubuntu to ask you this passphrase at login ps -u <username> | grep ssh-agent What is it and how do I use it?

Oracle function based index

Richard Foote's Blog Slides explaining implications and performance of function indexes and computed columns. Optimization steps: - Execute show plan before optimization - record and review - Check row count of tables in where clause to see impact of full table scans - Measure query performance to see if improvement is necessary - Index and or rewrite queries as necessary - Execute show plan to validate index selection by the CBO - Measure the query performance to validate gains - Document and share your results with the team For Function-based indexes: - Create a function that computes a virtual column - Create a function based index on the virtual column computed by the function - Use the virtual column via the function in the query where clause Syntax for function-based indexes: create [unique | nonclustered] index index_name on [[ database.] owner.] table_name (column_expression [asc | desc] [, column_expression [asc | desc]]... set showplan on set noexec on select * FROM so

Installing Subversion

Followed this link to install svn mkdir src cd src wget http://subversion.tigris.org/downloads/subversion-1.6.4.tar.bz2 wget http://subversion.tigris.org/downloads/subversion-deps-1.6.4.tar.bz2 tar -xvjpf subversion-1.6.4.tar.bz2 tar -xvjpf subversion-deps-1.6.4.tar.bz2 cd subversion-1.6.4 ./configure --prefix=$HOME --without-berkeley-db --with-ssl LDFLAGS="-L/lib64" make make install installing subversion on bluehost Setup repository and start server creating repository linux from scratch.org ssh setup svn book red-bean.com The below didn't work: Followed this link with corrections and modifications to install svn on hostmonster

JAMon

The Java Application Monitor (JAMon) is a free, simple, high performance, thread safe, Java API that allows developers to easily monitor production applications.

SQL server

DBA sleuthing

JBoss Log4j doesn't load dtd from classpath

How to fix it.

Sybase JDBC driver source code

Includes show plan implementation

SwisSQL Database migration tools

Support for Java on-the-fly SQL conversion. SwisSQL

Hibernate field level access queries db on getId

When a Hibernate entity is performing field level access, it initializes the proxies and queries the database even though the proxy has the id when getId method is called.

Hibernate cache

Caching and flushing Monitor statistics in jboss jmx-console: Hibernate * name=statistics Ehcache Ehcache performance Ehcache docs Hibernate Caches Hibernate cache documentation Truly Understanding Hibernate Second-Level Cache From above article: The cache is holds strings, and serializable identifiers for relationships. The cache does *not* holding on to actual instances of the objects. Why is this important? Two reasons. One, Hibernate doesn't have to worry that client code (i.e. your code) will manipulate the objects in a way that will disrupt the cache, and two, the relationships and associations do not become 'stale', and are easy to keep up to date as they are simply identifiers. The default setting is to not cache associations; and if you are not aware of this, and simply turn on caching quickly without really reading into how caching works in Hibernate, you will add the overhead of managing the cache without adding much of the benefits. After all, the primary be

Put Windows in its place

I am so happy! Ubuntu and VirtualBox have made it possible to, "Put Windows in its place". Windows is now safely sandboxed and subservient to a *nix operating system. I can now start, stop, reboot it, and constrain Windows use of resources without rebooting my entire system. VirtualBox seamless mode even allows me to run Windows applications as individual Windows right on my Ubuntu desktop. This is so much nicer than the WINE palarva. I installed Windows once under VirtualBox and can now clone it on my system from a single file. If it gets messed up, I only have to copy the original Windows install file which is safely backed up; no need to ever reinstall Windows again. I can make separate instances of Windows if/when I need one for a particular Windows only application, i.e., Enterprise Architect, Quicken, etc. The world of computing has become a better place. Thank you!

Oracle query null processing and indexes

Instead of IS NULL consider NVL and a function based index

Sort

Sort tab delimited file by column 7 (numeric), 2 (alpha-numeric), 3 (numeric) > sort -t " " -k 7,7n -k 2,2 -k 3,3n someFile > someFile.sorted

Oracle locks and blocking

Oracle locks and blocking analysis

Vertical JLabel

Extend BasicLabelUI

grep

Ctrl+v, Ctrl+i to enter a tab To grep lines from log4j error log with date and subsequent caused by: egrep "2009.*xception|Caused by|2009.*ERROR" xxx_errorlog > ~/xxx_errorlog.exceptions To gzip logs once daily: while true do ls | egrep "LockMonitor.*.log.20..-..-.." | egrep -v gz | xargs gzip sleep 86400 done To grep threads from JVM kill -3 <jbossPid> - dumps to jboss log OR jstack > <filename> grep "tid=" thread.dump > allThreads grep -B 1 BLOCKED thread.dump > blocked grep -B 1 RUNNABLE thread.dump > runnable grep -B 1 WAITING thread.dump > waiting egrep "tid|locked" thread.dump > locks -B 1 returns previous line -n will prepend line numbers Do multiple greps appending with >>, then sort

UML

Aggregation/composition symbol goes on the 1 side of the 1..* relationship. In Enterprise Architect (EA) draw aggregation/composition from the 1..* side towards the 1 side - seems backwards to me. {Ordered} goes on the opposite end of aggregation/composition symbol, see UML 2 Toolkit.

Graph library and auto-routing

Sarasvati Workflow editor uses: Netbeans Visual Library Eclipse GEF - auto-routing

Processing Console input

Java 6 added Console Java 5 added Scanner Prior versions required rolling your own input processing . Comparative examples

Java Initializers

Besides static initializers, instance initializer blocks are also supported. One use might be in an anonymous class to set daemon thread status and start the thread.

Debugging High CPU usage on J2EE app - JTOP

To debug high CPU usage on Java app, run JTOP with: java -jar %JDK_HOME%\demo\management\JTop\JTop.jar <hostaddr>:<port> The JVM must be started with the following options set: JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=11099" JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false" JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false" Find the outlier threads Do one of the following to get the Java PID: ps -ef | grep java OR jps OR jconsole Execute one of the following to get a thread stack dump: kill -3 <pid> OR jstack <pid> > %lt;someFile> OR jconsole - connect to VM, click on Threads tab, select thread OR jvisualvm - connect to VM, click thread dump button Analyze the thread stack to see where the code is executing causing high CPU

User complaints of slow J2EE pages - log4j SMTPAppender

Performed a thread stack dump and during slow user performance and saw many threads waiting on log4j appender locks. It turned out that these were due to two separate causes: SMTPAppender backups due to a congested/slow smtp server and VMWare VMFS congestion. Analysis revealed that the default behavior for log4j logging is synchronous. This is ensures the best chance that if the VM dies logging is likely to have been written and not lost because it was queued up in buffers. FileAppender and ConsoleAppender extend from WriterAppender which can be set immediateFlush(false) to append asynchronously. It is reported that this might yield as much as a 20% increase in performance, however you risk losing important forensic logging if a crash occurs. There is an AsyncAppender that can be plumbed in. It creates a queue and another thread that will asynchronously log to other appenders. This is useful for appenders like the SMTPAppender that does not extend from WriterAppender and does not have

ssh config file

alias hosts and specify options so don't have to prepend username like user@host. Can use * as wildcard in hostname Host prod User troy Port 22 HostName somehost.com ForwardX11 yes Compression yes

nawk

Created to parse HAProxy log for graphing grep'd out the page requests of interest, then parsed the file to graph in Open Office awk '{fu=gsub("/"," ",$9); print substr($1,6)" "$2" "$3" "$9" "$14" "$15" "substr($17,2)" "$18}' someTextFile.txt fu=gsub("/"," ",$9) turns "3/4/5/6/7" into "3 4 5 6 7"

Configuring USB support for VirtualBox under Ubuntu 8.10 Intrepid Ibis

You have to use the right version of VirtualBox to get USB support, NOT open-source edition (OSE) listed in Synaptic package manager, follow this post Follow this HOWTO to enable USB support

Extract private key from Java Keystore .jks and convert to PEM for OpenSSL

Certificates, file format, conversion Keytool to OpenSSL conversion tips HowTo export private key from keystore

System.nanoTime() returns sporadic values on multi-processor Solaris on VMWare

Consecutive calls to System.nanoTime() return sporadic differences that are zero, negative, large/huge, and stuck/hung/frozen/not changing for long periods on multi-processor Solaris x86 on/under VMWare. This has not been reproduced on non-VMWare multi-processor systems and single-processor VMWare systems. A trouble ticket was opened with VMWare and they indicated the %RDY was too high at 50 - 100% instead of 5%. They also recommend single-processor VMs vs. multi-processor VMs. The bottom line is that if the code does not run deterministically. Yes nanoTime issues cause real errors Dual processor Fedora 11 on VMWare does not exhibit zero, negative, or stuck nano times, so this appears to be a Solaris on VMWare issue. So as it turns out the VMWare instance created for windows was reloaded with both Fedora 11 and Solaris 5.10 and none of them exhibited the issue. So it seems that the VM image defaults for Windows vs. Solaris may be the issue. Dual processor Windows Server 2008 with Java

Setting up Stunnel for HAProxy SSL support

Stunnel requires OpenSSL Solaris 10 already has OpenSSL, so skip the following part: Download OpenSSL source here $ cd /usr/local/util $ wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/openssl-0.9.8k-sol10-x86-local.gz $ gunzip openssl-0.9.8k-sol10-x86-local.gz $ pkgadd -d openssl-0.9.8k-sol10-x86-local $ rm openssl-0.9.8k-sol10-x86-local If building from source: OpenSSL requires Perl 5 $ perl -version This is perl, v5.8.4 built for i86pc-solaris-64int ... Build and install OpenSSL as follows: $ ./config $ make $ make test $ make install OpenSSL installs in /usr/local/ssl by default. Get Stunnel source here The Stunnel version needs to be one that there is an HAProxy x-forwarded-for patch for, i.e., 4.22 $ cd /usr/local/util $ wget http://www.stunnel.org/download/stunnel/src/stunnel-4.22.tar.gz $ gunzip stunnel-4.22.tar.gz $ tar -xvf stunnel-4.22.tar $ rm stunnel-4.22.tar Download appropriate Stunnel x-forwarded-for source IP patch from HAProxy site $ wget http://hap

Quartz EE SE open-source Job Scheduler

Home Runs as stand-alone or in EE server. Quartz is included in JBoss. Supports cron type syntax, and is customizable. Has JMX bean to list scheduled events and when they will trigger.

Backup solutions

TimeVault like Apple TimeMachine rdiff-backup amanda flyback tar

Oracle on Windows vs. *nix port redirect issue

Oracle on Windows by default redirects connections to another port which does not occur by default on *nix. Oracle connection manager does not do this by default.

Scheduling/timing errors under Solaris on AMD, not Intel

System.nanoTime() returns large value and doesn't increase or increases sporadically.

Package by Feature not by Layer

Directory structure by feature is preferred over by layer.

Loading new JAXB in old JRE

HOWTO load new JAXB in an older JRE

HAProxy syslogd logging alternative

HAProxy uses syslogd which was not trivial to configure. I wrote a UDP logger that takes a bind address and port and logs all UDP packets via log4j DailyRollingFileAppender. startLogger.sh #!/bin/bash java -cp log4j-1.2.15.jar:udp_logger-0.0.1-SNAPSHOT.jar UdpLogger localhost 11088 & echo $! > haproxy.udp_logger.pid shutdownLogger.sh #!/bin/bash if [ -e haproxy.udp_logger.pid ] ; then vpid=`cat haproxy.udp_logger.pid` else echo "no pid file, exiting" exit fi if [ -n "$vpid" ] ; then exists=`ps -ef | grep $vpid | grep -v "grep"` echo $exists else echo "no pid found, exiting" fi if [ -n "$exists" ] ; then echo "kill $vpid" kill $vpid while ps -p $vpid > /dev/null; do sleep 1; done else echo "pid process not found to kill, exiting" fi restartLogger.sh #!/bin/bash ./shutdownLogger.sh ./startLogger.sh On Solaris in /etc/rc2.d install startup / shutdown links ln -s /usr/local/util/udp_logger/s

HostMonster / BlueHost and Java

Successfully installed Java, Apache Tomcat, JBoss 4.2.2, 4.2.3, 5, and Glassfish on HostMonster. All ran in minimal configuration. JBoss would not run with default configuration receiving `too many open files` because `ulimit -n` is 100. JBoss needs ~350 file descriptors to run. The admins at HostMonster were adamant that they would not increase the `ulimit -n` value. Told to go VPS or dedicated server. Bummer!

JBoss Tattletale

* Identify dependencies between JAR files * Find missing classes from the classpath * Spot if a class is located in multiple JAR files * Spot if the same JAR file is located in multiple locations * With a list of what each JAR file requires and provides * Verify the SerialVersionUID of a class * Find similar JAR files that have different version numbers * Find JAR files without a version number * Locate a class in a JAR file * Get the OSGi status of your project * Remove black listed API usage

SVG

Firefox

Bookmarklets

What is it HOWTO

Interesting images

Gears animated gif InkSkape about screen contest Image Library

Apache JMeter load testing

JMeter was easy to setup and use. It was very easy to launch non-gui remote instances and control and monitor them from a local GUI client. On the remote server, just launch the server from the included server script in the bin directory with no options. The client ships the test plan to the remote instances. To create a test plan: Under Test Plan node: Add : Thread Group: specify concurrent users, ramp-up, scheduling, and looping Under Thread Group: Add : Config Element : HTTP Request Defaults: specify host Add : Config Element : HTTP Cookie Manager: specify cookie type and clearing every session if desired Add : Sampler : HTTP Request: specify resource path Add : Listener : Graph Results: specify results file and what data to display on the graph, dynamically configurable at run time Click on Run : Start or Remote Start

Hostmonster dedicated IP and ports

Hostmonster documentations says: "These ports will automatically be opened, by default, after purchasing a dedicated IP address." After wasting hours, I discovered they changed the policy a week ago and now opening up ports must be requested by a ticket. After requesting the ports to be opened, I have been told that my account has to be migrated to a Dedicate IP server for no additional cost. The migration may cause my sites to be down from 4 - 24 hours. It was also requested that I backup my account before the migration. cpanel full backup command: /bin/gtar -c -f - -X /home1/<id>/cpbackup-exclude.conf -X /etc/cpbackup-exclude.conf --exclude backup-[!_]*_[!-]*-[!-]*-[!_]*_<id>* . Initially started a full backup without deleting two versions of Java JDK, two versions of Apache Tomcat and two versions of JBoss. Killing the backup from cpanel Process Manager did not kill the backup since it was running as root. Scheduling another backup after cleaning up and while t

Apache Tomcat 5 book

Connector Bind Interface

Subversion

Subversion Documentation

Hostmonster Performance Test Results

Created a very simple Java math execution loop with Thread.yield() calls after every calculation so it wouldn't hog all the CPU and hurt other user's performance. Executed with java1.6.0_13 with defaults. The program was executed only a few times (< 12) and never more than a few seconds (< 5). The program spawned 8 worker threads with no contention so there was one for each CPU. Execution times were observed as low as ~900 nS on Hostmonster vs. ~1500 nS on my laptop running Ubuntu 8.10, see additional specs and cpu info below. Monitoring top, and running the test program very briefly (< 5 sec), the CPU% peaked at 589% - WOW! Of course as a hosting service, and considering Java and GC, the performance vs. memory utilization, I/O performance, and availability are more important. Hostmonster system: From set: x86_64-redhat-linux-gnu From top: Mem: 16473136k total, 15851752k used, 621384k free, 653060k buffers Swap: 8193108k total, 235480k used, 79

JBoss

Clustering Guide 4.2 Clustering FAQ JBossCache 2nd level clustered transactional caching Versions of Tomcat in JBoss

JavaScript Disable Backspace Internet Explorer

Stop the backspace button in Internet Explorer from navigating

Cookies

Create and read cookies with JavaScript At least: 30 cookies per domain 4 KB per cookie 300 cookies total

DNS cache, TTL, ARP cache

To list TTL on linux: dig <FQ Hostname> To list TTL on Windows: nslookup set debug <FQ Hostname> To display remaining TTL on Windows: ipconfig /displaydns To flush dns on windows: ipconfig /flushdns Windows also caches failed dns resolution for a brief period. Flushing the DNS clears these also, it can be fixed by following this post . Linux by default doesn't have DNS cache unless nscd was installed. If nscd is installed restart it with: sudo /etc/init.d/nscd restart Firefox does have a DNS cache: To clear it go to off-line mode and back to on-line mode, select and deselect: File : Work Offline. To diable it get the DNS cache plugin or enter 'about:config' in the address bar and add a new Integer 'network.dnsCacheExpiration' with value of '0'. Microsoft Internet Explorer (IE) also has DNS cache: Older versions cached for 24 hours and newer versions cache for 30 minutes, see the tech article on manipulating. To display/list ARP cache on windows

Enterprise Architect free image library

Download here Import into a project, Tools : Import Reference Data After importing, select a node, type Ctrl+Shift+W and select alternate image from library.

Solaris VIP behavior - Gratuitous ARP

Tested VIP fail-over between two Solaris 10 x86 servers. If multiple systems with conflicting VIPs bring up the interfaces, the first interface up responds to the service. If the first interface fails or is downed, the other interface will not take over unless is is again signaled up and sends a Gratuitous ARP, see blog entry . How is gratuitous arp used on Windows

Java JVM options

Sun HotSpot: Garbage Collection Tuning IBM JVM: Download , incredibly-fast GC Oracle BEA JRocket - claims "industry's highest performing" JVM

Sub-second Full GC on 100GB heap, 50% nursery and 64 cpus

IBM JVM with -Xgcpolicy:gencon, the newest of all their GC policies IBM JVM downloads Quote from the Blog post: "And last I tried gencon (-Xgcpolicy:gencon), the newest of all their policies. Gencon is suppose to be used on "transactional systems", systems that create a lot of short lived objects. Isn't that what most java applications do? When I started it up, it seemed to be faster, and our load test confirmed that, 30% more throughput. But the amazing thing was that the full GCs were fast, really fast, in the 200-400ms range, for a 50G heap! But wait, it wasn't using most of the heap, and it was GCing all the time. Back to the verbose:gc log, AHA! The nursery was too small, it was about 10% of the heap, and because our application is almost all short lived objects I decided to increase the size of the nursery. I gave it 50% of the heap, and the time between GCs slowed down, but the time to perform the GC was still in the 350ms range. Awesome! I finall

Java RMI hole punching

Punching Holes with Java RMI Dr. Dobbs

Config VIP on Solaris 10

list existing interfaces ifconfig -a select an interface to add a VIP , i.e., hme0 select the next number that isn't used, i hme0:# Add virtual interface ifconfig hme0:1 plumb To remove the interface: ifconfig hme0:1 unplumb configure virtual interface ip you need an ip and mask assigned in advance ifconfig hme0:1 10.60.54.238 \ netmask 255.255.255.0 \ broadcast 10.60.54.255 check that it is available ifconfig -a At this point you can bind services to it, i.e., backups, but it isn't up, Up the interface when you need it to respond, down other server VIP interfaces if this server is taking over responding to the service. ifconfig hme0:1 up To make the service come up automatically , add the ip and hostname to the /etc/hosts file and create a file /etc/hostname.hme0:1 with the hostname in it. Configure, and up in one command: ifconfig hme0:1 10.60.54.238 \ netmask 255.255.255.0 \ broadcast 10.60.54.255 up See this post

Installing Failover VIP on Solaris 10 x86

Since I don't have a working alternative on Solaris: To avoid losing service access due to the loss of a single load balancer I’m writing a simple program that will run on each of the primary and secondary HAProxy servers. Each will monitor the alternate with a TCP connection. If it sees the alternate VIP disappear it will attempt to reestablish the connection to eliminate transient events. If still down and it can access the gateway it will up the VIP on its own OS. It will continue to monitor the alternate VIP. If it sees the alternate VIP available again, it will enter a small random wait. If the alternate stays up it will down the VIP on its own OS. The later is to avoid duplicate IPs and flapping. netstart -rn | grep default Use linux and keepalived, it's simpler and it works. Tried the following, but make failed: Download and install tk gunzip tk-8.5.3-sol10-x86-local.gz pkgadd -d tk-8.5.3-sol10-x86-local Download and install tcl gunzip tcl-8.5.3-sol10-x86-local.gz pkgadd

HTML JavaScript

NetBeans 6.5 - JavaScript Debugger: FireFox and Internet Explorer JavaScript libraries Prototype J avaScript framework comparison Various ways to play sound Sound bgsound, embed W3Schools HTML JavaScript Shake example Table CSS Redirect in Firefox and Internet Explorer: Works in Firefox and Not IE: <META HTTP-EQUIV="refresh" content="0 ; /foo/index.html"> Works in both: <META HTTP-EQUIV="refresh" content="1;URL=/foo/index.html"> Safe fonts on PC and Mac: arial, arial black, comic sans ms, courier, courier new, georgia, helvetica, impact, palatino, times new roman, trebuchet ms, verdana Include backups: CSS: {font-family: courier, arial} HTML Tag: <font face="helvetica, arial">text</font> HTML font list

HOWTO build and install HAProxy on Solaris 10 x86

SunOS 5.10 i86pc i386 Download HAProxy source from here gunzip haproxy-1.3.17.tar.gz tar -xvf haproxy-1.3.17.tar The readme file contains instructions on how to build it. cd haproxy-1.3.17 less README Download GNU make and gcc from sunfreeware.com - search the list on the right Install GNU make Installs to /usr/local/bin gunzip make-3.81-sol10-x86-local.gz pkgadd -d make-3.81-sol10-x86-local Install gcc: gunzip gcc-3.4.6-sol10-x86-local.gz pkgadd -d gcc-3.4.6-sol10-x86-local Make and install HAProxy: Make sure that GNU make is the first make in the path or specify path i.e., export /usr/local/bin:$PATH Make sure gcc can be found in the path i.e., export $PATH:/usr/sfw/bin make TARGET=solaris CPU=generic Create a user and group: /etc/passwd haproxy:x:114:126::/home/haproxy:/bin/false /etc/group haproxy:x:126: Create an config file , see docs and examples directory /etc/haproxy.cfg Install and link to startup / shutdown script Start last (relative to range of numbers) ln -sf /usr/lo

Apache commons Virtual File System (VFS)

Doesn't support creating jar or zip files Capability matrix

JBoss 4.2.x

The default app is located at: jboss-4.2.2.GA/server/ /deploy/jboss-web.deployer/ROOT.war To change the default landing page, change its WEB-INF/web.xml and/or index.html

Photoshop

Effects tutorials

IRC IM Bots

How to write a bot Google Talk bots

Sprint now flash

widget

Java Swing Calendar Component

MiG, very nice $795 one developer (no source) $10K (w/source) Calendar Component $50 one developer (no source) $500 (w/source)

SwingRCP for EclipseRCP

Develop and run Swing without wrappers or SWT bridge in EclipseRCP

NetBeans RCP

Examples

Java InetAddress isReachable ICMP (Ping)

It doesn't do ICMP on Windows, it opens TCP echo on port 7. On linux/unix you have to set the suid bit on Java executables to allow it to use ICMP. So that article didn't clearly explain the whole story. When the executable bit is set if a user has permissions to run the program the executable runs at permissions of the owner. If like mine, your java was owned by account with non-root privileges, it still won't be able to access ICMP. You have to set suid bit after changing ownership as the latter clears the suid bit. sudo chown -R root:root sudo chmod 4755 /bin/java Never did get this to work because once the suid bit was set, encountered the following error: libjli.so file not found. I believe this might have to do with suid bit not being set on LD_LIBRARY_PATH references and/or shared libs because it might present a security issue. After discussing with associates realized going this route is probably a bad idea. This would cause all Java programs to run as root presenti

Java traceroute, tracert

DocJar

Linux/Unix misc

http://linux.101hacks.com bash, profile, sourcing, environment inheritance, et. al. network connection monitoring tcptrack Use the following to avoid coding paths or using environment variables in scripts: BASEDIR=$(dirname $0) Erasing contents of a file with /dev/zero /dev/null /dev/zero Creating a RamDisk List CPUs and types: cat /proc/cpuinfo Filesystem structure Filesystem Hierarchy Standard (FHS) chrontab quick reference LD_LIBRARY_PATH - don't set it, set-uid programs ignore it List linked files ldd Iterate what make install will do: make -n install <makefile> Virtual IP configuration: Unix, Linux, Windows HA failover with keepalived: Linux HA through award-winning 'Failover': Solaris, Linux Load balancing/clustering: Window, Linux Ultra Monkey: load balancing and HA To kill process where pid is in file: backtick replaces command with command execution, see bash programming kill `cat pid.file` Reboot Solaris: shutdown -y -i6 -g0 Solaris lo