This is an automated email from the ASF dual-hosted git repository.
dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
The following commit(s) were added to refs/heads/master by this push:
new a9c4709 Additional profiling info was added, load build history
refactored
a9c4709 is described below
commit a9c4709ceed485b3f34d79bb0a5003e6224229da
Author: Dmitriy Pavlov <[email protected]>
AuthorDate: Mon Sep 17 23:09:40 2018 +0300
Additional profiling info was added, load build history refactored
---
.../apache/ignite/ci/IgnitePersistentTeamcity.java | 114 +++++++++++++--------
.../apache/ignite/ci/tcmodel/hist/BuildRef.java | 23 +++++
.../org/apache/ignite/ci/web/model/Version.java | 2 +-
.../ci/web/rest/monitoring/MonitoringService.java | 8 +-
ignite-tc-helper-web/src/main/webapp/index.html | 4 +-
5 files changed, 105 insertions(+), 46 deletions(-)
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
index fcd7b56..b05d357 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
@@ -33,7 +33,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
-import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -266,34 +265,86 @@ public class IgnitePersistentTeamcity implements
IAnalyticsEnabledTeamcity, ITea
return loaded;
}
- private <K, V extends List> V timedLoadIfAbsentOrMerge(IgniteCache<K,
Expirable<V>> cache, int seconds, Long cnt, K key,
- BiFunction<K, V, V> loadWithMerge) {
- @Nullable final Expirable<V> persistedBuilds = cache.get(key);
+ protected <K> List<BuildRef> loadBuildHistory(IgniteCache<K,
Expirable<List<BuildRef>>> cache,
+ int seconds,
+ Long cnt,
+ K key,
+ Function<K,
List<BuildRef>> realLoad) {
+ @Nullable Expirable<List<BuildRef>> persistedBuilds =
readBuildHistEntry( cache, (K) key);
- int fields = ObjectInterner.internFields(persistedBuilds);
+ if (persistedBuilds != null
+ && (persistedBuilds.isAgeLessThanSecs(seconds)
+ && (cnt == null ||
persistedBuilds.hasCounterGreaterThan(cnt)))) {
+ List<BuildRef> data = persistedBuilds.getData();
- if (persistedBuilds != null) {
- if (persistedBuilds.isAgeLessThanSecs(seconds) &&
- (cnt == null || persistedBuilds.hasCounterGreaterThan(cnt)))
- return persistedBuilds.getData();
+ ObjectInterner.internFields(persistedBuilds);
+
+ return data;
}
- Lock lock = cache.lock(key);
- lock.lock();
+ Lock lock = lockBuildHistEntry(cache, key);
- V apply;
try {
- apply = loadWithMerge.apply(key, persistedBuilds != null ?
persistedBuilds.getData() : null);
+ if (persistedBuilds != null
+ && (persistedBuilds.isAgeLessThanSecs(seconds)
+ && (cnt == null ||
persistedBuilds.hasCounterGreaterThan(cnt)))) {
+ List<BuildRef> data = persistedBuilds.getData();
+
+ ObjectInterner.internFields(persistedBuilds);
+
+ return data;
+ }
- final Expirable<V> newVal = new
Expirable<>(System.currentTimeMillis(), apply.size(), apply);
+ //todo sinceBuild:(number:) // --todo -10 build numbers
- cache.put(key, newVal);
+ List<BuildRef> dataFromRest;
+ try {
+ dataFromRest = realLoad.apply(key);
+ }
+ catch (Exception e) {
+ if (Throwables.getRootCause(e) instanceof
FileNotFoundException) {
+ System.err.println("Build history not found for build : "
+ key);
+ dataFromRest = Collections.emptyList();
+ }
+ else
+ throw e;
+ }
+ final List<BuildRef> persistedList = persistedBuilds != null ?
persistedBuilds.getData() : null;
+ final List<BuildRef> buildRefs = mergeHistoryMaps(persistedList,
dataFromRest);
+
+ final Expirable<List<BuildRef>> newVal
+ = new Expirable<>(System.currentTimeMillis(),
buildRefs.size(), buildRefs);
+
+ saveBuildHistoryEntry(cache, key, newVal);
+
+ return buildRefs;
}
finally {
lock.unlock();
}
+ }
- return apply;
+ @AutoProfiling
+ @SuppressWarnings("WeakerAccess")
+ protected <K> void saveBuildHistoryEntry(IgniteCache<K,
Expirable<List<BuildRef>>> cache, K key, Expirable<List<BuildRef>> newVal) {
+ cache.put(key, newVal);
+ }
+
+
+ @AutoProfiling
+ @SuppressWarnings("WeakerAccess")
+ protected <K> Expirable<List<BuildRef>> readBuildHistEntry(IgniteCache<K,
Expirable<List<BuildRef>>> cache, K key) {
+ return cache.get(key);
+ }
+
+ @AutoProfiling
+ @SuppressWarnings("WeakerAccess")
+ protected <K> Lock lockBuildHistEntry(IgniteCache<K,
Expirable<List<BuildRef>>> cache, K key) {
+ Lock lock = cache.lock(key);
+
+ lock.lock();
+
+ return lock;
}
/** {@inheritDoc} */
@@ -301,23 +352,8 @@ public class IgnitePersistentTeamcity implements
IAnalyticsEnabledTeamcity, ITea
@Override public List<BuildRef> getFinishedBuilds(String projectId, String
branch, Long cnt) {
final SuiteInBranch suiteInBranch = new SuiteInBranch(projectId,
branch);
- List<BuildRef> buildRefs = timedLoadIfAbsentOrMerge(buildHistCache(),
60, cnt, suiteInBranch,
- (key, persistedValue) -> {
- List<BuildRef> builds;
- try {
- builds = teamcity.getFinishedBuilds(projectId, branch,
cnt);
- }
- catch (Exception e) {
- if (Throwables.getRootCause(e) instanceof
FileNotFoundException) {
- System.err.println("Build history not found for build
: " + projectId + " in " + branch);
- builds = Collections.emptyList();
- }
- else
- throw e;
- }
-
- return mergeByIdToHistoricalOrder(persistedValue, builds);
- });
+ List<BuildRef> buildRefs = loadBuildHistory(buildHistCache(), 60, cnt,
suiteInBranch,
+ (key) -> teamcity.getFinishedBuilds(projectId, branch, cnt));
if (cnt == null)
return buildRefs;
@@ -328,7 +364,9 @@ public class IgnitePersistentTeamcity implements
IAnalyticsEnabledTeamcity, ITea
}
@NotNull
- private List<BuildRef> mergeByIdToHistoricalOrder(List<BuildRef>
persistedVal, List<BuildRef> mostActualVal) {
+ @AutoProfiling
+ @SuppressWarnings("WeakerAccess")
+ protected List<BuildRef> mergeHistoryMaps(@Nullable List<BuildRef>
persistedVal, List<BuildRef> mostActualVal) {
final SortedMap<Integer, BuildRef> merge = new TreeMap<>();
if (persistedVal != null)
@@ -346,12 +384,8 @@ public class IgnitePersistentTeamcity implements
IAnalyticsEnabledTeamcity, ITea
@Override public List<BuildRef> getFinishedBuildsIncludeSnDepFailed(String
projectId, String branch, Long cnt) {
final SuiteInBranch suiteInBranch = new SuiteInBranch(projectId,
branch);
- return timedLoadIfAbsentOrMerge(buildHistIncFailedCache(), 60, cnt,
suiteInBranch,
- (key, persistedValue) -> {
- List<BuildRef> failed =
teamcity.getFinishedBuildsIncludeSnDepFailed(projectId, branch, cnt);
-
- return mergeByIdToHistoricalOrder(persistedValue, failed);
- });
+ return loadBuildHistory(buildHistIncFailedCache(), 60, cnt,
suiteInBranch,
+ (key) -> teamcity.getFinishedBuildsIncludeSnDepFailed(projectId,
branch, cnt));
}
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/hist/BuildRef.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/hist/BuildRef.java
index 2305fc7..845c591 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/hist/BuildRef.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/hist/BuildRef.java
@@ -20,6 +20,8 @@ package org.apache.ignite.ci.tcmodel.hist;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
+
+import com.google.common.base.Objects;
import org.apache.ignite.ci.tcmodel.result.AbstractRef;
/**
@@ -102,4 +104,25 @@ public class BuildRef extends AbstractRef {
public boolean isComposite() {
return composite != null && composite;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ BuildRef buildRef = (BuildRef) o;
+ return Objects.equal(id, buildRef.id) &&
+ Objects.equal(buildTypeId, buildRef.buildTypeId) &&
+ Objects.equal(branchName, buildRef.branchName) &&
+ Objects.equal(status, buildRef.status) &&
+ Objects.equal(state, buildRef.state) &&
+ Objects.equal(buildNumber, buildRef.buildNumber) &&
+ Objects.equal(defaultBranch, buildRef.defaultBranch) &&
+ Objects.equal(composite, buildRef.composite) &&
+ Objects.equal(webUrl, buildRef.webUrl);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, buildTypeId, branchName, status, state,
buildNumber, defaultBranch, composite, webUrl);
+ }
}
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
index 9416057..024b08e 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
@@ -22,7 +22,7 @@ package org.apache.ignite.ci.web.model;
public static final String DEFAULT_CONTACT = "[email protected]";
/** TC Helper Version. */
- public String version = "20180916";
+ public String version = "20180917";
/** Ignite version. */
public String ignVer;
diff --git
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
index 66e2487..82b202d 100644
---
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
+++
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
@@ -65,11 +65,13 @@ public class MonitoringService {
public List<String> getCacheStat() {
Ignite ignite = CtxListener.getInjector(ctx).getInstance(Ignite.class);
-
List<String> res = new ArrayList<>();
- for (Iterator<String> iterator = ignite.cacheNames().iterator();
iterator.hasNext(); ) {
- String next = iterator.next();
+ final Collection<String> strings = ignite.cacheNames();
+
+ final ArrayList<String> cacheNames = new ArrayList<>(strings);
+ cacheNames.sort(String::compareTo);
+ for (String next : cacheNames) {
IgniteCache<?, ?> cache = ignite.cache(next);
if (cache == null)
diff --git a/ignite-tc-helper-web/src/main/webapp/index.html
b/ignite-tc-helper-web/src/main/webapp/index.html
index 839496e..f1cefe4 100644
--- a/ignite-tc-helper-web/src/main/webapp/index.html
+++ b/ignite-tc-helper-web/src/main/webapp/index.html
@@ -139,8 +139,8 @@ TeamCity Run All: <br>
<div id="runAll"></div>
<br>
-<a href="ignval.html">Ignite Log Values pretty-print</a><br>
-
+<a href="ignval.html">Ignite Log Values pretty-print</a>
+<a href="monitoring.html">Bot moniroting page</a> <br>
<div id="loadStatus"></div>
<div id="version"></div>