From e0e3715a43fb13deb331ae3dc948893a7bdb750f Mon Sep 17 00:00:00 2001 From: Jason Thomas jjthom3 Date: Fri, 25 Oct 2024 15:17:56 +0000 Subject: [PATCH] Removed ThreadConfigurableLogger class for upcoming SLF4J change --- core/common-util/pom.xml | 8 +-- .../query/planner/DefaultQueryPlanner.java | 6 +-- web-services/metrics/pom.xml | 8 +-- .../metrics/ShardTableQueryMetricHandler.java | 51 +++++++++---------- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/core/common-util/pom.xml b/core/common-util/pom.xml index e31de94740..cbef463809 100644 --- a/core/common-util/pom.xml +++ b/core/common-util/pom.xml @@ -26,6 +26,10 @@ gov.nsa.datawave.microservice authorization-api + + org.slf4j + slf4j-api + org.apache.accumulo accumulo-core @@ -37,10 +41,6 @@ - - org.slf4j - slf4j-api - diff --git a/warehouse/query-core/src/main/java/datawave/query/planner/DefaultQueryPlanner.java b/warehouse/query-core/src/main/java/datawave/query/planner/DefaultQueryPlanner.java index a698ce8c02..88ee6ab21e 100644 --- a/warehouse/query-core/src/main/java/datawave/query/planner/DefaultQueryPlanner.java +++ b/warehouse/query-core/src/main/java/datawave/query/planner/DefaultQueryPlanner.java @@ -1240,7 +1240,7 @@ protected Set 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); } } @@ -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); } } diff --git a/web-services/metrics/pom.xml b/web-services/metrics/pom.xml index 9fed678a1a..d1183b9e88 100644 --- a/web-services/metrics/pom.xml +++ b/web-services/metrics/pom.xml @@ -25,16 +25,16 @@ datawave-ws-query ${project.version} + + org.slf4j + slf4j-api + gov.nsa.datawave datawave-ingest-configuration ${project.version} test - - org.slf4j - slf4j-api - ${project.artifactId} diff --git a/web-services/metrics/src/main/java/datawave/query/metrics/ShardTableQueryMetricHandler.java b/web-services/metrics/src/main/java/datawave/query/metrics/ShardTableQueryMetricHandler.java index a5c5a76f99..af6fb96781 100644 --- a/web-services/metrics/src/main/java/datawave/query/metrics/ShardTableQueryMetricHandler.java +++ b/web-services/metrics/src/main/java/datawave/query/metrics/ShardTableQueryMetricHandler.java @@ -226,7 +226,7 @@ private void verifyTables() { private void writeMetrics(QueryMetric updatedQueryMetric, List storedQueryMetrics, Date lastUpdated, boolean delete) throws Exception { LiveContextWriter contextWriter = null; - MapContext context = null; + MapContext context = null; try { contextWriter = new LiveContextWriter(); @@ -239,7 +239,7 @@ private void writeMetrics(QueryMetric updatedQueryMetric, List stor AbstractColumnBasedHandler handler = new ContentQueryMetricsHandler<>(); handler.setup(context); - Multimap r = getEntries(handler, updatedQueryMetric, storedQueryMetric, lastUpdated, delete); + Multimap r = getEntries(handler, updatedQueryMetric, storedQueryMetric, lastUpdated, delete); try { if (r != null) { @@ -260,20 +260,20 @@ private void writeMetrics(QueryMetric updatedQueryMetric, List stor } } - public Map getEventFields(BaseQueryMetric queryMetric) { + public Map getEventFields(BaseQueryMetric queryMetric) { // ignore duplicates as none are expected - Map eventFields = new HashMap<>(); + Map eventFields = new HashMap<>(); ContentQueryMetricsIngestHelper ingestHelper = new ContentQueryMetricsIngestHelper(false); ingestHelper.setup(conf); - Multimap fieldsToWrite = ingestHelper.getEventFieldsToWrite(queryMetric); - for (Entry entry : fieldsToWrite.entries()) { + Multimap fieldsToWrite = ingestHelper.getEventFieldsToWrite(queryMetric); + for (Entry entry : fieldsToWrite.entries()) { eventFields.put(entry.getKey(), entry.getValue().getEventFieldValue()); } return eventFields; } - private Multimap getEntries(AbstractColumnBasedHandler handler, QueryMetric updatedQueryMetric, QueryMetric storedQueryMetric, - Date lastUpdated, boolean delete) { + private Multimap getEntries(AbstractColumnBasedHandler handler, QueryMetric updatedQueryMetric, QueryMetric storedQueryMetric, + Date lastUpdated, boolean delete) { Type type = TypeRegistry.getType("querymetrics"); ContentQueryMetricsIngestHelper ingestHelper = new ContentQueryMetricsIngestHelper(delete); @@ -284,7 +284,7 @@ private Multimap getEntries(AbstractColumnBasedHandler markings = updatedQueryMetric.getMarkings(); + Map markings = updatedQueryMetric.getMarkings(); if (markingFunctions == null || markings == null || markings.isEmpty()) { event.setVisibility(new ColumnVisibility(DEFAULT_SECURITY_MARKING)); } else { @@ -301,7 +301,7 @@ private Multimap getEntries(AbstractColumnBasedHandler fields; + final Multimap fields; if (delete) { fields = ingestHelper.getEventFieldsToDelete(updatedQueryMetric, storedQueryMetric); @@ -319,12 +319,12 @@ private Multimap getEntries(AbstractColumnBasedHandler r = handler.processBulk(key, event, fields, reporter); + Multimap r = handler.processBulk(key, event, fields, reporter); List keysToRemove = new ArrayList<>(); - Map tfFields = new HashMap<>(); + Map tfFields = new HashMap<>(); // if an event has more than two entries for a given field, only keep the longest - for (Entry> entry : r.asMap().entrySet()) { + for (Entry> entry : r.asMap().entrySet()) { String table = entry.getKey().getTableName().toString(); BulkIngestKey bulkIngestKey = entry.getKey(); Key currentKey = bulkIngestKey.getKey(); @@ -343,11 +343,11 @@ private Multimap getEntries(AbstractColumnBasedHandler l : tfFields.entrySet()) { + for (Entry l : tfFields.entrySet()) { r.put(l.getValue(), new Value(new byte[0])); } - for (Entry> entry : r.asMap().entrySet()) { + for (Entry> entry : r.asMap().entrySet()) { if (delete) { entry.getKey().getKey().setTimestamp(lastUpdated.getTime()); } else { @@ -380,7 +380,7 @@ public void updateMetric(QueryMetric updatedQueryMetric, DatawavePrincipal dataw QueryMetric updatedQueryMetricCopy; synchronized (ShardTableQueryMetricHandler.class) { cachedQueryMetric = (QueryMetric) metricsCache.get(updatedQueryMetric.getQueryId()); - Map storedPageMetricMap = new TreeMap<>(); + Map storedPageMetricMap = new TreeMap<>(); if (cachedQueryMetric != null) { List cachedPageMetrics = cachedQueryMetric.getPageTimes(); if (cachedPageMetrics != null) { @@ -444,7 +444,7 @@ private List getQueryMetrics(BaseResponse response, Query query, Da AccumuloClient client = null; try { - Map trackingMap = this.connectionFactory.getTrackingMap(Thread.currentThread().getStackTrace()); + Map 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); @@ -483,7 +483,7 @@ private List getQueryMetrics(BaseResponse response, Query query, Da List eventList = eventQueryResponse.getEvents(); if (eventList != null) { - for (EventBase event : eventList) { + for (EventBase event : eventList) { QueryMetric metric = (QueryMetric) toMetric(event); queryMetrics.add(metric); } @@ -556,7 +556,7 @@ public BaseQueryMetric toMetric(EventBase event) { BaseQueryMetric m = metricFactory.createMetric(false); List field = event.getFields(); m.setMarkings(event.getMarkings()); - TreeMap pageMetrics = Maps.newTreeMap(); + TreeMap pageMetrics = Maps.newTreeMap(); boolean createDateSet = false; for (FieldBase f : field) { @@ -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 tableConfigs = getTableConfigs(log, conf, tableNames); + Map tableConfigs = getTableConfigs(log, conf, tableNames); TableConfigHelper tableHelper = tableConfigs.get(table); @@ -736,8 +736,8 @@ protected void createAndConfigureTablesIfNecessary(String[] tableNames, TableOpe } @SuppressWarnings("unchecked") - private Map getTableConfigs(Logger log, Configuration conf, String[] tableNames) { - Map helperMap = new HashMap<>(tableNames.length); + private Map getTableConfigs(Logger log, Configuration conf, String[] tableNames) { + Map helperMap = new HashMap<>(tableNames.length); for (String table : tableNames) { String prop = table + TableConfigHelper.TABLE_CONFIG_CLASS_SUFFIX; @@ -751,8 +751,7 @@ private Map 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); } } @@ -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 {