Posts

Showing posts from 2013

Ubuntu 12 vnc ssh tunneling

http://askubuntu.com/questions/304017/how-to-set-up-remote-desktop-through-ssh

EHCache

To statically get access to caches so you can get a region and access a cached object for use or diagnosing issues. CacheManager.ALL_CACHE_MANAGERS http://ehcache.org/documentation/user-guide/concepts

STOMP + SSL testing

See STOMP protocol here . Edit activemq/conf/activemq.xml and add the following transport connectors: Start activemq. Connect from the command line: For non SSL just       telnet localhost 61613 For SSL      openssl s_client -connect localhost:61614 Connect with (login/passcode is only required if AMQ configured for authentication): CONNECT accept-version:1.1 login:system passcode:manager host:localhost ^@ CONNECTED will be echo'd Subscribe to one or more queues: SUBSCRIBE id:0 destination:/queue/someQueueName ack:client ^@ Send a message: SEND destination:/queue/someQueueName content-type:text/plain hello queue a ^@ Should see the sent message echo'd See the protocol for more

Thread deadlock analysis

"waiting for monitor entry [0x00007f0e2bbfa000]" the hexadecimal address does not correspond directly with lock addresses. Test code: public class ThreadMonitorTest implements Runnable {   ThreadMonitorTest b;   public static void main(String[] args)   {     ThreadMonitorTest a = new ThreadMonitorTest();     a.b = new ThreadMonitorTest();     a.b.b = a;       new Thread(a).start();     new Thread(a.b).start();   }   public void run()   {     synchronized(this) {       try       {         this.wait(60000);         synchronized (b)         {           b.wait(60000);         }       }       catch (InterruptedException e)       {         e.printStackTrace();       }     }   } } Stacktraces taken while the above test program was executing. --------------------------------------------------------------------------------- Immediately after starting, timed waiting. Thread-1" prio=10 tid=0x00007f0e48114000 nid=0x256e in Object.wait() [0x00

Generically load enum mapping via properties file

  public static void main(String[] args) {     final Properties props = loadProperties("some.properties");     loadMap(props, SomeEnum.class, someMap, "some.properties");   }   public > void loadMap(final Properties props, Class enumType,       Map m, final String resourceName)   {     for (Object o: props.keySet())     {       String key = null;       String value = null;       try       {         key = (String) o;         value = (String) props.get(key);         m.put(key, Enum.valueOf(enumType, value));       }       catch (Exception ex)       {         log.error(String.format("Error loading %s key %s, value %s", resourceName, key, value), ex);       }     }   }   public Properties loadProperties(String resourceName)   {     Properties props = new Properties();     try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName))     {       props.load(is);       return props;     }     catc

Ubuntu 12.04 Windows share

When using Places : Connect to Server use uppercase for the server and domain. The server does not start with \\. Alternatively enter Alt+F2 and enter smb://server/share and click the Run button, then enter the domain and credentials.

Oracle sqlplus history

linux rlwrap sqlplus http://www.oracle-base.com/articles/linux/rlwrap.php

Ubuntu - switch from Unity to Classic

sudo apt-get install gnome-session-fallback logout login and select GNOME Classic http://www.howtogeek.com/189912/how-to-install-the-gnome-classic-desktop-in-ubuntu-14.04/ http://norwied.wordpress.com/2012/12/25/panels-in-ubuntu-12-10-gnome-classic/ Drag and drop to top panel to add application shortcuts Click Alt+Meta(Windows key) and right click on top panel to get add menu Keyboard shortcuts like Alt+Tab won't work initially - install ccsm sudo apt-get install compizconfig-settings-manager Got to Application : System Tools : Preferences : CompizConfig Settings Manager Select Window Management and enable either Application Switcher or Static Application Switcher

ActiveMQ https

ActiveMQ supports tunneling JMS over https to transparently traverse firewalls, but the  documentation  doesn't indicate how to configure it and relevant examples were lacking via google. After hacking for half a day I finally stumbled upon the simple solution. Keep in mind that you will want to create you own keys and certificate. For testing I just used the ones provided in the activemq/conf dir. Simply configure an https transport connector in conf/activemq.xml and pass the keystore, password, and truststore to activemq when started. conf/activemq.xml <amq:transportconnector uri="https://0.0.0.0:61684"> activemq start parameters -Djavax.net.ssl.keyStore=/path/activemq/conf/broker.ks -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/path/activemq/conf/broker.ts import self-signed cert into client jdk keystore cd /path/jdk1.7.0_15/jre/lib/security keytool -import -trustcacerts -file /path/activemq/conf/broker-l

