Skip to content

Commit

Permalink
Less verbose logging
Browse files Browse the repository at this point in the history
Update logging level to be less verbose when run in production
which will ease the number of writes to disk.

Borrowed from OpenDev pending change.

Closes-Bug: #1290273
Change-Id: I8d873cf103e395f3ed1b41415c946dd6990ba9e0
  • Loading branch information
zaro0508 authored and hashar committed May 11, 2021
1 parent 30dd5de commit da9af33
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions src/main/java/hudson/plugins/gearman/AbstractWorkerThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void setAvailability(AvailabilityMonitor availability) {
*/
public void registerJobs() {

logger.info("---- AbstractorWorker registerJobs function ----");
logger.debug("---- AbstractorWorker registerJobs function ----");

}

Expand All @@ -134,20 +134,20 @@ public void start() {
public void stop() {

logger.info("---- " + getName() + " Request to stop AWT: " + this);
logger.info("---- " + getName() + " Thread: " + thread + " name: " + thread.getName());
logger.info("---- " + getName() + " Worker: " + worker);
logger.debug("---- " + getName() + " Thread: " + thread + " name: " + thread.getName());
logger.debug("---- " + getName() + " Worker: " + worker);
synchronized(this) {
running = false;
if (worker != null) {
worker.stop();
}
}

logger.info("---- " + getName() + " Interrupting worker");
logger.debug("---- " + getName() + " Interrupting worker");
// Interrupt the thread so it unblocks any blocking call
thread.interrupt();

logger.info("---- " + getName() + " Stop request done");
logger.debug("---- " + getName() + " Stop request done");
}

/*
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ComputerListenerImpl extends ComputerListener {
public void onConfigurationChange() {
// only fired on nodes configuration changes like a label or
// name change. Not fired on state changes, like offline or online.
logger.info("---- " + ComputerListenerImpl.class.getName() + ":"
logger.debug("---- " + ComputerListenerImpl.class.getName() + ":"
+ " onConfigurationChange");

// update functions only when gearman-plugin is enabled
Expand All @@ -61,7 +61,7 @@ public void onConfigurationChange() {
public void onOffline(Computer c) {
// gets called when existing slave dis-connects
// gets called when slave is deleted.
logger.info("---- " + ComputerListenerImpl.class.getName() + ":"
logger.debug("---- " + ComputerListenerImpl.class.getName() + ":"
+ " onOffline computer" + c);

// update functions only when gearman-plugin is enabled
Expand All @@ -79,7 +79,7 @@ public void onOnline(Computer c, TaskListener listener) throws IOException,
// gets called when master goes into online state
// gets called when existing slave re-connects
// gets called when new slave goes into online state
logger.info("---- " + ComputerListenerImpl.class.getName() + ":"
logger.debug("---- " + ComputerListenerImpl.class.getName() + ":"
+ " onOnline computer " + c);

// update functions only when gearman-plugin is enabled
Expand All @@ -102,7 +102,7 @@ public void onOnline(Computer c, TaskListener listener) throws IOException,
@Override
public void onTemporarilyOffline(Computer c, OfflineCause cause) {
// fired when master or slave goes into temporary offline state
logger.info("---- " + ComputerListenerImpl.class.getName() + ":"
logger.debug("---- " + ComputerListenerImpl.class.getName() + ":"
+ " onTemporarilyOffline computer " + c);
// update functions only when gearman-plugin is enabled
if (!GearmanPluginConfig.get().isEnablePlugin()) {
Expand All @@ -116,7 +116,7 @@ public void onTemporarilyOffline(Computer c, OfflineCause cause) {
@Override
public void onTemporarilyOnline(Computer c) {
// fired when master or slave goes into temporary online state
logger.info("---- " + ComputerListenerImpl.class.getName() + ":"
logger.debug("---- " + ComputerListenerImpl.class.getName() + ":"
+ " onTemporarilyOnline computer " + c);
// update functions only when gearman-plugin is enabled
if (!GearmanPluginConfig.get().isEnablePlugin()) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,17 @@ private boolean connectionIsAvailable(String host, int port,
} else {
try {
socket.connect(endPoint, timeout);
logger.info("Connection Success: " + endPoint);
logger.debug("Connection Success: " + endPoint);
return true;
} catch (Exception e) {
logger.info("Connection Failure: " + endPoint + " message: "
logger.warn("Connection Failure: " + endPoint + " message: "
+ e.getClass().getSimpleName() + " - " + e.getMessage());
} finally {
if (socket != null) {
try {
socket.close();
} catch (Exception e) {
logger.info(e.getMessage());
logger.warn(e.getMessage());
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/hudson/plugins/gearman/GearmanProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void initWorkers() {
} catch (NullPointerException npe) {
logger.info("---- Master is offline");
} catch (Exception e) {
logger.error("Exception while finding master", e);
logger.warn("Exception while finding master", e);
}

if (masterNode != null) {
Expand All @@ -147,7 +147,7 @@ public void initWorkers() {
}
}

logger.info("---- Num of executors running = " + getNumExecutors());
logger.debug("---- Num of executors running = " + getNumExecutors());
}

/*
Expand All @@ -171,7 +171,7 @@ public void createManagementWorker() {
gwt.start();
}

logger.info("---- Num of executors running = " + getNumExecutors());
logger.debug("---- Num of executors running = " + getNumExecutors());
}

/*
Expand All @@ -183,7 +183,7 @@ public void createExecutorWorkersOnNode(Computer computer) {
synchronized(gewtHandles) {
for (ExecutorWorkerThread t : gewtHandles) {
if (t.getComputer() == computer) {
logger.info("---- Executor thread already running for " + computer.getName());
logger.debug("---- Executor thread already running for " + computer.getName());
return;
}
}
Expand All @@ -210,7 +210,7 @@ public void createExecutorWorkersOnNode(Computer computer) {
}
}

logger.info("---- Num of executors running = " + getNumExecutors());
logger.debug("---- Num of executors running = " + getNumExecutors());

}

Expand Down Expand Up @@ -239,7 +239,7 @@ public void stopAll() {
wt.stop();
}

logger.info("---- Num of executors running = " + getNumExecutors());
logger.debug("---- Num of executors running = " + getNumExecutors());
}

/*
Expand Down Expand Up @@ -270,7 +270,7 @@ public void stop(Computer computer) {
t.stop();
}

logger.info("---- Num of executors running = " + getNumExecutors());
logger.debug("---- Num of executors running = " + getNumExecutors());
}

/*
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/hudson/plugins/gearman/MyGearmanWorkerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public synchronized void setUpdated(boolean updated) {
}

public void reconnect() {
LOG.info("---- Worker " + this + " starting reconnect for " + session.toString());
LOG.debug("---- Worker " + this + " starting reconnect for " + session.toString());
// In case we held the availability lock earlier, release it.
availability.unlock(this);
try {
Expand All @@ -178,7 +178,7 @@ public void reconnect() {
return;
}
}
LOG.info("---- Worker " + this + " ending reconnect for " + session.toString());
LOG.debug("---- Worker " + this + " ending reconnect for " + session.toString());
}

public MyGearmanWorkerImpl(AvailabilityMonitor availability) {
Expand Down Expand Up @@ -208,7 +208,7 @@ public String toString() {
}

public void setFunctions(Set<GearmanFunctionFactory> functions) {
LOG.info("---- Worker " + this + " registering " + functions.size() + " functions");
LOG.debug("---- Worker " + this + " registering " + functions.size() + " functions");
functionRegistry.setFunctions(functions);
ioAvailable.wakeup();
}
Expand Down Expand Up @@ -317,7 +317,7 @@ public void enqueueNoopEvent() {
public void work() {
GearmanSessionEvent event = null;
GearmanFunction function = null;
LOG.info("---- Worker " + this + " starting work");
LOG.debug("---- Worker " + this + " starting work");

if (!state.equals(State.IDLE)) {
throw new IllegalStateException("Can not call work while worker " +
Expand Down Expand Up @@ -360,7 +360,7 @@ public void work() {
// For the time being we will execute the jobs synchronously
// in the future, I expect to change this.
if (function != null) {
LOG.info("---- Worker " + this + " executing function");
LOG.debug("---- Worker " + this + " executing function");
submitFunction(function);
// Send another grab_job on the next loop
enqueueNoopEvent();
Expand Down Expand Up @@ -445,11 +445,11 @@ private GearmanFunction processSessionEvent(GearmanSessionEvent event)
switch (t) {
case JOB_ASSIGN:
//TODO Figure out what the right behavior is if JobUUIDRequired was false when we submitted but is now true
LOG.info("---- Worker " + this + " received job assignment");
LOG.debug("---- Worker " + this + " received job assignment");
return addNewJob(event);
case JOB_ASSIGN_UNIQ:
//TODO Figure out what the right behavior is if JobUUIDRequired was true when we submitted but is now false
LOG.info("---- Worker " + this + " received unique job assignment");
LOG.debug("---- Worker " + this + " received unique job assignment");
return addNewJob(event);
case NOOP:
LOG.debug("---- Worker " + this + " sending grab job after wakeup");
Expand Down Expand Up @@ -505,7 +505,7 @@ public boolean addServer(GearmanJobServerConnection conn)

reconnect();

LOG.debug("---- Worker " + this + " added server " + conn);
LOG.info("---- Worker " + this + " added server " + conn);
return true;
}

Expand Down Expand Up @@ -591,7 +591,7 @@ private List<Exception> shutDownWorker(boolean completeTasks) {
LOG.warn("---- Worker " + this + " encountered IOException while closing selector: ", ioe);
}
state = State.IDLE;
LOG.info("---- Worker " + this + " completed shutdown");
LOG.debug("---- Worker " + this + " completed shutdown");

return exceptions;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/gearman/StartJobWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private GearmanJobResult safeExecuteFunction()
logger.error("---- Worker " + this.worker + " has no " +
"computer while trying to take node offline.");
} else {
logger.info("---- Worker " + this.worker + " setting " +
logger.debug("---- Worker " + this.worker + " setting " +
"node offline.");
computer.setTemporarilyOffline(true,
new OfflineCause.ByCLI("Offline due to Gearman request"));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/gearman/StopJobWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public GearmanJobResult executeFunction() {
// abort the running jenkins build
if (!executor.isInterrupted()) {
executor.interrupt();
logger.info("---- Aborting build : " +
logger.debug("---- Aborting build : " +
jobName + ": " + buildNumber);
jobResult = true;
}
} else {
logger.info("---- Request to abourt non-building build : " +
logger.debug("---- Request to abort non-building build : " +
jobName + ": " + buildNumber);
}
} else {
Expand Down

0 comments on commit da9af33

Please sign in to comment.