ctubbsii commented on a change in pull request #2425: URL: https://github.com/apache/accumulo/pull/2425#discussion_r790011638
########## File path: server/tserver/src/main/java/org/apache/accumulo/tserver/memory/NativeMapLoader.java ########## @@ -0,0 +1,141 @@ +/* + * 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.accumulo.tserver.memory; + +import java.io.File; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.apache.accumulo.core.conf.Property; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +public class NativeMapLoader { + + private static final Logger log = LoggerFactory.getLogger(NativeMapLoader.class); + private static final Pattern dotSuffix = Pattern.compile("[.][^.]*$"); + private static final String PROP_NAME = "accumulo.native.lib.path"; + private static final AtomicBoolean loaded = new AtomicBoolean(false); + + // don't allow instantiation + private NativeMapLoader() {} Review comment: I initially tried that, but it didn't end up making any sense, because the native libraries that are loaded are static relative to the JVM (you can't "unload" them when the class is closed or garbage-collected). So, I could have had objects that have lifecycles, but still reference a single static `AtomicBoolean loaded` member, but ultimately it didn't make it easier to test, and it felt kludge-y. Static methods make it obvious that you're managing static state, which is necessarily static and can't be avoided, rather than obscuring that fact behind instantiable objects. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
