Wednesday, October 17, 2012

Setting up and playing with Apache Solr on Tomcat

A while back a had a little time to play with Solr, and was instantly blown away by the performance we could achieve on some of our bigger datasets.
Here is some of my initial setup and configuration learnings to maybe help someone get it up and running a little faster.
Starting with setting both up on windows.

Download and extract Apache Tomcat and Solr and copy into your working folders.
Tomcat Setup
If you want tomcat as a service install it using the following:
bin\service.bat install 
Edit the tomcat users under conf.:

If you are going to query Solr using international characters (>127) using HTTP-GET, you must configure Tomcat to conform to the URI standard by accepting percent-encoded UTF-8. Add: URIEncoding="UTF-8"
to the conf/server.xml

Copy the contents of the example\solr your solr home directory D:\Java\apache-solr-3.6.0\home
create the code fragment on $CATALINA_HOME/conf/Catalina/localhost/solr.xml pointing to your solr home.

Startup tomcat, login, deploy the solr.war. Solr Setup
It should be available at http://localhost:8080/solr/admin/ To create a quick test using SolrJ the creates and reads data: Grab the following Maven Libs: JUnit test: Adding data directly from the DB Firstly you need to add the relevant DB libs to the add classpath. Then create data-config.xml as below, if you require custom fields, those can be specified under the fieldstag in the schema.xml shown below the dataconfig.xml A custom field in the schema.xml: Add in the solrconfig.xml make sure to point the the data-config.xml, the handler has to be registered in the solrconfig.xml as follows. Once that is all setup a full import can be done with the following: http://localhost:8080/solr/admin/dataimport?command=full-import Then you should be good to go with some lightning fast data retrieval.

Sunday, September 9, 2012

Android App : iBoincStats


A while back I did an iOS app iBoincStats which has since been downloaded about 2300 times.

I have recently submitted another tiny game to Apple, and in the doldrums that is the app store approval process I 
set myself a little challenge: download, learn, write and publish iBoincStats for Android be the other application get approved.

I have to give Android full credit, if you are a Java developer, developing for Android is really simple. I tried getting it all
up and running a couple years back, but with the simulator taking 20 minutes+ to start up, I deleted it very quickly. This time with the latest SDK and intelliJ 11 it was just a little slower than the iOS environment and much more usable.

The default "look and feel" on Android really takes a lot more work to make it look as good an iOS app, I didn't really spend
enough time on that.
If anyone actually downloads it, I'll dedicate a little more time to it.
  

iBoincStats (For Android)

This is a simple stats client to view your BOINC project processing statistics.
Enter your cross project id and access your latest stats.
Some of the popular BOINC projects include:
Seti@home
climateprediction.net
Einstein@home
POEM@home
rosetta@home

More information regarding the BOINC project can be found at:
BOINC home
Wikipedia - Berkely Open Infrastructure for Network Computing
Screen Shots:



Thursday, August 2, 2012

sun.* Packages

Came accross this the other day when a coworker used sun.misc.Base64Decoder, something didn't feel right about the package name, but I had no justification on why he shouldn't use it. After a bit of searching I found the following link:
Sun Packages FAQ  

Quote:
The java.*, javax.* and org.* packages documented in the Java 2 Platform Standard Edition API Specification make up the official, supported, public interface.
 If a Java program directly calls only API in these packages, it will operate on all Java-compatible platforms, regardless of the underlying OS platform.


 The sun.* packages are not part of the supported, public interface. A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.

Makes obvious sense now, but it was actually something I was not aware of.

Tuesday, July 24, 2012

Drop all DB objects - Oracle

Created this for future reference. This SQL goes and drops all user objects in the current DB, great when messing with local Oracle XS DB
declare

v_str1 varchar2(200) := null;

cursor get_sql is select 'drop '||o.object_type||' '|| o.object_name|| DECODE(o.OBJECT_TYPE,'TABLE',' CASCADE CONSTRAINTS PURGE') v_str1
from user_objects o
where o.object_type in ('TABLE','VIEW','PACKAGE','TYPE','PROCEDURE','FUNCTION','TRIGGER','SEQUENCE') order by object_type,object_name;

begin

open get_sql;

loop

fetch get_sql into v_str1;
if get_sql%notfound
then exit;
end if;
execute immediate v_str1;
end loop;
close get_sql;
end;

Wednesday, March 28, 2012

Little handy Maven build helper plugin

