Package org.apache.flink.runtime.profiling

Examples of org.apache.flink.runtime.profiling.ProfilingException


    try {

      in = new BufferedReader(new FileReader(PROC_STAT));
      final String output = in.readLine();
      if (output == null) {
        throw new ProfilingException("Cannot read CPU utilization, return value is null");
      }

      in.close();
      in = null;

      final Matcher cpuMatcher = CPU_PATTERN.matcher(output);
      if (!cpuMatcher.matches()) {
        throw new ProfilingException("Cannot extract CPU utilization from output \"" + output + "\"");
      }

      /*
       * Extract the information from the read line according to
       * http://www.linuxhowtos.org/System/procstat.htm
       */

      final long cpuUser = Long.parseLong(cpuMatcher.group(1));
      final long cpuNice = Long.parseLong(cpuMatcher.group(2));
      final long cpuSys = Long.parseLong(cpuMatcher.group(3));
      final long cpuIdle = Long.parseLong(cpuMatcher.group(4));
      final long cpuIOWait = Long.parseLong(cpuMatcher.group(5));
      final long cpuIrq = Long.parseLong(cpuMatcher.group(6));
      final long cpuSoftirq = Long.parseLong(cpuMatcher.group(7));

      // Calculate deltas
      final long deltaCpuUser = cpuUser - this.lastCpuUser;
      final long deltaCpuNice = cpuNice - this.lastCpuNice;
      final long deltaCpuSys = cpuSys - this.lastCpuSys;
      final long deltaCpuIdle = cpuIdle - this.lastCpuIdle;
      final long deltaCpuIOWait = cpuIOWait - this.lastCpuIOWait;
      final long deltaCpuIrq = cpuIrq - this.lastCpuIrq;
      final long deltaCpuSoftirq = cpuSoftirq - this.lastCpuSoftirq;
      final long deltaSum = deltaCpuUser + deltaCpuNice + deltaCpuSys + deltaCpuIdle + deltaCpuIOWait
        + deltaCpuIrq + deltaCpuSoftirq;

      // TODO: Fix deltaSum = 0 situation

      // Set the percentage values for the profiling data object
      /*
       * profilingData.setIdleCPU((int)((deltaCpuIdle*PERCENT)/deltaSum));
       * profilingData.setUserCPU((int)((deltaCpuUser*PERCENT)/deltaSum));
       * profilingData.setSystemCPU((int)((deltaCpuSys*PERCENT)/deltaSum));
       * profilingData.setIoWaitCPU((int)((deltaCpuIOWait*PERCENT)/deltaSum));
       * profilingData.setHardIrqCPU((int)((deltaCpuIrq*PERCENT)/deltaSum));
       * profilingData.setSoftIrqCPU((int)((deltaCpuSoftirq*PERCENT)/deltaSum));
       */
      // TODO: bad quick fix
      if (deltaSum > 0) {
        profilingData.setIdleCPU((int) ((deltaCpuIdle * PERCENT) / deltaSum));
        profilingData.setUserCPU((int) ((deltaCpuUser * PERCENT) / deltaSum));
        profilingData.setSystemCPU((int) ((deltaCpuSys * PERCENT) / deltaSum));
        profilingData.setIoWaitCPU((int) ((deltaCpuIOWait * PERCENT) / deltaSum));
        profilingData.setHardIrqCPU((int) ((deltaCpuIrq * PERCENT) / deltaSum));
        profilingData.setSoftIrqCPU((int) ((deltaCpuSoftirq * PERCENT) / deltaSum));
      } else {
        profilingData.setIdleCPU((int) (deltaCpuIdle));
        profilingData.setUserCPU((int) (deltaCpuUser));
        profilingData.setSystemCPU((int) (deltaCpuSys));
        profilingData.setIoWaitCPU((int) (deltaCpuIOWait));
        profilingData.setHardIrqCPU((int) (deltaCpuIrq));
        profilingData.setSoftIrqCPU((int) (deltaCpuSoftirq));
      }
      // Store values for next call
      this.lastCpuUser = cpuUser;
      this.lastCpuNice = cpuNice;
      this.lastCpuSys = cpuSys;
      this.lastCpuIdle = cpuIdle;
      this.lastCpuIOWait = cpuIOWait;
      this.lastCpuIrq = cpuIrq;
      this.lastCpuSoftirq = cpuSoftirq;

    } catch (IOException ioe) {
      throw new ProfilingException("Error while reading CPU utilization: " + StringUtils.stringifyException(ioe));
    } catch (NumberFormatException nfe) {
      throw new ProfilingException("Error while reading CPU utilization: " + StringUtils.stringifyException(nfe));
    } finally {
      if (in != null) {
        try {
          in.close();
        } catch (IOException e) {
View Full Code Here


    ProfilerImplProtocol jobManagerProfilerTmp = null;
    try {
      jobManagerProfilerTmp = (ProfilerImplProtocol) RPC.getProxy(ProfilerImplProtocol.class, profilingAddress,
        NetUtils.getSocketFactory());
    } catch (IOException e) {
      throw new ProfilingException(StringUtils.stringifyException(e));
    }
    this.jobManagerProfiler = jobManagerProfilerTmp;

    // Initialize MX interface and check if thread contention monitoring is supported
    this.tmx = ManagementFactory.getThreadMXBean();
    if (this.tmx.isThreadContentionMonitoringSupported()) {
      this.tmx.setThreadContentionMonitoringEnabled(true);
    } else {
      throw new ProfilingException("The thread contention monitoring is not supported.");
    }

    // Create instance profiler
    this.instanceProfiler = new InstanceProfiler(instanceConnectionInfo);
View Full Code Here

      profilingServerTmp = RPC.getServer(this, rpcServerAddress.getHostName(), rpcServerAddress.getPort(),
        handlerCount);
      profilingServerTmp.start();
    } catch (IOException ioe) {
      throw new ProfilingException("Cannot start profiling RPC server: " + StringUtils.stringifyException(ioe));
    }
    this.profilingServer = profilingServerTmp;

  }
View Full Code Here

      profilingData.setBufferedMemory(bufferedMemory);
      profilingData.setCachedMemory(cachedMemory);
      profilingData.setCachedSwapMemory(cachedSwapMemory);

    } catch (IOException ioe) {
      throw new ProfilingException("Error while reading network utilization: "
        + StringUtils.stringifyException(ioe));
    } finally {
      if (in != null) {
        try {
          in.close();
View Full Code Here

  private long extractMemoryValue(String line) throws ProfilingException {

    final Matcher matcher = MEMORY_PATTERN.matcher(line);
    if (!matcher.matches()) {
      throw new ProfilingException("Cannot extract memory data for profiling from line " + line);
    }

    return Long.parseLong(matcher.group(1));
  }
View Full Code Here

      // Store values for next call
      this.lastReceivedBytes = receivedSum;
      this.lastTramsmittedBytes = transmittedSum;

    } catch (IOException ioe) {
      throw new ProfilingException("Error while reading network utilization: "
        + StringUtils.stringifyException(ioe));
    } catch (NumberFormatException nfe) {
      throw new ProfilingException("Error while reading network utilization: "
        + StringUtils.stringifyException(nfe));
    } finally {
      if (in != null) {
        try {
          in.close();
View Full Code Here

TOP

Related Classes of org.apache.flink.runtime.profiling.ProfilingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.