[
https://issues.apache.org/jira/browse/METRON-576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15686736#comment-15686736
]
ASF GitHub Bot commented on METRON-576:
---------------------------------------
Github user nickwallen commented on a diff in the pull request:
https://github.com/apache/incubator-metron/pull/366#discussion_r89112598
--- Diff:
metron-platform/metron-common/src/main/java/org/apache/metron/common/dsl/functions/resolver/BaseFunctionResolver.java
---
@@ -0,0 +1,198 @@
+/**
+ * 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.metron.common.dsl.functions.resolver;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.metron.common.dsl.Context;
+import org.apache.metron.common.dsl.Stellar;
+import org.apache.metron.common.dsl.StellarFunction;
+import org.apache.metron.common.dsl.StellarFunctionInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The base implementation of a function resolver.
+ *
+ */
+public abstract class BaseFunctionResolver implements FunctionResolver,
Serializable {
+
+ protected static final Logger LOG =
LoggerFactory.getLogger(BaseFunctionResolver.class);
+
+ /**
+ * Maps a function name to the metadata necessary to execute the Stellar
function.
+ */
+ private Supplier<Map<String, StellarFunctionInfo>> functions;
+
+ /**
+ * The Stellar execution context that can be used to inform the function
resolution process.
+ */
+ protected Context context;
+
+ public BaseFunctionResolver() {
+ // memoize provides lazy initialization and thread-safety (the ugly
cast is necessary for serialization)
+ functions = Suppliers.memoize((Supplier<Map<String,
StellarFunctionInfo>> & Serializable) this::resolveFunctions);
+ }
--- End diff --
> What I don't see, however, is the multithreading protection in the
original Singleton, but I might've missed it. What happens if function
resolution happens during the function scan? Do function resolutions block like
it did before until the scan completes?
@cestella It is the memoization that provides the thread-safety and
lazy-initialization. See comments in this section of code. I believe this is
sufficient. Let me know if I missed something.
> Stellar function resolution takes too long on running cluster
> -------------------------------------------------------------
>
> Key: METRON-576
> URL: https://issues.apache.org/jira/browse/METRON-576
> Project: Metron
> Issue Type: Improvement
> Reporter: Nick Allen
> Assignee: Nick Allen
>
> When running the Stellar REPL in a cluster on AWS, function resolution takes
> 50-60 seconds. The user is not able to execute any functions in the REPL
> until this process completes.
> The default function resolver searches the classpath for Stellar functions.
> The delay may be because there are just too many classes in the classpath to
> search on a running cluster. As more libraries are added as dependencies
> under /usr/metron/<version>/lib this problem just gets worse.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)