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

    https://github.com/apache/storm/pull/1139#discussion_r53723573
  
    --- Diff: storm-core/src/jvm/org/apache/storm/ui/UIHelpers.java ---
    @@ -0,0 +1,301 @@
    +/**
    + * 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.storm.ui;
    +
    +import clojure.lang.*;
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.ImmutableMap;
    +import org.apache.commons.lang.StringEscapeUtils;
    +import org.apache.storm.generated.ExecutorInfo;
    +import org.apache.storm.logging.filters.AccessLoggingFilter;
    +import org.apache.storm.utils.Utils;
    +import org.eclipse.jetty.server.Connector;
    +import org.eclipse.jetty.server.DispatcherType;
    +import org.eclipse.jetty.server.Server;
    +import org.eclipse.jetty.server.nio.SelectChannelConnector;
    +import org.eclipse.jetty.server.ssl.SslSocketConnector;
    +import org.eclipse.jetty.servlet.FilterHolder;
    +import org.eclipse.jetty.servlet.FilterMapping;
    +import org.eclipse.jetty.servlet.ServletContextHandler;
    +import org.eclipse.jetty.servlet.ServletHolder;
    +import org.eclipse.jetty.servlets.CrossOriginFilter;
    +import org.eclipse.jetty.util.ssl.SslContextFactory;
    +import org.json.simple.JSONValue;
    +
    +import javax.servlet.Servlet;
    +import java.io.PrintWriter;
    +import java.io.StringWriter;
    +import java.net.URLEncoder;
    +import java.util.*;
    +
    +public class UIHelpers {
    +
    +    private static final String[][] PRETTY_SEC_DIVIDERS = {
    +            new String[]{"s", "60"},
    +            new String[]{"m", "60"},
    +            new String[]{"h", "24"},
    +            new String[]{"d", null}};
    +
    +    public static String prettyUptimeSec(String sec) {
    +        return prettyUptimeSec(Integer.parseInt(sec));
    +    }
    +
    +    public static String prettyUptimeSec(int secs) {
    +        LinkedList<String> tmp = new LinkedList<>();
    +        int val = secs;
    +        for (String[] dividers : PRETTY_SEC_DIVIDERS) {
    +            if (val > 0) {
    +                if (dividers[1] != null) {
    +                    int div = Integer.parseInt(dividers[1]);
    +                    tmp.addFirst(val % div + dividers[0]);
    +                    val = val / div;
    +                } else {
    +                    tmp.addFirst(val + dividers[0]);
    +                }
    +            }
    +        }
    +        return Joiner.on(" ").join(tmp);
    +    }
    +
    --- End diff --
    
    I know "pretty-uptime-ms" is never be called. But it is API function which 
can be called by others.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to