Sunday, February 01, 2015

How to install 3 popular NoSQL databases for development in MacOSX for newbies Part 1 (mongodb) #nosql #mongodb #cassandra #couchbase #part1

  • Part 1(Mongodb) 
  • Part 2 (Cassandra)
  • Part 3 (CouchBase)
This post aims to help all developers (not only Java) that want to develop using NoSQL datastores, specifically MongoDB, Cassandra and Couchbase, in MaOSX. Before starting writing code you need to have the db engines installed and ready for tests. So our goal for these mini posts will be to  install all of them in our local environment and then start coding. (My goal is to write some coding posts using all of them, in the upcoming days).

I am currently using MacOSX 10.10.2 (Yosemite), I have already installed Maven 3.2.x and Java JDK 1.8 in my machine. If you need help as a junior java developer in MacOSX, then I suggest you go through this post

MongoDB

You need to download the binaries for MacOSX, which can be found here. Then, extract the .tgz file to a folder of your choice, for my case is a directory called

\home\work\mongodb\

After doing that you should have within the mongodb directory the following contents, as illustrated in the image below



We are almost there, all we need to do is create with the same director (could be anywhere else actually) a directory called data .  As illustrated in the image below.



 This is the directory where our mongodb instance will save it's data files. In order to start up our MongoDB instance, from the command line we need to issue the following command

> cd \home\work\mongodb\bin

> mongod --dbpath ../data

We should see something like the following, below :


Since I want to make my life easier, using the .profile file I have created an alias command that will start my test mongo, without having to make the 2 steps above. So if you edit your .profile under your home directory, you can add an alias the like the following:(beware these are my local, paths dont forget to change them).

alias startmongo='/Users/papo/work/mongodb/bin/mongod --dbpath /Users/papo/work/mongodb/data/'

So you can issue from command line the command >startmongo and your mongodb instance will start!

What about a client to check our database, maybe create some documents?

 RoboMongo is a nice MongoDB client for MacOSX! Easy to setup and use.

After downloading it, we setup a new connection, with the minimum information.


 And we are ready to go.



Easy!


Saturday, January 10, 2015

το τέλος της φιλελεύθερης ελπίδας μου.

Όπως όλοι οι Έλληνες λίγο πολυ, έτσι κι εγώ ειχα και έχω τις δικές μου πολιτικές εμμονές και ελπίδες. Με αυτές τις εκλογές, αυτή την εποχή, για μένα προσωπικά τελειώνει το κεφάλαιο της ελπίδας σε ότι εχει να κάνει με πράγματα που θα ήθελα να δω εγώ στην χώρα μου και στην διακυβέρνηση της.

Δηλάδη λιγότερο κράτος,μικρότερο, δικαιότερο και αποτελεσματικότερο φορολογικό συστημα, λιγότερη κρατικοδίαιτη επιχειρηματικότητα, λιγότερες κρατικοδίαιτες τράπεζες, αποτελεσματικότερο εκπαιδευτικό συστημα, παιδεία πιο κοντά στις ανάγκες της αγοράς, κράτος που να ευνοοεί την ελευθερη αγορά και όχι μονο τα δικά του παιδιά στην και καλά ελευθερη αγορά, αξιόπιστη δικαιοσύνη και όχι συνδεδεμένη με το πολιτικό συστημα, λιγότερους βουλευετές, λιγότερες υπηρεσίες και συμβουλια. 

Νόμιζα ότι υπήρχαν έστω και λίγες φωνές σε κάποια από τα φιλελευθερα πολιτικά σχήματα των τελευταίων ετών, τους ψήφιζα επί χρόνια, ημουν λάθος. 

