org.bdware.doip.cluster.util.DOResolutionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
The newest version!
package org.bdware.doip.cluster.util;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.audit.client.AuditIrpClient;
import org.bdware.doip.cluster.entity.BDWType;
import org.bdware.irp.client.IrpClient;
import org.bdware.irp.exception.IrpClientException;
import org.bdware.irp.stateinfo.StateInfoBase;
import org.bdware.sc.bean.ForkInfo;
import org.bdware.sc.bean.JoinInfo;
import org.bdware.sc.bean.RouteInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DOResolutionUtil {
private static final Logger LOGGER = LogManager.getLogger(DOResolutionUtil.class);
private static final Gson gson = new Gson();
// TODO rename bdoList in Router
public static String[] getDDOClusterInfo(JsonObject ddoInfo) {
JsonArray doList = ddoInfo.get("bdoList").getAsJsonArray();
List subDOIDsList = new ArrayList<>();
for (JsonElement doid : doList) {
subDOIDsList.add(doid.getAsString());
}
return subDOIDsList.toArray(new String[0]);
}
public static Map getDDORouteInfo(JsonObject bcoAccessRules) {
// 解析RouteInfo
JsonElement routeInfos = bcoAccessRules.get("routeInfo");
Map res = new HashMap<>();
assert routeInfos != null && !routeInfos.isJsonNull() && routeInfos.isJsonObject();
JsonObject routeInfosMap = routeInfos.getAsJsonObject();
for (String doipOperationName : routeInfosMap.keySet()) {
JsonObject doipFunctionRouteInfoJson = routeInfosMap.get(doipOperationName).getAsJsonObject();
RouteInfo doipFunctionRouteInfo = gson.fromJson(doipFunctionRouteInfoJson, RouteInfo.class);
res.put(doipOperationName, doipFunctionRouteInfo);
}
return res;
}
public static Map getDDOJoinInfo(JsonObject bcoAccessRules) {
// 解析JoinInfo
JsonElement joinInfos = bcoAccessRules.get("joinInfo");
Map res = new HashMap<>();
if (joinInfos == null || joinInfos.isJsonNull() || !joinInfos.isJsonObject())
return res;
JsonObject joinInfosMap = joinInfos.getAsJsonObject();
// new Gson().fromJson(joinInfosMap, new TypeToken