Ubuntu nfsv4 mount

Ubuntu documentation Server: Create export directory or skip if exporting an existing dir: sudo mkdir /export/someDir Install nfs server: sudo apt-get install nfs-kernel-server Edit  /etc/exports Add directory to export, could also be an existing dir: /export/someDir  *(ro,sync,no_root_squash) Start nfs server: sudo /etc/init.d/nfs-kernel-server start Client: Create mount point: sudo mkdir /media/someDir Install nfs server: sudo apt-get install nfs-kernel-server Mount exported dir: sudo mount 192.168.25.123:/export/someDir /media/someDir List all mounts mount due to a bug,  nfs mounts in /etc/fstab fail at startup Create a start script to resolve the issue. Startup/shutdown scripts: http://wiki.debian.org/LSBInitScripts Creates and removes /etc/init.d scripts: sudo update-rc.d -f mount_nfs.sh remove sudo update-rc.d mount_nfs.sh defaults Master/Slave Management script #!/bin/bash function trylock {   (  

Jar relocation to avoid conflicts

https://code.google.com/p/jarjar/

Logging builds and tests on linux

I like to keep a history of various operations so that I can compare them over time and with other systems. START_TIME=`date +%s` echo `date` 'building app' >> ~/bin/buildTiming.txt #Do the build, deployment, tests, or whatever echo `date` 'done building app ' $(echo `date +%s` - $START_TIME | bc) >> ~/bin/buildTiming.txt

Launch JConsole auto connect

jconsole `ps aux | awk '/[a]ctivemq-5.8/ {print $2}'` For the layperson that doesn't speak geek, full explanation of the syntax below: ` ` back-quotes delineate commands which are evaluated first so the result(s) are passed instead ps aux lists all running processes in user friendly format, pid in second column | pipes the output of the previous command to the input of the following command awk parses the ps output - don't need grep - SO ' ' single-quotes delineate instructions to awk / /  foreslashes delineate a regex evaluation in awk [a] sneaky use of regex to eliminate regex returning both activemq and awk pid from ps output - SO { }  braces delineate awk actions print $2 prints the 2nd column of the ps output

Recovering Crashed VBox VM

My Linux host os disk partition filled up due to .xsession_errors consuming all available space and subsequently the running VBox VMs did not shut down cleanly and would not restart. Below is a link indicating possible fixes for .xsession_errors issue. http://askubuntu.com/questions/177058/xsession-errors-file-is-huge-how-can-i-disable Both the active and previous versions of the vmName.vbox XML files became corrupted and the StorageControllers element contents were missing. I tried adding them from an old backup, but that didn't work since I had moved and rebuilt the VM. Should have had a more recent backup. I was able to recover by remapping the storage in the VirtualBox Manager, but it took several tries until I discovered the correct storage type and attributes. If I had recorded those somewhere, it would have been easier to recover.

ActiveMQ remote JMX

With ActiveMQ 5.3.2 at least, you can't connect remotely to JMX unless the hostname in /etc/hosts maps to the routable IP and not localhost 127.0.0.1 http://kyrill007.livejournal.com/3517.html

ActiveMQ Java 7 JAVA_HOME

Executing the stock ActiveMQ 5.3.2 startup script with java 7 complains about JAVA_HOME Turns out the error was related to .activemqrc that was created when I tested with ActiveMQ 5.8.0. The JAVACMD is set to "auto" in that file part way through the 5.3.2 activemq startup script. apache-activemq-5.3.2/bin$ activemq Error: JAVA_HOME is not defined correctly.   We cannot execute auto Java home was set correctly: ...java/apache-activemq-5.3.2/bin$ echo $JAVA_HOME /home/myusername/java/jdk1.7.0_15 Needed to edit the script and add the following right before "if [ -z "$JAVACMD" ] ; then" JAVACMD= This clears the mysterious setting to auto, echoing it returned a blank line: ...java/apache-activemq-5.3.2/bin$ echo $JAVACMD ...java/apache-activemq-5.3.2/bin$

ConcurrentHashMap misuse

Default constructor creates 16 segments which can consume excessive memory if lots of small Maps are constructed. Set the concurrency to 1 unless high contention is expected. http://ria101.wordpress.com/2011/12/12/concurrenthashmap-avoid-a-common-misuse/

svn revert cleanup

Revert all changes in a workspace svn revert -R . Remove all left over files with specific text in path after revert svn status | grep sl | awk '{print $2}' | xargs rm