Skip to content
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3ff732d
Add HazelcastHttpCache
enozcan Mar 26, 2020
c39db10
Secure body key uniqueness and set defaults.
enozcan Mar 27, 2020
f359a8e
Use Envoy's random for versioning.
enozcan Mar 30, 2020
d6f2568
Handle all connection failures. Use parameterized test for common ones.
enozcan Apr 1, 2020
8630701
Add local cache to use during tests.
enozcan Apr 3, 2020
2232761
Add plugin doc and fix spell check.
enozcan Apr 5, 2020
8ca71fc
Fix code format & clean up.
enozcan Apr 7, 2020
a3a1af4
Fix clang_tidy errors.
enozcan Apr 15, 2020
31c0b3c
Apply upstream changes
enozcan Apr 17, 2020
cabb409
Disable PartitionAware for body entries.
enozcan May 8, 2020
fc5c3ee
Merge branch 'master' into hazelcast_http_cache
enozcan May 8, 2020
7334709
Fix format and revert LookupRequest changes back.
enozcan May 8, 2020
839c418
Add serialization tests.
enozcan May 11, 2020
2576ebc
Move remote calls to cache accessors.
enozcan May 20, 2020
fde9e19
Change key serialization from UTF to byte array.
enozcan May 20, 2020
104f8e0
Update plugin doc.
enozcan May 20, 2020
1f152b5
Fix asan errors other than bitswap.
enozcan May 21, 2020
3ebb754
Add header eviction listener.
enozcan May 23, 2020
7665fa0
Allow overriding cached responses.
enozcan May 28, 2020
c2801f4
Add Bits.h patch for ubsan fix.
enozcan May 28, 2020
9172525
Fix clang warns.
enozcan May 29, 2020
bb9ce1e
Cover remote calls over offline client.
enozcan May 29, 2020
ce6651b
tsan fix
enozcan May 29, 2020
8e3129a
Address reviews.
enozcan Jun 10, 2020
570e362
Use max_body_bytes from CacheConfig.
enozcan Jun 6, 2020
66a1f01
Use core.SocketAddress for member address.
enozcan Jun 10, 2020
0acc4d1
Fix format.
enozcan Jun 11, 2020
d3b0cf5
Fix Windows lib name.
enozcan Jun 11, 2020
d40185f
Merge branch 'master' into hazelcast_http_cache
enozcan Jun 11, 2020
eb50942
Fix format.
enozcan Jun 11, 2020
7413c54
Remove accessor cast and move logs to accessor.
enozcan Jun 12, 2020
a1167a1
Pass accessor via cache::start
enozcan Jun 13, 2020
639bfbb
Revert back to unit64 max body bytes.
enozcan Jun 13, 2020
ab2f3fd
Add tests.
enozcan Jun 13, 2020
49ca85b
Add Windows build defines.
enozcan Jun 13, 2020
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
14 changes: 14 additions & 0 deletions bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ envoy_cmake_external(
}),
)

envoy_cmake_external(
name = "hazelcast_cpp_client",
cache_entries = {
"HZ_LIB_TYPE": "STATIC",
"CMAKE_BUILD_TYPE": "RELEASE",
"CMAKE_CXX_FLAGS": "-Wno-deprecated",
},
lib_source = "@com_github_hazelcast_cpp_client//:all",
static_libraries = select({
"//bazel:windows_x86_64": ["libHazelcastClient3.12.1_64.lib"],
"//conditions:default": ["libHazelcastClient3.12.1_64.a"],
}),
)

envoy_cmake_external(
name = "nghttp2",
cache_entries = {
Expand Down
188 changes: 188 additions & 0 deletions bazel/foreign_cc/hazelcast_cpp_client.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
--- CMakeLists.txt 2020-02-27 11:35:35.000000000 +0300
+++ CMakeLists.txt 2020-02-27 11:37:15.000000000 +0300
@@ -14,6 +14,7 @@
# limitations under the License.
#
cmake_minimum_required (VERSION 2.6.4)
+set(CMAKE_CXX_COMPILER_WORKS 1)
project (HazelcastClient)

# FLAGS
@@ -279,3 +280,9 @@
ADD_SUBDIRECTORY(examples)
message(STATUS "Configured to build the examples.")
ENDIF(HZ_BUILD_EXAMPLES)
+INSTALL(TARGETS ${HZ_LIB_NAME} DESTINATION lib)
+INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/hazelcast/generated-sources/include/hazelcast DESTINATION include FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/hazelcast/include/hazelcast DESTINATION include FILES_MATCHING PATTERN "*.h" PATTERN "*.inl")
+INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/external/release_include/boost DESTINATION include FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
+INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/external/release_include/easylogging++ DESTINATION include FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/external/include/asio/asio/include/asio DESTINATION include FILES_MATCHING PATTERN "*.hpp")

