diff --git a/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/ImdgService.java b/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/ImdgService.java index dd9adae43..d5eb9dff6 100644 --- a/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/ImdgService.java +++ b/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/ImdgService.java @@ -11,12 +11,14 @@ import org.springframework.stereotype.Service; import ru.clearing.classes.objects.BusinessObject; import ru.spcex.clearing.imdg.IMDGDistributedNames; import ru.spcex.platform.imdg.iml.hazelcast.util.HazelcastHelper; +import ru.spcex.platform.utils.log.ExceptionUtils; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; @Service public class ImdgService { @@ -33,7 +35,7 @@ public class ImdgService { return null; } - public int reloadMapFromDB() { + public int reloadMapFromDB(List warningMsgs) { log.info("Reload all from DB..."); long loadTime = System.currentTimeMillis(); int count = 0; @@ -48,6 +50,8 @@ public class ImdgService { ignoreUpdateMap.add(IMDGDistributedNames.Map_AccountBalance); ignoreUpdateMap.add(IMDGDistributedNames.Map_KeyRate); ignoreUpdateMap.add(IMDGDistributedNames.Map_LiabilitiesClaimsMoney); + ignoreUpdateMap.add("Map_TaskCodeDictionary"); + ignoreUpdateMap.add("Map_TaskcodeDictionary"); try { List> tasks = new ArrayList<>(); @@ -63,6 +67,7 @@ public class ImdgService { log.debug("Ignore sync for map {}", mapName); continue; } + AtomicInteger errorCount=new AtomicInteger(0); tasks.add(() -> { Long maxKey = null; // MapStoreConfig mapStoreConfig = hazelcastServerInstance.getConfig().getMapConfig(mapName).getMapStoreConfig(); @@ -84,6 +89,15 @@ public class ImdgService { maxKey = map.keySet().stream().max(Long::compareTo).orElse(null); log.trace("{} max(id)={}", mapName, maxKey); + } catch (IllegalArgumentException e) { + // когда нет MapStore: java.lang.IllegalArgumentException: First you should configure a map store at com.hazelcast.util.Preconditions.checkTrue(Preconditions.java:327) + // Такая ошибка обычно возникает во время разработки при частичном перезапуске IMDG (без отключения тестового сервиса) при работе над мапами. + log.error("Can not reload map \"{}\" cause: {}", mapName, ExceptionUtils.getStackTrace(e)); + if (warningMsgs != null) + warningMsgs.add("Can not load from map \"" + mapName + "\" " + e.getMessage()); + if (errorCount.incrementAndGet() > 10) { + throw new RuntimeException("Can not reload map " + mapName+", too many errors", e); + } } catch (RuntimeException e) { throw new RuntimeException("Can not reload map " + mapName, e); } @@ -107,7 +121,6 @@ public class ImdgService { executor.shutdown(); } log.info("IDGenerator can not reinit. Max map ID {}", maxKey); -// plannerAllTodayMaker.makeSchedulerAllTodayMap(); } catch (InterruptedException | ExecutionException e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); diff --git a/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/controller/Controller.java b/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/controller/Controller.java index 5a9d2d430..31f4f537e 100644 --- a/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/controller/Controller.java +++ b/clearing-parent/test-api-clearing/src/main/java/ru/spcex/clearing/test/controller/Controller.java @@ -13,6 +13,8 @@ import ru.spcex.platform.utils.log.ExceptionUtils; import java.io.IOException; import java.io.OutputStream; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import java.util.Map; @Service @@ -60,7 +62,9 @@ public class Controller extends HttpServerSimpleFramework { Long n = kafkaService.putMessage(fullCLass, qName, msg); writeLine(os, "Message #" + n + " success send: "); } catch (Exception er) { - writeLine(os, "

Message error:" + ExceptionUtils.getStackTrace(er) + "

"); + String errMsg = ExceptionUtils.getStackTrace(er); + errMsg = errMsg.replace("\n", "
\n"); + writeLine(os, "

Message error:" + errMsg + "

"); } writeLine(os, "

" + msg + "

"); } else { @@ -77,9 +81,14 @@ public class Controller extends HttpServerSimpleFramework { os.flush(); try { long clock = System.currentTimeMillis(); - int count = imdgService.reloadMapFromDB(); + List warnMsg=new ArrayList<>(); + int count = imdgService.reloadMapFromDB(warnMsg); clock = System.currentTimeMillis() - clock; writeLine(os, count + " map per " + clock + " ms
"); + if (!warnMsg.isEmpty()) { + for (String msg : warnMsg) + writeLine(os, "Warning: " + msg + "
"); + } } catch (Throwable e) { String msg = "Error reload: " + ExceptionUtils.getStackTrace(e); log.error(msg);