Add support for Hazelcast

This commit upgrades to Hazelcast 4.0.3, yet keeping compatibility with
Hazelcast 3.x.

Closes gh-20856
Closes gh-23475
This commit is contained in:
Stephane Nicoll
2020-09-09 17:48:49 +02:00
parent 7b183ef99d
commit 4009acf025
32 changed files with 418 additions and 79 deletions

View File

@@ -35,24 +35,24 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link HazelcastHealthIndicator} with Hazelcast 4.
* Tests for {@link HazelcastHealthIndicator} with Hazelcast 3.
*
* @author Dmytro Nosan
* @author Stephane Nicoll
*/
@ClassPathExclusions("hazelcast*.jar")
@ClassPathOverrides("com.hazelcast:hazelcast:4.0")
class Hazelcast4HazelcastHealthIndicatorTests {
@ClassPathOverrides("com.hazelcast:hazelcast:3.12.8")
class Hazelcast3HazelcastHealthIndicatorTests {
@Test
void hazelcastUp() throws IOException {
HazelcastInstance hazelcast = new HazelcastInstanceFactory(new ClassPathResource("hazelcast-4.xml"))
HazelcastInstance hazelcast = new HazelcastInstanceFactory(new ClassPathResource("hazelcast-3.xml"))
.getHazelcastInstance();
try {
Health health = new HazelcastHealthIndicator(hazelcast).health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsOnlyKeys("name", "uuid").containsEntry("name",
"actuator-hazelcast-4");
"actuator-hazelcast-3");
assertThat(health.getDetails().get("uuid")).asString().isNotEmpty();
}
finally {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.springframework.boot.actuate.metrics.cache;
import java.util.Collections;
import com.hazelcast.core.IMap;
import com.hazelcast.map.IMap;
import com.hazelcast.spring.cache.HazelcastCache;
import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;

View File

@@ -1,8 +1,8 @@
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd">
<instance-name>actuator-hazelcast-4</instance-name>
http://www.hazelcast.com/schema/config/hazelcast-config-3.12.xsd">
<instance-name>actuator-hazelcast-3</instance-name>
<map name="defaultCache"/>
<network>
<join>

View File

@@ -1,7 +1,7 @@
<hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.12.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd">
<instance-name>actuator-hazelcast</instance-name>
<map name="defaultCache" />
<network>