Skip to content
Permalink
Browse files
Fix of too-short history
  • Loading branch information
dspavlov committed Jun 26, 2019
1 parent 47f23e7 commit be469c905a8607f3a2d550f095afdf47ee1d5d9e
Showing 4 changed files with 69 additions and 2 deletions.
@@ -24,6 +24,8 @@
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.time.Duration;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
import javax.cache.Cache;
import javax.xml.bind.JAXBException;
@@ -62,9 +64,67 @@ public class RemoteClientTmpHelper {
* @param args Args.
*/
public static void main(String[] args) {
// mainDumpFatBuildStartTime(args);
System.err.println("Please insert option of main");
}


public static void mainDumpFatBuildStartTime(String[] args) {
try (Ignite ignite = tcbotServerConnectedClient()) {
IgniteCache<Long, FatBuildCompacted> bst = ignite.cache(FatBuildDao.TEAMCITY_FAT_BUILD_CACHE_NAME);
Iterator<Cache.Entry<Long, FatBuildCompacted>> iterator = bst.iterator();
try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(dumpsDir(),
"fatBuildStartTime.txt")))) {
while (iterator.hasNext()) {
Cache.Entry<Long, FatBuildCompacted> next = iterator.next();

FatBuildCompacted val = next.getValue();
long ageDays = -1;
long startDateTs = -2;

if (val != null) {
startDateTs = val.getStartDateTs();
ageDays = Duration.ofMillis(System.currentTimeMillis() - startDateTs).toDays();
}

writer.write(next.getKey() + " " + startDateTs + " " +
ageDays + "\n");
}

}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}


public static void mainDumpBuildStartTime(String[] args) {
try (Ignite ignite = tcbotServerConnectedClient()) {
IgniteCache<Long, Long> bst = ignite.cache(BUILD_START_TIME_CACHE_NAME);
Iterator<Cache.Entry<Long, Long>> iterator = bst.iterator();
try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(dumpsDir(),
"BuildStartTime.txt")))) {
while (iterator.hasNext()) {
Cache.Entry<Long, Long> next = iterator.next();

Long val = next.getValue();
long ageDays = -1;
if(val!=null)
ageDays = Duration.ofMillis(System.currentTimeMillis() - val).toDays();

writer.write(next.getKey() + " " + val + " " +
ageDays +"\n");
}

}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}


/**
* @param args Args.
*/
@@ -28,7 +28,7 @@
public static final String GITHUB_REF = "https://github.com/apache/ignite-teamcity-bot";

/** TC Bot Version. */
public static final String VERSION = "20190621";
public static final String VERSION = "20190626";

/** Java version, where Web App is running. */
public String javaVer;
@@ -239,7 +239,12 @@ public GetStartTimeProc() {

BinaryObject buildBinary = entry.getValue();

return buildBinary.field("startDate");
Long startDate = buildBinary.field("startDate");

if (startDate == null || startDate <= 0)
return null;

return startDate;
}
}
}
@@ -200,11 +200,13 @@ protected Set<Integer> determineLatestBuilds(
return buildInScope;
}

@SuppressWarnings("WeakerAccess")
@AutoProfiling
protected Map<Integer, Long> getStartTimeFromSpecialCache(int srvId, Set<Integer> buildIds) {
return runHistCompactedDao.getBuildsStartTime(srvId, buildIds);
}

@SuppressWarnings("WeakerAccess")
@AutoProfiling
protected Map<Integer, Long> getStartTimeFromFatBuild(int srvId, Set<Integer> buildIds) {
return fatBuildDao.getBuildStartTime(srvId, buildIds);

0 comments on commit be469c9

Please sign in to comment.