Create New Directory

To create a new directory, you must be a registered user and must authenticate to QueryIO server. Provide a valid destination path to create a directory.

Following interfaces can be used to create a new directory:

DFS Client API

Sample code below creates a new directory using DFS Client APIs. Apache Hadoop classes are used for this purpose.

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DFSConfigKeys;

public class PutDirectory {
	/*
	 * This program creates directory on the specified path recursively.
	 */
	public static void main(String[] args) throws IOException{
		Configuration conf = new Configuration(true);	//Create a configuration object to define hdfs properties
		conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://192.168.0.1:9000"); // URL for your namenode
		conf.set(DFSConfigKeys.DFS_REPLICATION_KEY, "3"); // Replication count for files you write
		
		//Initialize DFS FileSystem object with QueryIO configurations 
		FileSystem dfs = FileSystem.get(conf); //Returns the configured filesystem implementation.
		dfs.mkdirs(new Path("/queryio/demo/")); //Create Directory Operation: Creates new directory named "demo".
	}
}
	

FileSystem.mkdirs(path) creates a given directory and all non-existent parents into directory with the configuration provided. Path is the object of org.apache.Hadoop.fs.Path

WEBHDFS API

To create a new directory using WEBHDFS API, curl command is used.

Syntax of curl command to create directory is:

curl -i -X PUT "http://<HOST>:<PORT>/<PATH>?op=MKDIRS[&user.name=<username>][&permission=<OCTAL>]"
Sample Request:	
curl -i -X PUT "http://192.168.0.1:50070/webhdfs/v1/queryio/demo?user.name=admin&op=MKDIRS&permission=0700"
	

Above request creates a directory "demo" with permission 700.

The following is the actual HTTP request:

PUT /webhdfs/v1/queryio/demo/a?user.name=admin&op=MKDIRS&permission=0700 HTTP/1.1
User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
Host: 192.168.0.16:50070
Accept: */*
	

Create directory operation using WEBHDFS API returns a JSON object. Following is the HTTP response sent when QueryIO Server successfully creates a directory:

HTTP/1.1 200 OK
Content-Type: application/json
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Set-Cookie: hadoop.auth="u=admin&p=admin&t=simple&e=1356640714362&s=cicTFjtc8URHRKadmYxfj+ABcFM=";Path=/
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

{"boolean":true}
	


Copyright
  • Contact Us
  • Contact Us
  • 2018 QueryIO Corporation. All Rights Reserved.

    QueryIO, "Big Data Intelligence" and the QueryIO Logo are trademarks of QueryIO Corporation. Apache, Hadoop and HDFS are trademarks of The Apache Software Foundation.