Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public class MicroserviceInstance {

private String timestamp;

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("instanceId=" + instanceId + ";");
sb.append("serviceId=" + serviceId + ";");
sb.append("status=" + status + ";");
sb.append("endpoints=" + endpoints.toString());
return sb.toString();
}

public String getTimestamp() {
return timestamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.config.DynamicStringProperty;

import io.vertx.core.json.Json;

public class InstanceCacheCheckTask implements ServiceRegistryTaskInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(InstanceCacheCheckTask.class);

Expand Down Expand Up @@ -131,7 +129,7 @@ protected void runTask() {
InstanceCacheSummary instanceCacheSummary = checker.check();
eventBus.post(instanceCacheSummary);

LOGGER.info("check instance cache, result={}.", Json.encode(instanceCacheSummary));
LOGGER.info("check instance cache, result={}.", instanceCacheSummary.getStatus());
} catch (Throwable e) {
LOGGER.error("failed check instance cache..", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ protected InstanceCacheResult check(MicroserviceVersions microserviceVersions) {
String local = Json.encode(microserviceVersions.getPulledInstances());
String remote = Json.encode(remoteInstances);
if (local.equals(remote)) {
LOGGER.info("instance cache match. appId={}, microservice={}.\n"
+ "current cache: {}\n",
microserviceVersions.getAppId(),
microserviceVersions.getMicroserviceName(),
remoteInstances.toString());
instanceCacheResult.setStatus(Status.NORMAL);
return instanceCacheResult;
}
Expand All @@ -123,8 +128,8 @@ protected InstanceCacheResult check(MicroserviceVersions microserviceVersions) {
+ "remote cache: {}",
microserviceVersions.getAppId(),
microserviceVersions.getMicroserviceName(),
local,
remote);
microserviceVersions.getPulledInstances().toString(),
remoteInstances.toString());
instanceCacheResult.setStatus(Status.ABNORMAL);
instanceCacheResult.setDetail("instance cache not match");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void testDefaultValues() {
Assert.assertNull(oMicroserviceInstance.getHealthCheck());
Assert.assertNull(oMicroserviceInstance.getStage());
Assert.assertEquals(MicroserviceInstanceStatus.UP, oMicroserviceInstance.getStatus());
Assert.assertEquals("instanceId=null;serviceId=null;status=UP;endpoints=[]", oMicroserviceInstance.toString());
}

@SuppressWarnings("deprecation")
Expand All @@ -107,6 +108,8 @@ public void testInitializedValues() {
Assert.assertNotEquals(oMicroserviceInstance.hashCode(), other.hashCode());
Assert.assertEquals(oMicroserviceInstance, same);
Assert.assertEquals(oMicroserviceInstance.hashCode(), same.hashCode());
Assert.assertEquals("instanceId=testInstanceID;serviceId=testServiceID;status=DOWN;endpoints=[testEndpoints]",
oMicroserviceInstance.toString());
}

@SuppressWarnings("deprecation")
Expand Down