Skip to content

Commit bc667e0

Browse files
committed
Wdt State machine refactor
Summary: Get rid of ThreadData and move different functionalities into the appropriate modules Reviewed By: @uddipta Differential Revision: D2445473
1 parent 4fad601 commit bc667e0

27 files changed

+3976
-2799
lines changed

CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.2)
2222
# There is no C per se in WDT but if you use CXX only here many checks fail
2323
# Version is Major.Minor.YYMMDDX for up to 10 releases per day
2424
# Minor currently is also the protocol version - has to match with Protocol.cpp
25-
project("WDT" LANGUAGES C CXX VERSION 1.21.1510120)
25+
project("WDT" LANGUAGES C CXX VERSION 1.22.1510210)
2626

2727
# On MacOS this requires the latest (master) CMake (and/or CMake 3.1.1/3.2)
2828
set(CMAKE_CXX_STANDARD 11)
@@ -79,8 +79,13 @@ ErrorCodes.cpp
7979
FileByteSource.cpp
8080
FileCreator.cpp
8181
Protocol.cpp
82+
WdtThread.cpp
83+
ThreadsController.cpp
84+
ReceiverThread.cpp
8285
Receiver.cpp
8386
Reporting.cpp
87+
ThreadTransferHistory.cpp
88+
SenderThread.cpp
8489
Sender.cpp
8590
ServerSocket.cpp
8691
SocketUtils.cpp

ErrorCodes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#pragma once
1010

1111
#include <wdt/WdtConfig.h>
12-
12+
#include <glog/logging.h>
1313
#include <string>
1414

1515
namespace facebook {

FileCreator.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ int FileCreator::openExistingFile(const string &relPathStr) {
164164
WDT_CHECK(relPathStr[0] != '/');
165165
WDT_CHECK(relPathStr.back() != '/');
166166

167-
string path(rootDir_);
168-
path.append(relPathStr);
167+
const string path = rootDir_ + relPathStr;
169168

170169
int openFlags = O_WRONLY;
171170
START_PERF_TIMER
@@ -184,8 +183,7 @@ int FileCreator::createFile(const string &relPathStr) {
184183
CHECK(relPathStr[0] != '/');
185184
CHECK(relPathStr.back() != '/');
186185

187-
std::string path(rootDir_);
188-
path.append(relPathStr);
186+
const string path = rootDir_ + relPathStr;
189187

190188
int p = relPathStr.size();
191189
while (p && relPathStr[p - 1] != '/') {

Protocol.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ int Protocol::negotiateProtocol(int requestedProtocolVersion,
4949
}
5050

5151
std::ostream &operator<<(std::ostream &os, const Checkpoint &checkpoint) {
52-
os << "num-blocks: " << checkpoint.numBlocks
52+
os << "checkpoint-port: " << checkpoint.port
53+
<< "num-blocks: " << checkpoint.numBlocks
5354
<< " seq-id: " << checkpoint.lastBlockSeqId
5455
<< " block-offset: " << checkpoint.lastBlockOffset
5556
<< " received-bytes: " << checkpoint.lastBlockReceivedBytes;

README.md

+22-4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ caller get the mutable object of options and set different options accordingly.
125125
When wdt is run in a standalone mode, behavior is changed through gflags in
126126
wdtCmdLine.cpp
127127

128+
* WdtThread.{h|cpp}
129+
Common functionality and settings between SenderThread and ReceiverThread.
130+
Both of these kind of threads inherit from this base class.
131+
128132
* WdtBase.{h|cpp}
129133

130134
Common functionality and settings between Sender and Receiver
@@ -156,22 +160,36 @@ directory, sorted by decreasing size (as they are discovered, you can start
156160
pulling from the queue even before all the files are found, it will return
157161
the current largest file)
158162

163+
* ThreadTransferHistory.{h|cpp}
159164

160-
* Sender.{h|cpp}
165+
Every thread maintains a transfer history so that when a connection breaks
166+
it can talk to the receiver to find out up to where in the history has been
167+
sent. This class encapsulates all the logic for that bookkeeping
168+
169+
* SenderThread.{h|cpp}
170+
171+
Implements the functionality of one sender thread, which binds to a certain port
172+
and sends files over.
161173

162-
Formerly wdtlib.cpp - main code sending files
174+
* Sender.{h|cpp}
163175

176+
Spawns multiple SenderThread threads and sends the data across to receiver
164177

165178
### Consuming / Receiving
166179

167180
* FileCreator.{h|cpp}
168181

169182
Creates file and directories necessary for said file (mkdir -p like)
170183

171-
* Receiver.{h|cpp}
184+
* ReceiverThread.{h|cpp}
172185

173-
Formerly wdtlib.cpp - main code receiving files
186+
Implements the funcionality of the receiver threads, responsible for listening on
187+
a port and receiving files over the network.
188+
189+
* Receiver.{h|cpp}
174190

191+
Parent receiver class that spawns multiple ReceiverThread threads and receives
192+
data from a remote host
175193

176194
### Low level building blocks
177195

0 commit comments

Comments
 (0)