提交 7f3096c5 编写于 作者: J Jesse Glick

Deferring formatting Logger messages unless and until the log formatter is run.

No need to call isLoggable if you are only calling simply getters and relying on toString later.
上级 fd31a5d8
...@@ -516,7 +516,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -516,7 +516,7 @@ public class Queue extends ResourceController implements Saveable {
} }
} }
if (duplicatesInQueue.isEmpty()) { if (duplicatesInQueue.isEmpty()) {
LOGGER.fine(p.getFullDisplayName() + " added to queue"); LOGGER.log(Level.FINE, "{0} added to queue", p);
// put the item in the queue // put the item in the queue
WaitingItem added = new WaitingItem(due,p,actions); WaitingItem added = new WaitingItem(due,p,actions);
...@@ -525,7 +525,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -525,7 +525,7 @@ public class Queue extends ResourceController implements Saveable {
return added; return added;
} }
LOGGER.fine(p.getFullDisplayName() + " is already in the queue"); LOGGER.log(Level.FINE, "{0} is already in the queue", p);
// but let the actions affect the existing stuff. // but let the actions affect the existing stuff.
for(Item item : duplicatesInQueue) { for(Item item : duplicatesInQueue) {
...@@ -593,7 +593,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -593,7 +593,7 @@ public class Queue extends ResourceController implements Saveable {
* false if this was no-op. * false if this was no-op.
*/ */
public synchronized boolean cancel(Task p) { public synchronized boolean cancel(Task p) {
LOGGER.fine("Cancelling " + p.getFullDisplayName()); LOGGER.log(Level.FINE, "Cancelling {0}", p);
for (Iterator<WaitingItem> itr = waitingList.iterator(); itr.hasNext();) { for (Iterator<WaitingItem> itr = waitingList.iterator(); itr.hasNext();) {
Item item = itr.next(); Item item = itr.next();
if (item.task.equals(p)) { if (item.task.equals(p)) {
...@@ -607,7 +607,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -607,7 +607,7 @@ public class Queue extends ResourceController implements Saveable {
} }
public synchronized boolean cancel(Item item) { public synchronized boolean cancel(Item item) {
LOGGER.fine("Cancelling " + item.task.getFullDisplayName() + " item#" + item.id); LOGGER.log(Level.FINE, "Cancelling {0} item#{1}", new Object[] {item.task, item.id});
// use bitwise-OR to make sure that all the branches get evaluated all the time // use bitwise-OR to make sure that all the branches get evaluated all the time
boolean r = (item instanceof WaitingItem && waitingList.remove(item)) | blockedProjects.remove(item) | buildables.remove(item); boolean r = (item instanceof WaitingItem && waitingList.remove(item)) | blockedProjects.remove(item) | buildables.remove(item);
if(r) if(r)
...@@ -890,7 +890,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -890,7 +890,7 @@ public class Queue extends ResourceController implements Saveable {
// am I woken up because I have a project to build? // am I woken up because I have a project to build?
if (offer.workUnit != null) { if (offer.workUnit != null) {
// if so, just build it // if so, just build it
LOGGER.fine("Pop returning " + offer.workUnit + " for " + exec.getName()); LOGGER.log(Level.FINE, "Pop returning {0} for {1}", new Object[] {offer.workUnit, exec.getName()});
// TODO: I think this has to be done by the last executor that leaves the pop(), not by main executor // TODO: I think this has to be done by the last executor that leaves the pop(), not by main executor
if (offer.workUnit.isMainWork()) if (offer.workUnit.isMainWork())
...@@ -979,8 +979,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -979,8 +979,7 @@ public class Queue extends ResourceController implements Saveable {
* and it also gets invoked periodically (see {@link MaintainTask}.) * and it also gets invoked periodically (see {@link MaintainTask}.)
*/ */
public synchronized void maintain() { public synchronized void maintain() {
if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, "Queue maintenance started {0}", this);
LOGGER.fine("Queue maintenance started " + this);
{// blocked -> buildable {// blocked -> buildable
Iterator<BlockedItem> itr = blockedProjects.values().iterator(); Iterator<BlockedItem> itr = blockedProjects.values().iterator();
...@@ -988,7 +987,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -988,7 +987,7 @@ public class Queue extends ResourceController implements Saveable {
BlockedItem p = itr.next(); BlockedItem p = itr.next();
if (!isBuildBlocked(p) && allowNewBuildableTask(p.task)) { if (!isBuildBlocked(p) && allowNewBuildableTask(p.task)) {
// ready to be executed // ready to be executed
LOGGER.fine(p.task.getFullDisplayName() + " no longer blocked"); LOGGER.log(Level.FINE, "{0} no longer blocked", p.task);
itr.remove(); itr.remove();
makeBuildable(new BuildableItem(p)); makeBuildable(new BuildableItem(p));
} }
...@@ -1006,12 +1005,12 @@ public class Queue extends ResourceController implements Saveable { ...@@ -1006,12 +1005,12 @@ public class Queue extends ResourceController implements Saveable {
Task p = top.task; Task p = top.task;
if (!isBuildBlocked(top) && allowNewBuildableTask(p)) { if (!isBuildBlocked(top) && allowNewBuildableTask(p)) {
// ready to be executed immediately // ready to be executed immediately
LOGGER.fine(p.getFullDisplayName() + " ready to build"); LOGGER.log(Level.FINE, "{0} ready to build", p);
makeBuildable(new BuildableItem(top)); makeBuildable(new BuildableItem(top));
} else { } else {
// this can't be built now because another build is in progress // this can't be built now because another build is in progress
// set this project aside. // set this project aside.
LOGGER.fine(p.getFullDisplayName() + " is blocked"); LOGGER.log(Level.FINE, "{0} is blocked", p);
blockedProjects.put(p,new BlockedItem(top)); blockedProjects.put(p,new BlockedItem(top));
} }
} }
...@@ -1029,7 +1028,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -1029,7 +1028,7 @@ public class Queue extends ResourceController implements Saveable {
if (isBuildBlocked(p)) { if (isBuildBlocked(p)) {
itr.remove(); itr.remove();
blockedProjects.put(p.task,new BlockedItem(p)); blockedProjects.put(p.task,new BlockedItem(p));
LOGGER.fine(String.format("Catching that %s is blocked in the last minute", p)); LOGGER.log(Level.FINE, "Catching that {0} is blocked in the last minute", p);
continue; continue;
} }
...@@ -1044,10 +1043,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -1044,10 +1043,7 @@ public class Queue extends ResourceController implements Saveable {
// if we couldn't find the executor that fits, // if we couldn't find the executor that fits,
// just leave it in the buildables list and // just leave it in the buildables list and
// check if we can execute other projects // check if we can execute other projects
if (LOGGER.isLoggable(Level.FINER)) { LOGGER.log(Level.FINER, "Failed to map {0} to executors. candidates={1} parked={2}", new Object[] {p, candidates, parked.values()});
LOGGER.finer(String.format("Failed to map %s to executors. candidates=%s parked=%s",
p, candidates, parked.values()));
}
continue; continue;
} }
...@@ -1059,7 +1055,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -1059,7 +1055,7 @@ public class Queue extends ResourceController implements Saveable {
if (!wuc.getWorkUnits().isEmpty()) if (!wuc.getWorkUnits().isEmpty())
makePending(p); makePending(p);
else else
LOGGER.fine(String.format("BuildableItem %s with empty work units!?",p)); LOGGER.log(Level.FINE, "BuildableItem {0} with empty work units!?", p);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册