Github user HeartSaVioR commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2204#discussion_r128404026
  
    --- Diff: 
storm-webapp/src/main/java/org/apache/storm/daemon/logviewer/LogviewerServer.java
 ---
    @@ -0,0 +1,182 @@
    +/*
    + * 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.storm.daemon.logviewer;
    +
    +import static org.apache.storm.DaemonConfig.UI_HEADER_BUFFER_BYTES;
    +
    +import com.codahale.metrics.Meter;
    +import com.google.common.annotations.VisibleForTesting;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.util.Arrays;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.storm.DaemonConfig;
    +import org.apache.storm.daemon.logviewer.utils.DirectoryCleaner;
    +import org.apache.storm.daemon.logviewer.utils.LogCleaner;
    +import org.apache.storm.daemon.logviewer.utils.WorkerLogs;
    +import org.apache.storm.daemon.logviewer.webapp.LogviewerApplication;
    +import org.apache.storm.metric.StormMetricsRegistry;
    +import org.apache.storm.ui.FilterConfiguration;
    +import org.apache.storm.ui.UIHelpers;
    +import org.apache.storm.utils.ConfigUtils;
    +import org.apache.storm.utils.ObjectReader;
    +import org.apache.storm.utils.Utils;
    +import org.eclipse.jetty.server.Server;
    +import org.eclipse.jetty.servlet.DefaultServlet;
    +import org.eclipse.jetty.servlet.ServletContextHandler;
    +import org.eclipse.jetty.servlet.ServletHolder;
    +import org.eclipse.jetty.util.resource.Resource;
    +import org.glassfish.jersey.servlet.ServletContainer;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * The main entry of Logviewer.
    + */
    +public class LogviewerServer implements AutoCloseable {
    +    private static final Logger LOG = 
LoggerFactory.getLogger(LogviewerServer.class);
    +    private static final Meter meterShutdownCalls = 
StormMetricsRegistry.registerMeter("drpc:num-shutdown-calls");
    +    public static final String STATIC_RESOURCE_DIRECTORY_PATH = "./public";
    +
    +    private static Server mkHttpServer(Map<String, Object> conf) {
    +        Integer logviewerHttpPort = (Integer) 
conf.get(DaemonConfig.LOGVIEWER_PORT);
    +        Server ret = null;
    +        if (logviewerHttpPort != null && logviewerHttpPort >= 0) {
    +            LOG.info("Starting Logviewer HTTP servers...");
    +            Integer headerBufferSize = 
ObjectReader.getInt(conf.get(UI_HEADER_BUFFER_BYTES));
    +            String filterClass = (String) 
(conf.get(DaemonConfig.UI_FILTER));
    +            @SuppressWarnings("unchecked")
    +            Map<String, String> filterParams = (Map<String, String>) 
(conf.get(DaemonConfig.UI_FILTER_PARAMS));
    +            FilterConfiguration filterConfiguration = new 
FilterConfiguration(filterClass, filterParams);
    +            final List<FilterConfiguration> filterConfigurations = 
Arrays.asList(filterConfiguration);
    +
    +            final Integer httpsPort = 
ObjectReader.getInt(conf.get(DaemonConfig.LOGVIEWER_HTTPS_PORT), 0);
    +            final String httpsKsPath = (String) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_KEYSTORE_PATH));
    +            final String httpsKsPassword = (String) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_KEYSTORE_PASSWORD));
    +            final String httpsKsType = (String) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_KEYSTORE_TYPE));
    +            final String httpsKeyPassword = (String) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_KEY_PASSWORD));
    +            final String httpsTsPath = (String) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_TRUSTSTORE_PATH));
    +            final String httpsTsPassword = (String) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_TRUSTSTORE_PASSWORD));
    +            final String httpsTsType = (String) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_TRUSTSTORE_TYPE));
    +            final Boolean httpsWantClientAuth = (Boolean) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_WANT_CLIENT_AUTH));
    +            final Boolean httpsNeedClientAuth = (Boolean) 
(conf.get(DaemonConfig.LOGVIEWER_HTTPS_NEED_CLIENT_AUTH));
    +
    +            //TODO a better way to do this would be great.
    --- End diff --
    
    The comment was copied and pasted from DRPCServer.
    
    While porting I thought about how to do it better, but no idea given that 
LogviewerApplication instance is generated dynamically. It may be possible to 
not passing config map and re-read storm configuration in LogviewerApplication, 
but it is duplicated effort and we will not be able to inject other config map 
in unit test. 
    
    Maybe we could just remove the TODO comment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to