Με τις τελευταίες εξελίξεις, για μένα τελειώνει το ανέκδοτο (νόμιζα ότι ηταν ελπίδα) ότι μπορεί να υπάρχουν εκεί έξω φιλελευθερα σχήματα που μπορούν να με εκπροσωπίσουν. Λυπάμαι αλλά η Ελλάδα και ο Ελληνικός λαός δεν θέλει και δεν ονειρευεται τίποτα άλλο από τα μέτρια (κατ' ουσια) χρόνια του ΠΑΣΟΚ του 80 της ΝΔ του 2004 κτλ. Δηλαδή τα δικά μας δικάς μας, τα δικά σας δικα μας, ολοι βολεμένοι ολοι ευχαριστημένοι το κράτος μπουρδέλο. Δεξιοί, αριστεροί, κεντρο σε αυτό τον τόπο είναι απλά φιλόσοφοι φανφαρες, όλοι το ιδιο πρεσβευουν την γυφτιά και το καλο της τσέπης τους και των φίλων τους, αρκεί να καθίσουν στον φτηνό iron throne της εξουσίας σε ένα μικρό κράτος 10 εκατ, το οποίο εχει πτωχεύσει δεκαετίες τώρα.

Monday, November 17, 2014

Do you really want to speed up your Maven compile/packaging? Then takari lifecycle plugin is the answer. #maven #mvn #takari

Like many of you out there, I am working with a multi module Maven project. It is not a huge one comparing to many systems out there, it has 15 modules, with 3 different ear deployments, lots of parametrization with property files and around 100K lines of Java code. During peak development times, the code is heavily refactored, due it's legacy origins and so the need for continuous compiling/packaging and deployment, for every developer. 

Despite the steep learning curve all these years I have embraced Maven and it's philosophy. I am not saying that is perfect, but I truly believe that is a good tool, still relevant, especially while your project and team grows as you grow your project. (This post is not about Maven evangelism though). 

So, one of the problems we had on our team is that, despite switching the right flags, breaking and packaging our code into modules, using profiles and all the 'tools' maven provides, our build and packaging time was  slowly starting to increase, hitting the 1 minute threshold after a complete clean. Our main compiler was Sun/Oracle Javac and the time was monitored through packaging from the command line and not  through the IDE, where you can see different times depending on the 'Maven Integration' and internal compiler invoked by each tool. [My reference machine is my good old MacBookPro 2009, Core 2 Duo 2.5, with an Vertex 3 SSD (trim enabled)]

Recently while I was browsing Jason Van Zyl's (the father of Maven)  twitter account I discovered  the takari lifecycle plugin. Jason and his team are creating tools and plugins for the Maven ecosystem, that I hope to  bring  the much anticipated evolution  on the Maven ecosystem that the community of Maven seeks for a many years now. 

To cut a long story short, the takari lifecycle plugin, is an alternative Maven lifecycle implementation, that covers 5 different plugins into one. Once you activate it, it will take over, and invoke it's own implementation of the following 5  
  • resources plugin
  • compiler plugin
  • jar plugin
  • install plugin
  • deploy plugin
You can read about it here. The great thing at least in my case was the compiler plugin, that internally implements a incremental compilation strategy based on a mechanism that can detect changes on source files and resources!!

In order to understand the difference, when using the takari compiler plugin on your maven build compared with the classic compiler plugin and javac (which most probably many of you use), I am going to share a table from this blog post (explaining incremental compilation).

It is far more obvious that if you choose to invoke JDT instead of Javac, the results are going to be even better. Currently we stick with Javac, but the above diagram made me change the default compiler on my IntelliJ IDE, especially when I do refactoring and changes all around, JDT was anyway far better on incremental compilation comparing to Javac.

How to add takari to my build? Is it safe

Well in my case (and I guess for many of you out there), I just followed the proposed way here. I activated the plugin in my parent pom and then changed the packaging type for all my jar modules, into 'takari-jar'. 

  takari-jar

This is not, eventually the change is so easy that you can revert it back.

 The day that I pushed the takari lifecycle change on our git repo, after half an hour I started hearing 'wowss' and 'yeees' from my team members. Repated packaging on changes is very very cheap, changes on resources files and properties ensure that we will get a fresh package when needed. Our repacking times dropped to more than 50%-60%.

If you happen to have the same issues with your Maven build, I trully encourage you to try takari for a day - it will same you and your team some serious time.

I also want to note, that takari is free and despite the fact that is evolved and updated by the takari team for an unnamed 'big' client, the team is free to give it away for free and share it with the community. So thank you very much for this!!!The plugin is can be found on maven central.

The takari team is doing a weekly google hangout, information can be found here, I want to apologize that I have not managed yet to attend one, maybe soon enough.

So go Maven! go Takari!