Recently had to work on a project where the Maven codehaus axis plug was being used to generate a webservice client.

problem was everytime it built my IDE would moan about missing the generated classes, so I went searching and found this useful Build Helper plugin to help your IDE integration out.

Tuesday, March 6, 2012

iOS App : iBoincStats

My latest app iBoincStats has just been approved by Apple.  Releasing software (even something this small) is always a rush, it never gets old.

I decided to do an app instead of a game for a change, just to see what the interface builder, XML and "work" type development would be like. It turned out being a lot faster and simpler than I expected. I have also always been a big fan of BOINC, and checking my "stats" for many years now, all the way back before there was a BOINC platform, and it was only the SETI@Home project.
 (An added bonus: unlike games this one it would actually be available on the South African App store as well as the international ones)

During my development career I have never really spent a lot of time designing and developing UIs, I always ended up on the backend side of development projects. So take the next statement in that light:
I think Apple has actually done a pretty good job (after some initial learning frustration) with their interface builder and storyboard shipped with XCode. I sat down and after a good couple of hours of struggling, something eventually clicked and it all finally came together. I restarted my project, copied over the backend code and in literally 15 minutes the storyboard and 3 UIs were done. Awesome.

I had a couple "funnies" while still using XCode 4.2, but just upgraded to 4.3 and those particular issues seem to have been corrected.


iBoincStats

This is a simple stats client to view your BOINC project processing statistics.
Enter your cross project id and access your latest stats.
Some of the popular BOINC projects include:
Seti@home
climateprediction.net
Einstein@home
POEM@home
rosetta@home

More information regarding the BOINC project can be found at:
BOINC home
Wikipedia - Berkely Open Infrastructure for Network Computing
Screen Shots:



Wednesday, February 15, 2012

iOS App Store Validation Error

I was attempting to submit an update for Wordballs when I run into an archive validation issue:
iPhone/iPod Touch: Icon.png: icon dimensions (0 x 0) don't meet the size requirements.



The solution ended up being simple enough:
Select Project then go to Build Settings, select All, under Packaging set Compress PNG Files to NO.

I have no idea why this all of a sudden started on my 3rd update, just glad it was simple enough to solve

Sunday, January 29, 2012

Spring 3, Spring Web Services 2 & LDAP Security.

This year started on a good note, another one of those "the deadline won't change" / "skip all the red tape" / "Wild West" type of projects in which I got to figure out and implement some functionality using some relatively new libraries and tech for a change, well Spring 3 ain't new but in the Java 5, weblogic 10(.01), Spring 2.5.6 slow corporate kind of world it is all relative.
Due to general time constraints I am not including too much "fluff" in this post, just the nitty gritty of creating and securing a Spring 3 , Spring WS 2 web service using multiple XSDs and LDAP security.
The Code:

The Service Endpoint: ExampleServiceEndpoint
This is the class that will be exposed as web service using the configuration later in the post. The Code: CustomValidationCallbackHandler

This was my bit of custom code I wrote to extend the AbstactCallbackHandler allowing us to use LDAP. As per the comments in the CallbackHandler below, it's probably a good idea to have a cache manager, something like Hazelcast or Ehcache to cache authenticated users, depending on security / performance considerations.
The Digest Validator below can just be used directly from the Sun library, I was just wanted to see how it worked.


The service config:
The configuration for the Endpoint, CallbackHandler and the LDAP Authentication manager.
The Application Context - Server Side:
The Security Context - Server Side:

The Web XML:
Nothing really special here, just the Spring WS MessageDispatcherServlet.
The client config:
To test or use the service you'll need the following:
The Application Context - Client Side Test:

The Security Context - Client Side:

As usual with Java there can be a couple little nuances when it comes to jars and versions so below is part of the pom I used.
The Dependencies:

Saturday, January 28, 2012

Wordballs Release

Finally, Wordballs is live! 
My latest physics based word game. Please check it out if you have an iOS device, and let your friends know. 

It's Free (with ads) and 16mb to download. 
Please take a couple seconds to rate it as well, it will be much appreciated


This game actually took me some time to do. Crazy deadlines and some nasty hours at work meant for some slow going and some very late nights at times. 

I would just like to thank the teams from:

Chipmunk Physics
Cocos 2D

Without their awesome libraries / code this Wordballs would have been impossible.





Free Universal Version - In App Purchase available to remove ads
http://www.wordballs.com/

Popular Posts

Followers