Class UIHelpers

java.lang.Object
org.apache.storm.daemon.ui.UIHelpers

public class UIHelpers extends Object
  • Constructor Details

    • UIHelpers

      public UIHelpers()
  • Method Details

    • prettyUptimeStr

      public static String prettyUptimeStr(String val, Object[][] dividers)
      Prettify uptime string.
      Parameters:
      val - val.
      dividers - dividers.
      Returns:
      prettified uptime string.
    • prettyUptimeSec

      public static String prettyUptimeSec(String sec)
      Prettify uptime string.
      Parameters:
      sec - uptime in seconds.
      Returns:
      prettified uptime string.
    • prettyUptimeSec

      public static String prettyUptimeSec(int secs)
      prettyUptimeSec.
      Parameters:
      secs - secs
      Returns:
      prettyUptimeSec
    • prettyUptimeMs

      public static String prettyUptimeMs(String ms)
      prettyUptimeMs.
      Parameters:
      ms - ms
      Returns:
      prettyUptimeMs
    • prettyUptimeMs

      public static String prettyUptimeMs(int ms)
      prettyUptimeMs.
      Parameters:
      ms - ms
      Returns:
      prettyUptimeMs
    • urlFormat

      public static String urlFormat(String fmt, Object... args)
      url formatter for log links.
      Parameters:
      fmt - string format
      args - hostname and other arguments.
      Returns:
      string formatter
    • prettyExecutorInfo

      public static String prettyExecutorInfo(ExecutorInfo e)
      Prettified executor info.
      Parameters:
      e - from Nimbus call
      Returns:
      prettified executor info string
    • unauthorizedUserJson

      public static Map<String,Object> unauthorizedUserJson(String user)
      Unauthorized user json.
      Parameters:
      user - User id.
      Returns:
      Unauthorized user json.
    • configSsl

      public static void configSsl(org.eclipse.jetty.server.Server server, Integer port, String ksPath, String ksPassword, String ksType, String keyPassword, String tsPath, String tsPassword, String tsType, Boolean needClientAuth, Boolean wantClientAuth, boolean enableSslReload)
    • configSsl

      public static void configSsl(org.eclipse.jetty.server.Server server, Integer port, String ksPath, String ksPassword, String ksType, String keyPassword, String tsPath, String tsPassword, String tsType, Boolean needClientAuth, Boolean wantClientAuth, Integer headerBufferSize, boolean enableSslReload)
      configSsl.
      Parameters:
      server - server
      port - port
      ksPath - ksPath
      ksPassword - ksPassword
      ksType - ksType
      keyPassword - keyPassword
      tsPath - tsPath
      tsPassword - tsPassword
      tsType - tsType
      needClientAuth - needClientAuth
      wantClientAuth - wantClientAuth
      headerBufferSize - headerBufferSize
      enableSslReload - enable ssl reload
    • corsFilterHandle

      public static org.eclipse.jetty.servlet.FilterHolder corsFilterHandle()
      corsFilterHandle.
      Returns:
      corsFilterHandle
    • mkAccessLoggingFilterHandle

      public static org.eclipse.jetty.servlet.FilterHolder mkAccessLoggingFilterHandle()
      mkAccessLoggingFilterHandle.
      Returns:
      mkAccessLoggingFilterHandle
    • configFilter

      public static void configFilter(org.eclipse.jetty.server.Server server, javax.servlet.Servlet servlet, List<FilterConfiguration> filtersConfs)
    • configFilter

      public static void configFilter(org.eclipse.jetty.server.Server server, javax.servlet.Servlet servlet, List<FilterConfiguration> filtersConfs, Map<String,String> params)
      Config filter.
      Parameters:
      server - Server
      servlet - Servlet
      filtersConfs - FiltersConfs
      params - Filter params
    • configFilters

      public static void configFilters(org.eclipse.jetty.servlet.ServletContextHandler context, List<FilterConfiguration> filtersConfs)
      Config filters.
      Parameters:
      context - Servlet context
      filtersConfs - filter confs
    • jettyCreateServer

      public static org.eclipse.jetty.server.Server jettyCreateServer(Integer port, String host, Integer httpsPort, Boolean disableHttpBinding)
      Construct a Jetty Server instance.
    • jettyCreateServer

      public static org.eclipse.jetty.server.Server jettyCreateServer(Integer port, String host, Integer httpsPort, Integer headerBufferSize, Boolean disableHttpBinding)
      Construct a Jetty Server instance.
    • stormRunJetty

      public static void stormRunJetty(Integer port, String host, Integer httpsPort, Integer headerBufferSize, IConfigurator configurator) throws Exception
      Modified version of run-jetty Assumes configurator sets handler.
      Throws:
      Exception
    • stormRunJetty

      public static void stormRunJetty(Integer port, Integer headerBufferSize, IConfigurator configurator) throws Exception
      Throws:
      Exception
    • wrapJsonInCallback

      public static String wrapJsonInCallback(String callback, String response)
      wrapJsonInCallback.
      Parameters:
      callback - callbackParameterName
      response - response
      Returns:
      wrapJsonInCallback
    • getJsonResponseHeaders

      public static Map getJsonResponseHeaders(String callback, Map headers)
      getJsonResponseHeaders.
      Parameters:
      callback - callbackParameterName
      headers - headers
      Returns:
      getJsonResponseHeaders
    • getJsonResponseBody

      public static String getJsonResponseBody(Object data, String callback, boolean needSerialize)
    • exceptionToJson

      public static Map exceptionToJson(Exception ex, int statusCode)
      Converts exception into json map.
      Parameters:
      ex - Exception to be converted.
      statusCode - Status code to be returned.
      Returns:
      Map to be converted into json.
    • makeStandardResponse

      public static javax.ws.rs.core.Response makeStandardResponse(Object data, String callback)
    • makeStandardResponse

      public static javax.ws.rs.core.Response makeStandardResponse(Object data, String callback, javax.ws.rs.core.Response.Status status)
    • makeStandardResponse

      public static javax.ws.rs.core.Response makeStandardResponse(Object data, String callback, boolean needsSerialization, javax.ws.rs.core.Response.Status status)
      makeStandardResponse.
      Parameters:
      data - data
      callback - callbackParameterName
      needsSerialization - needsSerialization
      Returns:
      makeStandardResponse
    • getClusterSummary

      public static Map<String,Object> getClusterSummary(ClusterSummary clusterSummary, String user, Map<String,Object> conf)
      Converts thrift call result into map fit for UI/api.
      Parameters:
      clusterSummary - Obtained from Nimbus.
      user - User Making request
      conf - Storm Conf
      Returns:
      Cluster Summary for display on UI/monitoring purposes via API
    • unpackOwnerResourceSummary

      public static Map<String,Object> unpackOwnerResourceSummary(OwnerResourceSummary ownerResourceSummary)
      Prettify OwnerResourceSummary.
      Parameters:
      ownerResourceSummary - ownerResourceSummary
      Returns:
      Map of prettified OwnerResourceSummary.
    • getOwnerResourceSummaries

      public static Map<String,Object> getOwnerResourceSummaries(List<OwnerResourceSummary> ownerResourceSummaries, Map<String,Object> conf)
      Get prettified ownerResourceSummaries.
      Parameters:
      ownerResourceSummaries - ownerResourceSummaries from thrift call
      conf - Storm conf
      Returns:
      map to be converted to json.
    • getTopologyMap

      public static Map<String,Object> getTopologyMap(TopologySummary topologySummary)
      getTopologyMap.
      Parameters:
      topologySummary - topologySummary
      Returns:
      getTopologyMap
    • getOwnerResourceSummary

      public static Map<String,Object> getOwnerResourceSummary(List<OwnerResourceSummary> ownerResourceSummaries, Nimbus.Iface client, String id, Map<String,Object> config) throws org.apache.storm.thrift.TException
      Get a specific owner resource summary.
      Parameters:
      ownerResourceSummaries - Result from thrift call.
      client - client
      id - Owner id.
      config - Storm conf.
      Returns:
      prettified owner resource summary.
      Throws:
      org.apache.storm.thrift.TException
    • getLogviewerLink

      public static String getLogviewerLink(String host, String fname, Map<String,Object> config, int port)
      getLogviewerLink.
      Parameters:
      host - host
      fname - fname
      config - config
      port - port
      Returns:
      getLogviewerLink.
    • getNimbusLogLink

      public static String getNimbusLogLink(String host, Map<String,Object> config)
      Get log link to nimbus log.
      Parameters:
      host - nimbus host name
      config - storm config
      Returns:
      log link.
    • getSupervisorLogLink

      public static String getSupervisorLogLink(String host, Map<String,Object> config)
      Get log link to supervisor log.
      Parameters:
      host - supervisor host name
      config - storm config
      Returns:
      log link.
    • getWorkerLogLink

      public static String getWorkerLogLink(String host, int port, Map<String,Object> config, String topologyId)
      Get log link to supervisor log.
      Parameters:
      host - supervisor host name
      config - storm config
      Returns:
      log link.
    • getPrettifiedSupervisorMap

      public static Map<String,Object> getPrettifiedSupervisorMap(SupervisorSummary supervisorSummary, Map<String,Object> config)
      Get supervisor info in a map.
      Parameters:
      supervisorSummary - from nimbus call.
      config - Storm config.
      Returns:
      prettified supervisor info map.
    • getTopologyHistoryInfo

      public static Map<String,Object> getTopologyHistoryInfo(TopologyHistoryInfo topologyHistory)
      Get topology history.
      Parameters:
      topologyHistory - from Nimbus call.
      Returns:
      map ready to be returned.
    • isSecureLogviewer

      public static boolean isSecureLogviewer(Map<String,Object> config)
      Check if logviewer is secure.
      Parameters:
      config - Storm config.
      Returns:
      true if logiviwer is secure.
    • getLogviewerPort

      public static int getLogviewerPort(Map<String,Object> config)
      Get logviewer port depending on whether the logviewer is secure or not.
      Parameters:
      config - Storm config.
      Returns:
      appropriate port.
    • getWorkerSummaries

      public static List<Map> getWorkerSummaries(SupervisorPageInfo supervisorPageInfo, Map<String,Object> config)
      getWorkerSummaries.
      Parameters:
      supervisorPageInfo - supervisorPageInfo
      config - config
      Returns:
      getWorkerSummaries
    • getSupervisorSummary

      public static Map<String,Object> getSupervisorSummary(List<SupervisorSummary> supervisors, javax.ws.rs.core.SecurityContext securityContext, Map<String,Object> config)
      getSupervisorSummary.
      Parameters:
      supervisors - supervisor summary list.
      securityContext - security context injected.
      config - Storm config.
      Returns:
      Prettified JSON.
    • getSupervisorPageInfo

      public static Map<String,Object> getSupervisorPageInfo(SupervisorPageInfo supervisorPageInfo, Map<String,Object> config)
      getSupervisorPageInfo.
      Parameters:
      supervisorPageInfo - supervisorPageInfo
      config - config
      Returns:
      getSupervisorPageInfo
    • getAllTopologiesSummary

      public static Map<String,Object> getAllTopologiesSummary(List<TopologySummary> topologies, Map<String,Object> config)
      getAllTopologiesSummary.
      Parameters:
      topologies - topologies
      config - config
      Returns:
      getAllTopologiesSummary
    • getWindowHint

      public static String getWindowHint(String window)
      getWindowHint.
      Parameters:
      window - window
      Returns:
      getWindowHint
    • getStatDisplayMap

      public static Map<String,Double> getStatDisplayMap(Map<String,Double> rawDisplayMap)
      getStatDisplayMap.
      Parameters:
      rawDisplayMap - rawDisplayMap
      Returns:
      getStatDisplayMap
    • getTopologySummary

      public static Map<String,Object> getTopologySummary(TopologyPageInfo topologyPageInfo, String window, Map<String,Object> config, String remoteUser)
      getTopologySummary.
      Parameters:
      topologyPageInfo - topologyPageInfo
      window - window
      config - config
      remoteUser - remoteUser
      Returns:
      getTopologySummary
    • getTopologyWorkers

      public static Map<String,Object> getTopologyWorkers(TopologyInfo topologyInfo, Map config)
      getTopologyWorkers.
      Parameters:
      topologyInfo - topologyInfo
      config - config
      Returns:
      getTopologyWorkers.
    • getTopologyLag

      public static Map<String,Map<String,Object>> getTopologyLag(StormTopology userTopology, Map<String,Object> config)
      getTopologyLag.
      Parameters:
      userTopology - userTopology
      config - config
      Returns:
      getTopologyLag.
    • getBoltExecutors

      public static Map<String,List<ExecutorSummary>> getBoltExecutors(List<ExecutorSummary> executorSummaries, StormTopology stormTopology, boolean sys)
      getBoltExecutors.
      Parameters:
      executorSummaries - executorSummaries
      stormTopology - stormTopology
      sys - sys
      Returns:
      getBoltExecutors.
    • getSpoutExecutors

      public static Map<String,List<ExecutorSummary>> getSpoutExecutors(List<ExecutorSummary> executorSummaries, StormTopology stormTopology)
      getSpoutExecutors.
      Parameters:
      executorSummaries - executorSummaries
      stormTopology - stormTopology
      Returns:
      getSpoutExecutors.
    • sanitizeStreamName

      public static String sanitizeStreamName(String streamName)
      Sanitizes streamName for use as an identifier in the visualization. Replaces all characters except A-Z, a-z, '.', '-', and '_' with '_'. If streamName does not start with A-Z or a-z, adds '_s' prefix.
      Parameters:
      streamName - non-null streamName
      Returns:
      sanitized stream name
    • sanitizeTransferredStats

      public static Map<String,Map<String,Long>> sanitizeTransferredStats(Map<String,Map<String,Long>> stats)
      sanitizeTransferredStats.
      Parameters:
      stats - stats
      Returns:
      sanitizeTransferredStats
    • getStatMapFromExecutorSummary

      public static Map<String,Object> getStatMapFromExecutorSummary(ExecutorSummary executorSummary)
      getStatMapFromExecutorSummary.
      Parameters:
      executorSummary - executorSummary
      Returns:
      getStatMapFromExecutorSummary
    • getInputMap

      public static Map<String,Object> getInputMap(Map.Entry<GlobalStreamId,Grouping> entryInput)
      getInputMap.
      Parameters:
      entryInput - entryInput
      Returns:
      getInputMap
    • getVisualizationData

      public static Map<String,Object> getVisualizationData(Nimbus.Iface client, String window, String topoId, boolean sys) throws org.apache.storm.thrift.TException
      getVisualizationData.
      Parameters:
      client - client
      window - window
      topoId - topoId
      sys - sys
      Returns:
      getVisualizationData
      Throws:
      org.apache.storm.thrift.TException - TException
    • getStreamBox

      public static Map<String,Object> getStreamBox(Object visualization)
      getStreamBox.
      Parameters:
      visualization - visualization
      Returns:
      getStreamBox
    • getBuildVisualization

      public static Map<String,Object> getBuildVisualization(Nimbus.Iface client, Map<String,Object> config, String window, String id, boolean sys) throws org.apache.storm.thrift.TException
      getBuildVisualization.
      Parameters:
      client - client
      config - config
      window - window
      id - id
      sys - sys
      Returns:
      getBuildVisualization
      Throws:
      org.apache.storm.thrift.TException - TException
    • getActiveAction

      public static Map<String,Object> getActiveAction(ProfileRequest profileRequest, Map config, String topologyId)
      getActiveAction.
      Parameters:
      profileRequest - profileRequest
      config - config
      topologyId - topologyId
      Returns:
      getActiveAction
    • getActiveProfileActions

      public static List getActiveProfileActions(Nimbus.Iface client, String id, String component, Map config) throws org.apache.storm.thrift.TException
      getActiveProfileActions.
      Parameters:
      client - client
      id - id
      component - component
      config - config
      Returns:
      getActiveProfileActions
      Throws:
      org.apache.storm.thrift.TException - TException
    • getWorkerDumpLink

      public static String getWorkerDumpLink(String host, long port, String topologyId, Map<String,Object> config)
      getWorkerDumpLink.
      Parameters:
      host - host
      port - port
      topologyId - topologyId
      config - config
      Returns:
      getWorkerDumpLink
    • unpackBoltPageInfo

      public static Map<String,Object> unpackBoltPageInfo(ComponentPageInfo componentPageInfo, String topologyId, String window, boolean sys, Map config)
      unpackBoltPageInfo.
      Parameters:
      componentPageInfo - componentPageInfo
      topologyId - topologyId
      window - window
      sys - sys
      config - config
      Returns:
      unpackBoltPageInfo
    • unpackSpoutPageInfo

      public static Map<String,Object> unpackSpoutPageInfo(ComponentPageInfo componentPageInfo, String topologyId, String window, boolean sys, Map config)
      unpackSpoutPageInfo.
      Parameters:
      componentPageInfo - componentPageInfo
      topologyId - topologyId
      window - window
      sys - sys
      config - config
      Returns:
      unpackSpoutPageInfo
    • getComponentPage

      public static Map<String,Object> getComponentPage(Nimbus.Iface client, String id, String component, String window, boolean sys, String user, Map config) throws org.apache.storm.thrift.TException
      getComponentPage.
      Parameters:
      client - client
      id - id
      component - component
      window - window
      sys - sys
      user - user
      config - config
      Returns:
      getComponentPage
      Throws:
      org.apache.storm.thrift.TException - TException
    • getTopolgoyLogConfig

      public static Map<String,Object> getTopolgoyLogConfig(LogConfig logConfig)
      getTopolgoyLogConfig.
      Parameters:
      logConfig - logConfig
      Returns:
      getTopolgoyLogConfig
    • getTopologyOpResponse

      public static Map<String,Object> getTopologyOpResponse(String id, String op)
      getTopologyOpResponse.
      Parameters:
      id - id
      op - op
      Returns:
      getTopologyOpResponse
    • putTopologyActivate

      public static Map<String,Object> putTopologyActivate(Nimbus.Iface client, String id) throws org.apache.storm.thrift.TException
      putTopologyActivate.
      Parameters:
      client - client
      id - id
      Returns:
      putTopologyActivate
      Throws:
      org.apache.storm.thrift.TException - TException
    • putTopologyDeactivate

      public static Map<String,Object> putTopologyDeactivate(Nimbus.Iface client, String id) throws org.apache.storm.thrift.TException
      putTopologyDeactivate.
      Parameters:
      client - client
      id - id
      Returns:
      putTopologyDeactivate
      Throws:
      org.apache.storm.thrift.TException - TException
    • putTopologyDebugActionSpct

      public static Map<String,Object> putTopologyDebugActionSpct(Nimbus.Iface client, String id, String action, String spct, String component) throws org.apache.storm.thrift.TException
      putTopologyDebugActionSpct.
      Parameters:
      client - client
      id - id
      action - action
      spct - spct
      component - component
      Returns:
      putTopologyDebugActionSpct
      Throws:
      org.apache.storm.thrift.TException - TException
    • putTopologyRebalance

      public static Map<String,Object> putTopologyRebalance(Nimbus.Iface client, String id, String waitTime) throws org.apache.storm.thrift.TException
      putTopologyRebalance.
      Parameters:
      client - client
      id - id
      waitTime - waitTime
      Returns:
      putTopologyRebalance
      Throws:
      org.apache.storm.thrift.TException - TException
    • putTopologyKill

      public static Map<String,Object> putTopologyKill(Nimbus.Iface client, String id, String waitTime) throws org.apache.storm.thrift.TException
      putTopologyKill.
      Parameters:
      client - client
      id - id
      waitTime - waitTime
      Returns:
      putTopologyKill
      Throws:
      org.apache.storm.thrift.TException - TException
    • setTopologyProfilingAction

      public static void setTopologyProfilingAction(Nimbus.Iface client, String id, String hostPort, Long timestamp, Map<String,Object> config, ProfileAction profileAction) throws org.apache.storm.thrift.TException
      setTopologyProfilingAction.
      Parameters:
      client - client
      id - id
      hostPort - hostPort
      timestamp - timestamp
      config - config
      profileAction - profileAction
      Throws:
      org.apache.storm.thrift.TException - TException
    • getTopologyProfilingStart

      public static Map<String,Object> getTopologyProfilingStart(Nimbus.Iface client, String id, String hostPort, String timeout, Map<String,Object> config) throws org.apache.storm.thrift.TException
      getTopologyProfilingStart.
      Parameters:
      client - client
      id - id
      hostPort - hostPort
      timeout - timeout
      config - config
      Returns:
      getTopologyProfilingStart
      Throws:
      org.apache.storm.thrift.TException - TException
    • getTopologyProfilingStop

      public static Map<String,Object> getTopologyProfilingStop(Nimbus.Iface client, String id, String hostPort, Map<String,Object> config) throws org.apache.storm.thrift.TException
      getTopologyProfilingStop.
      Parameters:
      client - client
      id - id
      hostPort - hostPort
      config - config
      Returns:
      getTopologyProfilingStop
      Throws:
      org.apache.storm.thrift.TException - TException
    • getProfilingDisabled

      public static Map<String,Object> getProfilingDisabled()
      getProfilingDisabled.
      Returns:
      getProfilingDisabled
    • getTopologyProfilingDump

      public static Map<String,Object> getTopologyProfilingDump(Nimbus.Iface client, String id, String hostPort, Map<String,Object> config) throws org.apache.storm.thrift.TException
      getTopologyProfilingDump.
      Parameters:
      client - client
      id - id
      hostPort - hostPort
      config - config
      Returns:
      getTopologyProfilingDump
      Throws:
      org.apache.storm.thrift.TException - TException
    • getTopologyProfilingDumpJstack

      public static Map<String,Object> getTopologyProfilingDumpJstack(Nimbus.Iface client, String id, String hostPort, Map<String,Object> config) throws org.apache.storm.thrift.TException
      Throws:
      org.apache.storm.thrift.TException
    • getTopologyProfilingRestartWorker

      public static Map<String,Object> getTopologyProfilingRestartWorker(Nimbus.Iface client, String id, String hostPort, Map<String,Object> config) throws org.apache.storm.thrift.TException
      getTopologyProfilingRestartWorker.
      Parameters:
      client - client
      id - id
      hostPort - hostPort
      config - config
      Returns:
      getTopologyProfilingRestartWorker
      Throws:
      org.apache.storm.thrift.TException - TException
    • getTopologyProfilingDumpHeap

      public static Map<String,Object> getTopologyProfilingDumpHeap(Nimbus.Iface client, String id, String hostPort, Map<String,Object> config) throws org.apache.storm.thrift.TException
      getTopologyProfilingDumpHeap.
      Parameters:
      client - client
      id - id
      hostPort - hostport
      config - config
      Returns:
      getTopologyProfilingDumpHeap
      Throws:
      org.apache.storm.thrift.TException - TException
    • putTopologyLogLevel

      public static Map<String,Object> putTopologyLogLevel(Nimbus.Iface client, Map<String,Map> namedLogLevel, String id) throws org.apache.storm.thrift.TException
      putTopologyLogLevel.
      Parameters:
      client - client
      namedLogLevel - namedLogLevel
      id - id
      Returns:
      putTopologyLogLevel.
      Throws:
      org.apache.storm.thrift.TException - TException
    • getNimbusSummary

      public static Map<String,Object> getNimbusSummary(ClusterSummary clusterInfo, Map<String,Object> config)
      getNimbusSummary.
      Parameters:
      clusterInfo - clusterInfo
      config - config
      Returns:
      getNimbusSummary