donderdag 25 februari 2016

Hadoop op Linux Mint

Op distrowatch lijkt Linux Mint de meest populaire Linux distribution. Ik heb dus Linux Mint Cinnamon 64-bit geinstalleerd om Hadoop mee te testen. Hieronder volgt mijn verslag met aanpassingen.


Bij het maken van een VirtualBox image:
> 3d acceleration aanvinken in video settings.
> shared folder, use automount. Na het starten van mint:  sudo adduser xxxxxxx vboxsf      -> reboot. And you can access your folder.
> Guest additions CD gebruiken, anders wordt de shared folder niet gevonden.


Installeren van Java 8:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

met  dpkg -L oracle-java8-installer  kun je bepalen waar de installer geinstalleerd is, maar dat interesseert je niet. Je wilt namelijk de JAVA_HOME instellen. De JAVA_HOME moet /usr/lib/jvm/java-8-oracle worden.


.bashrc aanmaken voor de paden:
export PATH=$PATH:/home/rene/gradle-2.11/bin:/home/rene/hadoop-2.7.2/bin
export HADOOP_HOME=/home/rene/hadoop-2.7.2
export JAVA_HOME=/usr/lib/jvm/java-8-oracle


Installeren van Eclipse:
tar -zxvf eclipse.tar.gz

Desktop icon voor Eclipse:
ln -s /home/rene/eclipse/eclipse /home/rene/Desktop


Installeren van Maven:
In de .bashrc
export MAVEN_OPTS="-Xms1024m -Xmx3076m"
export M2_HOME=/opt/apache-maven-3.3.9
PATH=$M2_HOME/bin:$PATH
Je moet ant geinstalleerd hebben.
Daarna su
ant


Installeren van Spark:
sudo apt-get install git
Download Spark.
tar -zxvf spark1.6.1.tgz
cd naar de directory
./sbt/sbt assembly

./bin/pyspark
sudo mv spark-1.6.1 /opt/
vi ~/.bashrc
export PATH="/opt/spark-1.6.1/bin/:$PATH"


Nog wat ongerelateerde tips:
./configure
make
make test
sudo make install

rm -rf directory
pwd

gradle build
hadoop jar build/libs/SNAPSHOT.jar chp.WordCount wc-input wc-output

vrijdag 19 februari 2016

Intersystems Caché -- Gateway to hell

In 2005 ben ik een maand bezig geweest met Caché van Intersystems. Aangezien ik nu bezig ben met Hadoop/Big Data dacht ik weer terug aan Caché die zichzelf adverteert als Postrelational database. De truuk van Caché is dat het een Tree is, waarvan de nodes ergens anders opgeslagen kunnen worden. Komt in de buurt van Hadoop. Vandaar dat Caché zichzelf ook wel een Big Data oplossing noemt.

Maar wacht!

Caché zit zo slecht in elkaar dat het de "Gateway to hell" genoemd wordt door ontwikkelaars.
In dit bericht op het internet beschrijft een ontwikkelaar Caché en een zelfde ervaring heb ik ook gehad. Gelukkig hoefde ik uiteindelijk niet professioneel met Caché aan de gang.

Overigens heeft het bedrijf dat Caché gebruikte als z'n ontwikkeltool voor een advertentie-systeem het niet gehaald.

Misschien is Caché tegenwoordig beter, maar het zou me niet verbazen als dat niet zo is. Hieronder herhaal ik een gedeelte van deze post uit 2006:

My absolutly biggest beef with Caché is that all code is stored in the database. All code. Let it sink in for a while... Yes, that's right, you have to use a special application to edit your code. This means no easy backups (you have to either backup the whole database or make an 'export' of your project to XML), no version management system (CVS, Subversion), no auto documentation tools, no analysis tools, no nothing... I can't really tell you how much this sucks. The IDE, Intersystems Studio, is pretty much just a texteditor which highlights syntax errors in red. Thats it. When I complained about Studio a sales representant told me that "we're not a tools company, we're a database company" and then, in the next sentence as an answer to my question about the possibility to use other tools: "no". Go figure.

