+ All Categories
Home > Documents > A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires...

A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires...

Date post: 16-Oct-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
42
A Native Client for the Hadoop Distributed Filesystem by Colin P. McCabe
Transcript
Page 1: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

A Native Client for the Hadoop Distributed Filesystemby Colin P. McCabe

Page 2: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

About Me

©2014 Cloudera, Inc. All rights reserved.

● I work on HDFS and related storage technologies at Cloudera.

● Committer on the HDFS and Hadoop projects.● Previously worked on the Ceph distributed

filesystem

Page 3: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Roadmap

©2014 Cloudera, Inc. All rights reserved.

● Motivations● Design goals● Progress● Challenges● Future work

Page 4: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

The Hadoop Distributed Filesystem

©2014 Cloudera, Inc. All rights reserved.

HDFS is the most popular storage system for Hadoop.

Based on the concepts of robustness, fault-tolerance, and bringing the computation to the data

Page 5: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

HDFS Provides a Shared Namespace

DFSClient

DFSClient

DFSClient

/user/cmccabe/tpcds_1/user/cmccabe/reports/user/awang/reports

Page 6: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

HDFS Java Client

DistributedFileSystem

DFSClient

Hdfs

FileSystem FileContext

Page 7: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Accessing HDFS from a non-JVM Language

©2014 Cloudera, Inc. All rights reserved.

● The HDFS client is implemented in Java.● How can C and C++ (or even Python) code access

HDFS?○ libhdfs○ webhdfs○ libwebhdfs

Page 8: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

● A thin JNI wrapper around the code in Hadoop’s FileSystem.java.

JNI

libhdfs

©2014 Cloudera, Inc. All rights reserved.

DistributedFileSystem

DFSClient

FileSystem

Page 9: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

libhdfs

©2014 Cloudera, Inc. All rights reserved.

● Difficult to debug because it’s JNI (no gdb, signals)● Requires HDFS jars to be deployed on every client● Long startup time (must start up a JVM.)● Misnamed: can access other FSes besides HDFS● But: still the most widely used way of interfacing

native code with HDFS.

Page 10: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

webhdfs

©2014 Cloudera, Inc. All rights reserved.

● Exposes a REST API for HDFS● Creating HTTP requests is convenient in many languages (but

not so much in C / C++...)● Many optimizations not possible (short-circuit, mmap, etc.)

HTTP/1.1 200 OKContent-Type: application/jsonTransfer-Encoding: chunked...

Page 11: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

libwebhdfs

©2014 Cloudera, Inc. All rights reserved.

● A C library that makes webhdfs requests● More convenient for C and C++ programs than

creating HTTP requests manually● Doesn’t require the Hadoop jars installed on every

machine● Not as mature as libhdfs● Same performance disadvantages as raw webhdfs

Page 12: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

hdfs.h

©2014 Cloudera, Inc. All rights reserved.

● The C and C++ API for libwebhdfs and libhdfs● Backwards-compatible

/** * Create an HDFS builder. * * @return The HDFS builder, or NULL on error. */struct hdfsBuilder *hdfsNewBuilder(void);

/** * Set the username to use when connecting to the HDFS cluster. * * @param bld The HDFS builder * @param userName The user name. The string will be shallow-copied. */void hdfsBuilderSetUserName(struct hdfsBuilder *bld, const char *userName);

...

Page 13: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Fully Native Library

©2014 Cloudera, Inc. All rights reserved.

● Quick startup time (no need to start a JVM)● Doesn’t require Hadoop jars installed everywhere● Can support short-circuit and zero-copy

optimizations● None of the debugging issues with JNI

Page 14: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Roadmap

©2014 Cloudera, Inc. All rights reserved.

● Motivations● Design goals● Progress● Challenges● Future work

Page 15: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Goals

©2014 Cloudera, Inc. All rights reserved.

● Usability○ Create a client usable from C, C++, Objective C,

and other non-JVM languages○ Support the existing libhdfs.h API, which many

programs have been written against○ Cross-platform support: Linux, Windows, other

UNIXes...

Page 16: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Goals

©2014 Cloudera, Inc. All rights reserved.

● Deployability○ Don’t require the Hadoop jars to be installed to

function○ Read existing HDFS configuration XMLs○ Provide a shared library that can be linked into

existing applications

Page 17: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Goals

©2014 Cloudera, Inc. All rights reserved.

● Deployability○ Ideally, libhdfs3 can linked against existing code

which uses libhdfs or libwebhdfs and “just work”

Page 18: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Goals

©2014 Cloudera, Inc. All rights reserved.

● Maintainability○ Create a client which the Hadoop community can

maintain in the future○ Good code quality

Page 19: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Non-Goals

©2014 Cloudera, Inc. All rights reserved.

● Server implementations○ libhdfs3 is only a client library; it doesn’t include

implementations of the HDFS servers.● Completely replacing other access methods

○ Other access methods have different strengths○ libhdfs can access non-HDFS filesystems and make

use of new Java client features more quickly than a native client.

Page 20: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Roadmap

©2014 Cloudera, Inc. All rights reserved.

● Motivations● Design goals● Progress● Challenges● Future work

Page 21: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Progress

©2014 Cloudera, Inc. All rights reserved.

● HADOOP-10388 branch○ Started by myself, Abraham Elmarek, Binglin

Chan, and Wenwu Peng.○ A C client with implementations of all NameNode

RPCs○ Has an async Hadoop RPCv9 client

Page 22: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Progress

©2014 Cloudera, Inc. All rights reserved.

● HDFS-6994 branch○ Based on code contributed by Zhanwei Wang and

other folks at Pivotal○ Reviews and additional code by myself, Haohui

Mai, and others○ C++ code with support for Kerberos, NameNode

HA, and the client read and write paths.

Page 23: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Merger

©2014 Cloudera, Inc. All rights reserved.

● HDFS-6994 branch supersedes HADOOP-10388 branch

● Move over any useful code or features from HADOOP-10388, and merge our efforts.

Page 24: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Cleanup

©2014 Cloudera, Inc. All rights reserved.

● Remove pre-RPCv9 code● Add appropriate Apache headers● Use standard Hadoop file name conventions● Fix some naming issues and calling conventions● CMake cleanup

Page 25: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Integration

©2014 Cloudera, Inc. All rights reserved.

● Use the protobuf files from the Hadoop source rather than a bundled set of files

● Integrate into source tree● (Still to do) integrate with the Maven build cycle● (Still to do) Fix configuration parsing issues

Page 26: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Implementation

©2014 Cloudera, Inc. All rights reserved.

● Implement InputStream functionality ● Implement file system functionality● (in progress) Implement hdfs.h interface● (in progress) Implement OutputStream functionality● (in progress) Implement testing

Page 27: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Dependency Fixes

©2014 Cloudera, Inc. All rights reserved.

● Remove category X library dependencies and extra dependencies that might cause problems

● Remove non-threadsafe library dependencies

Page 28: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Roadmap

©2014 Cloudera, Inc. All rights reserved.

● Motivations● Design goals● Progress● Challenges● Future work

Page 29: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

C++11

©2014 Cloudera, Inc. All rights reserved.

● Many nice features● std::thread, std::chrono, std::shared_ptr

○ Widely used○ Cross platform

● But… not supported everywhere yet.● Compatibility challenges

Page 30: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

C++11 Issues

©2014 Cloudera, Inc. All rights reserved.

Client

libstdc++

libhdfs3.so

Page 31: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

C++11 Issues

©2014 Cloudera, Inc. All rights reserved.

Client

old libstdc++ new libstdc++

libhdfs3.so

Page 32: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Potential Solutions to C++11 Conundrums

● Avoid C++11 features○ Use tr1, or our own code

● Link statically against libstdc++ or libc++ (very difficult)

● Use Boost

©2014 Cloudera, Inc. All rights reserved.

Page 33: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Boost

● … has implementations of std::thread, std::chrono, and many other C++11 libraries

● Can work with C++98● Has its own compatibility issues● A heavyweight dependency● Use as “stepping stone” to C++11?

©2014 Cloudera, Inc. All rights reserved.

Page 34: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

New Client Features

©2014 Cloudera, Inc. All rights reserved.

● The Java HDFS client is always getting new features○ Encryption at rest support○ “Hedged” reads○ etc…

● The native client can reimplement these features, but it will probably always lag behind when doing so

Page 35: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Client Fallback

©2014 Cloudera, Inc. All rights reserved.

● Can the HDFS client fall back from libhdfs3 to libhdfs, if it requires a feature that libhdfs3 doesn’t have?

● Some work on this in HDFS-7041: add a library that can forward hdfs.h calls to any other library implementation

Page 36: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Open Issues

©2014 Cloudera, Inc. All rights reserved.

● Library name○ Does “libhdfs3” sound too much like version 3.0

of the unrelated libhdfs library?

Page 37: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Open Issues

©2014 Cloudera, Inc. All rights reserved.

● Code style○ We need a uniform C++ code style across

Hadoop… so far, we don’t have that○ Exceptions vs. return codes○ Google Coding style?

Page 38: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Roadmap

©2014 Cloudera, Inc. All rights reserved.

● Motivations● Design goals● Progress● Challenges● Future work

Page 39: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Future Work

©2014 Cloudera, Inc. All rights reserved.

● Windows support○ Need to wrap POSIX functions○ UCS-2 issues on Windows?

Page 40: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Future Work

©2014 Cloudera, Inc. All rights reserved.

● C++ API○ should be shared between libhdfs, libwebhdfs,

and libhdfs3○ Must avoid exposing library internals

Page 41: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Conclusion

©2014 Cloudera, Inc. All rights reserved.

● libhdfs3 will soon be a viable option for native clients to interface with HDFS

● Many advantages over existing methods● Thanks to everyone who has helped with this

Page 42: A Native Client for the Hadoop Distributed Filesystem by Colin P. … · 2017. 12. 14. · Requires HDFS jars to be deployed on every client Long startup time (must start up a JVM.)

Thanks for Listening!

©2014 Cloudera, Inc. All rights reserved.

http://www.cloudera.com/careers


Recommended