SlideShare a Scribd company logo
1 of 15
Download to read offline
HDFS Client Write/Read
Details
Wellington Chevreuil
HDFS Client Write Flow - Creating the OS
● Client calls DistributedFileSystem.create() method;
a. Performs an RPC call to NN to create the file in the image
b. Assuming file could be created, a DFSOutputStream instance will be created:
i. Setup basic properties for the write, such as block size, replication, enctype, caching
strategy, etc;
ii. Computes the chunk size (byte array buffer for each os.write);
iii. Creates the DataStreamer instance;
c. Starts the DataStreamer thread and return the DFSOutputStream instance to client;
HDFS Client Write Flow - Creating the OS
HDFS Client Write Flow - Writing to the OS
● With the OS instance, client is ready to write data.
● As client writes bytes, OS buffer gets filled and bytes are flushed, as we can
see in FSOutputSummer.write1;
● While flushing, checksum is calculated for the chunk and written together
with the data: FSOutputSummer.writeCheckumChunks;
● At this point, data is not yet streamed over the wire, but grouped into another
structure called Packet. Several chunks will form a packet:
DFSOutputStream.writeChunk
● Once the max number of chunks for the packet is reached, the given packet is
ready to be transmitted.
● DFSOutputStream enqueues the packet to be processed by DataStreamer
asynchronously.
HDFS Client Write Flow - Writing to the OS
● First, accumulate
chunks of data into
packets, then
enqueues packets for
async processing
HDFS Client Write Flow - Writing to the OS
● DataStreamer thread started while DFSOutputStream was being created
keeps looking the queue of packets: DFSOutputStream.DataStreamer.run;
a. Reads packet from the queue;
b. If block construction is in init or recovery stage:
■ create a new block on the image (via NN ADD_BLOCK RPC call);
■ opens an OS to the first DN in the pipeline;
● setup the Socket for first DN;
● create the OS instance;
● create a "Sender" instance wrapping the OS and send a WRITE_BLOCK OP (this
is an initial message to establish the stream between Client and DN. No actual
data sent yet;
■ creates ResponseProcessor and set stage to DATA_STREAMING;
c. If last packet for this block, set stage to PIPELINE_CLOSE;
d. Finally write data to the OS.
HDFS Client Write Flow - Writing to the OS
HDFS Client Write Flow - DN side
● At DN side, DataXceiverServer is responsible to accept an incoming socket connection. It then
spawns a DataXceiver thread.
● DataXceiver extends Receiver in order to parse DataTransfer operations. A receiver is the
counterpart of Sender, with logics to parse the DT protobuff message. Here it discovers the type of
OP.
● Since this a WRITE example, DataXceiver processes the WRITE_BLOCK op;
● TCP server handles client connections and delegates the processing to its DataXceiver threads.
● DataXceiver uses BlockReceiver, a helper class to read packets from the socket IS and also
forward it to the next DN in the pipeline.
● Assuming everything went smooth, BlockReceiver writes data to mirror and local disk. It will also
perform checksum verification and write the block checksum info.
● If last packet for the block, it will also trigger a finalize block OP to NN.
● DataXceiver then generates a response and write back to the socket OS.
HDFS Client Write Flow - DN side
HDFS Client Read Flow - Creating the IS
● Client calls DistributedFileSystem.open() method;
a. It uses DFSClient to create a DFSInputStream instance and wrap into a FSDataInputStream.
b. DFSInputStream initialisation locates the file blocks (via RPC call to NN), then sets up several
info regarding block locations, lengths, etc, which will all be needed during the client read.
c. That's enough to have the DFSInputStream instance created and returned to the client
HDFS Client Read Flow - Reading from the IS
● With an IS instance available, clients can start reading bytes from the given
file.
● Inside DFSInputStream.read() method, it checks if it's the first block or a if
current block is done, to decide if it has to create a new instance of
BlockReader.
○ If that's the case, it locates DNs holding the block and uses BlockReaderFactory to build a
new instance of BlockReader.
● BlockReader interface defines the contract for interacting with DNs data
directly. It currently has 4 implementations:
○ BlockReaderLocal and BlockReaderLocalLegacy (these are used for SCR);
○ RemoteBlockReader (deprecated) and RemoteBlockReader2 (these are used for remote
reads);
HDFS Client Read Flow - Reading from the IS
● It's also possible to plug in custom implementations to be used by client read
operations.
● We'll focus on client remote reads:
○ BlockReaderFactory creates an instance of RemoteBlockReader.
○ While being initialized, BlockReaderFactory stablishes the TCP Socket connection within a
DN and pass it to RemoteBlockReader2.
○ Using same Sender class from previous slides write examples, it sends a READ_BLOCK
operation to the DN.
○ It then obtains an IS from the TCP Socket and wraps it for reading block data.
○ The RemoteBlockReader2 instance is then returned to DFSInputStream.
○ DFSInputStream calls RemoteBlockReader2.read() method, which in turn uses
PacketReceiver.readNextPacket() method to read block data in packets from the TPC
Socket IS.
HDFS Client Read Flow - Reading from the IS
HDFS Client Read Flow - DN side
● TCP Connection creation and DT parsing logic is the same as from slide #8
for Write operation.
● Since this is READ_BLOCK op, DataXceiver uses BlockSender, a helper
class to read packets from disk or memory cache, then write back to the TCP
OS.
● Using BlockSender info about the block, DataXceiver verifies the checksum
and send DT message back to client.
● DataXceiver calls BlockSender.sendBlock to effectively read block data
and send back to client via the TCP stream.
● BlockSender implements logic specifics for caching, packet read control and
stream writing.
HDFS Client Read Flow - DN side

More Related Content

What's hot

Inter process communication
Inter process communicationInter process communication
Inter process communicationPradeep Kumar TS
 
Application layer
Application layerApplication layer
Application layerNeha Kurale
 
Harden Security Devices Against Increasingly Sophisticated Evasions
Harden Security Devices Against Increasingly Sophisticated EvasionsHarden Security Devices Against Increasingly Sophisticated Evasions
Harden Security Devices Against Increasingly Sophisticated EvasionsIxia
 
Metrics lightning talk
Metrics lightning talkMetrics lightning talk
Metrics lightning talkChris Lohfink
 
Tim eberhard bajug3_talk
Tim eberhard bajug3_talkTim eberhard bajug3_talk
Tim eberhard bajug3_talkTim Eberhard
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic ControlSUSE Labs Taipei
 
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...Alexander Krizhanovsky
 
NDMPCOPY lun from 7-mode NetApp to cDOT
NDMPCOPY lun from 7-mode NetApp to cDOTNDMPCOPY lun from 7-mode NetApp to cDOT
NDMPCOPY lun from 7-mode NetApp to cDOTAshwin Pawar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distribution system presentation of chapter 4(distributed systems concepts ...
Distribution system presentation of chapter 4(distributed systems   concepts ...Distribution system presentation of chapter 4(distributed systems   concepts ...
Distribution system presentation of chapter 4(distributed systems concepts ...hyunyoung Lee
 

What's hot (18)

Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Spanner
SpannerSpanner
Spanner
 
Application layer
Application layerApplication layer
Application layer
 
Ds1307
Ds1307Ds1307
Ds1307
 
Cache memory
Cache memoryCache memory
Cache memory
 
Spanner (may 19)
Spanner (may 19)Spanner (may 19)
Spanner (may 19)
 
Tc basics
Tc basicsTc basics
Tc basics
 
Harden Security Devices Against Increasingly Sophisticated Evasions
Harden Security Devices Against Increasingly Sophisticated EvasionsHarden Security Devices Against Increasingly Sophisticated Evasions
Harden Security Devices Against Increasingly Sophisticated Evasions
 
Week8 lec2-bscs1
Week8 lec2-bscs1Week8 lec2-bscs1
Week8 lec2-bscs1
 
Metrics lightning talk
Metrics lightning talkMetrics lightning talk
Metrics lightning talk
 
Tim eberhard bajug3_talk
Tim eberhard bajug3_talkTim eberhard bajug3_talk
Tim eberhard bajug3_talk
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
 
Tcpdump
TcpdumpTcpdump
Tcpdump
 
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
 
NDMPCOPY lun from 7-mode NetApp to cDOT
NDMPCOPY lun from 7-mode NetApp to cDOTNDMPCOPY lun from 7-mode NetApp to cDOT
NDMPCOPY lun from 7-mode NetApp to cDOT
 
Week5 lec3-bscs1
Week5 lec3-bscs1Week5 lec3-bscs1
Week5 lec3-bscs1
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distribution system presentation of chapter 4(distributed systems concepts ...
Distribution system presentation of chapter 4(distributed systems   concepts ...Distribution system presentation of chapter 4(distributed systems   concepts ...
Distribution system presentation of chapter 4(distributed systems concepts ...
 

Similar to HDFS client write/read implementation details

Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streamingphanleson
 
Choose one of these three options A IPC using FIFO B Shar.pdf
Choose one of these three options A IPC using FIFO B Shar.pdfChoose one of these three options A IPC using FIFO B Shar.pdf
Choose one of these three options A IPC using FIFO B Shar.pdfaghsports
 
An unsupervised framework for effective indexing of BigData
An unsupervised framework for effective indexing of BigDataAn unsupervised framework for effective indexing of BigData
An unsupervised framework for effective indexing of BigDataRamakrishna Prasad Sakhamuri
 
This project explores usage of the IPC in the form of shared.pdf
This project explores usage of the IPC in the form of shared.pdfThis project explores usage of the IPC in the form of shared.pdf
This project explores usage of the IPC in the form of shared.pdfadinathfashion1
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdfsecunderbadtirumalgi
 
Technical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques NadeauTechnical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques NadeauMapR Technologies
 
HadoooIO.ppt
HadoooIO.pptHadoooIO.ppt
HadoooIO.pptSheba41
 
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck - Pravega: Storage Rei...
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck -  Pravega: Storage Rei...Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck -  Pravega: Storage Rei...
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck - Pravega: Storage Rei...Flink Forward
 
SMB Traffic Analyzer @ Samba Xp 2009
SMB Traffic Analyzer @  Samba Xp 2009SMB Traffic Analyzer @  Samba Xp 2009
SMB Traffic Analyzer @ Samba Xp 2009hhetter
 
OpenSSL Basic Function Call Flow
OpenSSL Basic Function Call FlowOpenSSL Basic Function Call Flow
OpenSSL Basic Function Call FlowWilliam Lee
 
Analysis of the LAN Sync Protocol
Analysis of the LAN Sync ProtocolAnalysis of the LAN Sync Protocol
Analysis of the LAN Sync ProtocolSJSU
 
INT 222.pptx
INT 222.pptxINT 222.pptx
INT 222.pptxSaunya2
 
Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1KlaraOrban
 

Similar to HDFS client write/read implementation details (20)

Anatomy of file write in hadoop
Anatomy of file write in hadoopAnatomy of file write in hadoop
Anatomy of file write in hadoop
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
Choose one of these three options A IPC using FIFO B Shar.pdf
Choose one of these three options A IPC using FIFO B Shar.pdfChoose one of these three options A IPC using FIFO B Shar.pdf
Choose one of these three options A IPC using FIFO B Shar.pdf
 
An unsupervised framework for effective indexing of BigData
An unsupervised framework for effective indexing of BigDataAn unsupervised framework for effective indexing of BigData
An unsupervised framework for effective indexing of BigData
 
This project explores usage of the IPC in the form of shared.pdf
This project explores usage of the IPC in the form of shared.pdfThis project explores usage of the IPC in the form of shared.pdf
This project explores usage of the IPC in the form of shared.pdf
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
 
Technical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques NadeauTechnical Overview of Apache Drill by Jacques Nadeau
Technical Overview of Apache Drill by Jacques Nadeau
 
HDFS Design Principles
HDFS Design PrinciplesHDFS Design Principles
HDFS Design Principles
 
HadoooIO.ppt
HadoooIO.pptHadoooIO.ppt
HadoooIO.ppt
 
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck - Pravega: Storage Rei...
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck -  Pravega: Storage Rei...Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck -  Pravega: Storage Rei...
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck - Pravega: Storage Rei...
 
SMB Traffic Analyzer @ Samba Xp 2009
SMB Traffic Analyzer @  Samba Xp 2009SMB Traffic Analyzer @  Samba Xp 2009
SMB Traffic Analyzer @ Samba Xp 2009
 
Chapter 3-Processes2.pptx
Chapter 3-Processes2.pptxChapter 3-Processes2.pptx
Chapter 3-Processes2.pptx
 
Intake 37 12
Intake 37 12Intake 37 12
Intake 37 12
 
OpenSSL Basic Function Call Flow
OpenSSL Basic Function Call FlowOpenSSL Basic Function Call Flow
OpenSSL Basic Function Call Flow
 
Analysis of the LAN Sync Protocol
Analysis of the LAN Sync ProtocolAnalysis of the LAN Sync Protocol
Analysis of the LAN Sync Protocol
 
INT 222.pptx
INT 222.pptxINT 222.pptx
INT 222.pptx
 
Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1
 
10 Networking
10 Networking10 Networking
10 Networking
 
File System.pptx
File System.pptxFile System.pptx
File System.pptx
 
Nf Sp4
Nf Sp4Nf Sp4
Nf Sp4
 

More from wchevreuil

Cloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdf
Cloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdfCloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdf
Cloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdfwchevreuil
 
HBase System Tables / Metadata Info
HBase System Tables / Metadata InfoHBase System Tables / Metadata Info
HBase System Tables / Metadata Infowchevreuil
 
HBase tales from the trenches
HBase tales from the trenchesHBase tales from the trenches
HBase tales from the trencheswchevreuil
 
Hbasecon2019 hbck2 (1)
Hbasecon2019 hbck2 (1)Hbasecon2019 hbck2 (1)
Hbasecon2019 hbck2 (1)wchevreuil
 
Web hdfs and httpfs
Web hdfs and httpfsWeb hdfs and httpfs
Web hdfs and httpfswchevreuil
 
HBase replication
HBase replicationHBase replication
HBase replicationwchevreuil
 
I nd t_bigdata(1)
I nd t_bigdata(1)I nd t_bigdata(1)
I nd t_bigdata(1)wchevreuil
 
Hadoop - TDC 2012
Hadoop - TDC 2012Hadoop - TDC 2012
Hadoop - TDC 2012wchevreuil
 

More from wchevreuil (10)

Cloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdf
Cloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdfCloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdf
Cloudera Enabling Native Integration of NoSQL HBase with Cloud Providers.pdf
 
HBase System Tables / Metadata Info
HBase System Tables / Metadata InfoHBase System Tables / Metadata Info
HBase System Tables / Metadata Info
 
HBase RITs
HBase RITsHBase RITs
HBase RITs
 
HBase tales from the trenches
HBase tales from the trenchesHBase tales from the trenches
HBase tales from the trenches
 
Hbasecon2019 hbck2 (1)
Hbasecon2019 hbck2 (1)Hbasecon2019 hbck2 (1)
Hbasecon2019 hbck2 (1)
 
Web hdfs and httpfs
Web hdfs and httpfsWeb hdfs and httpfs
Web hdfs and httpfs
 
HBase replication
HBase replicationHBase replication
HBase replication
 
Hadoop tuning
Hadoop tuningHadoop tuning
Hadoop tuning
 
I nd t_bigdata(1)
I nd t_bigdata(1)I nd t_bigdata(1)
I nd t_bigdata(1)
 
Hadoop - TDC 2012
Hadoop - TDC 2012Hadoop - TDC 2012
Hadoop - TDC 2012
 

Recently uploaded

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 

Recently uploaded (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 

HDFS client write/read implementation details

  • 2. HDFS Client Write Flow - Creating the OS ● Client calls DistributedFileSystem.create() method; a. Performs an RPC call to NN to create the file in the image b. Assuming file could be created, a DFSOutputStream instance will be created: i. Setup basic properties for the write, such as block size, replication, enctype, caching strategy, etc; ii. Computes the chunk size (byte array buffer for each os.write); iii. Creates the DataStreamer instance; c. Starts the DataStreamer thread and return the DFSOutputStream instance to client;
  • 3. HDFS Client Write Flow - Creating the OS
  • 4. HDFS Client Write Flow - Writing to the OS ● With the OS instance, client is ready to write data. ● As client writes bytes, OS buffer gets filled and bytes are flushed, as we can see in FSOutputSummer.write1; ● While flushing, checksum is calculated for the chunk and written together with the data: FSOutputSummer.writeCheckumChunks; ● At this point, data is not yet streamed over the wire, but grouped into another structure called Packet. Several chunks will form a packet: DFSOutputStream.writeChunk ● Once the max number of chunks for the packet is reached, the given packet is ready to be transmitted. ● DFSOutputStream enqueues the packet to be processed by DataStreamer asynchronously.
  • 5. HDFS Client Write Flow - Writing to the OS ● First, accumulate chunks of data into packets, then enqueues packets for async processing
  • 6. HDFS Client Write Flow - Writing to the OS ● DataStreamer thread started while DFSOutputStream was being created keeps looking the queue of packets: DFSOutputStream.DataStreamer.run; a. Reads packet from the queue; b. If block construction is in init or recovery stage: ■ create a new block on the image (via NN ADD_BLOCK RPC call); ■ opens an OS to the first DN in the pipeline; ● setup the Socket for first DN; ● create the OS instance; ● create a "Sender" instance wrapping the OS and send a WRITE_BLOCK OP (this is an initial message to establish the stream between Client and DN. No actual data sent yet; ■ creates ResponseProcessor and set stage to DATA_STREAMING; c. If last packet for this block, set stage to PIPELINE_CLOSE; d. Finally write data to the OS.
  • 7. HDFS Client Write Flow - Writing to the OS
  • 8. HDFS Client Write Flow - DN side ● At DN side, DataXceiverServer is responsible to accept an incoming socket connection. It then spawns a DataXceiver thread. ● DataXceiver extends Receiver in order to parse DataTransfer operations. A receiver is the counterpart of Sender, with logics to parse the DT protobuff message. Here it discovers the type of OP. ● Since this a WRITE example, DataXceiver processes the WRITE_BLOCK op; ● TCP server handles client connections and delegates the processing to its DataXceiver threads. ● DataXceiver uses BlockReceiver, a helper class to read packets from the socket IS and also forward it to the next DN in the pipeline. ● Assuming everything went smooth, BlockReceiver writes data to mirror and local disk. It will also perform checksum verification and write the block checksum info. ● If last packet for the block, it will also trigger a finalize block OP to NN. ● DataXceiver then generates a response and write back to the socket OS.
  • 9. HDFS Client Write Flow - DN side
  • 10. HDFS Client Read Flow - Creating the IS ● Client calls DistributedFileSystem.open() method; a. It uses DFSClient to create a DFSInputStream instance and wrap into a FSDataInputStream. b. DFSInputStream initialisation locates the file blocks (via RPC call to NN), then sets up several info regarding block locations, lengths, etc, which will all be needed during the client read. c. That's enough to have the DFSInputStream instance created and returned to the client
  • 11. HDFS Client Read Flow - Reading from the IS ● With an IS instance available, clients can start reading bytes from the given file. ● Inside DFSInputStream.read() method, it checks if it's the first block or a if current block is done, to decide if it has to create a new instance of BlockReader. ○ If that's the case, it locates DNs holding the block and uses BlockReaderFactory to build a new instance of BlockReader. ● BlockReader interface defines the contract for interacting with DNs data directly. It currently has 4 implementations: ○ BlockReaderLocal and BlockReaderLocalLegacy (these are used for SCR); ○ RemoteBlockReader (deprecated) and RemoteBlockReader2 (these are used for remote reads);
  • 12. HDFS Client Read Flow - Reading from the IS ● It's also possible to plug in custom implementations to be used by client read operations. ● We'll focus on client remote reads: ○ BlockReaderFactory creates an instance of RemoteBlockReader. ○ While being initialized, BlockReaderFactory stablishes the TCP Socket connection within a DN and pass it to RemoteBlockReader2. ○ Using same Sender class from previous slides write examples, it sends a READ_BLOCK operation to the DN. ○ It then obtains an IS from the TCP Socket and wraps it for reading block data. ○ The RemoteBlockReader2 instance is then returned to DFSInputStream. ○ DFSInputStream calls RemoteBlockReader2.read() method, which in turn uses PacketReceiver.readNextPacket() method to read block data in packets from the TPC Socket IS.
  • 13. HDFS Client Read Flow - Reading from the IS
  • 14. HDFS Client Read Flow - DN side ● TCP Connection creation and DT parsing logic is the same as from slide #8 for Write operation. ● Since this is READ_BLOCK op, DataXceiver uses BlockSender, a helper class to read packets from disk or memory cache, then write back to the TCP OS. ● Using BlockSender info about the block, DataXceiver verifies the checksum and send DT message back to client. ● DataXceiver calls BlockSender.sendBlock to effectively read block data and send back to client via the TCP stream. ● BlockSender implements logic specifics for caching, packet read control and stream writing.
  • 15. HDFS Client Read Flow - DN side