Skip to content

Commit

Permalink
Removed ThreadConfigurableLogger class for upcoming SLF4J change
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Thomas jjthom3 committed Oct 25, 2024
1 parent 9b0617e commit e0e3715
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 37 deletions.
8 changes: 4 additions & 4 deletions core/common-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<groupId>gov.nsa.datawave.microservice</groupId>
<artifactId>authorization-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
Expand All @@ -37,10 +41,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ protected Set<String> loadExpansionFields(ShardQueryConfiguration config) {
return metadataHelper.getExpansionFields(config.getDatatypeFilter());
} catch (TableNotFoundException e) {
QueryException qe = new QueryException(DatawaveErrorCode.METADATA_ACCESS_ERROR, e);
log.info("",qe);
log.info("", qe);
throw new DatawaveFatalQueryException(qe);
}
}
Expand Down Expand Up @@ -1416,11 +1416,11 @@ protected ASTJexlScript timedExpandAnyFieldRegexNodes(QueryStopwatch timers, fin
} catch (EmptyUnfieldedTermExpansionException e) {
// The visitor will only throw this if we cannot expand anything resulting in empty query
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.UNFIELDED_QUERY_ZERO_MATCHES, e, MessageFormat.format("Query: ", query));
log.info("",qe);
log.info("", qe);
throw new NoResultsException(qe);
} catch (TableNotFoundException e) {
QueryException qe = new QueryException(DatawaveErrorCode.METADATA_ACCESS_ERROR, e);
log.info("",qe);
log.info("", qe);
throw new DatawaveFatalQueryException(qe);
}
}
Expand Down
8 changes: 4 additions & 4 deletions web-services/metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
<artifactId>datawave-ws-query</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>gov.nsa.datawave</groupId>
<artifactId>datawave-ingest-configuration</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void verifyTables() {
private void writeMetrics(QueryMetric updatedQueryMetric, List<QueryMetric> storedQueryMetrics, Date lastUpdated, boolean delete) throws Exception {
LiveContextWriter contextWriter = null;

MapContext<Text, RawRecordContainer, Text, Mutation> context = null;
MapContext<Text,RawRecordContainer,Text,Mutation> context = null;

try {
contextWriter = new LiveContextWriter();
Expand All @@ -239,7 +239,7 @@ private void writeMetrics(QueryMetric updatedQueryMetric, List<QueryMetric> stor
AbstractColumnBasedHandler<Key> handler = new ContentQueryMetricsHandler<>();
handler.setup(context);

Multimap<BulkIngestKey, Value> r = getEntries(handler, updatedQueryMetric, storedQueryMetric, lastUpdated, delete);
Multimap<BulkIngestKey,Value> r = getEntries(handler, updatedQueryMetric, storedQueryMetric, lastUpdated, delete);

try {
if (r != null) {
Expand All @@ -260,20 +260,20 @@ private void writeMetrics(QueryMetric updatedQueryMetric, List<QueryMetric> stor
}
}

public Map<String, String> getEventFields(BaseQueryMetric queryMetric) {
public Map<String,String> getEventFields(BaseQueryMetric queryMetric) {
// ignore duplicates as none are expected
Map<String, String> eventFields = new HashMap<>();
Map<String,String> eventFields = new HashMap<>();
ContentQueryMetricsIngestHelper ingestHelper = new ContentQueryMetricsIngestHelper(false);
ingestHelper.setup(conf);
Multimap<String, NormalizedContentInterface> fieldsToWrite = ingestHelper.getEventFieldsToWrite(queryMetric);
for (Entry<String, NormalizedContentInterface> entry : fieldsToWrite.entries()) {
Multimap<String,NormalizedContentInterface> fieldsToWrite = ingestHelper.getEventFieldsToWrite(queryMetric);
for (Entry<String,NormalizedContentInterface> entry : fieldsToWrite.entries()) {
eventFields.put(entry.getKey(), entry.getValue().getEventFieldValue());
}
return eventFields;
}

private Multimap<BulkIngestKey, Value> getEntries(AbstractColumnBasedHandler<Key> handler, QueryMetric updatedQueryMetric, QueryMetric storedQueryMetric,
Date lastUpdated, boolean delete) {
private Multimap<BulkIngestKey,Value> getEntries(AbstractColumnBasedHandler<Key> handler, QueryMetric updatedQueryMetric, QueryMetric storedQueryMetric,
Date lastUpdated, boolean delete) {
Type type = TypeRegistry.getType("querymetrics");
ContentQueryMetricsIngestHelper ingestHelper = new ContentQueryMetricsIngestHelper(delete);

Expand All @@ -284,7 +284,7 @@ private Multimap<BulkIngestKey, Value> getEntries(AbstractColumnBasedHandler<Key
event.setDataType(type);
event.setDate(storedQueryMetric.getCreateDate().getTime());
// get security markings from metric, otherwise default to PUBLIC
Map<String, String> markings = updatedQueryMetric.getMarkings();
Map<String,String> markings = updatedQueryMetric.getMarkings();
if (markingFunctions == null || markings == null || markings.isEmpty()) {
event.setVisibility(new ColumnVisibility(DEFAULT_SECURITY_MARKING));
} else {
Expand All @@ -301,7 +301,7 @@ private Multimap<BulkIngestKey, Value> getEntries(AbstractColumnBasedHandler<Key

event.setId(uidBuilder.newId(storedQueryMetric.getQueryId().getBytes(), (Date) null));

final Multimap<String, NormalizedContentInterface> fields;
final Multimap<String,NormalizedContentInterface> fields;

if (delete) {
fields = ingestHelper.getEventFieldsToDelete(updatedQueryMetric, storedQueryMetric);
Expand All @@ -319,12 +319,12 @@ private Multimap<BulkIngestKey, Value> getEntries(AbstractColumnBasedHandler<Key
String indexTable = handler.getShardIndexTableName().toString();
String reverseIndexTable = handler.getShardReverseIndexTableName().toString();
int fieldSizeThreshold = ingestHelper.getFieldSizeThreshold();
Multimap<BulkIngestKey, Value> r = handler.processBulk(key, event, fields, reporter);
Multimap<BulkIngestKey,Value> r = handler.processBulk(key, event, fields, reporter);
List<BulkIngestKey> keysToRemove = new ArrayList<>();
Map<String, BulkIngestKey> tfFields = new HashMap<>();
Map<String,BulkIngestKey> tfFields = new HashMap<>();

// if an event has more than two entries for a given field, only keep the longest
for (Entry<BulkIngestKey, Collection<Value>> entry : r.asMap().entrySet()) {
for (Entry<BulkIngestKey,Collection<Value>> entry : r.asMap().entrySet()) {
String table = entry.getKey().getTableName().toString();
BulkIngestKey bulkIngestKey = entry.getKey();
Key currentKey = bulkIngestKey.getKey();
Expand All @@ -343,11 +343,11 @@ private Multimap<BulkIngestKey, Value> getEntries(AbstractColumnBasedHandler<Key
}

// replace the longest of the keys from fields that get parsed as content
for (Entry<String, BulkIngestKey> l : tfFields.entrySet()) {
for (Entry<String,BulkIngestKey> l : tfFields.entrySet()) {
r.put(l.getValue(), new Value(new byte[0]));
}

for (Entry<BulkIngestKey, Collection<Value>> entry : r.asMap().entrySet()) {
for (Entry<BulkIngestKey,Collection<Value>> entry : r.asMap().entrySet()) {
if (delete) {
entry.getKey().getKey().setTimestamp(lastUpdated.getTime());
} else {
Expand Down Expand Up @@ -380,7 +380,7 @@ public void updateMetric(QueryMetric updatedQueryMetric, DatawavePrincipal dataw
QueryMetric updatedQueryMetricCopy;
synchronized (ShardTableQueryMetricHandler.class) {
cachedQueryMetric = (QueryMetric) metricsCache.get(updatedQueryMetric.getQueryId());
Map<Long, PageMetric> storedPageMetricMap = new TreeMap<>();
Map<Long,PageMetric> storedPageMetricMap = new TreeMap<>();
if (cachedQueryMetric != null) {
List<PageMetric> cachedPageMetrics = cachedQueryMetric.getPageTimes();
if (cachedPageMetrics != null) {
Expand Down Expand Up @@ -444,7 +444,7 @@ private List<QueryMetric> getQueryMetrics(BaseResponse response, Query query, Da
AccumuloClient client = null;

try {
Map<String, String> trackingMap = this.connectionFactory.getTrackingMap(Thread.currentThread().getStackTrace());
Map<String,String> trackingMap = this.connectionFactory.getTrackingMap(Thread.currentThread().getStackTrace());
client = this.connectionFactory.getClient(null, null, Priority.ADMIN, trackingMap);
QueryLogic<?> queryLogic = queryLogicFactory.getQueryLogic(query.getQueryLogicName(), datawavePrincipal);
runningQuery = new RunningQuery(null, client, Priority.ADMIN, queryLogic, query, query.getQueryAuthorizations(), datawavePrincipal, metricFactory);
Expand Down Expand Up @@ -483,7 +483,7 @@ private List<QueryMetric> getQueryMetrics(BaseResponse response, Query query, Da
List<EventBase> eventList = eventQueryResponse.getEvents();

if (eventList != null) {
for (EventBase<?, ?> event : eventList) {
for (EventBase<?,?> event : eventList) {
QueryMetric metric = (QueryMetric) toMetric(event);
queryMetrics.add(metric);
}
Expand Down Expand Up @@ -556,7 +556,7 @@ public BaseQueryMetric toMetric(EventBase event) {
BaseQueryMetric m = metricFactory.createMetric(false);
List<FieldBase> field = event.getFields();
m.setMarkings(event.getMarkings());
TreeMap<Long, PageMetric> pageMetrics = Maps.newTreeMap();
TreeMap<Long,PageMetric> pageMetrics = Maps.newTreeMap();

boolean createDateSet = false;
for (FieldBase f : field) {
Expand Down Expand Up @@ -712,13 +712,13 @@ public BaseQueryMetric toMetric(EventBase event) {
}

protected void createAndConfigureTablesIfNecessary(String[] tableNames, TableOperations tops, Configuration conf)
throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
for (String table : tableNames) {
// If the tables don't exist, then create them.
try {
if (!tops.exists(table)) {
tops.create(table);
Map<String, TableConfigHelper> tableConfigs = getTableConfigs(log, conf, tableNames);
Map<String,TableConfigHelper> tableConfigs = getTableConfigs(log, conf, tableNames);

TableConfigHelper tableHelper = tableConfigs.get(table);

Expand All @@ -736,8 +736,8 @@ protected void createAndConfigureTablesIfNecessary(String[] tableNames, TableOpe
}

@SuppressWarnings("unchecked")
private Map<String, TableConfigHelper> getTableConfigs(Logger log, Configuration conf, String[] tableNames) {
Map<String, TableConfigHelper> helperMap = new HashMap<>(tableNames.length);
private Map<String,TableConfigHelper> getTableConfigs(Logger log, Configuration conf, String[] tableNames) {
Map<String,TableConfigHelper> helperMap = new HashMap<>(tableNames.length);

for (String table : tableNames) {
String prop = table + TableConfigHelper.TABLE_CONFIG_CLASS_SUFFIX;
Expand All @@ -751,8 +751,7 @@ private Map<String, TableConfigHelper> getTableConfigs(Logger log, Configuration

if (tableHelper != null)
tableHelper.setup(table, conf, log);
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException |
NoSuchMethodException | InvocationTargetException e) {
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
Expand Down Expand Up @@ -798,7 +797,7 @@ public QueryMetricsSummaryResponse getUserQueriesSummary(Date begin, Date end, D
}

public QueryMetricsSummaryResponse getQueryMetricsSummary(Date begin, Date end, boolean onlyCurrentUser, DatawavePrincipal datawavePrincipal,
QueryMetricsSummaryResponse response) {
QueryMetricsSummaryResponse response) {

try {

Expand Down

0 comments on commit e0e3715

Please sign in to comment.