From e24bccb3f1b6d882b1dc9a49fae7f69cabbb325e Mon Sep 17 00:00:00 2001 From: Mengyi Zhou Date: Fri, 26 Jun 2015 13:29:01 +0800 Subject: [PATCH] add domain check --- .../zeus/service/model/handler/impl/SlbSyncImpl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/ctrip/zeus/service/model/handler/impl/SlbSyncImpl.java b/src/main/java/com/ctrip/zeus/service/model/handler/impl/SlbSyncImpl.java index 17911f39..0722737c 100644 --- a/src/main/java/com/ctrip/zeus/service/model/handler/impl/SlbSyncImpl.java +++ b/src/main/java/com/ctrip/zeus/service/model/handler/impl/SlbSyncImpl.java @@ -88,6 +88,16 @@ public class SlbSyncImpl implements SlbSync { if (slb.getSlbServers() == null || slb.getSlbServers().size() == 0) { throw new ValidationException("Slb with invalid server data cannot be persisted."); } + Set existingHost = new HashSet<>(); + for (VirtualServer virtualServer : slb.getVirtualServers()) { + for (Domain domain : virtualServer.getDomains()) { + String key = domain.getName() + ":" + virtualServer.getPort(); + if (existingHost.contains(key)) + throw new ValidationException("Duplicate domain and port is found: " + key); + else + existingHost.add(key); + } + } } private boolean removable(SlbDo d) throws DalException {