<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>hross.net</title>
        <link>http://hross.net/blog/</link>
        <description>Tech + Caffeine = blog</description>
        <language>en-US</language>
        <copyright>Copyright 2010</copyright>
        <lastBuildDate>Wed, 10 Mar 2010 08:42:04 -0500</lastBuildDate>
        <generator>http://www.sixapart.com/movabletype/</generator>
        <docs>http://www.rssboard.org/rss-specification</docs>
        
        <item>
            <title>Helvetica</title>
            <description><![CDATA[<p>The best thing about Netflix is the instant queue and its constant ability to surprise me. I end up watching movies and documentaries about things I would normally never see, simply because I wouldn’t know they exist. One such example is the documentary <a href="http://www.helveticafilm.com/">Helvetica</a>.</p>  <p>I am sure there are many consultants, programmers and others in the IT world who, like me, end up wearing the graphic designer hat from time to time. It may be to create icons or images for a web site, or it may be to edit CSS styles. </p>  <p>If you are one of these types of people, and you have even a passing interest in design, Helvetica is for you. It takes you down the rabbit hole of typeface design, various artistic movements, and the “why’s” and “how’s” of what make a good typeface. This is one of those movies that could actually make you better at your job and provide some interesting historical context around something we take for granted when we design web sites.</p>  <p>It will also make you look at normal everyday signage in a totally different light.</p>]]></description>
            <link>http://hross.net/blog/2010/03/helvetica.html</link>
            <guid>http://hross.net/blog/2010/03/helvetica.html</guid>
            
            
            <pubDate>Wed, 10 Mar 2010 08:42:04 -0500</pubDate>
        </item>
        
        <item>
            <title>Apache Directory</title>
            <description><![CDATA[<p>In one of my <a href="http://hross.net/blog/2009/09/windows-tools.html">previous posts</a> I mentioned <a href="http://directory.apache.org/studio/">Apache Directory Studio</a> as a great way to view LDAP directories, but the entire <a href="http://directory.apache.org/">Apache Directory</a> project really deserves its own post (and here it is).</p>  <p>First of all, Apache has implemented a fully featured directory browser (<a href="http://directory.apache.org/studio/">Apache Directory Studio</a>) and a fully featured LDAP directory (<a href="http://directory.apache.org/apacheds/1.5/">Apache Directory Server</a>). Both of these projects are entirely Java based. Studio is an eclipse based directory browser with all the bells and whistles. <a href="http://jxplorer.org/">JXplorer</a> is nice, but not as powerful or as easy to use.</p>  <p>However, the real power of ApacheDS is the server. It’s entirely java based and is <a href="http://directory.apache.org/apacheds/1.5/downloads.html">available for a variety of platforms, including Windows</a>. I have yet to find an easier platform to install and use on a variety of operating systems (especially Windows). Rather than trying to build a confusing <a href="http://www.openldap.org/">OpenLDAP</a> implementation, you can simply download, install, and start ApacheDS in 5 to 10 minutes. </p>  <p>And, oh by the way, you can also <a href="http://cwiki.apache.org/DIRxSRVx10/embedding-apacheds-as-a-web-application.html">embed and manipulate ApacheDS in your own applications</a>, since its written entirely in Java and the source code is freely available.</p>  <p>So, if you are looking for an easy, free, directory implementation for your next proof of concept, demo, or unit test, look no further than ApacheDS.</p>]]></description>
            <link>http://hross.net/blog/2010/03/apache-directory.html</link>
            <guid>http://hross.net/blog/2010/03/apache-directory.html</guid>
            
            
            <pubDate>Fri, 05 Mar 2010 10:19:34 -0500</pubDate>
        </item>
        
        <item>
            <title>Google Translate is Awesome</title>
            <description><![CDATA[<p>I am not sure this is even enough for a blog post, but… well it is. Here are just a few the of cool things you can do with Google Translate:</p>  <ol>   <li>Use the new audio capability to <a href="http://weston.ruter.net/projects/google-tts/">generate audio translations of text</a>, automatically.</li>    <li>Use the translate API to <a href="http://translate.google.com/translate_tools?hl=en&amp;layout=1&amp;eotf=1">translate your entire web page by simply including some javascript</a>.</li>    <li>Programmatically translate stuff using the <a href="http://code.google.com/p/google-api-translate-java/">unofficial Java API</a>. There is probably one for .NET, but I haven’t tried it.</li>    <li>Translate bits and pieces of your web site, on demand, using a very cool jQuery plugin called <a href="http://sundaymorning.jaysalvat.com/">Sunday Morning</a>.</li> </ol>]]></description>
            <link>http://hross.net/blog/2010/01/google-translate-is-awesome.html</link>
            <guid>http://hross.net/blog/2010/01/google-translate-is-awesome.html</guid>
            
            
            <pubDate>Thu, 14 Jan 2010 19:30:08 -0500</pubDate>
        </item>
        
        <item>
            <title>Synchronizing Email with Ruby</title>
            <description><![CDATA[<p>Recently, I was in the midst of a Windows 7 installation when my company decided to migrate my email to a new mail server. As we in the IT world are aware, migrations rarely go as planned. It seemed like as good a time as any for me to start a project I have long considered: migrating all of my email to Gmail.</p>  <p>I guess this is technically something I’m not supposed to do. Then again, it is no less secure than downloading and sending email using my local laptop and a standard email client (provided the passwords/accounts are properly encrypted). Either way, I love Gmail for personal email and there is no way my entire work organization is going to switch to Gmail, so I decided to set up my own little synchronization process.</p>  <p>Here is what I did:</p>  <p>1.) <a href="http://mail.google.com/support/bin/answer.py?hl=en&amp;answer=75725">Enable IMAP on my Gmail account</a>. My work email is already IMAP, so this let me drag and drop folders from one mail account to another using Thunderbird. Once all my folders were migrated, I only had to worry about new email in my inbox.</p>  <p>2.) Set up a synchronization process from my work email to my Gmail account. Transferring mail itself is pretty simple. There is an <a href="http://www.faqs.org/rfcs/rfc822.html">RFC that defines what mail messages look like</a>, so they are the same data from one mail account to the other. The trick is moving them automatically.</p>  <p>Since I already have a Linux host that runs full time (this site), it seemed like my most sane option would be to write something that I could schedule using <a href="http://en.wikipedia.org/wiki/Cron">cron</a>. Since I am a member of the <a href="http://en.wikipedia.org/wiki/Cargo_cult_programming">cargo cult</a>, I thought I could pretty easily find something on Google written in Java.</p>  <p>After some searching, though, it seemed like the best and simplest examples were all written in Ruby. Unfortunately, none of them did exactly what I wanted so I figured I would have to write a bit of code. Before I began this endeavor, I knew nothing about Ruby (yes, I am way behind), but it seemed like a good time to learn.</p>  <p>I started off with some setup: </p>  <p><a title="http://wiki.dreamhost.com/Ruby" href="http://wiki.dreamhost.com/Ruby">http://wiki.dreamhost.com/Ruby</a></p>  <p><a title="http://wiki.dreamhost.com/index.php/Ruby_on_Rails" href="http://wiki.dreamhost.com/index.php/Ruby_on_Rails">http://wiki.dreamhost.com/index.php/Ruby_on_Rails</a></p>  <p>Next I went with a few blogs/docs and some source from the beginnings of <a href="http://github.com/rgrove/larch">larch</a>:</p>  <p><a title="http://ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html" href="http://ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html">http://ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html</a></p>  <p><a title="http://wonko.com/post/ruby_script_to_sync_email_from_any_imap_server_to_gmail" href="http://wonko.com/post/ruby_script_to_sync_email_from_any_imap_server_to_gmail">http://wonko.com/post/ruby_script_to_sync_email_from_any_imap_server_to_gmail</a></p>  <p><a title="http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html" href="http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html">http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html</a></p>  <p>While I like larch, it doesn’t delete from my inbox, has way more features than I need, and it is more object oriented (and thus harder to understand) than I would like. Since I am a Ruby novice, I wanted something simple that I could make sure was working. Here is what I came up with:</p>  <pre>#! ~/run/bin/ruby
require 'net/imap'

puts &quot;Synchronizing mailboxes...&quot;

# create destination imap
dest = Net::IMAP.new(&quot;imap.gmail.com&quot;,993,true)
dest.login(&quot;my.account@gmail.com&quot;, &quot;password&quot;)

# create source imap
source = Net::IMAP.new(&quot;imap.work.com&quot;,993,true)
source.login(&quot;my.account@work.com&quot;, &quot;password&quot;)

puts &quot;Logins complete. Checking source mailbox for mail.&quot;

source.select('INBOX')
source.search([&quot;NOT&quot;, &quot;DELETED&quot;]).each do |message_id|
        puts &quot;Found message: #{message_id}&quot;
        msg = source.fetch(message_id, ['RFC822', 'FLAGS',
                  'INTERNALDATE'])[0]

        puts &quot;Transferring message with id: #{message_id}&quot;
        dest.append('INBOX', msg.attr['RFC822'], msg.attr['FLAGS'],
            msg.attr['INTERNALDATE'])

        puts &quot;Deleting message from source inbox.&quot;
        source.store(message_id, &quot;+FLAGS&quot;, [:Deleted])
end
puts &quot;Transfer complete. Logging out.&quot;

source.logout()
source.disconnect()

dest.logout()
dest.disconnect()

puts &quot;done.&quot;</pre>

<p>&#160;</p>

