dakirily commented on code in PR #121:
URL: https://github.com/apache/qpid-broker-j/pull/121#discussion_r866737318


##########
broker-plugins/broker-query-engine/src/main/java/org/apache/qpid/server/query/engine/QueryEngine.java:
##########
@@ -0,0 +1,129 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.query.engine;
+
+import java.math.BigDecimal;
+import java.time.ZoneId;
+import java.util.Map;
+import java.util.Objects;
+
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.port.HttpPort;
+import org.apache.qpid.server.query.engine.cache.MaxSizeHashMap;
+import org.apache.qpid.server.query.engine.evaluator.QueryEvaluator;
+import org.apache.qpid.server.query.engine.evaluator.settings.QuerySettings;
+import org.apache.qpid.server.query.engine.parsing.query.QueryExpression;
+
+/**
+ * Bridge class between broker configuration and query evaluator
+ */
+// sonar complains about underscores in variable names
+@SuppressWarnings("java:S116")
+public class QueryEngine
+{
+    /**
+     * Broker instance
+     */
+    private final Broker<?> _broker;
+
+    /**
+     * Cache holding queries
+     */
+    private final Map<String, QueryExpression<?, ?>> _queryCache;
+
+    /**
+     * Maximal allowed BigDecimal value.
+     * Is needed to prevent heap memory consumption when calculating very 
large numbers.
+     */
+    private BigDecimal _maxBigDecimalValue = 
BigDecimal.valueOf(Double.MAX_VALUE).pow(4);
+
+    /**
+     * Maximal amount of queries allowed caching
+     */
+    private final int _maxQueryCacheSize;
+
+    /**
+     * Maximal amount of query tree nodes allowed
+     */
+    private int _maxQueryDepth;
+
+    /**
+     * Zone id
+     */
+    private ZoneId _zoneId;
+
+    /**
+     * Constructor injects broker and retrieves default configuration values
+     *
+     * @param broker Broker instance
+     */
+    // mutable broker instance is stored intentionally
+    @SuppressWarnings("findbugs:EI_EXPOSE_REP2")
+    public QueryEngine(final Broker<?> broker)
+    {
+        Objects.requireNonNull(broker, "Broker instance not provided for 
querying");
+        _broker = broker;
+        final HttpPort<?> httpPort = broker.getPorts().stream()
+            .filter(port -> Objects.equals("HTTP", port.getType()))
+            .map(port -> (HttpPort<?>)port)
+            .findFirst()
+            .orElseThrow(() -> new IllegalArgumentException("HTTP port not 
found"));

Review Comment:
   As the configuration was moved to http management, code fragment with 
iteration over ports and exception throwing was removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to