The programming language has been slightly redesigned in later versions to something called 'Caché Objectscript'. This is a lame attempt to add OO concepts to a basically dead language. It's not enough to add something called 'class' and then be done. No exception handling, no encapsulation, no typing, and so on. Worst part is that the class is 'compiled' into something which is basically Mumps-based. Yes, thats right. You write in one language which compiles into more or less the same language. Smells like a macro-language if you ask me.

Problem is that if a runtime programming error occurs the error refer to the compiled code (!) and usually with a message like: "Error 8002 on line 142 in procedure WTFISGOINGON.inc" (or something to this effect). But it's not line 142 in your code! This is like coding in Java and having the VM point you to the bytecode when something goes wrong... With the error message "it's wrong".

And it doesn't stop there. Remember how popular it was in the end of the 90's to embedd programming languages in HTML-pages? ASP, PHP, and so on? Ofcourse Caché must have its own version, Caché Objectscript Pages or CSP. These are actually stored as regular files, probably because Intersystems use a mod for Apache to handle them. On execution these are compiled to Caché Objectscript classes... Yes, that's right, to something which in turn is compiled to yet another form. Where do you think errors refer?

Ohh, yes... Did I tell you that the documentation absolutely sucks? They have some documentation available similar to javadoc, but where the JDK tells you what you need (and usually more) their version is amazingly sparse. Once I tried to call a static method in a class and got errors however I did it. Turned out that that particular class wasn't converted to the new OO system and that you needed to use the old calling method, but this information was nowhere to be found (it didn't differ one bit from other classes I used).

I could go on here...

woensdag 10 februari 2016

WAMPserver op windows 10

Niet vergeten om de IIS-service te stoppen als je WAMPserver wilt draaien. IIS en WAMPserver willen namelijk beide dezelfde poort gebruiken.

Lambda en Anonymous classes in Java

package testpack;

import java.util.List;

public interface ListMethods {
    List<String> SortFruits(List<String> original);
}


package testpack;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class testlambda {

    public List<String> StrategyTest(ListMethods strategy) {
        List<String> fruits = Arrays.asList("Apple", "Tomato", "Currant", "Cranberry");
        return strategy.SortFruits(fruits);
    }
   
    public List<String> getFuitsAnotherWay() {
        ListMethods anonymMethods = new ListMethods() {
            public List<String> SortFruits(List<String> original) {
                Collections.sort(original);
                return original;
            }
        };
        return StrategyTest(anonymMethods); 
    }   

    public List<String> getFuitsAnotherWayLambda() {
        return StrategyTest((fruitList) -> {
            Collections.sort(fruitList);
            return fruitList;
        });
    }   
   
    public static void main(String[] args) {
       
        List<String> result;
       
        result = new ArrayList<String>();       
        result.add("hallo");
        result.add("nederland");
       
        result.stream()
                 .filter(x -> x != "nederland")
                 .forEach(x -> {
                     System.out.println(x);
                 });
       
        testlambda tl = new testlambda();
        result = tl.getFuitsAnotherWayLambda();
        for (String s: result) {
            System.out.println(s);
        }
       
        System.exit(-1);
    }

}

zondag 7 februari 2016

.NET naar Java

Van .NET naar Java:

ASP.NET page = JSP
ASP.NET code behind = Servlet
ASP.NET global.asax = ServletContextListener
ADO.NET = JDBC
Entity Framework = JPA
JAXB = ?
JSON.Net Newtonsoft  = GSON Google
DLL = JAR (Java ARchive. WAR is een Web ARchive, EAR is een Enterprise ARchive)
MSBuild = Maven

In Java heb je ook Generics (compile time), Annotations, boxing en unboxing, Lambda expressions (anonymous class met enkele method. Stream object)