<p>Simple, huh? I set this up to run as a cron job every ten minutes and that’s all it took.</p>]]></description>
            <link>http://hross.net/blog/2010/01/synchronizing-email-with-ruby.html</link>
            <guid>http://hross.net/blog/2010/01/synchronizing-email-with-ruby.html</guid>
            
            
            <pubDate>Mon, 11 Jan 2010 08:42:28 -0500</pubDate>
        </item>
        
        <item>
            <title>Windows Tools</title>
            <description><![CDATA[<p>It came out just in time for my birthday this year: <a href="http://www.hanselman.com/blog/ScottHanselmans2009UltimateDeveloperAndPowerUsersToolListForWindows.aspx">Scott Hanselman’s 2009 Windows Power Tools list</a>. It is indeed a great list. If you are a developer working in Windows and have a few minutes to spare, you might just find something on that list that makes your life a million times easier.</p>  <p>As some of you may know, I recently took a new job within Oracle, and as such I had the privilege of getting a brand new laptop for my birthday (okay, I happened to start the job the same week as my birthday, but it <strong>*felt*</strong> like I got a birthday present). There is nothing quite like a fancy new laptop and a list of awesome tools and utilities to install on it.</p>  <p>Anyway, since I’ve finally got it perfectly configured (never to be this fast or nice again), and since searching through the 2009 list is a bit of a grind, I thought I’d share my own, much smaller, list of tools I love (I’ll try to keep this not-so-development-oriented):</p>  <p><a href="http://www.pssoftlab.com/pshl_info.phtml"><strong>PS Hot Launch</strong></a> – I hate the start menu, and the quick start tray is never big enough for all my icons. Enter PS Hot Launch, where I can now keep all my frequently used programs <strong>and</strong> bind hotkeys for startup. There are a lot of heavy duty hotkey managers and the like, but for my money (or lack thereof) this is the easiest, best, and most free version.</p>  <p><strong><a href="http://sourceforge.net/projects/console/">Console</a></strong> – I never use a dos prompt anymore. This one looks way cooler and supports more features (like easy copy and paste).</p>  <p><strong><a href="http://gnuwin32.sourceforge.net/">GNU Win32</a></strong> – One of my biggest peeves about Windows is not being able to do <em>find . | xargs grep “blah”</em> and get results. I sometimes use <a href="http://www.cygwin.com/">cygwin</a>, but this is much less overhead and more native. Thank you GNU.</p>  <p><strong><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=bff59fcf-3148-40b8-a286-fe7274f6e4d8">Microsoft TimeZone</a></strong> – This is a weird one, but I find myself constantly having to check what time it is on the west coast, central, etc.. I am never sure how many hours to subtract. This super simple free utility runs in your tray and lets you customize up to five locales to show current times for when you click on it. A lot easier than googling “current time pacific”.</p>  <p><strong><a href="http://desktop.google.com/">Google Desktop</a></strong> – When it first came out, I thought “will I really use this?” Now I can’t go a day without it. How many times have you thought about an email you sent two months ago but could only remember various key words? Or an old coding project that has something specific you did that you now can’t remember? I can’t even count the number of hours this has saved me in “hunting for stuff” time. Seriously… if you don’t have this you don’t even know what you’re missing.</p>  <p><strong><a href="http://www.textpad.com/">Textpad</a></strong> – My favorite of the “enhanced text editors” crowd. It has a vast array of pluggable syntax highlighting (no more Eclipse to edit one line of Java code), explorer shell integration, and an intuitive interface without a ton of annoying bells and whistles.</p>  <p><strong><a href="http://www.postbox-inc.com/">Postbox</a></strong> – A lightweight email client. If it had better calendar integration I’d give it a gold star. Still a great quick and dirty client that has some nice search capability.</p>  <p><strong><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY</a></strong> – Remember when people made applications that fit in a single executable and just did the job? Yeah… I do too. If you’re not using PuTTY I have no idea why not.</p>  <p><a href="http://www.straightrunning.com/XmingNotes/"><strong>Xming</strong></a> – Perhaps a limited audience on this one, but if you need to use X in Windows, this one is for you.</p>  <p><strong><a href="http://www.oracle.com/technology/products/database/sql_developer">SQLDeveloper</a>&#160;</strong>– Wait… you mean to tell me Oracle made a lightweight, user friendly, super powerful database tool? And I don’t have to use sqlplus or <a href="http://www.toadsoft.com/">Toad</a> anymore? And it’s free?! Say no more…</p>  <p><a href="http://directory.apache.org/studio/"><strong>Apache Directory Studio/Server</strong></a> – I absolutely love these two. I used to use <strong><a href="http://www.ldapbrowser.com/">Softerra LDAP Browser</a></strong>, which is a great tool in its own right, but I cannot tell you how happy I am to see an easy to install, easy to configure LDAP directory for Windows. I can now test LDAP integrations with impunity! Documentation is a bit sparse, but the first time I downloaded and installed this sucker I got all warm and fuzzy inside.</p>  <p><a href="http://winmerge.org/"><strong>WinMerge</strong></a> – I blogged about this earlier and it is great for file and directory comparisons.</p>  <p><strong><a href="http://www.pdfsam.org/">PDF Split and Merge</a></strong> – This is a great tool if you find yourself having to create expense reports or combine PDF’s of scanned documents. The name says it all.</p>  <p><strong><a href="http://they.misled.us/dark-room">Darkroom</a></strong> – I tend to take a lot of notes in text editors and this one just looks awesome. You may not use it all the time, but it definitely gets an A+ on style points.</p>  <p>Here are a few more that are pretty common so I won’t write blurbs about them: <a href="http://www.pidgin.im/">Pidgin</a>, <a href="http://www.imgburn.com/">ImgBurn</a>, <a href="http://www.getpaint.net/">PaintDotNet</a>, <a href="http://download.live.com/writer">LiveWriter</a>, and <a href="http://www.wireshark.org/">Wireshark</a>. And of course there are the myriad plugins you can get for Firefox, but they deserve a separate post.</p>  <p>Alright... happy downloading!</p>]]></description>
            <link>http://hross.net/blog/2009/09/windows-tools.html</link>
            <guid>http://hross.net/blog/2009/09/windows-tools.html</guid>
            
            
            <pubDate>Sat, 12 Sep 2009 13:30:23 -0500</pubDate>
        </item>
        
        <item>
            <title>Sample Search Portlets</title>
            <description><![CDATA[<p>A while back I wrote <a href="http://hross.net/blog/2009/05/direct-web-remoting-jquery-and.html">this post</a> detailing my struggle to find a quick and dirty way of displaying paginated table data in the portal (or anywhere, for that matter). I ended up settling on the method I <a href="http://www.spartanjava.com/2008/paginated-lists-made-really-easy-part-1-of-2-front-end/">found at Spartan Java</a>.</p>  <p>While I enjoyed the series of articles, I still ended up having to review a <a href="http://dotnetslackers.com/articles/ajax/JQuery-Primer-Part-1.aspx">jQuery primer</a>, the <a href="http://directwebremoting.org/dwr/documentation.html">DWR documentation</a> and the <a href="http://svn.apache.org/repos/asf/ibatis/java/ibatis-3/trunk/doc/en/iBATIS-3-User-Guide.pdf">iBATIS user guide</a>. I would have liked to have been able to download the finished application. On top of that there were the usual struggles with portletizing the code, and scrambling to jam a bunch of features into the finished web application before launch.</p>  <p>Thus, when I got asked to provide some “development best practices” portal code, I was in a bit of a bind. I wanted to show off the WCI portal’s ability to consume and use a variety of frameworks, but my original source was… pretty crappy. In the end I went back and rewrote a very simple sample application from scratch (including documentation) using the methods described above.</p>  <p>Hopefully I can save you some time and effort in similar endeavors. Without further ado here is a link to a <a href="http://hross.net/blog/SearchSample.war">sample database search application</a> using the <a href="http://www.oracle.com/technology/obe/obe1013jdev/common/OBEConnection.htm">Oracle HR sample data</a>.</p>  <p>It’s nothing fancy (yes, there are even possible SQL injection vulnerabilities), but if you want a simple example of jQuery, iBATIS, Java and the portal, this is definitely something to check out. All you should have to do is import the war file into eclipse and read the index.html documentation.</p>]]></description>
            <link>http://hross.net/blog/2009/09/sample-search-portlets.html</link>
            <guid>http://hross.net/blog/2009/09/sample-search-portlets.html</guid>
            
            
            <pubDate>Thu, 03 Sep 2009 08:02:03 -0500</pubDate>
        </item>
        
        <item>
            <title>Configuring Oracle XE</title>
            <description><![CDATA[<p>Lately I have found myself setting up a lot of Amazon EC2 instances, new computers, virtual machines and the like. As such, I’ve come to know and love <a href="http://www.oracle.com/technology/products/database/xe/index.html">Oracle XE</a>. While it “just works”, there are a few tweaks that vastly improve performance and behavior. All of these tweaks require you to log in as the system user and run the noted SQL. In no particular order, they are:</p>  <ol>   <li>Modifying the default listening port of the web server (why is it listening on the default Tomcat port?!):      <br />      <pre>begin
	dbms_xdb.sethttpport('7080');
	dbms_xdb.setftpport('2100');
end;</pre>
  </li>

  <li>Increasing the number of sessions and processes so you don’t get locked out of the database: 
    <br />

    <pre>alter system set sessions=250 scope=spfile;
alter system set processes=200 scope=spfile;</pre>
  </li>

  <li>Making the web server available for non-local access (in case you are running out of a console): 
    <pre>begin 
	dbms_xdb.setlistnerlocalaccess(false); 
end;</pre>
  </li>
</ol>

<p>Here are the original links for these tips: </p>

<ul>
  <li><a href="http://www.markcallen.com/oracle/oracle-xe-tuning">Mark C. Allen</a> </li>

  <li><a href="http://daust.blogspot.com/2006/01/xe-changing-default-http-port.html">daust_de</a> </li>

  <li><a href="http://www.liberidu.com/blog/?p=185">blog.gralike.com</a> </li>
</ul>

<p>Finally, I have a tip of my own. If you are running Oracle XE in an EC2 instance (<a href="http://www.oracle.com/technology/pub/articles/lokitz-cloud.html">see this article</a>), you will undoubtedly notice that when you restart your brand new AMI with a new IP, Oracle will fail to start (doh!). In order to fix this, you need to do the following:</p>

<ol>
  <li>Make copies of your listener.ora and tnsnames.ora files. Modify them so that your current hostname in EC2 is replaced with “localhost”, and rename them to listener.ora.localhost and tnsnames.ora.localhost. </li>

  <li>Add this script to the /etc/init.d/oracle-xe startup script (under start is preferable): 
    <pre>NEWHOST=`hostname`

sed s/localhost/$NEWHOST/ /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora.localhost &gt; /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora
sed s/localhost/$NEWHOST/ /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/tnsnames.ora.localhost &gt; /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/tnsnames.ora</pre>
  </li>

  <li>Profit (you may want to modify the above to run as the oracle user -- not as root). </li>
</ol>

<p>(sorry Windows users, you will have to create your own variation of this)</p>]]></description>
            <link>http://hross.net/blog/2009/08/configuring-oracle-xe.html</link>
            <guid>http://hross.net/blog/2009/08/configuring-oracle-xe.html</guid>
            
            
            <pubDate>Thu, 27 Aug 2009 17:46:37 -0500</pubDate>
        </item>
        
        <item>
            <title>EC2/Cloudwatch Gaming Results</title>
            <description><![CDATA[<p>As I mentioned in <a href="http://hross.net/blog/2009/05/running-a-game-server-on-amazo.html">my previous post</a>, I wanted to capture some real world info on hosting a game server in the cloud. The results were a rousing success. We had 5 or 6 people connected at various times, played some Deathmatch and Capture the Flag, and everyone had a ping of 40 or less the entire time. I didn’t notice any latency whatsoever and there were absolutely no packet loss or lag complaints throughout.</p>  <p><strong><em>Cost</em></strong></p>  <p>I haven’t broken down the numbers yet, but all told I started up an EC2 instance and hosted a game for 2 hours. I also attached an elastic IP for ease of use. That cost me less than $0.50. I’d say that’s a pretty good deal.</p>  <p><em><strong>Usage</strong></em></p>  <p>Below are the usage stats for network I/O and CPU usage. I gathered these using <a href="http://hross.net/blog/2009/05/monitoring-performance-with-am.html">my simple Java application</a> and created these no-frills charts in Microsoft Excel (all told, this took about 5 minutes to put together):</p>  <p><a href="http://hross.net/blog/WindowsLiveWriter/EC2CloudwatchGamingResults_E05F/image_2.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="348" alt="image" src="http://hross.net/blog/WindowsLiveWriter/EC2CloudwatchGamingResults_E05F/image_thumb.png" width="644" border="0" /></a> </p>  <p><strong>Figure 1 – Network I/O over a 2 hour F.E.A.R. game.</strong></p>  <p>&#160;</p>  <p><a href="http://hross.net/blog/WindowsLiveWriter/EC2CloudwatchGamingResults_E05F/image_4.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="239" alt="image" src="http://hross.net/blog/WindowsLiveWriter/EC2CloudwatchGamingResults_E05F/image_thumb_1.png" width="644" border="0" /></a> </p>  <p><strong>Figure 2 – CPU Usage over a 2 hour F.E.A.R. game.</strong></p>  <p><strong><em>Conclusion</em></strong></p>  <p>This is a short and imperfect analysis, but overall I’d say the “small” EC2 instance could easily have handled a 16 person game, both from a load and network traffic standpoint, and it would have cost me a dollar or so to host for 2 hours. That seems like great bang for your buck if you’re looking to crank up a quick game and then move on to something else.</p>]]></description>
            <link>http://hross.net/blog/2009/05/ec2cloudwatch-gaming-results.html</link>
            <guid>http://hross.net/blog/2009/05/ec2cloudwatch-gaming-results.html</guid>
            
            
            <pubDate>Sun, 31 May 2009 18:37:19 -0500</pubDate>
        </item>
        
        <item>
            <title>Update Publisher Publishing Targets</title>
            <description><![CDATA[<p>I have recently been working on a utility for porting ALUI databases from a production environment to a development environment. <a href="http://fsanglier.blogspot.com/">Fabien Sanglier</a> started this effort, and I hope to have some code to contribute to his <a href="http://code.google.com/p/alui-toolbox/">ALUI toolbox project</a> very soon.</p>  <p>In the meantime, however, I have been banging my head against the pain that is migrating Publish and Preview target URL’s in Publisher. These URL’s are stored in a binary BLOB in the Publisher database, and are actually serialized Java classes, making them extremely difficult to update (especially when you don’t have access to the original Publisher source code).</p>  <p>My original plan was to wrap all of this stuff into one “uber-utility” and then blog about it. Recently, though, I saw this post on the Oracle Webcenter Interaction discussion forums: <a title="http://forums.oracle.com/forums/thread.jspa?threadID=900736&amp;tstart=0" href="http://forums.oracle.com/forums/thread.jspa?threadID=900736&amp;tstart=0">http://forums.oracle.com/forums/thread.jspa?threadID=900736&amp;tstart=0</a> and it made me think I should probably post the code for migrating Publishing Targets, for the benefit of the sanity of the community at large.</p>  <p>Here is a <a href="http://hross.net/blog/updatepublishtargets.jar">link to a jar file which will update Publisher publish targets</a>. If you crack the jar file with a zip editor, you will be able to update the <em>configuration.properties</em> file in the root directory to suit your needs.</p>  <p>I took the liberty of including the Publisher classes in my own jar, making it simpler to run from a command line. To run it, you will only need to download the correct jdbc driver for your database:</p>  <p><a href="http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html">Oracle JDBC Driver</a></p>  <p><a href="http://msdn.microsoft.com/en-us/data/aa937724.aspx">SQL Server JDBC Driver</a></p>  <p>Next, simply execute it from a java command line with the driver in your classpath, like so:</p>  <pre>java -cp updatepublishtargets.jar;ojdbc14.jar net.hross.content.UpdatePublishTargets</pre>

<p>Note that the utility is in debug mode by default, so nothing will happen to your Publisher database until you set debug to false in the configuration, although now is probably a good time to let you know that <strong><em>I provide no warranties of any kind with this code</em></strong>.</p>

<p>In order to build and run the source, you will need the <em>content.jar</em> and <em>dom4j.jar</em> found in the WEB-INF/lib directory of your <em>ptcs.war</em>. Here is the relevant source code, in case you are looking to build your own version of the utility (source is also in the jar):</p>

<pre class="csharpcode">package net.hross.content;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import net.hross.utility.Configuration;

import com.plumtree.content.data.AttributeKey;
import com.plumtree.content.data.impl.RdbiPublishingTarget;

<span class="kwrd">public</span> <span class="kwrd">class</span> UpdatePublishTargets {

    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> main(String[] args) {
        Connection connection = Configuration.getConnection();

        <span class="kwrd">if</span> (<span class="kwrd">null</span> == connection) {
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;Unable to connect to database. Exiting.&quot;</span>);
        }

        <span class="kwrd">int</span> directoryId = Integer.parseInt(Configuration
                .getString(Configuration.CONFIG_DIRECTORY_ID));
        boolean debug = Boolean.parseBoolean(Configuration
                .getString(Configuration.CONFIG_DEBUG_MODE));
        String newPublishTarget = Configuration
                .getString(Configuration.CONFIG_PUBLISH_TARGET);

        System.<span class="kwrd">out</span>.println(<span class="str">&quot;Updating publish targets for directory ID: &quot;</span>
                + directoryId);

        System.<span class="kwrd">out</span>.println();
        <span class="kwrd">if</span> (debug) {
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;** DEBUG MODE ON ** Nothing will be updated.&quot;</span>);
        } <span class="kwrd">else</span> {
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;** DEBUG MODE OFF ** This is happening for real.&quot;</span>);
        }
        System.<span class="kwrd">out</span>.println();

        updatePublishTarget(connection, directoryId, newPublishTarget, debug);
    }

    <span class="rem">/***</span>
<span class="rem">     * Update the publishing target for a specified directory ID (-1 for all</span>
<span class="rem">     * items).</span>
<span class="rem">     * </span>
<span class="rem">     * @param connection</span>
<span class="rem">     *            Publisher database connection.</span>
<span class="rem">     * @param directoryId</span>
<span class="rem">     *            Directory ID to update. -1 for all items.</span>
<span class="rem">     * @param newPublishTarget</span>
<span class="rem">     *            - New publishing target.</span>
<span class="rem">     * @param debug</span>
<span class="rem">     *            - if true, no replace will be made, data will just be output.</span>
<span class="rem">     */</span>
    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> updatePublishTarget(Connection connection,
            <span class="kwrd">int</span> directoryId, String newPublishTarget, boolean debug) {

        <span class="rem">// create a statement to query the directory id</span>
        <span class="kwrd">try</span> {

            <span class="rem">// create prepared statement for directory query</span>
            PreparedStatement psDirectory = <span class="kwrd">null</span>;
            <span class="kwrd">if</span> (directoryId &gt; 0) {
                psDirectory = connection
                        .prepareStatement(<span class="str">&quot;SELECT * FROM PCSDIRECTORY WHERE ITEMTYPE=0 AND DIRECTORYID=?&quot;</span>);
                psDirectory.setInt(1, directoryId);
            } <span class="kwrd">else</span> {
                psDirectory = connection
                        .prepareStatement(<span class="str">&quot;SELECT * FROM PCSDIRECTORY WHERE ITEMTYPE=0&quot;</span>);
            }
            ResultSet rs = psDirectory.executeQuery();

            <span class="rem">// loop through any rows we need to check</span>
            <span class="kwrd">while</span> (rs.next()) {

                <span class="rem">// get basic info about the object</span>
                String itemName = rs.getString(<span class="str">&quot;ITEMNAME&quot;</span>);
                <span class="kwrd">int</span> size = rs.getInt(<span class="str">&quot;DATASIZE&quot;</span>);
                
                <span class="rem">// reset directory ID in case it was generic</span>
                directoryId = rs.getInt(<span class="str">&quot;DIRECTORYID&quot;</span>);

                <span class="rem">// get binary input stream</span>
                InputStream input = rs.getBinaryStream(<span class="str">&quot;DATABYTES&quot;</span>);

                <span class="rem">// if there's actually some settings, let's check them</span>
                <span class="kwrd">if</span> ((<span class="kwrd">null</span> != input) &amp;&amp; (0 != size)) {

                    <span class="rem">// generic catch statement for problems with this item</span>
                    <span class="kwrd">try</span> {
                        <span class="kwrd">byte</span>[] buffer = <span class="kwrd">new</span> <span class="kwrd">byte</span>[size];
                        input.read(buffer);

                        <span class="rem">// load the hash map from the database</span>
                        Map map = (HashMap) deserialize(buffer);

                        <span class="rem">// loop through the keys in the hash map</span>
                        Iterator keys = map.keySet().iterator();
                        <span class="kwrd">while</span> (keys.hasNext()) {
                            Object key = keys.next();

                            <span class="rem">// this should probably always be true</span>
                            <span class="kwrd">if</span> (key.getClass().equals(AttributeKey.<span class="kwrd">class</span>)) {
                                AttributeKey akey = (AttributeKey) key;

                                <span class="rem">// if we found a publishing target...</span>
                                <span class="kwrd">if</span> (akey.getKeyString().equals(
                                        <span class="str">&quot;PUBLISHING_TARGET&quot;</span>)) {
                                    System.<span class="kwrd">out</span>.println();
                                    System.<span class="kwrd">out</span>.println(<span class="str">&quot;--------------------&quot;</span>);
                                    System.<span class="kwrd">out</span>
                                            .println(<span class="str">&quot;Updating publishing target for:&quot;</span>);
                                    System.<span class="kwrd">out</span>.println(directoryId + <span class="str">&quot; - &quot;</span>
                                            + itemName);

                                    <span class="rem">// get the publishing target info</span>
                                    RdbiPublishingTarget val = (RdbiPublishingTarget) map
                                            .get(key);
                                    String publishTarget = val
                                            .getPublishDetail()
                                            .getTargetLocation();
                                    String publishBrowser = val
                                            .getPublishDetail()
                                            .getBrowserLocation();
                                    String previewTarget = val
                                            .getPreviewDetail()
                                            .getTargetLocation();
                                    String previewBrowser = val
                                            .getPreviewDetail()
                                            .getBrowserLocation();
                                    String ftpUser = val.getPublishDetail()
                                            .getUsername();
                                    String ftpPassword = val.getPublishDetail()
                                            .getPassword();

                                    System.<span class="kwrd">out</span>
                                            .println(<span class="str">&quot;Publish  browser location: &quot;</span>
                                                    + publishBrowser);
                                    System.<span class="kwrd">out</span>.println(<span class="str">&quot;Preview target: &quot;</span>
                                            + previewTarget);
                                    System.<span class="kwrd">out</span>
                                            .println(<span class="str">&quot;Preview browser location: &quot;</span>
                                                    + previewBrowser);
                                    System.<span class="kwrd">out</span>.println(<span class="str">&quot;FTP user: &quot;</span> + ftpUser);
                                    System.<span class="kwrd">out</span>.println(<span class="str">&quot;FTP password: &quot;</span>
                                            + ftpPassword);
                                    System.<span class="kwrd">out</span>.println(<span class="str">&quot;Old publish target: &quot;</span>
                                            + publishTarget);
                                    System.<span class="kwrd">out</span>.println(<span class="str">&quot;New publish target: &quot;</span>
                                            + newPublishTarget);

                                    <span class="rem">// if we are doing this for real, update</span>
                                    <span class="rem">// values</span>
                                    <span class="kwrd">if</span> (!debug) {
                                        val.setTargetValues(newPublishTarget,
                                                publishBrowser, previewTarget,
                                                previewBrowser, ftpUser,
                                                ftpPassword);

                                        map.put(key, val);

                                        <span class="rem">// update the directory</span>
                                        serializeToDirectory(connection,
                                                directoryId, map);
                                        System.<span class="kwrd">out</span>.println(<span class="str">&quot;Update successful.&quot;</span>);
                                    }
                                    System.<span class="kwrd">out</span>.println(<span class="str">&quot;--------------------&quot;</span>);
                                    System.<span class="kwrd">out</span>.println();
                                }
                            }
                        }

                        <span class="rem">// clean up</span>
                        input.close();
                    } <span class="kwrd">catch</span> (IOException ex) {
                        System.<span class="kwrd">out</span>.println(<span class="str">&quot;Something bad happened.&quot;</span>);
                        ex.printStackTrace();
                    }
                } <span class="rem">// if null</span>
            } <span class="rem">// while next rs</span>
        } <span class="kwrd">catch</span> (SQLException ex) {
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;Something bad happened.&quot;</span>);
            ex.printStackTrace();
        }

        System.<span class="kwrd">out</span>.println(<span class="str">&quot;Procedure successfully completed.&quot;</span>);
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> Object deserialize(<span class="kwrd">byte</span> bytes[]) {
        <span class="kwrd">try</span> {
            ByteArrayInputStream byteStream = <span class="kwrd">new</span> ByteArrayInputStream(bytes);
            ObjectInputStream objectStream = <span class="kwrd">new</span> ObjectInputStream(byteStream);
            <span class="kwrd">return</span> objectStream.readObject();
        } <span class="kwrd">catch</span> (Exception ex) {
            <span class="kwrd">return</span> <span class="kwrd">null</span>;
        }
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> serializeToDirectory(Connection conn, <span class="kwrd">int</span> directoryId,
            Object obj) throws IOException, SQLException {
        <span class="kwrd">byte</span> bytes[] = getBytes(obj);
        ByteArrayInputStream byteStream = <span class="kwrd">new</span> ByteArrayInputStream(bytes);

        PreparedStatement ps = conn
                .prepareStatement(<span class="str">&quot;UPDATE PCSDIRECTORY SET DATASIZE=?, DATABYTES=? WHERE DIRECTORYID=?&quot;</span>);
        ps.setInt(1, bytes.length);
        ps.setBinaryStream(2, byteStream, bytes.length);
        ps.setInt(3, directoryId);
        ps.execute();
        conn.commit();
    }

    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">byte</span>[] getBytes(Object obj) throws java.io.IOException {
        ByteArrayOutputStream bos = <span class="kwrd">new</span> ByteArrayOutputStream();
        ObjectOutputStream oos = <span class="kwrd">new</span> ObjectOutputStream(bos);
        oos.writeObject(obj);
        oos.flush();
        oos.close();
        bos.close();
        <span class="kwrd">byte</span>[] data = bos.toByteArray();
        <span class="kwrd">return</span> data;
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>]]></description>
            <link>http://hross.net/blog/2009/05/update-publisher-publishing-ta.html</link>
            <guid>http://hross.net/blog/2009/05/update-publisher-publishing-ta.html</guid>
            
            
            <pubDate>Thu, 21 May 2009 08:09:38 -0500</pubDate>
        </item>
        
        <item>
            <title>Monitoring Performance with Amazon CloudWatch</title>
            <description><![CDATA[<p>It is rare that I am on the bleeding edge of technology. Normally, I don’t think its worth the time and effort necessary to learn something brand new unless it has been at least somewhat widely adopted and accepted by the community at large.</p>  <p>Oddly enough, my blog post about <a href="http://hross.net/blog/2009/05/running-a-game-server-on-amazo.html">running a game server on EC2</a> turned out to be perfectly timed, as Amazon <a href="http://aws.amazon.com/about-aws/whats-new/2009/05/17/monitoring-auto-scaling-elastic-load-balancing/">launched its new CloudWatch, Elastic Scaling and Load Balancing services on Sunday</a>. And since, as I discussed earlier, I have been looking at ways to monitor the usage of my EC2 game server, I somehow find myself on the bleeding edge of the cloud.</p>  <h3>Why CloudWatch?</h3>  <p>As I discussed in my <a href="http://hross.net/blog/2009/05/running-a-game-server-on-amazo.html">previous post</a>, setting up monitoring on an EC2 instance wasn’t that hard to do. However, it did come with some drawbacks:</p>  <ul>   <li><strong>Maintenance</strong> – Although it can be fun to install new software and learn its in’s and out’s, the actual task of upgrading that software, maintaining it, patching it, watching it for security risks, etc, etc is a major pain in the rear end. <a href="http://aws.amazon.com/cloudwatch/">CloudWatch</a> solves this problem by providing a simple service for retrieving performance data, no maintenance or special setup required. </li>    <li><strong>Granularity</strong> – As I discovered with <a href="http://munin.projects.linpro.no/">munin</a>, there are limitations to the frequency with which you can store performance data, not to mention the storage requirements for vast quantities of it. Again, this is hidden from us in the case of <a href="http://aws.amazon.com/cloudwatch/">CloudWatch</a>. </li>    <li><strong>Performance</strong> – Last but certainly not least, monitoring something usually incurs a performance hit. In my previous article I was sampling data on the same host I was tracking statistics from. The very act of collecting performance data could cause that data to be skewed. Since <a href="http://aws.amazon.com/cloudwatch/">CloudWatch</a> abstracts this away from individual instances, this is no longer a problem. </li> </ul>  <h3>Getting Started With CloudWatch</h3>  <p>There are quite a few resources available to get you started with CloudWatch. I recommend taking a look at the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2521&amp;categoryID=187">javascript scratch pad</a> and the other various <a href="http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=187">developer libraries already available</a> (more on this later).</p>  <p>If you really want to get down to the nitty gritty, you should start with the CloudWatch command line interface (CLI). Here are some simple steps to get you started:</p>  <ol>   <li>Download the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&amp;categoryID=88">EC2 API Tools</a> first (you’ll need them to set up monitoring). Check out the <a href="http://docs.amazonwebservices.com/AWSEC2/2008-12-01/GettingStartedGuide/">Getting Started Guide</a> for instructions on extracting the tools and setting up the proper environment variables. </li>    <li>Download the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2534&amp;categoryID=88">CloudWatch API Tools</a>. Check out the included readme for details on environment variable setup. </li>    <li>Start up an EC2 instance like you normally would (see my <a href="http://hross.net/blog/2009/05/running-a-game-server-on-amazo.html">previous post</a>). </li>    <li>Enable monitoring on your running instance using the EC2 API Tools command: <em>ec2-monitor-instances &lt;instanceId&gt;.</em> </li>    <li>Take a look at the <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/DeveloperGuide/index.html">CloudWatch Getting Started Guide</a> for details on the available monitoring parameters, etc. </li>    <li>Run the CloudWatch command <em>mon-get-stats</em> to get some statistics from your running instance (<em>mon-get-stats –help</em> should give you some examples). </li> </ol>  <p>Here are a few things to keep in mind when running the command line utility:</p>  <ul>   <li>I normally output data to a CSV file so I can create fancy graphs in Excel. Here is an example command (Windows) that delimits stats by comma and outputs to a CSV file:      <pre>mon-get-stats CPUUtilization --start-time 2009-05-19T21:00:00
 --end-time 2009-05-19T22:00:00 --period 60 --statistics Average 
--namespace AWS/EC2 --delimiter &quot;,&quot; 
--dimensions &quot;InstanceId=i-2bb5cc42&quot; &gt; stats.csv</pre>
  </li>

  <li>Timestamps – As per the forums, input timestamps are in <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> format with the default timezone UTC (Eastern Standard Time + 4 hours). Output timestamps are in UTC and cannot be changed (so start thinking in Greenwich Mean Time). </li>

  <li>Virtually as soon as monitoring is enabled, statistics are retrieved from your instances. Data is available up to a per-minute frequency and is stored for two weeks. </li>
</ul>

<h3>Writing a Simple Java Monitoring Utility</h3>

<p>As much fun as I was having trying to parse and decipher various command line inputs, I was somewhat disappointed in the output. For one thing, there was the time formatting problem. For another, only one set of statistics (CPU utilization, network I/O, etc) were available at one time.</p>

<p>I am not one to do more work than I need to, so instead of setting off to invent an uber-utility for aggregating data, I simply downloaded the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2517&amp;categoryID=187">Java library for CloudWatch</a> and hacked up some of the sample code until I had a very basic utility for downloading and aggregating the data I wanted. I present it below in case someone finds it useful:</p>

<pre class="csharpcode">import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;

import com.amazonaws.cloudwatch.AmazonCloudWatch;
import com.amazonaws.cloudwatch.AmazonCloudWatchClient;
import com.amazonaws.cloudwatch.AmazonCloudWatchException;
import com.amazonaws.cloudwatch.model.Datapoint;
import com.amazonaws.cloudwatch.model.GetMetricStatisticsRequest;
import com.amazonaws.cloudwatch.model.GetMetricStatisticsResponse;
import com.amazonaws.cloudwatch.model.GetMetricStatisticsResult;

<span class="kwrd">public</span> <span class="kwrd">class</span> GrabStats {

    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> main(String[] args) {
        
        String fileName = <span class="str">&quot;C:\\stats.csv&quot;</span>;

        String startTime = <span class="str">&quot;2009-05-19T20:00:00&quot;</span>;
        String endTime = <span class="str">&quot;2009-05-20T00:00:00&quot;</span>;
        
        String[] statList = { <span class="str">&quot;CPUUtilization&quot;</span>,<span class="str">&quot;NetworkIn&quot;</span>,<span class="str">&quot;NetworkOut&quot;</span> }; <span class="rem">//(%, bytes, bytes)</span>
        
        HashMap&lt;String, HashMap&lt;String, Double&gt;&gt; map = <span class="kwrd">new</span> HashMap&lt;String, HashMap&lt;String, Double&gt;&gt;();
        
        <span class="rem">// grab stats for each stat value</span>
        <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; statList.length; i++) {
            HashMap&lt;String, Double&gt; stats = getStatistics(startTime, endTime, statList[i]);
            map.put(statList[i], stats);
        }
        
        <span class="rem">// write to disk</span>
        <span class="kwrd">try</span> {
            FileWriter fw = <span class="kwrd">new</span> FileWriter(fileName);
            
            <span class="rem">// write the header</span>
            fw.write(<span class="str">&quot;Date&quot;</span>);
            <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; statList.length; i++) {
                fw.write(<span class="str">&quot;,&quot;</span>);
                fw.write(statList[i]);
            }
            fw.write(<span class="str">&quot;\n&quot;</span>);
            
            <span class="rem">// get a date iterator from our first statistic</span>
            Iterator&lt;String&gt; dateIterator = map.get(statList[0]).keySet().iterator();

            <span class="kwrd">while</span>(dateIterator.hasNext()) {
                String date = dateIterator.next();
                fw.write(date);
                
                <span class="rem">// get values for each stat at this date</span>
                <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; statList.length; i++) {
                    Double <span class="kwrd">value</span> = map.get(statList[i]).get(date);
                    fw.write(<span class="str">&quot;,&quot;</span>);
                    fw.write(<span class="kwrd">value</span>.toString());
                }
                
                fw.write(<span class="str">&quot;\n&quot;</span>);
            }
            
            fw.close();
        } <span class="kwrd">catch</span> (IOException ex) {
            <span class="rem">// error storing data</span>
            System.<span class="kwrd">out</span>.print(<span class="str">&quot;Error writing file: &quot;</span> + fileName);
        }

    }

    <span class="rem">// define the cloudwatch service (should be a singleton)</span>
    <span class="kwrd">private</span> <span class="kwrd">static</span> final String _accessKeyId = <span class="str">&quot;&lt;insert key here&gt;&quot;</span>;
    <span class="kwrd">private</span> <span class="kwrd">static</span> final String _secretAccessKey = <span class="str">&quot;&lt;insert access key here&gt;&quot;</span>;
    <span class="kwrd">private</span> <span class="kwrd">static</span> AmazonCloudWatch _service = <span class="kwrd">new</span> AmazonCloudWatchClient(
            _accessKeyId, _secretAccessKey);

    <span class="kwrd">public</span> <span class="kwrd">static</span> HashMap&lt;String, Double&gt; getStatistics(String startTime,
            String endTime, String statName) {
        HashMap&lt;String, Double&gt; map = <span class="kwrd">new</span> HashMap&lt;String, Double&gt;();

        <span class="rem">// build the request with some defaults</span>
        GetMetricStatisticsRequest request = <span class="kwrd">new</span> GetMetricStatisticsRequest();
        ArrayList&lt;String&gt; stats = <span class="kwrd">new</span> ArrayList&lt;String&gt;();
        stats.add(<span class="str">&quot;Average&quot;</span>);
        request.setStartTime(startTime);
        request.setEndTime(endTime);
        request.setPeriod(60); <span class="rem">// statistics every minute</span>
        request.setMeasureName(statName);
        request.setNamespace(<span class="str">&quot;AWS/EC2&quot;</span>);
        request.setStatistics(stats);

        <span class="kwrd">try</span> {

            GetMetricStatisticsResponse response = _service
                    .getMetricStatistics(request);

            <span class="kwrd">if</span> (response.isSetGetMetricStatisticsResult()) {
                GetMetricStatisticsResult getMetricStatisticsResult = response
                        .getGetMetricStatisticsResult();
                java.util.List&lt;Datapoint&gt; datapointsList = getMetricStatisticsResult
                        .getDatapoints();
                <span class="kwrd">for</span> (Datapoint datapoints : datapointsList) {
                    map.put(datapoints.getTimestamp(), datapoints.getAverage());
                }
            }

        } <span class="kwrd">catch</span> (AmazonCloudWatchException ex) {

            System.<span class="kwrd">out</span>.println(<span class="str">&quot;Caught Exception: &quot;</span> + ex.getMessage());
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;Response Status Code: &quot;</span> + ex.getStatusCode());
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;Error Code: &quot;</span> + ex.getErrorCode());
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;Error Type: &quot;</span> + ex.getErrorType());
            System.<span class="kwrd">out</span>.println(<span class="str">&quot;Request ID: &quot;</span> + ex.getRequestId());
            System.<span class="kwrd">out</span>.print(<span class="str">&quot;XML: &quot;</span> + ex.getXML());
        }

        <span class="kwrd">return</span> map;
    }

}</pre>
<style type="text/css">



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<h3>Conclusion</h3>

