Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions hadoop-hdds/common/dev-support/findbugsExcludeFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<Match>
<Package name="org.apache.hadoop.hdds.protocol.proto"/>
</Match>
<Match>
<Class name="org.apache.hadoop.hdds.cli.GenericCli"></Class>
<Bug pattern="DM_EXIT" />
</Match>
<Match>
<Class name="org.apache.hadoop.ozone.OzoneConsts"/>
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.ratis.util.ExitUtils;
import picocli.CommandLine;
import picocli.CommandLine.ExitCode;
import picocli.CommandLine.Option;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void run(String[] argv) {
int exitCode = execute(argv);

if (exitCode != ExitCode.OK) {
System.exit(exitCode);
ExitUtils.terminate(exitCode, null, null);
}
}

Expand Down
20 changes: 0 additions & 20 deletions hadoop-ozone/httpfsgateway/dev-support/findbugsExcludeFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,4 @@
limitations under the License.
-->
<FindBugsFilter>
<Match>
<Class name="org.apache.ozone.lib.service.instrumentation.InstrumentationService" />
<Method name="getToAdd" />
<Bug pattern="UL_UNRELEASED_LOCK" />
</Match>
<Match>
<Class name="org.apache.ozone.fs.http.server.HttpFSServerWebApp" />
<Method name="destroy" />
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
</Match>
<Match>
<Class name="org.apache.ozone.lib.servlet.ServerWebApp" />
<Field name="authority" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
<Match>
<Class name="org.apache.ozone.lib.service.hadoop.FileSystemAccessService" />
<Method name="closeFileSystem" />
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.ozone.fs.http.server;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
Expand All @@ -36,7 +37,7 @@
* </code> implementation that is wired in HttpFSServer's WAR
* <code>WEB-INF/web.xml</code>.
* <p>
* It provides acces to the server context via the singleton {@link #get}.
* It provides access to the server context via the singleton {@link #get}.
* <p>
* All the configuration is loaded from configuration properties prefixed
* with <code>httpfs.</code>.
Expand All @@ -56,8 +57,8 @@ public class HttpFSServerWebApp extends ServerWebApp {
*/
public static final String CONF_ADMIN_GROUP = "admin.group";

private static HttpFSServerWebApp server;
private static HttpFSServerMetrics metrics;
private static final AtomicReference<HttpFSServerWebApp> SERVER = new AtomicReference<>();
private static final AtomicReference<HttpFSServerMetrics> METRICS = new AtomicReference<>();

private String adminGroup;

Expand All @@ -80,13 +81,12 @@ public HttpFSServerWebApp() throws IOException {
*/
@Override
public void init() throws ServerException {
if (server != null) {
if (!SERVER.compareAndSet(null, this)) {
throw new RuntimeException("HttpFSServer server already initialized");
}
server = this;
super.init();
adminGroup = getConfig().get(getPrefixedName(CONF_ADMIN_GROUP), "admin");
LOG.info("Connects to Namenode [{}]",
LOG.info("Connects to FileSystem [{}]",
get().get(FileSystemAccess.class).getFileSystemConfiguration().
get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
setMetrics(getConfig());
Expand All @@ -97,7 +97,8 @@ public void init() throws ServerException {
*/
@Override
public void destroy() {
server = null;
SERVER.set(null);
HttpFSServerMetrics metrics = METRICS.getAndSet(null);
if (metrics != null) {
metrics.shutdown();
}
Expand All @@ -106,11 +107,11 @@ public void destroy() {

private static void setMetrics(Configuration config) {
LOG.info("Initializing HttpFSServerMetrics");
metrics = HttpFSServerMetrics.create(config, "HttpFSServer");
METRICS.updateAndGet(prev -> prev != null ? prev : HttpFSServerMetrics.create(config, "HttpFSServer"));
JvmPauseMonitor pauseMonitor = new JvmPauseMonitor();
pauseMonitor.init(config);
pauseMonitor.start();
metrics.getJvmMetrics().setPauseMonitor(pauseMonitor);
METRICS.get().getJvmMetrics().setPauseMonitor(pauseMonitor);
FSOperations.setBufferSize(config);
DefaultMetricsSystem.initialize("HttpFSServer");
}
Expand All @@ -121,15 +122,15 @@ private static void setMetrics(Configuration config) {
* @return the HttpFSServer server singleton.
*/
public static HttpFSServerWebApp get() {
return server;
return SERVER.get();
}

/**
* gets the HttpFSServerMetrics instance.
* @return the HttpFSServerMetrics singleton.
*/
public static HttpFSServerMetrics getMetrics() {
return metrics;
return METRICS.get();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,43 +129,23 @@ private <T> T getToAdd(String group,
Class<T> klass,
Lock lock,
Map<String, Map<String, T>> map) {
boolean locked = false;
lock.lock();
try {
Map<String, T> groupMap = map.get(group);
if (groupMap == null) {
lock.lock();
locked = true;
groupMap = map.get(group);
if (groupMap == null) {
groupMap = new ConcurrentHashMap<String, T>();
map.put(group, groupMap);
}
}
T element = groupMap.get(name);
if (element == null) {
if (!locked) {
lock.lock();
locked = true;
}
element = groupMap.get(name);
if (element == null) {
try {
if (klass == Timer.class) {
element = (T) new Timer(timersSize);
} else {
element = klass.newInstance();
return map
.computeIfAbsent(group, k -> new ConcurrentHashMap<>())
.computeIfAbsent(name, k -> {
try {
if (klass == Timer.class) {
return (T) new Timer(timersSize);
} else {
return klass.newInstance();
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
groupMap.put(name, element);
}
}
return element;
});
} finally {
if (locked) {
lock.unlock();
}
lock.unlock();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public InetSocketAddress getAuthority() throws ServerException {
if (authority == null) {
authority = resolveAuthority();
}
return authority;
}
return authority;
}
}