Skip to content
Permalink
Browse files
IGNITE-11947: Fix for resending relatively fresh failures: removed di…
…rectly from DB
  • Loading branch information
dspavlov committed Jul 1, 2019
1 parent 8f69c4a commit a4433f36e6370b89a93c44c4ec083355d713514c
Showing 2 changed files with 53 additions and 4 deletions.
@@ -26,6 +26,7 @@
import java.io.UncheckedIOException;
import java.time.Duration;
import java.util.Iterator;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import javax.cache.Cache;
import javax.xml.bind.JAXBException;
@@ -34,6 +35,7 @@
import org.apache.ignite.Ignition;
import org.apache.ignite.ci.issue.Issue;
import org.apache.ignite.ci.issue.IssueKey;
import org.apache.ignite.ci.issue.IssueType;
import org.apache.ignite.ci.issue.IssuesStorage;
import org.apache.ignite.ci.tcbot.user.UserAndSessionsStorage;
import org.apache.ignite.ci.teamcity.ignited.BuildRefCompacted;
@@ -67,10 +69,60 @@ public class RemoteClientTmpHelper {
* @param args Args.
*/
public static void main(String[] args) {
// mainDumpIssues(args);
// mainDropInvalidIssues(args);
System.err.println("Please insert option of main");
}

public static void mainDropInvalidIssues(String[] args) {
try (Ignite ignite = tcbotServerConnectedClient()) {
IgniteCache<IssueKey, Issue> bst = ignite.cache(IssuesStorage.BOT_DETECTED_ISSUES);
Iterator<Cache.Entry<IssueKey, Issue>> iter = bst.iterator();
try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(dumpsDir(),
"Issues_dropped.txt")))) {
while (iter.hasNext()) {
Cache.Entry<IssueKey, Issue> next = iter.next();

boolean rmv = false;
Issue val = next.getValue();
if (val.type == null)
rmv = true;

//don't touch it
if (Objects.equals(val.type, IssueType.newContributedTestFailure.code()))
continue;

long ageDays = -1;
if (val != null && val.buildStartTs == null) {
if (val.detectedTs == null)
rmv = true;
else
ageDays = Duration.ofMillis(System.currentTimeMillis() - val.detectedTs).toDays();


rmv = true;
}

if(rmv) {
bst.remove(next.getKey());

String str = "Removing issue " + next.getKey() + " " + val.type + " detected " +
ageDays + " days ago\n";
writer.write(str);
System.err.println(str);
}
}

writer.flush();
}
catch (IOException e) {
throw new UncheckedIOException(e);
}

dumpDictionary(ignite);
}
}


public static void mainDumpIssues(String[] args) {
try (Ignite ignite = tcbotServerConnectedClient()) {
IgniteCache<IssueKey, Issue> bst = ignite.cache(IssuesStorage.BOT_DETECTED_ISSUES);
@@ -161,9 +161,6 @@ protected String sendNewNotificationsEx() {
long issueAgeMs = System.currentTimeMillis() - detected;

long bound = TimeUnit.HOURS.toMillis(2);
//temporary to issue missed notifications
if (issue.buildStartTs == null)
bound = TimeUnit.DAYS.toMillis(InvocationData.MAX_DAYS) / 2;

return issueAgeMs <= bound;
})

0 comments on commit a4433f3

Please sign in to comment.