use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class NodeStateImpl method fromJson.
@SuppressWarnings({ "checkstyle:npathcomplexity" })
@Override
public void fromJson(JsonObject json) {
String jsonClusterState = getString(json, "clusterState", null);
if (jsonClusterState != null) {
clusterState = ClusterState.valueOf(jsonClusterState);
}
String jsonNodeState = getString(json, "nodeState", null);
if (jsonNodeState != null) {
nodeState = com.hazelcast.instance.impl.NodeState.valueOf(jsonNodeState);
}
String jsonClusterVersion = getString(json, "clusterVersion", null);
if (jsonClusterVersion != null) {
clusterVersion = Version.of(jsonClusterVersion);
}
String jsonNodeVersion = getString(json, "memberVersion", null);
if (jsonNodeState != null) {
memberVersion = MemberVersion.of(jsonNodeVersion);
}
weakSecretsConfigs = new HashMap<String, List<String>>();
JsonValue jsonWeakConfigs = json.get("weakConfigs");
if (jsonWeakConfigs != null) {
JsonObject weakConfigsJsObj = jsonWeakConfigs.asObject();
for (JsonObject.Member member : weakConfigsJsObj) {
List<String> weaknesses = new ArrayList<String>();
for (JsonValue value : member.getValue().asArray()) {
weaknesses.add(value.asString());
}
weakSecretsConfigs.put(member.getName(), weaknesses);
}
}
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class LocalWanPublisherStatsImpl method toJson.
@Override
public JsonObject toJson() {
JsonObject root = new JsonObject();
root.add("isConnected", connected);
root.add("state", state.name());
return root;
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class KubernetesApiEndpointSlicesProvider method extractNodes.
@Override
public Map<EndpointAddress, String> extractNodes(JsonObject jsonObject, List<EndpointAddress> privateAddresses) {
Map<EndpointAddress, String> result = new HashMap<>();
Set<EndpointAddress> left = new HashSet<>(privateAddresses);
for (JsonValue item : toJsonArray(jsonObject.get("items"))) {
List<Integer> ports = new ArrayList<>();
for (JsonValue port : toJsonArray(item.asObject().get("ports"))) {
ports.add(port.asObject().get("port").asInt());
}
for (JsonValue endpoint : toJsonArray(item.asObject().get("endpoints"))) {
JsonObject endpointObject = endpoint.asObject();
String nodeName = convertToString(endpointObject.get("nodeName"));
Map<EndpointAddress, String> nodes = extractNodes(endpointObject.get("addresses"), ports, nodeName);
for (Map.Entry<EndpointAddress, String> nodeEntry : nodes.entrySet()) {
EndpointAddress address = nodeEntry.getKey();
if (privateAddresses.contains(address)) {
result.put(address, nodes.get(address));
left.remove(address);
}
}
}
}
if (!left.isEmpty()) {
// At least one Hazelcast Member POD does not have 'nodeName' assigned.
throw noNodeNameAssignedException(left);
}
return result;
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class KubernetesClient method extractZone.
private static String extractZone(JsonObject nodeJson) {
JsonObject labels = nodeJson.get("metadata").asObject().get("labels").asObject();
List<String> zoneLabels = asList("topology.kubernetes.io/zone", "failure-domain.kubernetes.io/zone", "failure-domain.beta.kubernetes.io/zone");
for (String zoneLabel : zoneLabels) {
JsonValue zone = labels.get(zoneLabel);
if (zone != null) {
return toString(zone);
}
}
return null;
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class KubernetesClient method extractLoadBalancerAddress.
private static String extractLoadBalancerAddress(JsonObject serviceResponse) {
JsonObject ingress = serviceResponse.get("status").asObject().get("loadBalancer").asObject().get("ingress").asArray().get(0).asObject();
JsonValue address = ingress.get("ip");
if (address == null) {
address = ingress.get("hostname");
}
return address.asString();
}
Aggregations