forked from Qortal/qortal
Reduce build queue log spam by only logging high priority items (5 and above).
This commit is contained in:
parent
49b307db60
commit
a6aabaa7f0
@ -1,5 +1,7 @@
|
|||||||
package org.qortal.arbitrary;
|
package org.qortal.arbitrary;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.qortal.arbitrary.exception.MissingDataException;
|
import org.qortal.arbitrary.exception.MissingDataException;
|
||||||
import org.qortal.arbitrary.ArbitraryDataFile.*;
|
import org.qortal.arbitrary.ArbitraryDataFile.*;
|
||||||
import org.qortal.arbitrary.misc.Service;
|
import org.qortal.arbitrary.misc.Service;
|
||||||
@ -10,12 +12,16 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class ArbitraryDataBuildQueueItem extends ArbitraryDataResource {
|
public class ArbitraryDataBuildQueueItem extends ArbitraryDataResource {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(ArbitraryDataBuildQueueItem.class);
|
||||||
|
|
||||||
private final Long creationTimestamp;
|
private final Long creationTimestamp;
|
||||||
private Long buildStartTimestamp = null;
|
private Long buildStartTimestamp = null;
|
||||||
private Long buildEndTimestamp = null;
|
private Long buildEndTimestamp = null;
|
||||||
private Integer priority = 0;
|
private Integer priority = 0;
|
||||||
private boolean failed = false;
|
private boolean failed = false;
|
||||||
|
|
||||||
|
private static int HIGH_PRIORITY_THRESHOLD = 5;
|
||||||
|
|
||||||
/* The maximum amount of time to spend on a single build */
|
/* The maximum amount of time to spend on a single build */
|
||||||
// TODO: interrupt an in-progress build
|
// TODO: interrupt an in-progress build
|
||||||
public static long BUILD_TIMEOUT = 60*1000L; // 60 seconds
|
public static long BUILD_TIMEOUT = 60*1000L; // 60 seconds
|
||||||
@ -89,6 +95,19 @@ public class ArbitraryDataBuildQueueItem extends ArbitraryDataResource {
|
|||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHighPriority() {
|
||||||
|
return this.priority >= HIGH_PRIORITY_THRESHOLD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(String message) {
|
||||||
|
if (this.isHighPriority()) {
|
||||||
|
LOGGER.info(message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOGGER.debug(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setFailed(boolean failed) {
|
public void setFailed(boolean failed) {
|
||||||
this.failed = failed;
|
this.failed = failed;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.qortal.controller.arbitrary;
|
package org.qortal.controller.arbitrary;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.qortal.arbitrary.ArbitraryDataBuildQueueItem;
|
import org.qortal.arbitrary.ArbitraryDataBuildQueueItem;
|
||||||
import org.qortal.utils.NTP;
|
import org.qortal.utils.NTP;
|
||||||
|
|
||||||
@ -13,8 +11,6 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
public class ArbitraryDataBuildManager extends Thread {
|
public class ArbitraryDataBuildManager extends Thread {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(ArbitraryDataBuildManager.class);
|
|
||||||
|
|
||||||
private static ArbitraryDataBuildManager instance;
|
private static ArbitraryDataBuildManager instance;
|
||||||
|
|
||||||
private volatile boolean isStopping = false;
|
private volatile boolean isStopping = false;
|
||||||
@ -106,7 +102,7 @@ public class ArbitraryDataBuildManager extends Thread {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info("Added {} to build queue", queueItem);
|
queueItem.log(String.format("Added %s to build queue", queueItem));
|
||||||
|
|
||||||
// Added to queue
|
// Added to queue
|
||||||
return true;
|
return true;
|
||||||
@ -154,7 +150,7 @@ public class ArbitraryDataBuildManager extends Thread {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info("Added {} to failed builds list", queueItem);
|
queueItem.log(String.format("Added %s to failed builds list", queueItem));
|
||||||
|
|
||||||
// Added to queue
|
// Added to queue
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.qortal.controller.arbitrary;
|
package org.qortal.controller.arbitrary;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.qortal.arbitrary.ArbitraryDataBuildQueueItem;
|
import org.qortal.arbitrary.ArbitraryDataBuildQueueItem;
|
||||||
import org.qortal.arbitrary.exception.MissingDataException;
|
import org.qortal.arbitrary.exception.MissingDataException;
|
||||||
import org.qortal.controller.Controller;
|
import org.qortal.controller.Controller;
|
||||||
@ -15,8 +13,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ArbitraryDataBuilderThread implements Runnable {
|
public class ArbitraryDataBuilderThread implements Runnable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(ArbitraryDataBuilderThread.class);
|
|
||||||
|
|
||||||
public ArbitraryDataBuilderThread() {
|
public ArbitraryDataBuilderThread() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -75,19 +71,19 @@ public class ArbitraryDataBuilderThread implements Runnable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Perform the build
|
// Perform the build
|
||||||
LOGGER.info("Building {}...", queueItem);
|
queueItem.log(String.format("Building %s... priority: %d", queueItem, queueItem.getPriority()));
|
||||||
queueItem.build();
|
queueItem.build();
|
||||||
this.removeFromQueue(queueItem);
|
this.removeFromQueue(queueItem);
|
||||||
LOGGER.info("Finished building {}", queueItem);
|
queueItem.log(String.format("Finished building %s", queueItem));
|
||||||
|
|
||||||
} catch (MissingDataException e) {
|
} catch (MissingDataException e) {
|
||||||
LOGGER.info("Missing data for {}: {}", queueItem, e.getMessage());
|
queueItem.log(String.format("Missing data for %s: %s", queueItem, e.getMessage()));
|
||||||
queueItem.setFailed(true);
|
queueItem.setFailed(true);
|
||||||
this.removeFromQueue(queueItem);
|
this.removeFromQueue(queueItem);
|
||||||
// Don't add to the failed builds list, as we may want to retry sooner
|
// Don't add to the failed builds list, as we may want to retry sooner
|
||||||
|
|
||||||
} catch (IOException | DataException | RuntimeException e) {
|
} catch (IOException | DataException | RuntimeException e) {
|
||||||
LOGGER.info("Error building {}: {}", queueItem, e.getMessage());
|
queueItem.log(String.format("Error building %s: %s", queueItem, e.getMessage()));
|
||||||
// Something went wrong - so remove it from the queue, and add to failed builds list
|
// Something went wrong - so remove it from the queue, and add to failed builds list
|
||||||
queueItem.setFailed(true);
|
queueItem.setFailed(true);
|
||||||
buildManager.addToFailedBuildsList(queueItem);
|
buildManager.addToFailedBuildsList(queueItem);
|
||||||
|
Loading…
Reference in New Issue
Block a user