diff --git a/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp b/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp index 7d7809d3a..7c894d508 100644 --- a/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp +++ b/src/communication/bolt/v1/decoder/chunked_decoder_buffer.hpp @@ -93,7 +93,6 @@ class ChunkedDecoderBuffer { size_t size = buffer_.size(); if (size < 2) { - DLOG(WARNING) << "Size < 2"; return ChunkState::Partial; } @@ -108,8 +107,6 @@ class ChunkedDecoderBuffer { } if (size < chunk_size + 2) { - DLOG(WARNING) << fmt::format( - "Chunk size is {} but only have {} data bytes.", chunk_size, size); return ChunkState::Partial; } diff --git a/src/communication/bolt/v1/decoder/decoder.hpp b/src/communication/bolt/v1/decoder/decoder.hpp index 0abc03fe8..ff0e4322d 100644 --- a/src/communication/bolt/v1/decoder/decoder.hpp +++ b/src/communication/bolt/v1/decoder/decoder.hpp @@ -33,10 +33,7 @@ class Decoder { bool ReadValue(DecodedValue *data) { uint8_t value; - VLOG(20) << "[ReadValue] Start"; - if (!buffer_.Read(&value, 1)) { - DLOG(WARNING) << "[ReadValue] Marker data missing!"; return false; } @@ -80,7 +77,6 @@ class Decoder { // won't perform an additional signature read. uint8_t signature; if (!buffer_.Read(&signature, 1)) { - DLOG(WARNING) << "[ReadVertex] Missing marker and/or signature data!"; return false; } switch (static_cast(signature)) { @@ -91,9 +87,6 @@ class Decoder { case Signature::Path: return ReadPath(data); default: - DLOG(WARNING) << "[ReadValue] Expected [node | unbounded_ege | " - "path] signature, received " - << signature; return false; } } @@ -126,11 +119,9 @@ class Decoder { */ bool ReadValue(DecodedValue *data, DecodedValue::Type type) { if (!ReadValue(data)) { - DLOG(WARNING) << "[ReadValue] ReadValue call failed!"; return false; } if (data->type() != type) { - DLOG(WARNING) << "[ReadValue] Decoded value has wrong type!"; return false; } return true; @@ -148,16 +139,12 @@ class Decoder { bool ReadMessageHeader(Signature *signature, Marker *marker) { uint8_t values[2]; - VLOG(20) << "[ReadMessageHeader] Start"; - if (!buffer_.Read(values, 2)) { - DLOG(WARNING) << "[ReadMessageHeader] Marker data missing!"; return false; } *marker = (Marker)values[0]; *signature = (Signature)values[1]; - DLOG(WARNING) << "[ReadMessageHeader] Success"; return true; } @@ -166,15 +153,12 @@ class Decoder { private: bool ReadNull(const Marker &marker, DecodedValue *data) { - VLOG(20) << "[ReadNull] Start"; DCHECK(marker == Marker::Null) << "Received invalid marker!"; *data = DecodedValue(); - VLOG(20) << "[ReadNull] Success"; return true; } bool ReadBool(const Marker &marker, DecodedValue *data) { - VLOG(20) << "[ReadBool] Start"; DCHECK(marker == Marker::False || marker == Marker::True) << "Received invalid marker!"; if (marker == Marker::False) { @@ -182,156 +166,120 @@ class Decoder { } else { *data = DecodedValue(true); } - VLOG(20) << "[ReadBool] Success"; return true; } bool ReadInt(const Marker &marker, DecodedValue *data) { uint8_t value = utils::UnderlyingCast(marker); int64_t ret; - VLOG(20) << "[ReadInt] Start"; if (value >= 240 || value <= 127) { - VLOG(20) << "[ReadInt] Found a TinyInt"; ret = value; if (value >= 240) ret -= 256; } else if (marker == Marker::Int8) { - VLOG(20) << "[ReadInt] Found an Int8"; int8_t tmp; if (!buffer_.Read(reinterpret_cast(&tmp), sizeof(tmp))) { - DLOG(WARNING) << "[ReadInt] Int8 missing data!"; return false; } ret = tmp; } else if (marker == Marker::Int16) { - VLOG(20) << "[ReadInt] Found an Int16"; int16_t tmp; if (!buffer_.Read(reinterpret_cast(&tmp), sizeof(tmp))) { - DLOG(WARNING) << "[ReadInt] Int16 missing data!"; return false; } ret = utils::Bswap(tmp); } else if (marker == Marker::Int32) { - VLOG(20) << "[ReadInt] Found an Int32"; int32_t tmp; if (!buffer_.Read(reinterpret_cast(&tmp), sizeof(tmp))) { - DLOG(WARNING) << "[ReadInt] Int32 missing data!"; return false; } ret = utils::Bswap(tmp); } else if (marker == Marker::Int64) { - VLOG(20) << "[ReadInt] Found an Int64"; if (!buffer_.Read(reinterpret_cast(&ret), sizeof(ret))) { - DLOG(WARNING) << "[ReadInt] Int64 missing data!"; return false; } ret = utils::Bswap(ret); } else { - DLOG(WARNING) << "[ReadInt] Received invalid marker " - << utils::UnderlyingCast(marker); return false; } *data = DecodedValue(ret); - VLOG(20) << "[ReadInt] Success"; return true; } bool ReadDouble(const Marker marker, DecodedValue *data) { uint64_t value; double ret; - VLOG(20) << "[ReadDouble] Start"; DCHECK(marker == Marker::Float64) << "Received invalid marker!"; if (!buffer_.Read(reinterpret_cast(&value), sizeof(value))) { - DLOG(WARNING) << "[ReadDouble] Missing data!"; return false; } value = utils::Bswap(value); // cppcheck-suppress invalidPointerCast ret = *reinterpret_cast(&value); *data = DecodedValue(ret); - VLOG(20) << "[ReadDouble] Success"; return true; } int64_t ReadTypeSize(const Marker &marker, const uint8_t type) { uint8_t value = utils::UnderlyingCast(marker); if ((value & 0xF0) == utils::UnderlyingCast(MarkerTiny[type])) { - VLOG(20) << "[ReadTypeSize] Found a TinyType"; return value & 0x0F; } else if (marker == Marker8[type]) { - VLOG(20) << "[ReadTypeSize] Found a Type8"; uint8_t tmp; if (!buffer_.Read(reinterpret_cast(&tmp), sizeof(tmp))) { - DLOG(WARNING) << "[ReadTypeSize] Type8 missing data!"; return -1; } return tmp; } else if (marker == Marker16[type]) { - VLOG(20) << "[ReadTypeSize] Found a Type16"; uint16_t tmp; if (!buffer_.Read(reinterpret_cast(&tmp), sizeof(tmp))) { - DLOG(WARNING) << "[ReadTypeSize] Type16 missing data!"; return -1; } tmp = utils::Bswap(tmp); return tmp; } else if (marker == Marker32[type]) { - VLOG(20) << "[ReadTypeSize] Found a Type32"; uint32_t tmp; if (!buffer_.Read(reinterpret_cast(&tmp), sizeof(tmp))) { - DLOG(WARNING) << "[ReadTypeSize] Type32 missing data!"; return -1; } tmp = utils::Bswap(tmp); return tmp; } else { - DLOG(WARNING) << "[ReadTypeSize] Received invalid marker " - << utils::UnderlyingCast(marker); return -1; } } bool ReadString(const Marker &marker, DecodedValue *data) { - VLOG(20) << "[ReadString] Start"; auto size = ReadTypeSize(marker, MarkerString); if (size == -1) { - DLOG(WARNING) << "[ReadString] Couldn't get size!"; return false; } std::unique_ptr ret(new uint8_t[size]); if (!buffer_.Read(ret.get(), size)) { - DLOG(WARNING) << "[ReadString] Missing data!"; return false; } *data = DecodedValue(std::string(reinterpret_cast(ret.get()), size)); - VLOG(20) << "[ReadString] Success"; return true; } bool ReadList(const Marker &marker, DecodedValue *data) { - VLOG(20) << "[ReadList] Start"; auto size = ReadTypeSize(marker, MarkerList); if (size == -1) { - DLOG(WARNING) << "[ReadList] Couldn't get size!"; return false; } std::vector ret(size); for (int64_t i = 0; i < size; ++i) { if (!ReadValue(&ret[i])) { - DLOG(WARNING) << "[ReadList] Couldn't read element " << i; return false; } } *data = DecodedValue(ret); - VLOG(20) << "[ReadList] Success"; return true; } bool ReadMap(const Marker &marker, DecodedValue *data) { - VLOG(20) << "[ReadMap] Start"; auto size = ReadTypeSize(marker, MarkerMap); if (size == -1) { - DLOG(WARNING) << "[ReadMap] Couldn't get size!"; return false; } @@ -340,29 +288,23 @@ class Decoder { std::map ret; for (int64_t i = 0; i < size; ++i) { if (!ReadValue(&dv)) { - DLOG(WARNING) << "[ReadMap] Couldn't read index " << i; return false; } if (dv.type() != DecodedValue::Type::String) { - DLOG(WARNING) << "[ReadMap] Index " << i << " isn't a string!"; return false; } str = dv.ValueString(); if (!ReadValue(&dv)) { - DLOG(WARNING) << "[ReadMap] Couldn't read element " << i; return false; } ret.insert(std::make_pair(str, dv)); } if (ret.size() != size) { - DLOG(WARNING) - << "[ReadMap] The client sent multiple objects with same indexes!"; return false; } *data = DecodedValue(ret); - VLOG(20) << "[ReadMap] Success"; return true; } @@ -370,25 +312,20 @@ class Decoder { DecodedValue dv; DecodedVertex vertex; - VLOG(20) << "[ReadVertex] Start"; - // read ID if (!ReadValue(&dv, DecodedValue::Type::Int)) { - DLOG(WARNING) << "[ReadVertex] Couldn't read ID!"; return false; } vertex.id = dv.ValueInt(); // read labels if (!ReadValue(&dv, DecodedValue::Type::List)) { - DLOG(WARNING) << "[ReadVertex] Couldn't read labels!"; return false; } auto &labels = dv.ValueList(); vertex.labels.resize(labels.size()); for (size_t i = 0; i < labels.size(); ++i) { if (labels[i].type() != DecodedValue::Type::String) { - DLOG(WARNING) << "[ReadVertex] Label has wrong type!"; return false; } vertex.labels[i] = labels[i].ValueString(); @@ -396,15 +333,12 @@ class Decoder { // read properties if (!ReadValue(&dv, DecodedValue::Type::Map)) { - DLOG(WARNING) << "[ReadVertex] Couldn't read properties!"; return false; } vertex.properties = dv.ValueMap(); *data = DecodedValue(vertex); - VLOG(20) << "[ReadVertex] Success"; - return true; } @@ -413,63 +347,50 @@ class Decoder { DecodedValue dv; DecodedEdge edge; - VLOG(20) << "[ReadEdge] Start"; - if (!buffer_.Read(&value, 1)) { - DLOG(WARNING) << "[ReadEdge] Missing marker and/or signature data!"; return false; } // check header if (marker != Marker::TinyStruct5) { - DLOG(WARNING) << "[ReadEdge] Received invalid marker " - << (uint64_t)utils::UnderlyingCast(marker); return false; } if (value != utils::UnderlyingCast(Signature::Relationship)) { - DLOG(WARNING) << "[ReadEdge] Received invalid signature " << value; return false; } // read ID if (!ReadValue(&dv, DecodedValue::Type::Int)) { - DLOG(WARNING) << "[ReadEdge] Couldn't read ID!"; return false; } edge.id = dv.ValueInt(); // read from if (!ReadValue(&dv, DecodedValue::Type::Int)) { - DLOG(WARNING) << "[ReadEdge] Couldn't read from_id!"; return false; } edge.from = dv.ValueInt(); // read to if (!ReadValue(&dv, DecodedValue::Type::Int)) { - DLOG(WARNING) << "[ReadEdge] Couldn't read to_id!"; return false; } edge.to = dv.ValueInt(); // read type if (!ReadValue(&dv, DecodedValue::Type::String)) { - DLOG(WARNING) << "[ReadEdge] Couldn't read type!"; return false; } edge.type = dv.ValueString(); // read properties if (!ReadValue(&dv, DecodedValue::Type::Map)) { - DLOG(WARNING) << "[ReadEdge] Couldn't read properties!"; return false; } edge.properties = dv.ValueMap(); *data = DecodedValue(edge); - VLOG(20) << "[ReadEdge] Success"; - return true; } @@ -477,33 +398,26 @@ class Decoder { DecodedValue dv; DecodedUnboundedEdge edge; - VLOG(20) << "[ReadUnboundedEdge] Start"; - // read ID if (!ReadValue(&dv, DecodedValue::Type::Int)) { - DLOG(WARNING) << "[ReadUnboundedEdge] Couldn't read ID!"; return false; } edge.id = dv.ValueInt(); // read type if (!ReadValue(&dv, DecodedValue::Type::String)) { - DLOG(WARNING) << "[ReadUnboundedEdge] Couldn't read type!"; return false; } edge.type = dv.ValueString(); // read properties if (!ReadValue(&dv, DecodedValue::Type::Map)) { - DLOG(WARNING) << "[ReadUnboundedEdge] Couldn't read properties!"; return false; } edge.properties = dv.ValueMap(); *data = DecodedValue(edge); - VLOG(20) << "[ReadUnboundedEdge] Success"; - return true; } @@ -511,17 +425,12 @@ class Decoder { DecodedValue dv; DecodedPath path; - VLOG(20) << "[ReadPath] Start"; - // vertices if (!ReadValue(&dv, DecodedValue::Type::List)) { - DLOG(WARNING) << "[ReadPath] Couldn't read vertices!"; return false; } for (const auto &vertex : dv.ValueList()) { if (vertex.type() != DecodedValue::Type::Vertex) { - DLOG(WARNING) << "[ReadPath] Received a '" << vertex.type() - << "' element in the vertices list!"; return false; } path.vertices.emplace_back(vertex.ValueVertex()); @@ -529,13 +438,10 @@ class Decoder { // edges if (!ReadValue(&dv, DecodedValue::Type::List)) { - DLOG(WARNING) << "[ReadPath] Couldn't read edges!"; return false; } for (const auto &edge : dv.ValueList()) { if (edge.type() != DecodedValue::Type::UnboundedEdge) { - DLOG(WARNING) << "[ReadPath] Received a '" << edge.type() - << "' element in the edges list!"; return false; } path.edges.emplace_back(edge.ValueUnboundedEdge()); @@ -543,13 +449,10 @@ class Decoder { // indices if (!ReadValue(&dv, DecodedValue::Type::List)) { - DLOG(WARNING) << "[ReadPath] Couldn't read indices!"; return false; } for (const auto &index : dv.ValueList()) { if (index.type() != DecodedValue::Type::Int) { - DLOG(WARNING) << "[ReadPath] Received a '" << index.type() - << "' element in the indices list (expected an int)!"; return false; } path.indices.emplace_back(index.ValueInt()); @@ -557,8 +460,6 @@ class Decoder { *data = DecodedValue(path); - VLOG(20) << "[ReadPath] Success"; - return true; } }; diff --git a/src/communication/bolt/v1/encoder/chunked_encoder_buffer.hpp b/src/communication/bolt/v1/encoder/chunked_encoder_buffer.hpp index 36aaab924..fa5b9515b 100644 --- a/src/communication/bolt/v1/encoder/chunked_encoder_buffer.hpp +++ b/src/communication/bolt/v1/encoder/chunked_encoder_buffer.hpp @@ -126,7 +126,6 @@ class ChunkedEncoderBuffer { // Flush the whole buffer. if (!output_stream_.Write(buffer_.data() + offset_, size_ - offset_)) return false; - DLOG(INFO) << "Flushed << " << size_ << " bytes."; // Cleanup. Clear(); @@ -150,7 +149,6 @@ class ChunkedEncoderBuffer { // Flush the first chunk if (!output_stream_.Write(buffer_.data(), first_chunk_size_)) return false; - DLOG(INFO) << "Flushed << " << first_chunk_size_ << " bytes."; // Cleanup. // Here we use offset as a method of deleting from the front of the diff --git a/src/communication/bolt/v1/session.hpp b/src/communication/bolt/v1/session.hpp index 929376d9f..300314b5f 100644 --- a/src/communication/bolt/v1/session.hpp +++ b/src/communication/bolt/v1/session.hpp @@ -77,8 +77,6 @@ class Session { input_stream_.size()); return; } - DLOG(WARNING) << fmt::format("Decoding handshake of size {}", - input_stream_.size()); state_ = StateHandshakeRun(*this); if (UNLIKELY(state_ == State::Close)) { ClientFailureInvalidData(); @@ -121,10 +119,6 @@ class Session { ClientFailureInvalidData(); return; } - - DLOG(INFO) << fmt::format("Input stream size: {}", input_stream_.size()); - DLOG(INFO) << fmt::format("Decoder buffer size: {}", - decoder_buffer_.Size()); } } diff --git a/src/communication/bolt/v1/states/error.hpp b/src/communication/bolt/v1/states/error.hpp index 7b36da06c..e52e44f06 100644 --- a/src/communication/bolt/v1/states/error.hpp +++ b/src/communication/bolt/v1/states/error.hpp @@ -21,13 +21,10 @@ State StateErrorRun(TSession &session, State state) { Marker marker; Signature signature; if (!session.decoder_.ReadMessageHeader(&signature, &marker)) { - DLOG(INFO) << "Missing header data!"; + DLOG(WARNING) << "Missing header data!"; return State::Close; } - DLOG(INFO) << fmt::format("Message signature is: 0x{:02X}", - utils::UnderlyingCast(signature)); - // Clear the data buffer if it has any leftover data. session.encoder_buffer_.Clear(); diff --git a/src/communication/bolt/v1/states/executing.hpp b/src/communication/bolt/v1/states/executing.hpp index b001d9062..ac10af79d 100644 --- a/src/communication/bolt/v1/states/executing.hpp +++ b/src/communication/bolt/v1/states/executing.hpp @@ -222,7 +222,6 @@ State HandleRun(TSession &session, State state, Marker marker) { // TODO: Get rid of duplications in PullAll/DiscardAll functions. template State HandlePullAll(Session &session, State state, Marker marker) { - DLOG(INFO) << "[PullAll]"; if (marker != Marker::TinyStruct) { DLOG(WARNING) << fmt::format( "Expected TinyStruct marker, but received 0x{:02X}!", @@ -246,7 +245,6 @@ State HandlePullAll(Session &session, State state, Marker marker) { template State HandleDiscardAll(Session &session, State state, Marker marker) { - DLOG(INFO) << "[DiscardAll]"; if (marker != Marker::TinyStruct) { DLOG(WARNING) << fmt::format( "Expected TinyStruct marker, but received 0x{:02X}!", diff --git a/src/communication/bolt/v1/states/init.hpp b/src/communication/bolt/v1/states/init.hpp index ba2f3b5ad..4713d7020 100644 --- a/src/communication/bolt/v1/states/init.hpp +++ b/src/communication/bolt/v1/states/init.hpp @@ -20,7 +20,6 @@ template State StateInitRun(Session &session) { DCHECK(!session.encoder_buffer_.HasData()) << "There should be no data to write in this state"; - DLOG(INFO) << "Parsing message"; Marker marker; Signature signature;