Repository: hadoop Updated Branches: refs/heads/HDFS-7240 7de7daa5b -> ac77b1803
HDFS-13341. Ozone: Move ozone specific ServiceRuntimeInfo utility to the framework. Contributed by Elek, Marton. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ac77b180 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ac77b180 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ac77b180 Branch: refs/heads/HDFS-7240 Commit: ac77b180375651dfb1d8cf2be7d15f39fe706aee Parents: 7de7daa Author: Anu Engineer <aengin...@apache.org> Authored: Mon Apr 2 20:43:31 2018 -0700 Committer: Anu Engineer <aengin...@apache.org> Committed: Mon Apr 2 20:43:31 2018 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/cblock/CBlockManager.java | 2 +- .../apache/hadoop/jmx/ServiceRuntimeInfo.java | 64 ------ .../hadoop/jmx/ServiceRuntimeInfoImpl.java | 55 ----- .../apache/hadoop/ozone/scm/HdslServerUtil.java | 2 +- hadoop-hdsl/framework/README.md | 24 ++ .../hadoop/hdsl/server/BaseHttpServer.java | 218 +++++++++++++++++++ .../apache/hadoop/hdsl/server/ServerUtils.java | 140 ++++++++++++ .../hadoop/hdsl/server/ServiceRuntimeInfo.java | 64 ++++++ .../hdsl/server/ServiceRuntimeInfoImpl.java | 55 +++++ .../apache/hadoop/hdsl/server/package-info.java | 23 ++ .../hadoop/ozone/web/OzoneHttpServer.java | 218 ------------------- .../apache/hadoop/ozone/web/package-info.java | 23 -- .../hadoop/ozone/web/util/ServerUtils.java | 140 ------------ .../hadoop/ozone/web/util/package-info.java | 23 -- .../hadoop/hdsl/server/TestBaseHttpServer.java | 99 +++++++++ .../org/apache/hadoop/ozone/scm/SCMMXBean.java | 2 +- .../org/apache/hadoop/ozone/scm/SCMStorage.java | 2 +- .../ozone/scm/StorageContainerManager.java | 4 +- .../scm/StorageContainerManagerHttpServer.java | 4 +- .../ozone/scm/block/BlockManagerImpl.java | 2 +- .../ozone/scm/block/DeletedBlockLogImpl.java | 2 +- .../ozone/scm/container/ContainerMapping.java | 2 +- .../ozone/scm/node/SCMNodePoolManager.java | 2 +- .../hadoop/ozone/web/client/OzoneBucket.java | 2 +- .../ozone/web/client/OzoneRestClient.java | 2 +- .../hadoop/ozone/web/client/OzoneVolume.java | 2 +- .../hadoop/ozone/web/TestOzoneHttpServer.java | 98 --------- .../org/apache/hadoop/ozone/ksm/KSMMXBean.java | 2 +- .../ozone/ksm/KSMMetadataManagerImpl.java | 2 +- .../org/apache/hadoop/ozone/ksm/KSMStorage.java | 2 +- .../hadoop/ozone/ksm/KeySpaceManager.java | 4 +- .../ozone/ksm/KeySpaceManagerHttpServer.java | 4 +- 32 files changed, 645 insertions(+), 643 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-cblock/server/src/main/java/org/apache/hadoop/cblock/CBlockManager.java ---------------------------------------------------------------------- diff --git a/hadoop-cblock/server/src/main/java/org/apache/hadoop/cblock/CBlockManager.java b/hadoop-cblock/server/src/main/java/org/apache/hadoop/cblock/CBlockManager.java index 788d01e..12b505a 100644 --- a/hadoop-cblock/server/src/main/java/org/apache/hadoop/cblock/CBlockManager.java +++ b/hadoop-cblock/server/src/main/java/org/apache/hadoop/cblock/CBlockManager.java @@ -54,7 +54,7 @@ import org.apache.hadoop.utils.LevelDBStore; import static org.apache.hadoop.cblock.CblockUtils.getCblockServerRpcAddr; import static org.apache.hadoop.cblock.CblockUtils.getCblockServiceRpcAddr; -import static org.apache.hadoop.ozone.web.util.ServerUtils +import static org.apache.hadoop.hdsl.server.ServerUtils .updateRPCListenAddress; import org.iq80.leveldb.DBIterator; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfo.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfo.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfo.java deleted file mode 100644 index 085872b..0000000 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfo.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.hadoop.jmx; - -/** - * Common runtime information for any service components. - * - * Note: it's intentional to not use MXBean or MBean as a suffix of the name. - * - * Most of the services extends the ServiceRuntimeInfoImpl class and also - * implements a specific MXBean interface which extends this interface. - * - * This inheritance from multiple path could confuse the jmx system and - * some jmx properties could be disappeared. - * - * The solution is to always extend this interface and use the jmx naming - * convention in the new interface.. - */ -public interface ServiceRuntimeInfo { - - /** - * Gets the version of Hadoop. - * - * @return the version - */ - String getVersion(); - - /** - * Get the version of software running on the Namenode. - * - * @return a string representing the version - */ - String getSoftwareVersion(); - - /** - * Get the compilation information which contains date, user and branch. - * - * @return the compilation information, as a JSON string. - */ - String getCompileInfo(); - - /** - * Gets the NN start time in milliseconds. - * - * @return the NN start time in msec - */ - long getStartedTimeInMillis(); - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfoImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfoImpl.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfoImpl.java deleted file mode 100644 index 5061494..0000000 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/ServiceRuntimeInfoImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.hadoop.jmx; - -import org.apache.hadoop.util.VersionInfo; - -/** - * Helper base class to report the standard version and runtime information. - * - */ -public class ServiceRuntimeInfoImpl implements ServiceRuntimeInfo { - - private long startedTimeInMillis; - - @Override - public String getVersion() { - return VersionInfo.getVersion() + ", r" + VersionInfo.getRevision(); - } - - @Override - public String getSoftwareVersion() { - return VersionInfo.getVersion(); - } - - @Override - public String getCompileInfo() { - return VersionInfo.getDate() + " by " + VersionInfo.getUser() + " from " - + VersionInfo.getBranch(); - } - - @Override - public long getStartedTimeInMillis() { - return startedTimeInMillis; - } - - public void setStartTime() { - startedTimeInMillis = System.currentTimeMillis(); - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/container-service/src/main/java/org/apache/hadoop/ozone/scm/HdslServerUtil.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/container-service/src/main/java/org/apache/hadoop/ozone/scm/HdslServerUtil.java b/hadoop-hdsl/container-service/src/main/java/org/apache/hadoop/ozone/scm/HdslServerUtil.java index 11e6d56..21123eb 100644 --- a/hadoop-hdsl/container-service/src/main/java/org/apache/hadoop/ozone/scm/HdslServerUtil.java +++ b/hadoop-hdsl/container-service/src/main/java/org/apache/hadoop/ozone/scm/HdslServerUtil.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import static org.apache.hadoop.hdsl.HdslUtils.*; -import static org.apache.hadoop.ozone.web.util.ServerUtils.sanitizeUserArgs; +import static org.apache.hadoop.hdsl.server.ServerUtils.sanitizeUserArgs; import static org.apache.hadoop.scm.ScmConfigKeys.*; /** http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/README.md ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/README.md b/hadoop-hdsl/framework/README.md new file mode 100644 index 0000000..1f4d217 --- /dev/null +++ b/hadoop-hdsl/framework/README.md @@ -0,0 +1,24 @@ +<!-- + 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. +--> + +# Server framework for HDSL/Ozone + +This project contains generic utilities and resources for all the HDSL/Ozone +server-side components. + +The project is shared between the server/service projects but not with the +client packages. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/BaseHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/BaseHttpServer.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/BaseHttpServer.java new file mode 100644 index 0000000..f9c3991 --- /dev/null +++ b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/BaseHttpServer.java @@ -0,0 +1,218 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.hadoop.hdsl.server; + +import com.google.common.base.Optional; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hdfs.DFSConfigKeys; +import org.apache.hadoop.hdfs.DFSUtil; +import org.apache.hadoop.http.HttpConfig; +import org.apache.hadoop.http.HttpServer2; +import org.apache.hadoop.net.NetUtils; +import org.eclipse.jetty.webapp.WebAppContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServlet; +import java.io.IOException; +import java.net.InetSocketAddress; + +import static org.apache.hadoop.hdsl.HdslUtils.getHostNameFromConfigKeys; +import static org.apache.hadoop.hdsl.HdslUtils.getPortNumberFromConfigKeys; + +/** + * Base class for HTTP server of the Ozone related components. + */ +public abstract class BaseHttpServer { + + private static final Logger LOG = + LoggerFactory.getLogger(BaseHttpServer.class); + + private HttpServer2 httpServer; + private final Configuration conf; + + private InetSocketAddress httpAddress; + private InetSocketAddress httpsAddress; + + private HttpConfig.Policy policy; + + private String name; + + public BaseHttpServer(Configuration conf, String name) throws IOException { + this.name = name; + this.conf = conf; + if (isEnabled()) { + policy = DFSUtil.getHttpPolicy(conf); + if (policy.isHttpEnabled()) { + this.httpAddress = getHttpBindAddress(); + } + if (policy.isHttpsEnabled()) { + this.httpsAddress = getHttpsBindAddress(); + } + HttpServer2.Builder builder = null; + builder = DFSUtil.httpServerTemplateForNNAndJN(conf, this.httpAddress, + this.httpsAddress, name, getSpnegoPrincipal(), getKeytabFile()); + + final boolean xFrameEnabled = conf.getBoolean( + DFSConfigKeys.DFS_XFRAME_OPTION_ENABLED, + DFSConfigKeys.DFS_XFRAME_OPTION_ENABLED_DEFAULT); + + final String xFrameOptionValue = conf.getTrimmed( + DFSConfigKeys.DFS_XFRAME_OPTION_VALUE, + DFSConfigKeys.DFS_XFRAME_OPTION_VALUE_DEFAULT); + + builder.configureXFrame(xFrameEnabled).setXFrameOption(xFrameOptionValue); + + httpServer = builder.build(); + + } + + } + + /** + * Add a servlet to BaseHttpServer. + * @param servletName The name of the servlet + * @param pathSpec The path spec for the servlet + * @param clazz The servlet class + */ + protected void addServlet(String servletName, String pathSpec, + Class<? extends HttpServlet> clazz) { + httpServer.addServlet(servletName, pathSpec, clazz); + } + + /** + * Returns the WebAppContext associated with this HttpServer. + * @return WebAppContext + */ + protected WebAppContext getWebAppContext() { + return httpServer.getWebAppContext(); + } + + protected InetSocketAddress getBindAddress(String bindHostKey, + String addressKey, String bindHostDefault, int bindPortdefault) { + final Optional<String> bindHost = + getHostNameFromConfigKeys(conf, bindHostKey); + + final Optional<Integer> addressPort = + getPortNumberFromConfigKeys(conf, addressKey); + + final Optional<String> addresHost = + getHostNameFromConfigKeys(conf, addressKey); + + String hostName = bindHost.or(addresHost).or(bindHostDefault); + + return NetUtils.createSocketAddr( + hostName + ":" + addressPort.or(bindPortdefault)); + } + + /** + * Retrieve the socket address that should be used by clients to connect + * to the HTTPS web interface. + * + * @return Target InetSocketAddress for the Ozone HTTPS endpoint. + */ + public InetSocketAddress getHttpsBindAddress() { + return getBindAddress(getHttpsBindHostKey(), getHttpsAddressKey(), + getBindHostDefault(), getHttpsBindPortDefault()); + } + + /** + * Retrieve the socket address that should be used by clients to connect + * to the HTTP web interface. + * <p> + * * @return Target InetSocketAddress for the Ozone HTTP endpoint. + */ + public InetSocketAddress getHttpBindAddress() { + return getBindAddress(getHttpBindHostKey(), getHttpAddressKey(), + getBindHostDefault(), getHttpBindPortDefault()); + + } + + public void start() throws IOException { + if (httpServer != null && isEnabled()) { + httpServer.start(); + updateConnectorAddress(); + } + + } + + private boolean isEnabled() { + return conf.getBoolean(getEnabledKey(), true); + } + + public void stop() throws Exception { + if (httpServer != null) { + httpServer.stop(); + } + } + + /** + * Update the configured listen address based on the real port + * <p> + * (eg. replace :0 with real port) + */ + public void updateConnectorAddress() { + int connIdx = 0; + if (policy.isHttpEnabled()) { + httpAddress = httpServer.getConnectorAddress(connIdx++); + String realAddress = NetUtils.getHostPortString(httpAddress); + conf.set(getHttpAddressKey(), realAddress); + LOG.info( + String.format("HTTP server of %s is listening at http://%s", + name.toUpperCase(), realAddress)); + } + + if (policy.isHttpsEnabled()) { + httpsAddress = httpServer.getConnectorAddress(connIdx); + String realAddress = NetUtils.getHostPortString(httpsAddress); + conf.set(getHttpsAddressKey(), realAddress); + LOG.info( + String.format("HTTP server of %s is listening at https://%s", + name.toUpperCase(), realAddress)); + } + } + + public InetSocketAddress getHttpAddress() { + return httpAddress; + } + + public InetSocketAddress getHttpsAddress() { + return httpsAddress; + } + + protected abstract String getHttpAddressKey(); + + protected abstract String getHttpsAddressKey(); + + protected abstract String getHttpBindHostKey(); + + protected abstract String getHttpsBindHostKey(); + + protected abstract String getBindHostDefault(); + + protected abstract int getHttpBindPortDefault(); + + protected abstract int getHttpsBindPortDefault(); + + protected abstract String getKeytabFile(); + + protected abstract String getSpnegoPrincipal(); + + protected abstract String getEnabledKey(); + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServerUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServerUtils.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServerUtils.java new file mode 100644 index 0000000..f315ecb --- /dev/null +++ b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServerUtils.java @@ -0,0 +1,140 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.hadoop.hdsl.server; + +import java.io.File; +import java.net.InetSocketAddress; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hdsl.conf.OzoneConfiguration; +import org.apache.hadoop.ipc.RPC; +import org.apache.hadoop.ozone.OzoneConfigKeys; + +import com.google.common.base.Preconditions; +import org.apache.http.client.methods.HttpRequestBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Generic utilities for all HDSL/Ozone servers. + */ +public class ServerUtils { + + private static final Logger LOG = LoggerFactory.getLogger( + ServerUtils.class); + + private ServerUtils() { + } + + /** + * Checks that a given value is with a range. + * + * For example, sanitizeUserArgs(17, 3, 5, 10) + * ensures that 17 is greater/equal than 3 * 5 and less/equal to 3 * 10. + * + * @param valueTocheck - value to check + * @param baseValue - the base value that is being used. + * @param minFactor - range min - a 2 here makes us ensure that value + * valueTocheck is at least twice the baseValue. + * @param maxFactor - range max + * @return long + */ + public static long sanitizeUserArgs(long valueTocheck, long baseValue, + long minFactor, long maxFactor) + throws IllegalArgumentException { + if ((valueTocheck >= (baseValue * minFactor)) && + (valueTocheck <= (baseValue * maxFactor))) { + return valueTocheck; + } + String errMsg = String.format("%d is not within min = %d or max = " + + "%d", valueTocheck, baseValue * minFactor, baseValue * maxFactor); + throw new IllegalArgumentException(errMsg); + } + + + /** + * After starting an RPC server, updates configuration with the actual + * listening address of that server. The listening address may be different + * from the configured address if, for example, the configured address uses + * port 0 to request use of an ephemeral port. + * + * @param conf configuration to update + * @param rpcAddressKey configuration key for RPC server address + * @param addr configured address + * @param rpcServer started RPC server. + */ + public static InetSocketAddress updateRPCListenAddress( + OzoneConfiguration conf, String rpcAddressKey, + InetSocketAddress addr, RPC.Server rpcServer) { + return updateListenAddress(conf, rpcAddressKey, addr, + rpcServer.getListenerAddress()); + } + + + /** + * After starting an server, updates configuration with the actual + * listening address of that server. The listening address may be different + * from the configured address if, for example, the configured address uses + * port 0 to request use of an ephemeral port. + * + * @param conf configuration to update + * @param addressKey configuration key for RPC server address + * @param addr configured address + * @param listenAddr the real listening address. + */ + public static InetSocketAddress updateListenAddress(OzoneConfiguration conf, + String addressKey, InetSocketAddress addr, InetSocketAddress listenAddr) { + InetSocketAddress updatedAddr = new InetSocketAddress(addr.getHostString(), + listenAddr.getPort()); + conf.set(addressKey, + addr.getHostString() + ":" + listenAddr.getPort()); + return updatedAddr; + } + + + /** + * Releases a http connection if the request is not null. + * @param request + */ + public static void releaseConnection(HttpRequestBase request) { + if (request != null) { + request.releaseConnection(); + } + } + + + /** + * Checks and creates Ozone Metadir Path if it does not exist. + * + * @param conf - Configuration + * + * @return File MetaDir + */ + public static File getOzoneMetaDirPath(Configuration conf) { + String metaDirPath = conf.getTrimmed(OzoneConfigKeys + .OZONE_METADATA_DIRS); + Preconditions.checkNotNull(metaDirPath); + File dirPath = new File(metaDirPath); + if (!dirPath.exists() && !dirPath.mkdirs()) { + throw new IllegalArgumentException("Unable to create paths. Path: " + + dirPath); + } + return dirPath; + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfo.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfo.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfo.java new file mode 100644 index 0000000..f9c57ea --- /dev/null +++ b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfo.java @@ -0,0 +1,64 @@ +/* + * 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.hadoop.hdsl.server; + +/** + * Common runtime information for any service components. + * + * Note: it's intentional to not use MXBean or MBean as a suffix of the name. + * + * Most of the services extends the ServiceRuntimeInfoImpl class and also + * implements a specific MXBean interface which extends this interface. + * + * This inheritance from multiple path could confuse the jmx system and + * some jmx properties could be disappeared. + * + * The solution is to always extend this interface and use the jmx naming + * convention in the new interface.. + */ +public interface ServiceRuntimeInfo { + + /** + * Gets the version of Hadoop. + * + * @return the version + */ + String getVersion(); + + /** + * Get the version of software running on the Namenode. + * + * @return a string representing the version + */ + String getSoftwareVersion(); + + /** + * Get the compilation information which contains date, user and branch. + * + * @return the compilation information, as a JSON string. + */ + String getCompileInfo(); + + /** + * Gets the NN start time in milliseconds. + * + * @return the NN start time in msec + */ + long getStartedTimeInMillis(); + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfoImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfoImpl.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfoImpl.java new file mode 100644 index 0000000..92f00b1 --- /dev/null +++ b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/ServiceRuntimeInfoImpl.java @@ -0,0 +1,55 @@ +/* + * 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.hadoop.hdsl.server; + +import org.apache.hadoop.util.VersionInfo; + +/** + * Helper base class to report the standard version and runtime information. + * + */ +public class ServiceRuntimeInfoImpl implements ServiceRuntimeInfo { + + private long startedTimeInMillis; + + @Override + public String getVersion() { + return VersionInfo.getVersion() + ", r" + VersionInfo.getRevision(); + } + + @Override + public String getSoftwareVersion() { + return VersionInfo.getVersion(); + } + + @Override + public String getCompileInfo() { + return VersionInfo.getDate() + " by " + VersionInfo.getUser() + " from " + + VersionInfo.getBranch(); + } + + @Override + public long getStartedTimeInMillis() { + return startedTimeInMillis; + } + + public void setStartTime() { + startedTimeInMillis = System.currentTimeMillis(); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/package-info.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/package-info.java new file mode 100644 index 0000000..b38215c --- /dev/null +++ b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/hdsl/server/package-info.java @@ -0,0 +1,23 @@ +/** + * 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.hadoop.hdsl.server; + +/** + * Common server side utilities for all the hdsl/ozone server components. + */ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/OzoneHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/OzoneHttpServer.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/OzoneHttpServer.java deleted file mode 100644 index 27ca3ec..0000000 --- a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/OzoneHttpServer.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.hadoop.ozone.web; - -import com.google.common.base.Optional; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hdfs.DFSConfigKeys; -import org.apache.hadoop.hdfs.DFSUtil; -import org.apache.hadoop.http.HttpConfig; -import org.apache.hadoop.http.HttpServer2; -import org.apache.hadoop.net.NetUtils; -import org.eclipse.jetty.webapp.WebAppContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.servlet.http.HttpServlet; -import java.io.IOException; -import java.net.InetSocketAddress; - -import static org.apache.hadoop.hdsl.HdslUtils.getHostNameFromConfigKeys; -import static org.apache.hadoop.hdsl.HdslUtils.getPortNumberFromConfigKeys; - -/** - * Base class for HTTP server of the Ozone related components. - */ -public abstract class OzoneHttpServer { - - private static final Logger LOG = - LoggerFactory.getLogger(OzoneHttpServer.class); - - private HttpServer2 httpServer; - private final Configuration conf; - - private InetSocketAddress httpAddress; - private InetSocketAddress httpsAddress; - - private HttpConfig.Policy policy; - - private String name; - - public OzoneHttpServer(Configuration conf, String name) throws IOException { - this.name = name; - this.conf = conf; - if (isEnabled()) { - policy = DFSUtil.getHttpPolicy(conf); - if (policy.isHttpEnabled()) { - this.httpAddress = getHttpBindAddress(); - } - if (policy.isHttpsEnabled()) { - this.httpsAddress = getHttpsBindAddress(); - } - HttpServer2.Builder builder = null; - builder = DFSUtil.httpServerTemplateForNNAndJN(conf, this.httpAddress, - this.httpsAddress, name, getSpnegoPrincipal(), getKeytabFile()); - - final boolean xFrameEnabled = conf.getBoolean( - DFSConfigKeys.DFS_XFRAME_OPTION_ENABLED, - DFSConfigKeys.DFS_XFRAME_OPTION_ENABLED_DEFAULT); - - final String xFrameOptionValue = conf.getTrimmed( - DFSConfigKeys.DFS_XFRAME_OPTION_VALUE, - DFSConfigKeys.DFS_XFRAME_OPTION_VALUE_DEFAULT); - - builder.configureXFrame(xFrameEnabled).setXFrameOption(xFrameOptionValue); - - httpServer = builder.build(); - - } - - } - - /** - * Add a servlet to OzoneHttpServer. - * @param servletName The name of the servlet - * @param pathSpec The path spec for the servlet - * @param clazz The servlet class - */ - protected void addServlet(String servletName, String pathSpec, - Class<? extends HttpServlet> clazz) { - httpServer.addServlet(servletName, pathSpec, clazz); - } - - /** - * Returns the WebAppContext associated with this HttpServer. - * @return WebAppContext - */ - protected WebAppContext getWebAppContext() { - return httpServer.getWebAppContext(); - } - - protected InetSocketAddress getBindAddress(String bindHostKey, - String addressKey, String bindHostDefault, int bindPortdefault) { - final Optional<String> bindHost = - getHostNameFromConfigKeys(conf, bindHostKey); - - final Optional<Integer> addressPort = - getPortNumberFromConfigKeys(conf, addressKey); - - final Optional<String> addresHost = - getHostNameFromConfigKeys(conf, addressKey); - - String hostName = bindHost.or(addresHost).or(bindHostDefault); - - return NetUtils.createSocketAddr( - hostName + ":" + addressPort.or(bindPortdefault)); - } - - /** - * Retrieve the socket address that should be used by clients to connect - * to the HTTPS web interface. - * - * @return Target InetSocketAddress for the Ozone HTTPS endpoint. - */ - public InetSocketAddress getHttpsBindAddress() { - return getBindAddress(getHttpsBindHostKey(), getHttpsAddressKey(), - getBindHostDefault(), getHttpsBindPortDefault()); - } - - /** - * Retrieve the socket address that should be used by clients to connect - * to the HTTP web interface. - * <p> - * * @return Target InetSocketAddress for the Ozone HTTP endpoint. - */ - public InetSocketAddress getHttpBindAddress() { - return getBindAddress(getHttpBindHostKey(), getHttpAddressKey(), - getBindHostDefault(), getHttpBindPortDefault()); - - } - - public void start() throws IOException { - if (httpServer != null && isEnabled()) { - httpServer.start(); - updateConnectorAddress(); - } - - } - - private boolean isEnabled() { - return conf.getBoolean(getEnabledKey(), true); - } - - public void stop() throws Exception { - if (httpServer != null) { - httpServer.stop(); - } - } - - /** - * Update the configured listen address based on the real port - * <p> - * (eg. replace :0 with real port) - */ - public void updateConnectorAddress() { - int connIdx = 0; - if (policy.isHttpEnabled()) { - httpAddress = httpServer.getConnectorAddress(connIdx++); - String realAddress = NetUtils.getHostPortString(httpAddress); - conf.set(getHttpAddressKey(), realAddress); - LOG.info( - String.format("HTTP server of %s is listening at http://%s", - name.toUpperCase(), realAddress)); - } - - if (policy.isHttpsEnabled()) { - httpsAddress = httpServer.getConnectorAddress(connIdx); - String realAddress = NetUtils.getHostPortString(httpsAddress); - conf.set(getHttpsAddressKey(), realAddress); - LOG.info( - String.format("HTTP server of %s is listening at https://%s", - name.toUpperCase(), realAddress)); - } - } - - public InetSocketAddress getHttpAddress() { - return httpAddress; - } - - public InetSocketAddress getHttpsAddress() { - return httpsAddress; - } - - protected abstract String getHttpAddressKey(); - - protected abstract String getHttpsAddressKey(); - - protected abstract String getHttpBindHostKey(); - - protected abstract String getHttpsBindHostKey(); - - protected abstract String getBindHostDefault(); - - protected abstract int getHttpBindPortDefault(); - - protected abstract int getHttpsBindPortDefault(); - - protected abstract String getKeytabFile(); - - protected abstract String getSpnegoPrincipal(); - - protected abstract String getEnabledKey(); - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/package-info.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/package-info.java deleted file mode 100644 index cb0de5e..0000000 --- a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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.hadoop.ozone.web; - -/** - * Classes related to the ozone web interface. - */ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/ServerUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/ServerUtils.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/ServerUtils.java deleted file mode 100644 index 016d0f5..0000000 --- a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/ServerUtils.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.hadoop.ozone.web.util; - -import java.io.File; -import java.net.InetSocketAddress; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hdsl.conf.OzoneConfiguration; -import org.apache.hadoop.ipc.RPC; -import org.apache.hadoop.ozone.OzoneConfigKeys; - -import com.google.common.base.Preconditions; -import org.apache.http.client.methods.HttpRequestBase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Generic utilities for all HDSL/Ozone servers. - */ -public class ServerUtils { - - private static final Logger LOG = LoggerFactory.getLogger( - ServerUtils.class); - - private ServerUtils() { - } - - /** - * Checks that a given value is with a range. - * - * For example, sanitizeUserArgs(17, 3, 5, 10) - * ensures that 17 is greater/equal than 3 * 5 and less/equal to 3 * 10. - * - * @param valueTocheck - value to check - * @param baseValue - the base value that is being used. - * @param minFactor - range min - a 2 here makes us ensure that value - * valueTocheck is at least twice the baseValue. - * @param maxFactor - range max - * @return long - */ - public static long sanitizeUserArgs(long valueTocheck, long baseValue, - long minFactor, long maxFactor) - throws IllegalArgumentException { - if ((valueTocheck >= (baseValue * minFactor)) && - (valueTocheck <= (baseValue * maxFactor))) { - return valueTocheck; - } - String errMsg = String.format("%d is not within min = %d or max = " + - "%d", valueTocheck, baseValue * minFactor, baseValue * maxFactor); - throw new IllegalArgumentException(errMsg); - } - - - /** - * After starting an RPC server, updates configuration with the actual - * listening address of that server. The listening address may be different - * from the configured address if, for example, the configured address uses - * port 0 to request use of an ephemeral port. - * - * @param conf configuration to update - * @param rpcAddressKey configuration key for RPC server address - * @param addr configured address - * @param rpcServer started RPC server. - */ - public static InetSocketAddress updateRPCListenAddress( - OzoneConfiguration conf, String rpcAddressKey, - InetSocketAddress addr, RPC.Server rpcServer) { - return updateListenAddress(conf, rpcAddressKey, addr, - rpcServer.getListenerAddress()); - } - - - /** - * After starting an server, updates configuration with the actual - * listening address of that server. The listening address may be different - * from the configured address if, for example, the configured address uses - * port 0 to request use of an ephemeral port. - * - * @param conf configuration to update - * @param addressKey configuration key for RPC server address - * @param addr configured address - * @param listenAddr the real listening address. - */ - public static InetSocketAddress updateListenAddress(OzoneConfiguration conf, - String addressKey, InetSocketAddress addr, InetSocketAddress listenAddr) { - InetSocketAddress updatedAddr = new InetSocketAddress(addr.getHostString(), - listenAddr.getPort()); - conf.set(addressKey, - addr.getHostString() + ":" + listenAddr.getPort()); - return updatedAddr; - } - - - /** - * Releases a http connection if the request is not null. - * @param request - */ - public static void releaseConnection(HttpRequestBase request) { - if (request != null) { - request.releaseConnection(); - } - } - - - /** - * Checks and creates Ozone Metadir Path if it does not exist. - * - * @param conf - Configuration - * - * @return File MetaDir - */ - public static File getOzoneMetaDirPath(Configuration conf) { - String metaDirPath = conf.getTrimmed(OzoneConfigKeys - .OZONE_METADATA_DIRS); - Preconditions.checkNotNull(metaDirPath); - File dirPath = new File(metaDirPath); - if (!dirPath.exists() && !dirPath.mkdirs()) { - throw new IllegalArgumentException("Unable to create paths. Path: " + - dirPath); - } - return dirPath; - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/package-info.java b/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/package-info.java deleted file mode 100644 index a28a6d4..0000000 --- a/hadoop-hdsl/framework/src/main/java/org/apache/hadoop/ozone/web/util/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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.hadoop.ozone.web.util; - -/** - * Shared utilities for both Ozone/HDSL server side components. - */ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/framework/src/test/java/org/apache/hadoop/hdsl/server/TestBaseHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/framework/src/test/java/org/apache/hadoop/hdsl/server/TestBaseHttpServer.java b/hadoop-hdsl/framework/src/test/java/org/apache/hadoop/hdsl/server/TestBaseHttpServer.java new file mode 100644 index 0000000..fcd5f7f --- /dev/null +++ b/hadoop-hdsl/framework/src/test/java/org/apache/hadoop/hdsl/server/TestBaseHttpServer.java @@ -0,0 +1,99 @@ +/** + * 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.hadoop.hdsl.server; + +import org.apache.hadoop.conf.Configuration; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Test Common ozone/hdsl web methods. + */ +public class TestBaseHttpServer { + @Test + public void getBindAddress() throws Exception { + Configuration conf = new Configuration(); + conf.set("enabled", "false"); + + BaseHttpServer baseHttpServer = new BaseHttpServer(conf, "test") { + @Override + protected String getHttpAddressKey() { + return null; + } + + @Override + protected String getHttpsAddressKey() { + return null; + } + + @Override + protected String getHttpBindHostKey() { + return null; + } + + @Override + protected String getHttpsBindHostKey() { + return null; + } + + @Override + protected String getBindHostDefault() { + return null; + } + + @Override + protected int getHttpBindPortDefault() { + return 0; + } + + @Override + protected int getHttpsBindPortDefault() { + return 0; + } + + @Override + protected String getKeytabFile() { + return null; + } + + @Override + protected String getSpnegoPrincipal() { + return null; + } + + @Override + protected String getEnabledKey() { + return "enabled"; + } + }; + + conf.set("addresskey", "0.0.0.0:1234"); + + Assert.assertEquals("/0.0.0.0:1234", baseHttpServer + .getBindAddress("bindhostkey", "addresskey", + "default", 65).toString()); + + conf.set("bindhostkey", "1.2.3.4"); + + Assert.assertEquals("/1.2.3.4:1234", baseHttpServer + .getBindAddress("bindhostkey", "addresskey", + "default", 65).toString()); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMMXBean.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMMXBean.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMMXBean.java index 336ed44..3b31d9f 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMMXBean.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMMXBean.java @@ -21,7 +21,7 @@ package org.apache.hadoop.ozone.scm; import java.util.Map; import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.jmx.ServiceRuntimeInfo; +import org.apache.hadoop.hdsl.server.ServiceRuntimeInfo; /** * http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMStorage.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMStorage.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMStorage.java index b38741d..4a6d4c0 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMStorage.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/SCMStorage.java @@ -27,7 +27,7 @@ import org.apache.hadoop.hdsl.protocol.proto.HdslProtos.NodeType; import static org.apache.hadoop.ozone.OzoneConsts.SCM_ID; import static org.apache.hadoop.ozone.OzoneConsts.STORAGE_DIR; -import static org.apache.hadoop.ozone.web.util.ServerUtils.getOzoneMetaDirPath; +import static org.apache.hadoop.hdsl.server.ServerUtils.getOzoneMetaDirPath; /** * SCMStorage is responsible for management of the StorageDirectories used by http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java index 88391e2..cef8808 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java @@ -33,7 +33,7 @@ import org.apache.hadoop.hdsl.protocol.DatanodeDetails; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.ipc.ProtobufRpcEngine; import org.apache.hadoop.ipc.RPC; -import org.apache.hadoop.jmx.ServiceRuntimeInfoImpl; +import org.apache.hadoop.hdsl.server.ServiceRuntimeInfoImpl; import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.util.MBeans; import org.apache.hadoop.ozone.OzoneConfigKeys; @@ -103,7 +103,7 @@ import static org.apache.hadoop.ozone.scm.HdslServerUtil .getScmClientBindAddress; import static org.apache.hadoop.ozone.scm.HdslServerUtil .getScmDataNodeBindAddress; -import static org.apache.hadoop.ozone.web.util.ServerUtils +import static org.apache.hadoop.hdsl.server.ServerUtils .updateRPCListenAddress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManagerHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManagerHttpServer.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManagerHttpServer.java index 62c871c..0dcf364 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManagerHttpServer.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManagerHttpServer.java @@ -18,8 +18,8 @@ package org.apache.hadoop.ozone.scm; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hdsl.server.BaseHttpServer; import org.apache.hadoop.ozone.OzoneConfigKeys; -import org.apache.hadoop.ozone.web.OzoneHttpServer; import org.apache.hadoop.scm.ScmConfigKeys; import java.io.IOException; @@ -27,7 +27,7 @@ import java.io.IOException; /** * HttpServer2 wrapper for the Ozone Storage Container Manager. */ -public class StorageContainerManagerHttpServer extends OzoneHttpServer { +public class StorageContainerManagerHttpServer extends BaseHttpServer { public StorageContainerManagerHttpServer(Configuration conf) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java index e368f73..36f73cc 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java @@ -36,7 +36,7 @@ import org.apache.hadoop.utils.BatchOperation; import org.apache.hadoop.utils.MetadataStore; import org.apache.hadoop.utils.MetadataStoreBuilder; -import static org.apache.hadoop.ozone.web.util.ServerUtils.getOzoneMetaDirPath; +import static org.apache.hadoop.hdsl.server.ServerUtils.getOzoneMetaDirPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/DeletedBlockLogImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/DeletedBlockLogImpl.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/DeletedBlockLogImpl.java index fe3bbce..77c59b0 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/DeletedBlockLogImpl.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/block/DeletedBlockLogImpl.java @@ -29,7 +29,7 @@ import org.apache.hadoop.utils.MetadataKeyFilters.MetadataKeyFilter; import org.apache.hadoop.utils.MetadataStore; import org.apache.hadoop.utils.MetadataStoreBuilder; -import static org.apache.hadoop.ozone.web.util.ServerUtils.getOzoneMetaDirPath; +import static org.apache.hadoop.hdsl.server.ServerUtils.getOzoneMetaDirPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java index 112e58e..364bf7d 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java @@ -43,7 +43,7 @@ import org.apache.hadoop.utils.MetadataKeyFilters.MetadataKeyFilter; import org.apache.hadoop.utils.MetadataStore; import org.apache.hadoop.utils.MetadataStoreBuilder; -import static org.apache.hadoop.ozone.web.util.ServerUtils.getOzoneMetaDirPath; +import static org.apache.hadoop.hdsl.server.ServerUtils.getOzoneMetaDirPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java ---------------------------------------------------------------------- diff --git a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java index a8b9c35..f9b193f 100644 --- a/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java +++ b/hadoop-hdsl/server-scm/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java @@ -28,7 +28,7 @@ import org.apache.hadoop.ozone.scm.exceptions.SCMException; import org.apache.hadoop.utils.MetadataStore; import org.apache.hadoop.utils.MetadataStoreBuilder; -import static org.apache.hadoop.ozone.web.util.ServerUtils.getOzoneMetaDirPath; +import static org.apache.hadoop.hdsl.server.ServerUtils.getOzoneMetaDirPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java index a5dee9d..1d5edd2 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java @@ -30,7 +30,7 @@ import org.apache.hadoop.ozone.web.response.BucketInfo; import org.apache.hadoop.ozone.web.response.KeyInfo; import org.apache.hadoop.ozone.web.response.ListKeys; -import static org.apache.hadoop.ozone.web.util.ServerUtils.releaseConnection; +import static org.apache.hadoop.hdsl.server.ServerUtils.releaseConnection; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpDelete; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java index f88dfe0..8ee363c 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java @@ -31,7 +31,7 @@ import org.apache.hadoop.ozone.web.response.VolumeInfo; import org.apache.hadoop.ozone.web.utils.OzoneUtils; import org.apache.hadoop.util.Time; -import static org.apache.hadoop.ozone.web.util.ServerUtils.releaseConnection; +import static org.apache.hadoop.hdsl.server.ServerUtils.releaseConnection; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpDelete; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java index ac853d2..14488a3 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java @@ -31,7 +31,7 @@ import org.apache.hadoop.ozone.web.response.VolumeInfo; import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.web.utils.OzoneUtils; -import static org.apache.hadoop.ozone.web.util.ServerUtils.releaseConnection; +import static org.apache.hadoop.hdsl.server.ServerUtils.releaseConnection; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpDelete; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestOzoneHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestOzoneHttpServer.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestOzoneHttpServer.java deleted file mode 100644 index e4c95a5..0000000 --- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/web/TestOzoneHttpServer.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * 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.hadoop.ozone.web; - -import org.apache.hadoop.hdsl.conf.OzoneConfiguration; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Common ozone web methods. - */ -public class TestOzoneHttpServer { - @Test - public void getBindAddress() throws Exception { - OzoneConfiguration conf = new OzoneConfiguration(); - conf.set("enabled", "false"); - - OzoneHttpServer ozoneHttpServer = new OzoneHttpServer(conf, "test") { - @Override - protected String getHttpAddressKey() { - return null; - } - - @Override - protected String getHttpsAddressKey() { - return null; - } - - @Override - protected String getHttpBindHostKey() { - return null; - } - - @Override - protected String getHttpsBindHostKey() { - return null; - } - - @Override - protected String getBindHostDefault() { - return null; - } - - @Override - protected int getHttpBindPortDefault() { - return 0; - } - - @Override - protected int getHttpsBindPortDefault() { - return 0; - } - - @Override - protected String getKeytabFile() { - return null; - } - - @Override - protected String getSpnegoPrincipal() { - return null; - } - - @Override - protected String getEnabledKey() { - return "enabled"; - } - }; - - conf.set("addresskey", "0.0.0.0:1234"); - - Assert.assertEquals("/0.0.0.0:1234", ozoneHttpServer - .getBindAddress("bindhostkey", "addresskey", - "default", 65).toString()); - - conf.set("bindhostkey", "1.2.3.4"); - - Assert.assertEquals("/1.2.3.4:1234", ozoneHttpServer - .getBindAddress("bindhostkey", "addresskey", - "default", 65).toString()); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMXBean.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMXBean.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMXBean.java index 42331f6..2e1fbd3 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMXBean.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMXBean.java @@ -19,7 +19,7 @@ package org.apache.hadoop.ozone.ksm; import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.jmx.ServiceRuntimeInfo; +import org.apache.hadoop.hdsl.server.ServiceRuntimeInfo; /** * This is the JMX management interface for ksm information. http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java index 21e02a2..f241de6 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java @@ -65,7 +65,7 @@ import static org.apache.hadoop.ozone.ksm.KSMConfigKeys .OZONE_KSM_DB_CACHE_SIZE_DEFAULT; import static org.apache.hadoop.ozone.ksm.KSMConfigKeys .OZONE_KSM_DB_CACHE_SIZE_MB; -import static org.apache.hadoop.ozone.web.util.ServerUtils.getOzoneMetaDirPath; +import static org.apache.hadoop.hdsl.server.ServerUtils.getOzoneMetaDirPath; /** * KSM metadata manager interface. http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMStorage.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMStorage.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMStorage.java index 6e48952..d444e5c 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMStorage.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KSMStorage.java @@ -26,7 +26,7 @@ import org.apache.hadoop.ozone.common.Storage; import org.apache.hadoop.hdsl.protocol.proto.HdslProtos.NodeType; import static org.apache.hadoop.ozone.OzoneConsts.SCM_ID; -import static org.apache.hadoop.ozone.web.util.ServerUtils.getOzoneMetaDirPath; +import static org.apache.hadoop.hdsl.server.ServerUtils.getOzoneMetaDirPath; /** * KSMStorage is responsible for management of the StorageDirectories used by http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java index ef61005..2c00bec 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java @@ -25,7 +25,7 @@ import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.ipc.Client; import org.apache.hadoop.ipc.ProtobufRpcEngine; import org.apache.hadoop.ipc.RPC; -import org.apache.hadoop.jmx.ServiceRuntimeInfoImpl; +import org.apache.hadoop.hdsl.server.ServiceRuntimeInfoImpl; import org.apache.hadoop.ozone.common.Storage.StorageState; import org.apache.hadoop.ozone.ksm.exceptions.KSMException; import org.apache.hadoop.ozone.ksm.helpers.KsmBucketArgs; @@ -67,7 +67,7 @@ import static org.apache.hadoop.hdsl.HdslUtils.getScmAddressForBlockClients; import static org.apache.hadoop.hdsl.HdslUtils.getScmAddressForClients; import static org.apache.hadoop.hdsl.HdslUtils.isHdslEnabled; import static org.apache.hadoop.ozone.KsmUtils.getKsmAddress; -import static org.apache.hadoop.ozone.web.util.ServerUtils +import static org.apache.hadoop.hdsl.server.ServerUtils .updateRPCListenAddress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac77b180/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManagerHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManagerHttpServer.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManagerHttpServer.java index b229c89..3cf4360 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManagerHttpServer.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManagerHttpServer.java @@ -20,14 +20,14 @@ package org.apache.hadoop.ozone.ksm; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.ozone.OzoneConfigKeys; import org.apache.hadoop.ozone.OzoneConsts; -import org.apache.hadoop.ozone.web.OzoneHttpServer; +import org.apache.hadoop.hdsl.server.BaseHttpServer; import java.io.IOException; /** * HttpServer wrapper for the KeySpaceManager. */ -public class KeySpaceManagerHttpServer extends OzoneHttpServer { +public class KeySpaceManagerHttpServer extends BaseHttpServer { public KeySpaceManagerHttpServer(Configuration conf, KeySpaceManager ksm) throws IOException { --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org