--- hazelcast/include/hazelcast/util/Bits.h 2020-01-28 11:42:05.000000000 +0300
+++ hazelcast/include/hazelcast/util/Bits.h 2020-05-22 23:11:16.000000000 +0300
@@ -26,6 +26,7 @@
#endif

#include <stdint.h>
+#include <string.h> // This patch fixes asan build for Envoy Http Cache.

#if defined(linux) || defined(__linux__) || defined (__GLIBC__) || defined(__GNU__)

@@ -124,7 +125,7 @@
#ifdef HZ_BIG_ENDIAN
swap_2(source, target);
#else
- *(static_cast<uint16_t *>(target)) = *(static_cast<const uint16_t *>(source));
+ memcpy(target, source, sizeof(uint16_t));
#endif
}

@@ -136,7 +137,7 @@
#ifdef HZ_BIG_ENDIAN
swap_4(source, target);
#else
- *(static_cast<uint32_t *>(target)) = *(static_cast<const uint32_t *>(source));
+ memcpy(target, source, sizeof(uint32_t));
#endif
}

@@ -148,7 +149,7 @@
#ifdef HZ_BIG_ENDIAN
swap_8(source, target);
#else
- *(static_cast<uint64_t *>(target)) = *(static_cast<const uint64_t *>(source));
+ memcpy(target, source, sizeof(uint64_t));
#endif
}

@@ -170,7 +171,7 @@
#ifdef HZ_BIG_ENDIAN
swap_2(source, target);
#else
- *(static_cast<uint16_t *>(target)) = *(static_cast<const uint16_t *>(source));
+ memcpy(target, source, sizeof(uint16_t));
#endif
}

@@ -182,7 +183,7 @@
#ifdef HZ_BIG_ENDIAN
swap_4(source, target);
#else
- *(static_cast<uint32_t *>(target)) = *(static_cast<const uint32_t *>(source));
+ memcpy(target, source, sizeof(uint32_t));
#endif
}

@@ -194,13 +195,15 @@
#ifdef HZ_BIG_ENDIAN
swap_8(source, target);
#else
- *(static_cast<uint64_t *>(target)) = *(static_cast<const uint64_t *>(source));
+ memcpy(target, source, sizeof(uint64_t));
#endif
}

