All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qwazr.cluster.ClusterStatusJson Maven / Gradle / Ivy

There is a newer version: 1.5.2
Show newest version
/*
 * Copyright 2015-2017 Emmanuel Keller / QWAZR
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.qwazr.cluster; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.qwazr.server.ServerException; import java.util.Date; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import java.util.UUID; @JsonInclude(Include.NON_NULL) public class ClusterStatusJson { public final String me; public final String uuid; public final String webapp; public final TreeMap> groups; public final TreeMap services; @JsonProperty("last_keep_alive_execution") public final Date lastKeepAliveExecution; @JsonProperty("active_nodes") public final TreeMap activeNodes; public final TreeSet masters; @JsonCreator private ClusterStatusJson(@JsonProperty("me") final String me, @JsonProperty("uuid") final String uuid, @JsonProperty("webapp") final String webapp, @JsonProperty("active_nodes") final TreeMap activeNodes, @JsonProperty("groups") final TreeMap> groups, @JsonProperty("services") final TreeMap services, @JsonProperty("masters") final TreeSet masters, @JsonProperty("last_keep_alive_execution") final Date lastKeepAliveExecution) throws ServerException { this.me = me; this.uuid = uuid; this.webapp = webapp; this.groups = groups; this.services = services; this.masters = masters; this.lastKeepAliveExecution = lastKeepAliveExecution; this.activeNodes = activeNodes; } ClusterStatusJson(final String me, final UUID uuid, final String webapp, final TreeMap nodesMap, final TreeMap> groups, final TreeMap> services, final Set masters, final Date lastKeepAliveExecution) throws ServerException { this(me, uuid.toString(), webapp, nodesMap, groups, toServices(services), masters == null ? null : new TreeSet<>(masters), lastKeepAliveExecution); } final static TreeMap EMPTY = new TreeMap<>(); private static TreeMap toServices( final TreeMap> services) { if (services == null || services.isEmpty()) return EMPTY; final TreeMap servicesTree = new TreeMap<>(); services.forEach( (service, nodesSet) -> servicesTree.put(service, ClusterServiceStatusJson.StatusEnum.of(nodesSet))); return servicesTree; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy