Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/HdfsFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ bool HdfsFile::openRead() {
if (hfile) {
LOG_OPER("[hdfs] opened for read %s", filename.c_str());
return true;
} else {
close();
}
return false;
}
Expand Down Expand Up @@ -78,7 +80,11 @@ bool HdfsFile::openWrite() {
LOG_OPER("[hdfs] opened for write %s", filename.c_str());
}
return true;
} else {
LOG_OPER("[hdfs] Failed to openWrite() hdfs file [%s]", filename.c_str());
close();
}

return false;
}

Expand All @@ -105,7 +111,10 @@ void HdfsFile::close() {

// Close the file system
LOG_OPER("[hdfs] disconnecting fileSys for %s", filename.c_str());
hdfsDisconnect(fileSys);
int retval = hdfsDisconnect(fileSys);
if(retval != 0) {
LOG_OPER("[hdfs] Failed to disconnect filesystem for [%s]", filename.c_str());
}
LOG_OPER("[hdfs] disconnected fileSys for %s", filename.c_str());
fileSys = 0;
}
Expand All @@ -125,7 +134,8 @@ bool HdfsFile::write(const std::string& data) {
if (retVal) {
int val = hdfsHFlush(fileSys, hfile);
if (val == -1) {
LOG_OPER("[hdfs] flush failed");
LOG_OPER("[hdfs] flush failed, closing file [%s]", filename.c_str());
close();
retVal = false;
}
}
Expand All @@ -134,7 +144,11 @@ bool HdfsFile::write(const std::string& data) {

void HdfsFile::flush() {
if (hfile) {
hdfsHFlush(fileSys, hfile);
int val = hdfsHFlush(fileSys, hfile);
if (val == -1) {
LOG_OPER("[hdfs] flush failed, closing file %s", filename.c_str());
close();
}
}
}

Expand Down