Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 7 additions & 12 deletions src/client/async_preader/AsyncPReaderCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ namespace Internal
}
else
{
tcp::endpoint endpoint(address::from_string(datanode.getIpAddr()), datanode.getIpcPort());
tcp::endpoint endpoint(address::from_string(datanode.getIpAddr()), datanode.getXferPort());
tcpStream = std::make_shared<boost::beast::tcp_stream>(
bnet::make_strand(Hdfs::Internal::AsyncCb::AsioGlobalContext::Instance()));
tcpStream->expires_after(std::chrono::milliseconds(conf->getRpcConnectTimeout()));
Expand All @@ -281,13 +281,9 @@ namespace Internal
auto self = shared_from_this();
CheckProcessing(readContext);
error_code ec;
WriteBuffer wb;
ProtocolUtil::composeReadBlockHeader(*binfo, token, clientName.c_str(), start, len, &wb);
std::string rawdata;
int size = wb.getDataSize(0);
rawdata.resize(size);
memcpy(&rawdata[0], wb.getBuffer(0), size);
auto buf = boost::asio::buffer(rawdata, size);
ProtocolUtil::composeReadBlockHeader(*binfo, token, clientName.c_str(), start, len, &sendReadRawDataBuffer);
int size = sendReadRawDataBuffer.getDataSize(0);
auto buf = boost::asio::buffer(sendReadRawDataBuffer.getBuffer(0), size);
tcpStream->expires_after(std::chrono::milliseconds(conf->getInputWriteTimeout()));
bnet::async_write(*tcpStream, buf, [this, self, size](error_code ec, size_t length) {
CheckEc(ec);
Expand Down Expand Up @@ -668,14 +664,13 @@ namespace Internal
status.set_status(Status::DT_PROTO_SUCCESS);
}

WriteBuffer buffer;
int size = status.ByteSize();
buffer.writeVarint32(size);
status.SerializeToArray(buffer.alloc(size), size);
sendStatusRawDataBuffer.writeVarint32(size);
status.SerializeToArray(sendStatusRawDataBuffer.alloc(size), size);
tcpStream->expires_after(std::chrono::milliseconds(conf->getInputWriteTimeout()));
bnet::async_write(
*tcpStream,
boost::asio::buffer(buffer.getBuffer(0), buffer.getDataSize(0)),
boost::asio::buffer(sendStatusRawDataBuffer.getBuffer(0), sendStatusRawDataBuffer.getDataSize(0)),
[this, self](error_code ec, size_t length) {
tcpStream->expires_never();
sentStatus = true;
Expand Down
4 changes: 4 additions & 0 deletions src/client/async_preader/AsyncPReaderCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ namespace Internal
std::unique_ptr<boost::asio::steady_timer> delayTimer = nullptr;

int packetCount = 0;

// boost::asio::buffer is a shallow copy we need hold raw data
WriteBuffer sendReadRawDataBuffer;
WriteBuffer sendStatusRawDataBuffer;
};
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/common/HWCrc32c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ static inline uint32_t _mm_crc32_u8(uint32_t crc, uint8_t value) {

#endif

#elif ((defined(__arm__) || defined(__aarch64__)))
#include "sse2neon.h"
#endif

namespace Hdfs {
namespace Internal {

Expand All @@ -82,6 +86,8 @@ bool HWCrc32c::available() {
*/
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
return (ecx & (1 << 20)) != 0;
#elif ((defined(__arm__) || defined(__aarch64__)))
return true;
#else
return false;
#endif
Expand Down Expand Up @@ -159,6 +165,4 @@ void HWCrc32c::updateInt64(const char * b, int len) {
}

}
}

#endif /* _HDFS_LIBHDFS3_COMMON_HWCHECKSUM_H_ */
}
Loading