]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/jaegertracing/jaeger-client-cpp/src/jaegertracing/utils/HTTPTransporter.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / jaegertracing / jaeger-client-cpp / src / jaegertracing / utils / HTTPTransporter.h
diff --git a/ceph/src/jaegertracing/jaeger-client-cpp/src/jaegertracing/utils/HTTPTransporter.h b/ceph/src/jaegertracing/jaeger-client-cpp/src/jaegertracing/utils/HTTPTransporter.h
deleted file mode 100644 (file)
index 5340d24..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*\r
- * Copyright (c) 2019, The Jaeger Authors\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef JAEGERTRACING_UTILS_UDPCLIENT5_H\r
-#define JAEGERTRACING_UTILS_UDPCLIENT5_H\r
-\r
-#include <iostream>\r
-#include <sstream>\r
-#include <stdexcept>\r
-#include <system_error>\r
-\r
-#include "jaegertracing/Compilers.h"\r
-\r
-#include "jaegertracing/utils/Transport.h"\r
-\r
-#include "jaegertracing/net/IPAddress.h"\r
-#include "jaegertracing/net/Socket.h"\r
-#include "jaegertracing/net/http/Response.h"\r
-\r
-#include <thrift/protocol/TBinaryProtocol.h>\r
-#include <thrift/transport/TBufferTransports.h>\r
-#include <thrift/transport/THttpClient.h>\r
-\r
-namespace jaegertracing {\r
-namespace utils {\r
-\r
-class HTTPTransporter : public Transport {\r
-  public:\r
-    HTTPTransporter(const net::URI& endpoint, int maxPacketSize);\r
-\r
-    ~HTTPTransporter() { close(); }\r
-\r
-    void emitBatch(const thrift::Batch& batch) override\r
-    {\r
-        // Resets the buffer to write a new batch\r
-        _buffer->resetBuffer();\r
-\r
-        // Does the serialisation to Thrift\r
-        auto oprot = _protocol.get();\r
-        batch.write(oprot);\r
-        oprot->writeMessageEnd();\r
-        oprot->getTransport()->writeEnd();\r
-        oprot->getTransport()->flush();\r
-\r
-        uint8_t* data = nullptr;\r
-        uint32_t size = 0;\r
-        _buffer->getBuffer(&data, &size);\r
-\r
-        // Sends the HTTP message\r
-        const auto numWritten = ::send(_socket.handle(), reinterpret_cast<char*>(data), sizeof(uint8_t) * size, 0);\r
-\r
-        if (static_cast<unsigned>(numWritten) != size) {\r
-            std::ostringstream oss;\r
-            oss << "Failed to write message, numWritten=" << numWritten << ", size=" << size;\r
-            throw std::system_error(errno, std::system_category(), oss.str());\r
-        }\r
-\r
-        // Waits for response. Check that the server acknowledged\r
-        // and returned a green status [200, 201, 202, 203, 204]\r
-        net::http::Response response = net::http::read(_socket);\r
-        if (response.statusCode() < 200 && response.statusCode() > 204) {\r
-          std::ostringstream oss;\r
-          oss << "Failed to write message, HTTP error " << response.statusCode() << response.reason();\r
-          throw std::system_error(errno, std::system_category(), oss.str());\r
-        }\r
-    }\r
-\r
-    std::unique_ptr<apache::thrift::protocol::TProtocolFactory>\r
-    protocolFactory() const override\r
-    {\r
-        return std::unique_ptr<apache::thrift::protocol::TProtocolFactory>(\r
-            new apache::thrift::protocol::TBinaryProtocolFactory());\r
-    }\r
-\r
-  private:\r
-    std::shared_ptr<apache::thrift::transport::TMemoryBuffer> _buffer;\r
-    net::IPAddress _serverAddr;\r
-    std::shared_ptr<::apache::thrift::transport::THttpClient> _httpClient;\r
-    std::shared_ptr<apache::thrift::protocol::TProtocol> _protocol;\r
-\r
-    static constexpr auto kHttpPacketMaxLength = 1024 * 1024; // 1MB\r
-};\r
-\r
-}  // namespace utils\r
-}  // namespace jaegertracing\r
-\r
-#endif  // JAEGERTRACING_UTILS_UDPCLIENT_H\r