hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel Ángel Álvarez de la Concepción <maalva...@us.es>
Subject Accessing Hadoop DFS for Data Storage and Retrieval Using Java
Date Tue, 09 Mar 2010 16:04:58 GMT
Hi,

 

I tried to run the Java code and it doesn't work.

 

I pasted the code below:

 

public class testHadoop {

    public static final String DIR_HADOOP = "hdfs://my.machine.com";

    public static final String PORT_HADOOP = "9000";

 

    public static void main(String[] args) {

        Configuration config = new Configuration();

        config.set("fs.default.name", DIR_HADOOP + ":" + PORT_HADOOP);

 

        try {

            FileSystem haddopFileSystem = FileSystem.get(config);

 

            String directory = "test";

            Path hadoopDirectory = new
Path(haddopFileSystem.getWorkingDirectory() + "/" + directory);

 

            haddopFileSystem.mkdirs(hadoopDirectory);

 

            Path sourceDirectory = new
Path("C://Windows/media/ringout.wav");

 

            haddopFileSystem.copyFromLocalFile(sourceDirectory,
hadoopDirectory);

 

            Path sourceFile = new
Path(haddopFileSystem.getWorkingDirectory() + "/test/ringout.wav");

            Path targetDirectory = new Path("C://");

 

            haddopFileSystem.copyToLocalFile(sourceFile, targetDirectory);

 

            haddopFileSystem.delete(hadoopDirectory, true);

        } catch(IOException ex) {

            Logger.getLogger(testHadoop.class.getName()).log(Level.SEVERE,
null, ex);

        }

    }

}

 

The result of this code is an exception:

 

org.apache.hadoop.security.AccessControlException:
org.apache.hadoop.security.AccessControlException: Permission denied:
user=varadero\miguelangel, access=WRITE,
inode="tmp":root:supergroup:rwxr-xr-x

        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)

        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)

        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)

        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

        at
org.apache.hadoop.ipc.RemoteException.instantiateException(RemoteException.j
ava:96)

        at
org.apache.hadoop.ipc.RemoteException.unwrapRemoteException(RemoteException.
java:58)

        at org.apache.hadoop.hdfs.DFSClient.mkdirs(DFSClient.java:914)

        at
org.apache.hadoop.hdfs.DistributedFileSystem.mkdirs(DistributedFileSystem.ja
va:262)

        at org.apache.hadoop.fs.FileSystem.mkdirs(FileSystem.java:1120)

        at hadoop.testHadoop.main(testHadoop.java:37)

Caused by: org.apache.hadoop.ipc.RemoteException:
org.apache.hadoop.security.AccessControlException: Permission denied:
user=varadero\miguelangel, access=WRITE,
inode="tmp":root:supergroup:rwxr-xr-x

        at
org.apache.hadoop.hdfs.server.namenode.PermissionChecker.check(PermissionChe
cker.java:176)

        at
org.apache.hadoop.hdfs.server.namenode.PermissionChecker.check(PermissionChe
cker.java:157)

        at
org.apache.hadoop.hdfs.server.namenode.PermissionChecker.checkPermission(Per
missionChecker.java:105)

        at
org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkPermission(FSNamesy
stem.java:4514)

        at
org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkAncestorAccess(FSNa
mesystem.java:4484)

        at
org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirsInternal(FSNamesys
tem.java:1766)

        at
org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirs(FSNamesystem.java
:1735)

        at
org.apache.hadoop.hdfs.server.namenode.NameNode.mkdirs(NameNode.java:542)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508)

        at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959)

        at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955)

        at java.security.AccessController.doPrivileged(Native Method)

        at javax.security.auth.Subject.doAs(Subject.java:396)

        at org.apache.hadoop.ipc.Server$Handler.run(Server.java:953)

 

        at org.apache.hadoop.ipc.Client.call(Client.java:740)

        at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)

        at $Proxy0.mkdirs(Unknown Source)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at
org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocati
onHandler.java:82)

        at
org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHand
ler.java:59)

        at $Proxy0.mkdirs(Unknown Source)

        at org.apache.hadoop.hdfs.DFSClient.mkdirs(DFSClient.java:912)

        ... 3 more

 

What's happend?

 

Miguel Ángel Álvarez de la Concepción

Departamento de Lenguajes y Sistemas Informáticos

Escuela Técnica Superior de Ingeniería Informática

Universidad de Sevilla

Teléfono: 954.556.086

Email: maalvarez@us.es

 


Mime
View raw message