<p>The CloudWatch tools and utilities are nothing less than I’d expect from Amazon. Everything worked as expected, the documentation was well put together and there were no real surprises with the API. Overall, I am very satisfied with the finished product of my meager efforts.</p>

<p>There are, of course, a few shortcomings:</p>

<ol>
  <li>It would be nice to have more statistics available (memory usage being the main one I’m thinking of). Having the ability to define and collect your own statistics via an API would be even better. Since the API already has a flexible way of defining statistic and type, I have to assume this is coming. </li>

  <li>Output visualization is certainly lacking. It would be great to see someone hack a Google Chart generator into the javascript scratch pad (given my lack of copious amounts of free time, this person won’t be me). </li>

  <li>Adding some statistic collection and enablement to ElasticFox would certainly make things easier to set up and administer. </li>
</ol>

<p>I have to assume these drawbacks will be addressed in future updates, as they have been in the past. I am willing to accept them as the price to pay for being on the bleeding edge of the cloud.</p>]]></description>
            <link>http://hross.net/blog/2009/05/monitoring-performance-with-am.html</link>
            <guid>http://hross.net/blog/2009/05/monitoring-performance-with-am.html</guid>
            
            
            <pubDate>Tue, 19 May 2009 20:13:24 -0500</pubDate>
        </item>
        
        <item>
            <title>Direct Web Remoting, jQuery and Tables</title>
            <description><![CDATA[<p>I recently came across a project where I had a need to display the results of a large SQL query in an HTML table using Java. Of course, I wanted to paginate it, style it, use AJAX to update it, and avoid the need for bulky toolkits or large frameworks. Oh yeah, I was also on an extremely tight deadline (<em>read:</em> proper coding and design principles were not used).</p>  <p>I looked into a couple of options:</p>  <ol>   <li><a href="http://displaytag.sourceforge.net/1.2/">Display Tag</a> – I used this for another project, but it uses session variables to paginate and doesn’t lend itself well to AJAX updates. </li>    <li><a href="http://code.google.com/webtoolkit/">GWT</a> – One of the guys over at <a href="http://www.function1.com">Function1</a> used it recently and it looked pretty slick. Unfortunately, it seemed like a lot of overhead and a styling headache for simple “display a table” functionality. </li>    <li><a href="http://directwebremoting.org/">DWR</a> and <a href="http://jquery.com/">jQuery</a> – As it turns out, I found a great series of blog posts (<a href="http://www.spartanjava.com/2008/paginated-lists-made-really-easy-part-1-of-2-front-end/">part 1</a>, <a href="http://www.spartanjava.com/2008/paginated-lists-made-really-easy-part-2-of-2-back-end/">part 2</a>) over at Spartan Java that pretty much laid out a solution to my problem.</li> </ol>  <p>As you can see from the posts on Spartan Java, creating the framework to display SQL results using DWR and jQuery was simple, fast, and fairly straightforward. Because the poster makes some assumptions about your knowledge of DWR and jQuery, I would suggest combining the above with the <a href="http://directwebremoting.org/dwr/getstarted">getting started guide for DWR</a> and the <a href="http://docs.jquery.com/How_jQuery_Works">jQuery tutorials</a>, if you are unfamiliar with either.</p>  <p>If you know basic DHTML and Java the learning curve should be no problem.</p>  <h3>DWR and the Portal</h3>  <p>As usual, the code I was writing was eventually destined to show up in the portal. Because jQuery is just a simple javascript library, it works great in the portal without issue. Unfortunately, DWR, like many other AJAX frameworks, has its issues when it is gatewayed.</p>  <p>After combing through the dustier nooks of the documentation, googling profusely, and downloading the source code, I discovered the secret to making DWR work. Since some of you may be thinking “wow, DWR looks like something I want to use in my next portlet”, I thought I’d elaborate:</p>  <ol>   <li>Add an anchor tag to whatever portlet you will eventually display in the portal. This anchor tag should have an id (let’s call it “gatewaybase”) and it should reference the base path of DWR in your application (this will almost always be /dwr/). So, for any portlet I want to use DWR in, I would always have the following (this is in a JSP, you might need to change &lt;%=path%&gt; to another base path): </li>    <pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">src</span><span class="kwrd">=&quot;dwr/interface/ClassNameExample.js&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>
&lt;script src=<span class="str">&quot;dwr/engine.js&quot;</span>&gt;<span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">id</span><span class="kwrd">=&quot;gatewaybase&quot;</span> <span class="attr">target</span><span class="kwrd">=&quot;&lt;%=path%&gt;/dwr/&quot;</span> <span class="attr">href</span><span class="kwrd">=&quot;&lt;%=path%&gt;/dwr/&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>
  <style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

  <li>
    <div>The trick to getting DWR working is intercepting its initialization javascript. As it turns out, DWR unofficially supports this, but does not document it. Assuming you’re using jQuery, adding this javascript to either an external .js file, or directly in the page, should do the trick: </div>

    <pre class="csharpcode">jQuery(document).ready(<span class="kwrd">function</span>() {
    <span class="kwrd">if</span> (<span class="kwrd">typeof</span>(PTPortalPage)!=<span class="str">&quot;undefined&quot;</span>) {
        <span class="rem">//TODO: this check won't work if JS in gateway</span>
        dwr.engine._urlRewriteHandler = doInterceptUrl;
    } <span class="kwrd">else</span> <span class="kwrd">if</span> (document.getElementById(<span class="str">&quot;gatewaybase&quot;</span>) != <span class="kwrd">null</span>) {
        dwr.engine._urlRewriteHandler = doInterceptUrl;
    }
});

<span class="kwrd">function</span> doInterceptUrl(data) {
    <span class="rem">// this function intercepts http requests from DWR</span>
    <span class="rem">// and gateways them using an anchor on the main page</span>
    <span class="rem">//TODO: is there a better way? AJAX request for base?</span>
    <span class="kwrd">var</span> rooturl = document.getElementById(<span class="str">&quot;gatewaybase&quot;</span>).href;
    <span class="kwrd">var</span> nongateroot = document.getElementById(<span class="str">&quot;gatewaybase&quot;</span>).target;

    data = data.replace(nongateroot, rooturl);
    <span class="kwrd">return</span> data; 
};</pre>
  </li>
</ol>

<p>What this will do is effectively intercept any javascript requests from your page and add a properly gatewayed URL (via that anchor tag you added in step 1) to the HTTP request.</p>

<p>Also note that you may need to modify your web.xml with the following init-param for DWR:</p>

<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">servlet</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">servlet-name</span><span class="kwrd">&gt;</span>dwr-invoker<span class="kwrd">&lt;/</span><span class="html">servlet-name</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">display-name</span><span class="kwrd">&gt;</span>DWR Servlet<span class="kwrd">&lt;/</span><span class="html">display-name</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">servlet-class</span><span class="kwrd">&gt;</span>org.directwebremoting.servlet.DwrServlet<span class="kwrd">&lt;/</span><span class="html">servlet-class</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">init-param</span><span class="kwrd">&gt;</span>
     <span class="kwrd">&lt;</span><span class="html">param-name</span><span class="kwrd">&gt;</span>debug<span class="kwrd">&lt;/</span><span class="html">param-name</span><span class="kwrd">&gt;</span>
     <span class="kwrd">&lt;</span><span class="html">param-value</span><span class="kwrd">&gt;</span>true<span class="kwrd">&lt;/</span><span class="html">param-value</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">init-param</span><span class="kwrd">&gt;</span>
  <span class="rem">&lt;!-- added for gateway compatability --&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">init-param</span><span class="kwrd">&gt;</span>
     <span class="kwrd">&lt;</span><span class="html">param-name</span><span class="kwrd">&gt;</span>crossDomainSessionSecurity<span class="kwrd">&lt;/</span><span class="html">param-name</span><span class="kwrd">&gt;</span>
     <span class="kwrd">&lt;</span><span class="html">param-value</span><span class="kwrd">&gt;</span>false<span class="kwrd">&lt;/</span><span class="html">param-value</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">init-param</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">servlet</span><span class="kwrd">&gt;</span></pre>
I’m sure there are probably a million ways to build a better mousetrap when displaying tables with Java, but using the above technologies was quick, easy and rewarding.]]></description>
            <link>http://hross.net/blog/2009/05/direct-web-remoting-jquery-and.html</link>
            <guid>http://hross.net/blog/2009/05/direct-web-remoting-jquery-and.html</guid>
            
            
            <pubDate>Mon, 11 May 2009 21:34:49 -0500</pubDate>
        </item>
        
        <item>
            <title>Running a Game Server on Amazon EC2</title>
            <description><![CDATA[<p>Yes, it’s true that I haven’t posted in quite a while. My bad. Hopefully you enjoy this little tidbit, even though it’s my first non-ALUI post on this blog…</p>  <h3>Game Night</h3>  <p>Recently, after a long workday some co-workers and friends of mine started discussing a “game night”. All of us have jobs, lives outside of work, and are no longer college students, but all of us remember the glory days of <a href="http://en.wikipedia.org/wiki/Counter-Strike">Counterstrike</a>, <a href="http://en.wikipedia.org/wiki/Quake">Quake</a> and the like.</p>  <p>Of course, none of us has anything more than a decently performing laptop, and all of us have an aversion to spending money. And so it was that we happened upon a game called <a href="http://projectorigin.warnerbros.com/fearcombat/main">F.E.A.R. Combat</a>. Perhaps its a bit long in the tooth, and perhaps it is behind the times, but it sure is fun, and it sure is <strong>FREE</strong>.</p>  <p>The point of that longwinded story is that every other Wednesday has become game night, or more specifically, <strong>F.E.A.R.</strong> night. And since we are all computer geeks, and we all work in the web technology world in some way or another, <a href="http://techopener.com/blog/">someone</a> brought up the idea of running a <strong>F.E.A.R.</strong> instance on Amazon’s EC2.</p>  <p>Recently, I had a bit of time on my hands and an urge to try it out, and thus this post was born…</p>  <h3>Starting and Connecting to an EC2 Instance</h3>  <p>First, I signed up for <a href="http://aws.amazon.com/ec2/">Amazon EC2</a> (actually, I had already signed up when I wrote <a href="http://hross.net/blog/2008/04/integrating-amazon-s3-with-the.html">this blog post</a>). The invaluable <a href="http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/index.html">Getting Started Guide</a> contained all the basics I needed to start instances, make images, sign up, etc..</p>  <p>Next, I made sure to download the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=609">ElasticFox plugin for Firefox</a>. This makes managing and running EC2 instances much easier. If you want to get started quickly, here is a great <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1797">Getting Started Guide</a> for the plugin.</p>  <p>After installing and setting up ElasticFox, I was ready to start up a base image. I chose to run an Ubuntu image, since package management and documentation is readily available. <a href="http://alestic.com/">This site</a> has a few base AMI’s which I used to get started. I simply searched for the AMI ID I wanted and followed the Elasticfox instructions on starting an instance.</p>  <p>One thing I had to keep in mind was that I wanted to allow the proper TCP/UDP access so that people could connect to my server. In this case, I allowed the following ports:</p>  <div align="center">   <table cellspacing="0" cellpadding="2" width="400" align="center" border="1"><tbody>       <tr>         <td valign="top" width="133"><strong>Application</strong></td>          <td valign="top" width="133"><strong>Protocol</strong></td>          <td valign="top" width="133"><strong>Port</strong></td>       </tr>        <tr>         <td valign="top" width="133">SSH</td>          <td valign="top" width="133">TCP</td>          <td valign="top" width="133">22</td>       </tr>        <tr>         <td valign="top" width="133">HTTP</td>          <td valign="top" width="133">TCP</td>          <td valign="top" width="133">80</td>       </tr>        <tr>         <td valign="top" width="133">F.E.A.R.</td>          <td valign="top" width="133">TCP/UDP</td>          <td valign="top" width="133">27888</td>       </tr>        <tr>         <td valign="top" width="133">TeamSpeak</td>          <td valign="top" width="133">UDP</td>          <td valign="top" width="133">8767</td>       </tr>     </tbody></table> </div>  <p align="center">&#160;</p>  <p>The other thing I did, in order to keep things simple for future connections, was associate a static IP with my running instance (these are called <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1346">Elastic IP’s</a> in EC2 parlance). The procedure is mind-numbingly simple in ElasticFox, so I’ll refer you to the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1797">Getting Started Guide</a> if you need more information on how to do it.</p>  <p>At first, I had some issues actually connecting to my image using SSH (Elasticfox will auto launch an SSH client). The problem ended up being that I was using <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">Putty</a> for SSH and it does not recognize the private key format used by EC2. Doh. Fortunately, you can convert your keys using Puttygen. Amazon was nice enough to dedicate an appendix in their <a href="http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/index.html">Getting Started Guide</a> for <a href="http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/index.html?putty.html">this exact problem</a>.</p>  <p>Problem solved.</p>  <p>My next steps were the steps you’d take to install and configure any server so that it could host F.E.A.R. Combat, a TeamSpeak server (an in-game voice communication server), and a <a href="http://munin.projects.linpro.no/">Munin</a> monitoring instance (so I could get some stats to see how well EC2 performed in a real world scenario).</p>  <h3>Preparing for the Installation</h3>  <p>After everything was running, I wanted to make sure I had the prerequisites to run F.E.A.R. and install any optional components. As it turned out, my Ubuntu instance was fairly locked down. In order to download/install what I needed, I had to <a href="https://help.ubuntu.com/community/Repositories/CommandLine">update my sources list to included the multiverse and universe repositories</a>.</p>  <p>Once this was done, I updated the list of installable applications via:</p>  <pre>apt-get update</pre>

<p>And installed some C++ compatibility libraries for the dedicated server via:</p>

<pre>apt-get install libstdc++5</pre>

<p>At this point I was all set to install the base components of my server.</p>

<h3>Installing and Configuring F.E.A.R. Combat</h3>

<p>My first step was to download the <a href="http://fear.filefront.com/file/FEAR_v108_Dedicated_Linux_Server;71429">F.E.A.R. dedicated linux server here</a>.</p>

<p>Since I already had the prerequisites installed (see above), all I had to do was extract the archive to disk, modify the included <em>start.sh</em> to my liking (I used a custom configuration via the –optionsfile argument, used nohup to prevent it from shutting down accidentally, etc), and start the server.</p>

<h3>Installing and Configuring TeamSpeak</h3>

<p><a href="http://www.teamspeak.com/">TeamSpeak</a> is an in-game voice communication server. Since my game night buddies are mostly remote, I figured it would be nice to provide some voice communication for trash talk and strategy.</p>

<p>I logged in as root and ran:</p>

<pre>apt-get install teamspeak-server</pre>

<p>A teamspeak user was added, the server started and I was ready to rock and roll. As for configuring the server… it seemed to work okay, so I didn’t bother =). However, you can find some <a href="http://forum.teamspeak.com/showthread.php?t=15438">instructions for configuration here</a>.</p>

<h3>Installing and Configuring Munin</h3>

<p><a href="http://munin.projects.linpro.no/">Munin</a> is a monitoring tool that allows you to capture CPU, memory, process data, and all kinds of other stats in 5 minute increments. It can be used for monitoring many systems with many kinds of statistics, but that is outside of the scope of this post. For now let’s just say I wanted a simple way to capture statistics for my AMI.</p>

<p>The installation also turned out to be very simple. It involved using apt-get to install apache and Munin. Rather than regale you with the details, I’ll just point you to <a href="http://www.debuntu.org/book/export/html/134">this simple tutorial</a>.</p>

<p><strong>Note:</strong> I did have some issues getting Munin to work at first, but once I made sure my local node was listening on the loopback adapter only, it seemed to work. See <em>Section 1.3 (Configuring the Node)</em> of the <a href="http://www.debuntu.org/book/export/html/134">tutorial</a> for details.</p>

<h3>Creating and Registering an AMI</h3>

<p>At this point I had everything I needed to run a game server. I tested client connections to my Teamspeak host, Apache server hosting Munin, and the F.E.A.R. server itself and everything worked great.</p>

<p>The only problem was that if I ever shut down the running instance, all of my work would be gone and I would have to re-install everything the next time I wanted to host a game. Thus, I needed to create an AMI from my base image.</p>

<p>The procedure for this was relatively simple, and well documented in the Getting Started Guide <a href="http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/index.html?creating-an-image.html">here</a>. However, there are a few things you might want to know before you dive in:</p>

<ul>
  <li>You’ll need at least a basic working knowledge of <a href="http://aws.amazon.com/s3/">Amazon S3</a>, since you’ll need it to store your finished AMI. I suggest grabbing <a href="http://www.s3fox.net/Default.aspx">S3Fox</a> and using it to create an Amazon S3 bucket. This process is fairly simple, but still a minor annoyance. </li>

  <li>The base image I used did not have the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351">EC2 API tools</a> installed on it, which meant that I could not register my EC2 instance without installing them. I did this by running: </li>
</ul>

<pre>apt-get install ec2-api-tools</pre>

<p>After that, all I needed to do was set my <strong>JAVA_HOME</strong> environment variable and follow the rest of the <a href="http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/index.html?creating-an-image.html">Getting Started Guide</a>.</p>

<h3>Final Thoughts</h3>

<p><strong><em><u>Security:</u></em></strong></p>

<p>As you probably noticed, the configuration on my AMI is hardly secure. I ran things as root, didn’t bother changing passwords or restricting IP’s, etc, etc.. I offer no excuses, save my own laziness.</p>

<p>However, the nice thing about an AMI is that it is only going to be used on game night for a few hours. I’m hardly worried about being hacked. Any time there is a problem, all I have to do is terminate the instance and boot up another AMI. Since nothing is persistent, and there are no credentials on the box, this is great. </p>

<p>Imagine if I had set up a dedicated server for this. I’d have to worry about all kinds of hardening due to the longevity of the configuration. Yuck.</p>

<p><strong><em><u>Going Further:</u></em></strong> </p>

<p>Of course, as always, there are some things I could have done that would have taken this post further:</p>

<ul>
  <li>Capturing “real” usage stats and anecdotal performance data (is this a feasible, reliable, and cost effective solution?). This will probably follow in a future blog post (after the next “game night”). </li>

  <li>Writing a wrapper for the AMI so that it can be started and stopped on-demand via the web. Someone could definitely write a dedicated hosting web site if they could figure out all the possible licensing restrictions. </li>
</ul>

<p>Otherwise… that’s about it. After reading this you should be in a position to create your own AMI’s using EC2. The overall experience for me was rather pleasant, though there were some things I think Amazon could have done to simplify the process.</p>]]></description>
            <link>http://hross.net/blog/2009/05/running-a-game-server-on-amazo.html</link>
            <guid>http://hross.net/blog/2009/05/running-a-game-server-on-amazo.html</guid>
            
            
            <pubDate>Sun, 10 May 2009 21:52:54 -0500</pubDate>
        </item>
        
        <item>
            <title>Adventures in Search - Part 4 - Search Node Operation</title>
            <description><![CDATA[<p>You know, it's funny how some things can seem extremely complicated and then when you crack them open they turn out to be fairly easy to understand. Remember the mystery behind how a G.I. Joe stayed together, but then you broke one and found it was simply a rubber band holding his guts together? Turns out search server is much like that. A terribly complicated-seeming C program that, fundamentally, is held together by a rubber band.</p> <h3>What is a Search Node?</h3> <p>From my <a href="http://hross.net/blog/2008/07/adventures-in-search-part-1-wh.html">previous posts</a>, you've probably inferred that search nodes are the fundamental building blocks of ALUI's search capability. In fact, search nodes are actually the *only* building blocks of the search capability. Everything you need to set up a clustered or non-clustered search environment is contained in one simple install, a few directories and an executable.</p> <p>All this seemingly complicated system amounts to is the following breakdown:</p> <ol> <li>An executable running somewhere listening for requests  <li>An open TCP port that receives text based search queries  <li>Two directories that contain everything search needs to operate: a cluster directory and a node directory.</li></ol> <p>Here's a more complicated picture of what I just listed:</p> <p><a href="http://hross.net/blog/WindowsLiveWriter/AdventuresinSearchPart4SearchNodeOperati_92AA/search_node_architecture_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="354" alt="search_node_architecture" src="http://hross.net/blog/WindowsLiveWriter/AdventuresinSearchPart4SearchNodeOperati_92AA/search_node_architecture_thumb.jpg" width="523" border="0"></a>&nbsp;</p> <p><strong>Figure 1 - Search Node Architecture</strong></p> <h3>Search Requests</h3> <p>Let's start with the executable. When you start it up using the command line (from the bin directory in a *nix environment, or via a service on Windows), it uses environment variables to find its various configuration files, starts up a process, opens a TCP socket on whatever port you tell it to, and sits around waiting for stuff to happen.</p> <p>The "stuff that happens" turns out to also be fairly simple. Search server doesn't actually know anything about portals, documents or anything else for that matter. It sits around and waits for one of two things:</p> <ul> <li>An index request (put some information into the search index so it can be searched for later)  <li>A search request (search for something in the current index)</li></ul> <p>These two things are specified in a text-based custom language over a TCP port. What I mean is that you, Joe Six-pack, could open up a telnet session to your search server port and type a search query (index or request) freehand, were you so inclined. You would type something like the following:</p><pre>( FIELDALIAS ptsearch,[2]PT1,[2]PT1_en,[0.1]PT2,[0.1]PT2_en,[0.1]PT50 ) (((ptsearch:a) TAG phraseQ OR (ptsearch:a*) TAG nearQ) AND ((subtype:"PTCARD")[0])) AND ((((@type:"PTPORTAL")[0]) OR ((@type:"PTCONTENTTEMPLATE")[0])) AND (((ptacl:"u2") OR (ptacl:"51"))[0]) AND (((ptfacl:"u2") OR (ptfacl:"51"))[0])) </pre><pre>METRIC logtf [1] RESULTS 10 PRINT FIELDS parentids,ptacl,ptfacl,PT51,PT56,@type,subtype,ancestors,PT58,PT7,PT53,abstracttype,</pre><pre>PT1,PT1_en,PT2,PT2_en,PT3,PT4,PT5,PT6,PT8,collab_properties,collab_project_url,collab_project_name,collab_icon_alttext_index,collab_acl,publisheduser,portletid TERMS 10000 results[1-10] KWIC 15
</pre>
<p>&nbsp;</p>
<p>Obviously, this kind of a query isn't very pretty or intuitive, but the point is you could type it via telnet and search server would spit out an XML formatted response to your query. You can see these types of queries in your search node logs if you set your logging levels high enough. Lucky for you, the search API takes care of all of this heavy lifting and converts those XML results into the pretty HTML you see when you perform a search in the portal.</p>
<h3>Building a Search Index</h3>
<p>"Okay Ross," you're probably thinking, "I can run search queries over telnet to see what's in my search index. That's all well and good, but how does all that junk get in the index in the first place?"</p>
<p>How indeed. As I mentioned above, that junk gets in there via an index request, which is much like a search request (runs over a TCP port, follows a specific querying language), but allows whoever or whatever to put information into search instead of extract it.</p>
<p>If you look closely at your Publisher <em>content.properties</em> file, Collaboration <em>config.xml</em> file or even at the portal database (PTSERVERCONFIG table), you will see an "Indexing Search Port" and "Indexing Search Host" specified. What these values really do is tell each product (Portal, Publisher, Collaboration) where to submit their new document data (i.e. when someone publishes something, uploads something to a project, or a crawler runs). That data is submitted over the same TCP port to the same type of node that handles queries.</p>
<h3>How an Indexing Request Works</h3>
<p>Here's a brief explanation followed by a couple of pictures:</p>
<ol>
<li>An index request is submitted to a search node. Since that search node may be part of a multi-node cluster, the request goes straight to the cluster file system (remember, all nodes share this directory). 
<li>The request is assigned a transaction ID and added to a queue on the cluster (you can see this in the form of the requests folder in the cluster folder of your search node). 
<li>Every search node in the cluster independently maintains its own transaction ID, which corresponds to the last index request it processed. These nodes continually poll the shared requests folder. If they find a transaction that has a higher ID than the one they maintain, they pull the information for that transaction and add it to their local search index. They then update their local transaction ID to match the transaction they just processed.</li></ol>
<p>You can actually see this process in real time by amping up your search logs and watching the transaction ID's increment when you upload a collab document, create and admin object, etc.. Here's a few Powerpoint diagrams I created of this process:</p>
<p><a href="http://hross.net/blog/WindowsLiveWriter/AdventuresinSearchPart4SearchNodeOperati_92AA/index_request1_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="332" alt="index_request1" src="http://hross.net/blog/WindowsLiveWriter/AdventuresinSearchPart4SearchNodeOperati_92AA/index_request1_thumb.jpg" width="566" border="0"></a> </p>
<p><strong>Figure 2 - Adding an index request to the cluster's transaction queue.</strong></p>
<p><a href="http://hross.net/blog/WindowsLiveWriter/AdventuresinSearchPart4SearchNodeOperati_92AA/index_request2_2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="359" alt="index_request2" src="http://hross.net/blog/WindowsLiveWriter/AdventuresinSearchPart4SearchNodeOperati_92AA/index_request2_thumb.jpg" width="568" border="0"></a> </p>
<p><strong>Figure 3 - Updating a local search index from the transaction queue.</strong></p>
<h3>Conclusion</h3>
<p>As far as node operation goes, that should clear up most of the mystery. At this point, you should understand most of the how's and why's of search operation. The last piece to this puzzle is the "checkpoint" feature, which I'll review in the final exciting chapter of this blog series.</p>]]></description>
            <link>http://hross.net/blog/2008/12/adventures-in-search-part-4-se.html</link>
            <guid>http://hross.net/blog/2008/12/adventures-in-search-part-4-se.html</guid>
            
            
            <pubDate>Mon, 08 Dec 2008 07:48:21 -0500</pubDate>
        </item>
        
        <item>
            <title>Back in the Saddle (Again)</title>
            <description><![CDATA[<p>As you may have noticed (or not noticed, if your read this site from your aggregator), my blog has undergone some much needed renovation. I realize that as a blog reader myself, I appreciate a dearth of "State of the Union" posts in the blogs I read. Nonetheless, there have been quite a few changes, so here's an infrequent update...</p> <ul> <li>I use Movable Type to publish, and despite its complexity, I love the customizability and performance. I found <a href="http://www.codemonkeyramblings.com/themes/2008/03/shadedgrey.html">a great style</a> from the <a href="http://www.codemonkeyramblings.com/themes/">CMR Movable Type Styles Blog</a>, and have customized it to my liking. Finally, no more blah "Minimalist Red" scheme.  <li><a href="http://dev2dev.bea.com">Dev2Dev</a> is finally gone for good, which means some of my blog images were 404'ing. Thank you helpful readers for pointing this out. I finally went back and reset them to point to my own blog.  <li><a href="http://blog.billbenac.com/blog/">Bill Benac</a> recommended we Plumtree bloggers start linking to each other, so you'll notice a blogroll on the right side of the page. If you're blogging and you want to be listed here, give me a shout.  <li>The blog slogan has now officially become "Tech + Caffeine = blog", since I'm tired of dealing with these product name changes. <a href="http://blog.thebdgway.com/2008/10/top-ten-tips-for-writing-plumtree.html">As are other people, apparently</a>.  <li>That Jeep in the picture is mine, featured in some mind-blowingly isolated terrain right outside the <a href="http://www.nps.gov/badl/">Badlands</a>.</li></ul> <p>So what's in store for the future? Well, I still have some posts to write in my Search Series, I have a long backlog of posts regarding various technical minutiae, and then there is your input... Thoughts?</p>]]></description>
            <link>http://hross.net/blog/2008/10/back-in-the-saddle-again.html</link>
            <guid>http://hross.net/blog/2008/10/back-in-the-saddle-again.html</guid>
            
            
            <pubDate>Tue, 28 Oct 2008 17:38:19 -0500</pubDate>
        </item>
        
        <item>
            <title>Using diff to avoid re-importing PTE&apos;s</title>
            <description><![CDATA[<p>Let's take a quick timeout from Search for a more basic post...</p> <p>I don't have a "Cool Tools" section of my blog, like some other <a href="http://function1.com">notable ALUI bloggers</a>, but I do know of a few "cool tools" that have helped me do my job. One of my favorites is a fancy <a href="http://en.wikipedia.org/wiki/Diff">diff</a> utility called <a href="http://www.winmerge.org/">WinMerge</a>.</p> <p><em>(go download it now if you haven't already)</em></p> <p>One of the primary things I use it for is validating product upgrades. If you're as lazy and/or paranoid as I am, you have probably given pause during an ALUI upgrade when you saw the step "re-import the PTE". As most of us know, re-importing a PTE is a mixed bag, as it comes along with a lot of dependencies and can frequently wipe out customizations to web services, portlets, etc. Worse yet, you never quite know what's happening when you import.</p> <p>What if we could analyze a PTE and figure out what changes were made so that we could either: </p> <ul> <ul> <li>make the changes ourselves</li> <li>not bother re-importing</li> <li>at least know what changes were going to be made to our existing data?</li></ul></ul> <p>Turns out this is rather simple (and, obviously, involves WinMerge).</p> <p>Let's use a relevant example to demonstrate: a Publisher upgrade from 6.4 to 6.5. This is an upgrade of a minor revision number, so you would think there would be relatively few changes to the PTE's. Nonetheless, the install guide tells me to re-import, re-import, re-import.</p> <p>Yuck.</p> <p>Instead, I'll take an alternate approach. First, I run the Publisher 6.5 upgrade installer as I normally would. However, once I get to the re-import step, I navigate to the ptcs/6.4/serverpackages directory of my <strong>previous Publisher install</strong> and grab the publisher.pte file therein. Next, I grab the same PTE file from my ptcs/6.5/serverpackages directory.</p> <p>Now I have both default install PTE's. Any differences between them will be the changes due to the 6.4 to 6.5 upgrade. Since these PTE's are really just XML files with fairly obvious naming conventions, I simply open them up side by side in WinMerge and compare the differences...</p> <p><a href="http://hross.net/blog/WindowsLiveWriter/UsingdifftoavoidreimportingPTEs_A0F5/pte_diff_2.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="124" alt="pte_diff" src="http://hross.net/blog/WindowsLiveWriter/UsingdifftoavoidreimportingPTEs_A0F5/pte_diff_thumb.jpg" width="615" border="0"></a> </p> <p>As it turns out, the only changes to the Publisher package in 6.5 are some /jspell URL's that have been added to the gateway settings for some web services. Since I can read the new URL in WinDiff, I can copy the gateway URL's and add them manually. Now I no longer need to import the PTE.</p> <p>... and even if there were more changes and I had to re-import, I would be well informed of what they were before running the import.</p> <p>Okay. We now return you to your regularly scheduled programming.</p>]]></description>
            <link>http://hross.net/blog/2008/10/using-diff-to-avoid-reimportin.html</link>
            <guid>http://hross.net/blog/2008/10/using-diff-to-avoid-reimportin.html</guid>
            
            
            <pubDate>Thu, 23 Oct 2008 16:08:23 -0500</pubDate>
        </item>
        
    </channel>
</rss>
