SomeFire commented on a change in pull request #74: IGNITE-10275 Refactor of
visa caching. Jira spam fix.
URL: https://github.com/apache/ignite-teamcity-bot/pull/74#discussion_r234598100
##########
File path:
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java
##########
@@ -63,33 +70,78 @@
@Inject private Ignite ignite;
/** */
- @Inject private VisasHistoryStorage visasHistoryStorage;
+ @Inject private VisasHistoryStorage visasHistStorage;
/** */
@Inject private IStringCompactor strCompactor;
+ /** */
+ private ReentrantLock observationLock = new ReentrantLock();
+
/**
*/
ObserverTask() {
}
/** */
- private IgniteCache<CompactBuildsInfo, Object> compactInfos() {
+ private IgniteCache<CompactContributionKey, CompactBuildsInfo>
compactInfos() {
return
ignite.getOrCreateCache(TcHelperDb.getCacheV2TxConfig(BUILDS_CACHE_NAME));
}
+ /** */
+ @Nullable public BuildsInfo getInfo(ContributionKey key) {
+ CompactBuildsInfo compactBuildsInfo = compactInfos().get(new
CompactContributionKey(key, strCompactor));
+
+ return Objects.isNull(compactBuildsInfo) ? null :
compactBuildsInfo.toBuildInfo(strCompactor);
+ }
+
+
/** */
public Collection<BuildsInfo> getInfos() {
List<BuildsInfo> buildsInfos = new ArrayList<>();
- compactInfos().forEach(entry ->
buildsInfos.add(entry.getKey().toBuildInfo(strCompactor)));
+ compactInfos().forEach(entry ->
buildsInfos.add(entry.getValue().toBuildInfo(strCompactor)));
return buildsInfos;
}
/** */
public void addInfo(BuildsInfo info) {
- compactInfos().put(new CompactBuildsInfo(info, strCompactor), new
Object());
+ visasHistStorage.put(new VisaRequest(info));
+
+ compactInfos().put(new
CompactContributionKey(info.getContributionKey(), strCompactor),
+ new CompactBuildsInfo(info, strCompactor));
+ }
+
+ /** */
+ private void removeBuildInfo(CompactContributionKey key) {
+ try {
+ BuildsInfo buildsInfo =
compactInfos().get(key).toBuildInfo(strCompactor);
+
+ boolean rmv = compactInfos().remove(key);
+
+ Preconditions.checkState(rmv, "Key not found: " +
key.toContributionKey(strCompactor).toString());
+ }
+ catch (Exception e) {
+ logger.error("Cache remove: " + e.getMessage(), e);
+
+ throw new RuntimeException("Observer queue: " +
+ getInfos().stream().map(bi ->
bi.getContributionKey().toString())
+ .collect(Collectors.joining(", ")) +
+ " Error: " + X.getFullStackTrace(e));
+ }
+ }
+
+ /** */
+ public void removeBuildInfo(ContributionKey key) {
Review comment:
Move public method higher than private.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services