Skip to content

Commit

Permalink
task-2619: Update Logging to SLF4j in datawave-core (#2685)
Browse files Browse the repository at this point in the history
* task-2619: Update Logging to SLF4J in datawave-core

* GitHub Actions: Fix Formatting

* task-2619: Update Logging to SLF4j in datawave-core, fix typos

---------

Co-authored-by: GitHub Actions <datawave@github.com>
  • Loading branch information
emiliodskinner and GitHub Actions authored Jan 16, 2025
1 parent f6fdf59 commit 4ade38a
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
Expand All @@ -25,7 +26,7 @@

public class CacheableQueryRowImpl extends CacheableQueryRow implements ObjectSizeOf {

private static Logger log = Logger.getLogger(CacheableQueryRowImpl.class);
private static Logger log = LoggerFactory.getLogger(CacheableQueryRowImpl.class);

private String user = null;
private String queryId = null;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void addColumn(String columnName, TypedValue columnTypedValue, Map<String
this.markings = markings;
}
} catch (MarkingFunctions.Exception e) {
log.error("Invalid markings " + markings + ", skipping column " + columnName + "=" + columnTypedValue, e);
log.error("Invalid markings {} skipping column {} = {}", markings, columnName, columnTypedValue, e);
return;
}
} else {
Expand All @@ -77,7 +78,7 @@ public void addColumn(String columnName, TypedValue columnTypedValue, Map<String
// use combined marking as new markings
this.markings = markingFunctions.translateFromColumnVisibility(combinedVisibility);
} catch (MarkingFunctions.Exception e) {
log.error("Invalid markings " + markings + ", skipping column " + columnName + "=" + columnTypedValue, e);
log.error("Invalid markings {} skipping column {} = {}", markings, columnName, columnTypedValue, e);
return;
}
}
Expand Down Expand Up @@ -294,7 +295,7 @@ public void setMarkings(Map<String,String> markings) {
markingFunctions.translateToColumnVisibility(markings);
this.markings = markings;
} catch (MarkingFunctions.Exception e) {
log.error("Invalid markings " + markings, e);
log.error("Invalid markings {}", markings, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import java.util.Set;
import java.util.TreeSet;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import datawave.marking.MarkingFunctions;
import datawave.webservice.query.cachedresults.CacheableQueryRow;
import datawave.webservice.query.result.event.ResponseObjectFactory;

public class CacheableQueryRowReader {

private static Logger log = Logger.getLogger(CacheableQueryRowReader.class);
private static Logger log = LoggerFactory.getLogger(CacheableQueryRowReader.class);

public static CacheableQueryRow createRow(ResultSet cachedRowSet, Set<String> fixedFieldsInEvent, ResponseObjectFactory responseObjectFactory,
MarkingFunctions markingFunctions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import org.apache.curator.framework.recipes.shared.SharedCountListener;
import org.apache.curator.framework.recipes.shared.SharedCountReader;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

Expand All @@ -28,7 +29,7 @@
* Object that caches data from Accumulo tables.
*/
public class AccumuloTableCacheImpl implements AccumuloTableCache {
private final Logger log = Logger.getLogger(this.getClass());
private final Logger log = LoggerFactory.getLogger(this.getClass());

private final ExecutorService executorService;
private final AccumuloTableCacheProperties accumuloTableCacheProperties;
Expand All @@ -38,7 +39,7 @@ public class AccumuloTableCacheImpl implements AccumuloTableCache {
private boolean connectionFactoryProvided = false;

public AccumuloTableCacheImpl(ExecutorService executorService, AccumuloTableCacheProperties accumuloTableCacheProperties) {
log.debug("Called AccumuloTableCacheImpl with accumuloTableCacheConfiguration = " + accumuloTableCacheProperties);
log.debug("Called AccumuloTableCacheImpl with accumuloTableCacheConfiguration = {}", accumuloTableCacheProperties);
this.executorService = executorService;
this.accumuloTableCacheProperties = accumuloTableCacheProperties;
setup();
Expand All @@ -55,7 +56,7 @@ private static ExecutorService getThreadPoolExecutor(AccumuloTableCachePropertie
}

public void setup() {
log.debug("accumuloTableCacheConfiguration was setup as: " + accumuloTableCacheProperties);
log.debug("accumuloTableCacheConfiguration was setup as: {}", accumuloTableCacheProperties);
instance = new InMemoryInstance();
details = new HashMap<>();
cacheCoordinators = new ArrayList<>();
Expand Down Expand Up @@ -85,19 +86,19 @@ public void setup() {
@Override
public void stateHasChanged(SharedTriStateReader reader, SharedTriState.STATE value) throws Exception {
if (log.isTraceEnabled()) {
log.trace("table:" + tableName + " stateHasChanged(" + reader + ", " + value + "). This listener does nothing");
log.trace("table: {} stateHasChanged( {}, {} ). This listener does nothing", tableName, reader, value);
}
}

@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if (log.isTraceEnabled()) {
log.trace("table:" + tableName + " stateChanged(" + client + ", " + newState + "). This listener does nothing");
log.trace("table: {} stateChanged( {}, {} ). This listener does nothing", tableName, client, newState);
}
}
});
} catch (Exception e) {
log.debug("Failure registering a triState for " + tableName, e);
log.debug("Failure registering a triState for {}", tableName, e);
}

try {
Expand Down Expand Up @@ -146,7 +147,7 @@ public void submitReloadTasks() {
for (Entry<String,TableCache> entry : details.entrySet()) {
Future<Boolean> ref = entry.getValue().getReference();
if (null != ref && (ref.isCancelled() || ref.isDone())) {
log.info("Reloading complete for table: " + entry.getKey());
log.info("Reloading complete for table: {}", entry.getKey());
entry.getValue().setReference(null);
}

Expand All @@ -159,12 +160,12 @@ public void submitReloadTasks() {
}
long last = entry.getValue().getLastRefresh().getTime();
if ((now - last) > entry.getValue().getReloadInterval()) {
log.info("Reloading " + entry.getKey());
log.info("Reloading {}", entry.getKey());
try {
Future<Boolean> result = executorService.submit(entry.getValue());
entry.getValue().setReference(result);
} catch (Exception e) {
log.error("Error reloading table: " + entry.getKey(), e);
log.error("Error reloading table: {}", entry.getKey(), e);
}
}
}
Expand Down Expand Up @@ -193,7 +194,7 @@ public void reloadTableCache(String tableName) {
if (null == details.get(tableName)) {
return;
}
log.debug("Reloading table cache for " + tableName);
log.debug("Reloading table cache for {}", tableName);
// send an eviction notice to the cluster
try {
details.get(tableName).getWatcher().incrementCounter(tableName);
Expand All @@ -207,13 +208,13 @@ public void reloadTableCache(String tableName) {
private void handleReloadTypeMetadata(String tableName) {
String triStateName = tableName + ":needsUpdate";
try {
log.debug(triStateName + " handleReloadTypeMetadata(" + tableName + ")");
log.debug("{} handleReloadTypeMetadata( {} )", triStateName, tableName);
SharedCacheCoordinator watcher = details.get(tableName).getWatcher();
if (!watcher.checkTriState(triStateName, SharedTriState.STATE.NEEDS_UPDATE)) {
watcher.setTriState(triStateName, SharedTriState.STATE.NEEDS_UPDATE);
}
} catch (Throwable e) {
log.debug("table:" + tableName + " could not update the triState '" + triStateName + " on watcher for table " + tableName, e);
log.debug("table: {} could not update the triState {} on watcher for table {}", tableName, triStateName, tableName, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import org.apache.accumulo.core.iterators.user.RegExFilter;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;

Expand All @@ -40,7 +41,7 @@ public class BaseTableCache implements Serializable, TableCache {

private static final long serialVersionUID = 1L;

private final transient Logger log = Logger.getLogger(this.getClass());
private final transient Logger log = LoggerFactory.getLogger(this.getClass());

/** should be set by configuration **/
private String tableName = null;
Expand Down Expand Up @@ -221,7 +222,7 @@ public Boolean call() throws Exception {
// the table will not exist the first time this is run
}
instanceClient.tableOperations().rename(tempTableName, tableName);
log.info("Cached " + count + " k,v for table: " + tableName);
log.info("Cached {} k,v for table: {}", count, tableName);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
Expand All @@ -238,7 +239,7 @@ public Boolean call() throws Exception {
if (null != writer)
writer.close();
} catch (Exception e) {
log.warn("Error closing batch writer for table: " + tempTableName, e);
log.warn("Error closing batch writer for table: {}", tempTableName, e);
}
lock.unlock();
}
Expand Down Expand Up @@ -269,7 +270,7 @@ private void createNamespaceIfNecessary(NamespaceOperations namespaceOperations,
}
} catch (NamespaceExistsException e) {
// in this case, somebody else must have created the namespace after our existence check
log.info("Tried to create Accumulo namespace," + namespace + ", but it already exists");
log.info("Tried to create Accumulo namespace, {}, but it already exists", namespace);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import org.apache.curator.framework.recipes.shared.SharedValueListener;
import org.apache.curator.framework.recipes.shared.SharedValueReader;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Maps;
import com.google.common.util.concurrent.MoreExecutors;
Expand All @@ -28,7 +29,7 @@
*/
public class SharedBoolean implements Closeable, SharedBooleanReader, Listenable<SharedBooleanListener> {

private static Logger log = Logger.getLogger(SharedBoolean.class);
private static Logger log = LoggerFactory.getLogger(SharedBoolean.class);

private final Map<SharedBooleanListener,SharedValueListener> listeners = Maps.newConcurrentMap();
private final SharedValue sharedValue;
Expand All @@ -39,19 +40,19 @@ public SharedBoolean(CuratorFramework client, String path, boolean seedValue) {

public boolean getBoolean() {
if (log.isDebugEnabled()) {
log.debug("in getBoolean, sharedValue has " + Arrays.toString(sharedValue.getValue()));
log.debug("in getBoolean, sharedValue has {}", Arrays.toString(sharedValue.getValue()));
}
return fromBytes(this.sharedValue.getValue());
}

public void setBoolean(boolean newBoolean) throws Exception {
this.sharedValue.setValue(toBytes(newBoolean));
log.debug("someone setBoolean to " + newBoolean);
log.debug("someone setBoolean to {}", newBoolean);
}

public boolean trySetBoolean(boolean newBoolean) throws Exception {
if (log.isDebugEnabled()) {
log.debug("tryToSetBoolean(" + newBoolean + ")");
log.debug("tryToSetBoolean( {} )", newBoolean);
}
return this.sharedValue.trySetValue(toBytes(newBoolean));
}
Expand All @@ -64,7 +65,7 @@ public void addListener(final SharedBooleanListener listener, Executor executor)
SharedValueListener valueListener = new SharedValueListener() {
public void valueHasChanged(SharedValueReader sharedValue, byte[] newValue) throws Exception {
if (log.isDebugEnabled()) {
log.debug("valueHasChanged in " + Arrays.toString(sharedValue.getValue()) + " to " + Arrays.toString(newValue));
log.debug("valueHasChanged in {} to {}", Arrays.toString(sharedValue.getValue()), Arrays.toString(newValue));
}

listener.booleanHasChanged(SharedBoolean.this, SharedBoolean.fromBytes(newValue));
Expand Down Expand Up @@ -96,8 +97,8 @@ private static byte[] toBytes(boolean value) {

private static boolean fromBytes(byte[] bytes) {
if (log.isDebugEnabled()) {
log.debug("fromBytes(" + Arrays.toString(bytes) + ") and bytes.length > 0 && bytes[0] == (byte) 1 returning:"
+ (bytes.length > 0 && bytes[0] == (byte) 1));
log.debug("fromBytes( {} ) and bytes.length > 0 && bytes[0] == (byte) 1 returning: {}", Arrays.toString(bytes),
(bytes.length > 0 && bytes[0] == (byte) 1));
}
return bytes.length > 0 && bytes[0] == (byte) 1;
}
Expand Down
Loading

0 comments on commit 4ade38a

Please sign in to comment.