inline static int32_t readIntB(std::vector<byte> &buffer, unsigned long pos) {
#ifdef HZ_BIG_ENDIAN
- return *((int32_t *) (&buffer[0] + pos));
+ int32_t result;
+ memcpy(&result, (&buffer[0] + pos), sizeof(int32_t));
+ return result;
#else
int32_t result;
swap_4(&(buffer[0]) + pos, &result);
@@ -215,7 +218,7 @@
*/
inline static void bigEndianToNative2(const void *source, void *target) {
#ifdef HZ_BIG_ENDIAN
- *(static_cast<uint16_t *>(target)) = *(static_cast<const uint16_t *>(source));
+ memcpy(target, source, sizeof(uint16_t));
#else
swap_2(source, target);
#endif
@@ -227,7 +230,7 @@
*/
inline static void bigEndianToNative4(const void *source, void *target) {
#ifdef HZ_BIG_ENDIAN
- *(static_cast<uint32_t *>(target)) = *(static_cast<const uint32_t *>(source));
+ memcpy(target, source, sizeof(uint32_t));
#else
swap_4(source, target);
#endif
@@ -239,7 +242,7 @@
*/
inline static void bigEndianToNative8(const void *source, void *target) {
#ifdef HZ_BIG_ENDIAN
- *(static_cast<uint64_t *>(target)) = *(static_cast<const uint64_t *>(source));
+ memcpy(target, source, sizeof(uint64_t));
#else
swap_8(source, target);
#endif
@@ -251,7 +254,7 @@
*/
inline static void nativeToBigEndian2(void *source, void *target) {
#ifdef HZ_BIG_ENDIAN
- *(static_cast<uint16_t *>(target)) = *(static_cast<const uint16_t *>(source));
+ memcpy(target, source, sizeof(uint16_t));
#else
swap_2(source, target);

@@ -264,7 +267,7 @@
*/
inline static void nativeToBigEndian4(const void *source, void *target) {
#ifdef HZ_BIG_ENDIAN
- *(static_cast<uint32_t *>(target)) = *(static_cast<const uint32_t *>(source));
+ memcpy(target, source, sizeof(uint32_t));
#else
swap_4(source, target);
#endif
@@ -276,7 +279,7 @@
*/
inline static void nativeToBigEndian8(void *source, void *target) {
#ifdef HZ_BIG_ENDIAN
- *(static_cast<uint64_t *>(target)) = *(static_cast<const uint64_t *>(source));
+ memcpy(target, source, sizeof(uint64_t));
#else
swap_8(source, target);
#endif
@@ -286,25 +289,32 @@

private :
inline static void swap_2(const void *orig, void* target) {
- *reinterpret_cast<uint16_t *> (target) =
- bswap16 (*reinterpret_cast<uint16_t const *> (orig));
+ uint16_t raw;
+ memcpy(&raw, orig, sizeof(uint16_t));
+ uint16_t swapped = bswap16(raw);
+ memcpy(target, &swapped, sizeof(uint16_t));
}

inline static void swapInplace4(void *orig) {
- uint32_t value = * reinterpret_cast<const uint32_t*> (orig);
+ uint32_t value;
+ memcpy(&value, orig, sizeof(uint32_t));
swap_4(&value, orig);
}

inline static void swap_4 (const void* orig, void* target)
{
- *reinterpret_cast<uint32_t *> (target) =
- bswap32 (*reinterpret_cast<uint32_t const *> (orig));
+ uint32_t raw;
+ memcpy(&raw, orig, sizeof(uint32_t));
+ uint32_t swapped = bswap32(raw);
+ memcpy(target, &swapped, sizeof(uint32_t));
}

inline static void swap_8 (const void* orig, void* target)
{
- *reinterpret_cast<uint64_t *> (target) =
- bswap64 (*reinterpret_cast<uint64_t const *> (orig));
+ uint64_t raw;
+ memcpy(&raw, orig, sizeof(uint64_t));
+ uint64_t swapped = bswap64(raw);
+ memcpy(target, &swapped, sizeof(uint64_t));
}
};
}
15 changes: 15 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def envoy_dependencies(skip_targets = []):
_com_github_google_libprotobuf_mutator()
_com_github_gperftools_gperftools()
_com_github_grpc_grpc()
_com_github_hazelcast_cpp_client()
_com_github_jbeder_yaml_cpp()
_com_github_libevent_libevent()
_com_github_luajit_luajit()
Expand Down Expand Up @@ -323,6 +324,20 @@ def _com_github_google_libprotobuf_mutator():
build_file = "@envoy//bazel/external:libprotobuf_mutator.BUILD",
)

def _com_github_hazelcast_cpp_client():
location = _get_location("com_github_hazelcast_cpp_client")
http_archive(
name = "com_github_hazelcast_cpp_client",
build_file_content = BUILD_ALL_CONTENT,
patch_args = ["-p0"],
patches = ["@envoy//bazel/foreign_cc:hazelcast_cpp_client.patch"],
**location
)
native.bind(
name = "hazelcast_cpp_client",
actual = "@envoy//bazel/foreign_cc:hazelcast_cpp_client",
)

def _com_github_jbeder_yaml_cpp():
location = _get_location("com_github_jbeder_yaml_cpp")
http_archive(
Expand Down
9 changes: 9 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ DEPENDENCY_REPOSITORIES = dict(
use_category = ["dataplane", "controlplane"],
cpe = "cpe:2.3:a:grpc:grpc:*",
),
com_github_hazelcast_cpp_client = dict(
sha256 = "3c43c81135e415ce708486564dc125bde93c2c9f8965d5af4b603ec91ff52f6e",
strip_prefix = "hazelcast-cpp-client-3.12.1",
# Using non official tarball due to missing submodule files in the official release.
# TODO(enozcan): Use official release with init & updating submodules

@enozcan enozcan Apr 7, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to update submodules before building the external dependency?

urls = ["https://github.com/enozcan/envoy-hazelcast-cpp-client/raw/master/hazelcast-cpp-client-3.12.1.zip"],
use_category = ["dataplane"],
cpe = "N/A",
),
com_github_luajit_luajit = dict(
sha256 = "409f7fe570d3c16558e594421c47bdd130238323c9d6fd6c83dedd2aaeb082a8",
strip_prefix = "LuaJIT-2.1.0-beta3",
Expand Down
1 change: 1 addition & 0 deletions source/common/common/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace Logger {
FUNCTION(filter) \
FUNCTION(forward_proxy) \
FUNCTION(grpc) \
FUNCTION(hazelcast_http_cache) \
FUNCTION(hc) \
FUNCTION(health_checker) \
FUNCTION(http) \
Expand Down
Loading