SomeFire commented on a change in pull request #76: IGNITE-10275 Refactor of visa caching.
URL: https://github.com/apache/ignite-teamcity-bot/pull/76#discussion_r234972281 ########## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java ########## @@ -57,88 +48,69 @@ /** Logger. */ private static final Logger logger = LoggerFactory.getLogger(ObserverTask.class); - /** */ - public static final String BUILDS_CACHE_NAME = "compactBuildsInfosCache"; - /** Helper. */ @Inject private ITcHelper tcHelper; /** Helper. */ @Inject private IJiraIntegration jiraIntegration; - /** Ignite. */ - @Inject private Ignite ignite; - /** */ @Inject private VisasHistoryStorage visasHistStorage; /** */ - @Inject private IStringCompactor strCompactor; + private ReentrantLock observationLock = new ReentrantLock(); /** */ - private ReentrantLock observationLock = new ReentrantLock(); + private Map<ContributionKey, BuildsInfo> infos = new HashMap<>(); /** */ ObserverTask() { } /** */ - private IgniteCache<CompactContributionKey, CompactBuildsInfo> compactInfos() { - return ignite.getOrCreateCache(TcHelperDb.getCacheV2TxConfig(BUILDS_CACHE_NAME)); + public void init() { + visasHistStorage.getLastVisas().stream() + .filter(req -> req.isObserving()) + .forEach(req -> infos.put(req.getInfo().getContributionKey(), req.getInfo())); } /** */ @Nullable public BuildsInfo getInfo(ContributionKey key) { - CompactBuildsInfo compactBuildsInfo = compactInfos().get(new CompactContributionKey(key, strCompactor)); - - return Objects.isNull(compactBuildsInfo) ? null : compactBuildsInfo.toBuildInfo(strCompactor); + return infos.get(key); } /** */ public Collection<BuildsInfo> getInfos() { - List<BuildsInfo> buildsInfos = new ArrayList<>(); - - compactInfos().forEach(entry -> buildsInfos.add(entry.getValue().toBuildInfo(strCompactor))); - - return buildsInfos; + return infos.values(); } /** */ public void addInfo(BuildsInfo info) { - visasHistStorage.put(new VisaRequest(info)); + visasHistStorage.updateLastVisaRequest(info.getContributionKey(), req -> req.setObservingStatus(false)); Review comment: Add observation lock here. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] With regards, Apache Git Services |
Free forum by Nabble | Edit this page |