Class StatsCollector

java.lang.Object
io.antmedia.statistic.StatsCollector
All Implemented Interfaces:
IStatsCollector, Aware, DisposableBean, ApplicationContextAware

public class StatsCollector extends Object implements IStatsCollector, ApplicationContextAware, DisposableBean
  • Field Details

  • Constructor Details

    • StatsCollector

      public StatsCollector()
  • Method Details

    • start

      public void start()
    • startKafkaProducer

      private void startKafkaProducer()
    • getVertWorkerQueueSizeStatic

      private static int getVertWorkerQueueSizeStatic()
    • getVertWorkerQueueSize

      public int getVertWorkerQueueSize()
    • getWebRTCVertxWorkerQueueSizeStatic

      private static int getWebRTCVertxWorkerQueueSizeStatic()
    • getWebRTCVertxWorkerQueueSize

      public int getWebRTCVertxWorkerQueueSize()
    • sendWebRTCClientStats

      private void sendWebRTCClientStats()
    • collectAndSendWebRTCClientsStats

      public void collectAndSendWebRTCClientsStats()
    • sendWebRTCClientStats2Kafka

      public void sendWebRTCClientStats2Kafka(List<WebRTCClientStats> webRTCClientStatList, String streamId)
    • createKafkaProducer

      public org.apache.kafka.clients.producer.Producer<Long,String> createKafkaProducer()
    • getFileSystemInfoJSObject

      public static com.google.gson.JsonObject getFileSystemInfoJSObject()
    • getGPUInfoJSObject

      public static com.google.gson.JsonObject getGPUInfoJSObject(int deviceIndex, GPUUtils gpuUtils)
    • getGPUInfoJSObject

      public static com.google.gson.JsonArray getGPUInfoJSObject()
    • getCPUInfoJSObject

      public static com.google.gson.JsonObject getCPUInfoJSObject()
    • getThreadDump

      public static ThreadInfo[] getThreadDump()
    • getThreadDumpJSON

      public static com.google.gson.JsonArray getThreadDumpJSON()
    • getDeadLockedThreads

      private static com.google.gson.JsonArray getDeadLockedThreads(long[] deadLockedThreads)
    • getThreadInfoJSONObject

      public static com.google.gson.JsonObject getThreadInfoJSONObject()
    • getJVMMemoryInfoJSObject

      public static com.google.gson.JsonObject getJVMMemoryInfoJSObject()
    • getSystemInfoJSObject

      public static com.google.gson.JsonObject getSystemInfoJSObject()
    • getSysteMemoryInfoJSObject

      public static com.google.gson.JsonObject getSysteMemoryInfoJSObject()
    • getJVMNativeMemoryInfoJSObject

      public static com.google.gson.JsonObject getJVMNativeMemoryInfoJSObject()
    • getServerTime

      public static com.google.gson.JsonObject getServerTime()
      Returns server uptime and startime in milliseconds
      Returns:
    • getAdminAppAdaptor

      public static AdminApplication getAdminAppAdaptor(ApplicationContext appContext)
    • getAppAdaptor

      public static AntMediaApplicationAdapter getAppAdaptor(ApplicationContext appContext)
    • getSystemResourcesInfo

      public static com.google.gson.JsonObject getSystemResourcesInfo(Queue<IScope> scopes)
    • getDBQueryAverageTimeMs

      public long getDBQueryAverageTimeMs()
    • getHLSViewers

      private static int getHLSViewers(IScope scope)
    • getDASHViewers

      private static int getDASHViewers(IScope scope)
    • sendInstanceStats

      public void sendInstanceStats(Queue<IScope> scopes)
    • send2Kafka

      public void send2Kafka(com.google.gson.JsonElement jsonElement, String topicName)
    • addCpuMeasurement

      public void addCpuMeasurement(int measurment)
    • getMemoryLoad

      public int getMemoryLoad()
    • getOSType

      public int getOSType()
    • enoughResource

      public boolean enoughResource()
      Description copied from interface: IStatsCollector
      Check if cpu usage and ram usage does not exceed the limit
      Specified by:
      enoughResource in interface IStatsCollector
      Returns:
      true if not exceeding the limit, false if exceeding limit
    • sendUnexpectedShutdownHook

      public void sendUnexpectedShutdownHook(List<String> appNames)
    • sendPOST

      public int sendPOST(String url, com.google.gson.JsonObject json) throws IOException
      Throws:
      IOException
    • getFreeRam

      public int getFreeRam()
      Description copied from interface: IStatsCollector
      In MB
      Specified by:
      getFreeRam in interface IStatsCollector
      Returns:
      the free RAM that server can use
    • getMinFreeRamSize

      public int getMinFreeRamSize()
      Description copied from interface: IStatsCollector
      It's configurable In MB
      Specified by:
      getMinFreeRamSize in interface IStatsCollector
      Returns:
      the free RAM size that server should have all the time
    • setMinFreeRamSize

      public void setMinFreeRamSize(int ramLimit)
    • setCpuLoad

      public void setCpuLoad(int cpuLoad)
    • getCpuLoad

      public int getCpuLoad()
      Description copied from interface: IStatsCollector
      It calculates the average CPU usage for a specified time.
      Specified by:
      getCpuLoad in interface IStatsCollector
      Returns:
      the current CPU usage
    • getWindowSize

      public int getWindowSize()
    • setWindowSize

      public void setWindowSize(int windowSize)
    • getVertx

      public io.vertx.core.Vertx getVertx()
    • setVertx

      public void setVertx(io.vertx.core.Vertx vertx)
    • setWebRTCVertx

      public void setWebRTCVertx(io.vertx.core.Vertx webRTCVertx)
    • setCpuLimit

      public void setCpuLimit(int cpuLimit)
    • getCpuLimit

      public int getCpuLimit()
      Description copied from interface: IStatsCollector
      It's configurable and it's based on percentage. Max value is 100.
      Specified by:
      getCpuLimit in interface IStatsCollector
      Returns:
      the CPU limit that server does not exceed.
    • setApplicationContext

      public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
      Specified by:
      setApplicationContext in interface ApplicationContextAware
      Throws:
      BeansException
    • getStaticSendPeriod

      public int getStaticSendPeriod()
    • setStaticSendPeriod

      public void setStaticSendPeriod(int staticSendPeriod)
    • setKafkaProducer

      public void setKafkaProducer(org.apache.kafka.clients.producer.Producer<Long,String> kafkaProducer)
    • getKafkaBrokers

      public String getKafkaBrokers()
    • setKafkaBrokers

      public void setKafkaBrokers(String kafkaBrokers)
    • setScopes

      public void setScopes(Queue<IScope> scopes)
    • cancelHeartBeat

      public void cancelHeartBeat()
    • isHeartBeatEnabled

      public boolean isHeartBeatEnabled()
    • setHeartBeatEnabled

      public void setHeartBeatEnabled(boolean heartBeatEnabled)
    • getHeartbeatPeriodMs

      public int getHeartbeatPeriodMs()
    • setHeartbeatPeriodMs

      public void setHeartbeatPeriodMs(int heartbeatPeriodMs)
    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface DisposableBean
      Throws:
      Exception
    • getMeasurementPeriod

      public int getMeasurementPeriod()
    • startAnalytic

      public void startAnalytic()
    • setUserEmail

      public void setUserEmail(String userEmail)
    • getUserEmail

      public String getUserEmail()
    • findAdminUser

      private String findAdminUser(List<User> userList)
    • getHttpClient

      public org.apache.http.impl.client.CloseableHttpClient getHttpClient()
    • getUnexpectedShutDownDelayMs

      public long getUnexpectedShutDownDelayMs()
    • setUnexpectedShutDownDelayMs

      public void setUnexpectedShutDownDelayMs(long unexpectedShutDownDelayMs)
    • setWebhookURL

      public void setWebhookURL(String webhookURL)
    • getMemoryLimit

      public int getMemoryLimit()
    • setMemoryLimit

      public void setMemoryLimit(int memoryLimit)