AnsweredAssumed Answered

Connecting to MapR Cluster using Java API

Question asked by hitesh.sarabu on Jul 5, 2017
Latest reply on Jul 14, 2017 by cathy

I am creating a java application for a simple data dump from our M7 cluster but I can't seem to get connected. I am on OS X and have the MapR client configured and can access the cluster through the client in terminal. We use a ticket based authentication using maprlogin and that works as well.

 

Code is below, some private information is scrubbed out.


import java.io.File;
import java.io.IOException;
import java.util.Scanner;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.*;

public class CDRGetter {

    private static Scanner in = new Scanner(System.in);

    public static void main(String[] args){
        System.out.println("Please enter the amount of rows in each CSV file in thousands (up to 100): ");
        Constants constants = new Constants();
        constants.setCsvRows(getUserResponse());

        //TODO: Allow user to confirm the file path that they would like to put their csv files in

        //TODO: Create a DB Object
        //Connection connection = ConnectionFactory.createConnection(conf);
        try {
            System.setProperty("hadoop.home.dir", "/opt/mapr/hadoop/hadoop-2.7.0/");
            Configuration conf = HBaseConfiguration.create();

            conf.set("hadoop.spoofed.user.uid", "54537");
            conf.set("hadoop.spoofed.user.gid", "210");
            conf.set("hadoop.spoofed.user.username", "USERNAME");
            System.out.println(conf.toString());

            FileSystem fs = FileSystem.get(conf);
            System.out.println(fs.toString());
            //HBaseAdmin hbase = new HBaseAdmin (conf);
            /*
            HTable table = new HTable(conf, DB_ADDRESS.getBytes());
            Scan scan = new Scan();
            ResultScanner resultScanner = table.getScanner(scan);

            for(Result result:resultScanner){
                for(KeyValue kv : result.raw()){
                    System.out.print(new String(kv.getRow()) + " ");
                    System.out.print(new String(kv.getFamily()) + ":");
                    System.out.print(new String(kv.getQualifier()) + " ");
                    System.out.print(kv.getTimestamp() + " ");
                    System.out.println(new String(kv.getValue()));
                }
            }
            */
        }
        catch(IOException e){
            e.printStackTrace();
            System.exit(1);
        }

        catch(Exception e){
            e.printStackTrace();
        }
        //TODO: Move the data into CSV files

    }

    private static int getUserResponse(){
        if(in.hasNextInt()){
            return in.nextInt();
        }
        else{
            System.out.println("That response was invalid, please try again: ");
            return getUserResponse();
        }
    }
}

and the error I get is here:

 

Configuration: core-default.xml, core-site.xml, hbase-default.xml, hbase-site.xml 17/07/05 14:31:21 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 17/07/05 14:31:21 INFO security.JniBasedUnixGroupsMappingWithFallback: Falling back to shell based java.io.IOException: failure to login: java.lang.VerifyError: class com.mapr.fs.proto.Security$TicketAndKey overrides final method getParserForType.()Lcom/google/protobuf/Parser; at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.mapr.security.Security.GetTicketAndKeyForCluster(Security.java:451) at com.mapr.login.client.MapRLoginHttpsClient.doesSecurityHaveGoodKey(MapRLoginHttpsClient.java:223) at com.mapr.login.client.MapRLoginHttpsClient.authenticateIfNeeded(MapRLoginHttpsClient.java:136) at com.mapr.login.client.MapRLoginHttpsClient.authenticateIfNeeded(MapRLoginHttpsClient.java:115) at com.mapr.security.maprsasl.MaprSecurityLoginModule.login(MaprSecurityLoginModule.java:221) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at javax.security.auth.login.LoginContext.invoke(LoginContext.java:755) at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680) at javax.security.auth.login.LoginContext.login(LoginContext.java:587) at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:455) at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:436) at org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:1678) at org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:1671) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1539) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:258) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:129) at CDRGetter.main(CDRGetter.java:41) at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:475) at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:436) at org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:1678) at org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:1671) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1539) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:258) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:129) at CDRGetter.main(CDRGetter.java:41) Caused by: javax.security.auth.login.LoginException: java.lang.VerifyError: class com.mapr.fs.proto.Security$TicketAndKey overrides final method getParserForType.()Lcom/google/protobuf/Parser; at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.mapr.security.Security.GetTicketAndKeyForCluster(Security.java:451) at com.mapr.login.client.MapRLoginHttpsClient.doesSecurityHaveGoodKey(MapRLoginHttpsClient.java:223) at com.mapr.login.client.MapRLoginHttpsClient.authenticateIfNeeded(MapRLoginHttpsClient.java:136) at com.mapr.login.client.MapRLoginHttpsClient.authenticateIfNeeded(MapRLoginHttpsClient.java:115) at com.mapr.security.maprsasl.MaprSecurityLoginModule.login(MaprSecurityLoginModule.java:221) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at javax.security.auth.login.LoginContext.invoke(LoginContext.java:755) at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680) at javax.security.auth.login.LoginContext.login(LoginContext.java:587) at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:455) at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:436) at org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:1678) at org.apache.hadoop.fs.FileSystem$Cache$Key.(FileSystem.java:1671) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1539) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:258) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:129) at CDRGetter.main(CDRGetter.java:41) at javax.security.auth.login.LoginContext.invoke(LoginContext.java:856) at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680) at javax.security.auth.login.LoginContext.login(LoginContext.java:587) at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:455) ... 7 more

 

 

Thanks in advance!

Outcomes