Пример #1
0
 /**
  * A static convience method for decoding an object from a String.
  *
  * <p>All exceptions are logged using LogMgr internally and then rethrown as GlueException with
  * the same message as written to the log.
  *
  * @param title The name to be given to the object when decoded.
  * @param bytes The Glue formated data to be decoded.
  * @throws GlueException If unable to decode the string.
  */
 public static Object decodeBytes(String title, byte bytes[]) throws GlueException {
   try {
     GlueDecoderImpl gd = new GlueDecoderImpl();
     InputStream in = null;
     try {
       in = new ByteArrayInputStream(bytes);
       GlueParser parser = new GlueParser(in);
       return parser.Decode(gd, gd.getState());
     } catch (ParseException ex) {
       throw new GlueException(ex);
     } catch (TokenMgrError ex) {
       throw new GlueException(ex);
     } finally {
       in.close();
     }
   } catch (GlueException ex) {
     String msg = ("Unable to Glue decode: " + title + "\n" + "  " + ex.getMessage());
     LogMgr.getInstance().log(LogMgr.Kind.Glu, LogMgr.Level.Severe, msg);
     throw new GlueException(msg);
   } catch (Exception ex) {
     String msg = Exceptions.getFullMessage("INTERNAL ERROR:", ex, true, true);
     LogMgr.getInstance().log(LogMgr.Kind.Glu, LogMgr.Level.Severe, msg);
     throw new GlueException(msg);
   }
 }
Пример #2
0
    public synchronized void update(JobState prevState, QueueJobInfo info) {
      if (LogMgr.getInstance().isLoggable(LogMgr.Kind.Ops, LogMgr.Level.Finest)) {
        LogMgr.getInstance()
            .log(
                LogMgr.Kind.Ops,
                LogMgr.Level.Finest,
                "Job Count Update ["
                    + info.getJobID()
                    + "]: "
                    + prevState
                    + " -> "
                    + info.getState());
      }

      //      if(LogMgr.getInstance().isLoggable(LogMgr.Kind.Ops, LogMgr.Level.Finest)) {
      //         StringBuilder buf = new StringBuilder();
      //         buf.append("Job Pre-Counts [" + info.getJobID() + "]: " +
      //                    prevState + " -> " + info.getState() + "\n  ");
      //         for(JobState js : JobState.all())
      //           buf.append(js + "[" + pCounts[js.ordinal()] + "] ");
      //         LogMgr.getInstance().log(LogMgr.Kind.Ops, LogMgr.Level.Finest, buf.toString());
      //       }

      if (prevState != null) {
        if (pCounts[prevState.ordinal()] > 0) {
          pCounts[prevState.ordinal()]--;
        } else {
          LogMgr.getInstance()
              .logAndFlush(
                  LogMgr.Kind.Ops,
                  LogMgr.Level.Warning,
                  "Somehow the count of jobs with a "
                      + prevState
                      + " state was already "
                      + "when attempting to decrement the count after a change to a "
                      + info.getState()
                      + " state for the job ("
                      + info.getJobID()
                      + ")!");
        }
      }

      pCounts[info.getState().ordinal()]++;

      //     if(LogMgr.getInstance().isLoggable(LogMgr.Kind.Ops, LogMgr.Level.Finest)) {
      //         StringBuilder buf = new StringBuilder();
      //         buf.append("Job Post-Counts [" + info.getJobID() + "]: " +
      //                    prevState + " -> " + info.getState() + "\n  ");
      //         for(JobState js : JobState.all())
      //           buf.append(js + "[" + pCounts[js.ordinal()] + "] ");
      //         LogMgr.getInstance().log(LogMgr.Kind.Ops, LogMgr.Level.Finest, buf.toString());
      //       }
    }
Пример #3
0
  public UpdateAssetGUI() {
    try {
      PluginMgrClient.init();
      mclient = new MasterMgrClient();
      queue = new QueueMgrClient();
      plug = PluginMgrClient.getInstance();
      log = LogMgr.getInstance();

      pAssetManager = new TreeMap<String, AssetInfo>();

      project = "lr";
      charList = new TreeMap<String, String>();
      setsList = new TreeMap<String, String>();
      propsList = new TreeMap<String, String>();

      potentialUpdates = new TreeSet<String>();
      pSubstituteFields = new TreeMap<String, LinkedList<JBooleanField>>();

      /* load the look-and-feel */
      {
        try {
          SynthLookAndFeel synth = new SynthLookAndFeel();
          synth.load(
              LookAndFeelLoader.class.getResourceAsStream("synth.xml"), LookAndFeelLoader.class);
          UIManager.setLookAndFeel(synth);
        } catch (java.text.ParseException ex) {
          log.log(
              LogMgr.Kind.Ops,
              LogMgr.Level.Severe,
              "Unable to parse the look-and-feel XML file (synth.xml):\n" + "  " + ex.getMessage());
          System.exit(1);
        } catch (UnsupportedLookAndFeelException ex) {
          log.log(
              LogMgr.Kind.Ops,
              LogMgr.Level.Severe,
              "Unable to load the Pipeline look-and-feel:\n" + "  " + ex.getMessage());
          System.exit(1);
        }
      }

      /* application wide UI settings */
      {
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
        ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
      }
    } catch (PipelineException ex) {
      ex.printStackTrace();
    } // end try/catch
  } // end constructor
Пример #4
0
  /** Get the distribution of job states for the jobs in the given group. */
  public double[] getDistribution(TaskTimer timer, long groupID) {
    Counters counters = null;
    timer.acquire();
    synchronized (pCountersByGroup) {
      timer.resume();
      counters = pCountersByGroup.get(groupID);
    }

    if (counters != null) {
      double dist[] = counters.distribution();

      //       if(LogMgr.getInstance().isLoggable(LogMgr.Kind.Ops, LogMgr.Level.Finest)) {
      //         StringBuilder buf = new StringBuilder();
      //         buf.append("Job Group Distribution [" + groupID + "]:\n  ");
      //         for(JobState js : JobState.all())
      //           buf.append(js + "[" + String.format("%1$.4f", dist[js.ordinal()]) + "] ");
      // 	LogMgr.getInstance().log(LogMgr.Kind.Ops, LogMgr.Level.Finest, buf.toString());
      //       }

      return dist;
    } else {
      LogMgr.getInstance()
          .logAndFlush(
              LogMgr.Kind.Ops,
              LogMgr.Level.Warning,
              "Somehow the job group (" + groupID + ") was not in the state counts table!");

      return new double[JobState.all().size()];
    }
  }
Пример #5
0
  /**
   * Get the percentage of jobs in the job group owning the given job which are currently Queued or
   * Preempted.
   */
  public double percentPending(TaskTimer timer, long jobID) {
    Counters counters = null;
    timer.acquire();
    synchronized (pCountersByJob) {
      timer.resume();
      counters = pCountersByJob.get(jobID);
    }

    if (counters != null) {
      double percent = counters.percentPending();

      //       if(LogMgr.getInstance().isLoggable(LogMgr.Kind.Ops, LogMgr.Level.Finest))
      //         LogMgr.getInstance().log
      //           (LogMgr.Kind.Ops, LogMgr.Level.Finest,
      //            "Percent Pending [" + jobID + "]: " + String.format("%1$.4f", percent));

      return percent;
    } else {
      LogMgr.getInstance()
          .logAndFlush(
              LogMgr.Kind.Ops,
              LogMgr.Level.Warning,
              "Somehow the job (" + jobID + ") was not in the state counts table!");
      return 0.0;
    }
  }
  /**
   * Constructs a new response.
   *
   * @param timer The timing statistics for a task.
   * @param names The names of all toolsets.
   */
  public MiscGetAllToolsetNamesRsp(TaskTimer timer, TreeMap<String, TreeSet<OsType>> names) {
    super(timer);

    if (names == null) throw new IllegalArgumentException("The toolset names cannot be (null)!");
    pNames = names;

    LogMgr.getInstance()
        .logAndFlush(
            LogMgr.Kind.Net, LogMgr.Level.Finest, "MasterMgr.getToolsetNames()\n  " + getTimer());
  }
Пример #7
0
  /** Create a new set of shared job state counters for all jobs in the given group. */
  public void initCounters(TaskTimer timer, QueueJobGroup group) {
    long groupID = group.getGroupID();

    if (LogMgr.getInstance().isLoggable(LogMgr.Kind.Ops, LogMgr.Level.Finest))
      LogMgr.getInstance()
          .log(LogMgr.Kind.Ops, LogMgr.Level.Finest, "Init Job Counts for Group (" + groupID + ")");

    SortedSet<Long> jobIDs = group.getJobIDs();
    Counters counters = new Counters(jobIDs.size());

    timer.acquire();
    synchronized (pCountersByGroup) {
      timer.resume();

      if (pCountersByGroup.put(groupID, counters) != null)
        LogMgr.getInstance()
            .logAndFlush(
                LogMgr.Kind.Ops,
                LogMgr.Level.Warning,
                "Somehow the job group ("
                    + groupID
                    + ") was already in the state "
                    + "counts table!");
    }

    timer.acquire();
    synchronized (pCountersByJob) {
      timer.resume();

      for (Long jobID : jobIDs) {
        if (pCountersByJob.put(jobID, counters) != null)
          LogMgr.getInstance()
              .logAndFlush(
                  LogMgr.Kind.Ops,
                  LogMgr.Level.Warning,
                  "Somehow the job (" + jobID + ") was already in the state counts table!");
      }
    }
  }
Пример #8
0
  /**
   * Update the job state counts after a change to the job state information.
   *
   * @param timer The operation timer.
   * @param prevState The previous job state before the change or <CODE>null</CODE> if the previous
   *     state is unknown.
   * @para info The current job info which includes the updated job state.
   */
  public void update(TaskTimer timer, JobState prevState, QueueJobInfo info) {
    Counters counters = null;
    timer.acquire();
    synchronized (pCountersByJob) {
      timer.resume();
      counters = pCountersByJob.get(info.getJobID());
    }

    if (counters != null) counters.update(prevState, info);
    else
      LogMgr.getInstance()
          .logAndFlush(
              LogMgr.Kind.Ops,
              LogMgr.Level.Warning,
              "Somehow the job (" + info.getJobID() + ") was not in the state counts table!");
  }
Пример #9
0
  /** Get the percentage of jobs in the job group which are currently Queued or Preempted. */
  public double percentPendingByGroup(TaskTimer timer, long jobGroupID) {
    Counters counters = null;
    timer.acquire();
    synchronized (pCountersByGroup) {
      timer.resume();
      counters = pCountersByGroup.get(jobGroupID);
    }

    if (counters != null) {
      double percent = counters.percentPending();

      return percent;
    } else {
      LogMgr.getInstance()
          .logAndFlush(
              LogMgr.Kind.Ops,
              LogMgr.Level.Warning,
              "Somehow the job group (" + jobGroupID + ") was not in the state counts table!");
      return 0.0;
    }
  }
Пример #10
0
  /**
   * A static convience method for decoding an object from the given file.
   *
   * <p>All exceptions are logged using LogMgr internally and then rethrown as GlueException with
   * the same message as written to the log.
   *
   * @param title The name to be given to the object when decoded.
   * @param file The Glue format file to be decoded.
   * @throws GlueException If unable to decode the string.
   */
  public static Object decodeFile(String title, File file) throws GlueException {
    LogMgr.getInstance()
        .log(LogMgr.Kind.Glu, LogMgr.Level.Finest, "Reading " + title + ": " + file);

    try {
      InputStream in = null;
      try {
        in = new BufferedInputStream(new FileInputStream(file));
      } catch (IOException ex) {
        String msg =
            ("I/O ERROR: \n"
                + "  Unable to open file ("
                + file
                + ") to decode: "
                + title
                + "\n"
                + "    "
                + ex.getMessage());
        LogMgr.getInstance().log(LogMgr.Kind.Glu, LogMgr.Level.Severe, msg);
        throw new GlueException(msg);
      }

      try {
        GlueDecoderImpl gd = new GlueDecoderImpl();
        GlueParser parser = new GlueParser(in, "UTF-8");
        return parser.Decode(gd, gd.getState());
      } catch (ParseException ex) {
        throw new GlueException(ex);
      } catch (TokenMgrError ex) {
        throw new GlueException(ex);
      } finally {
        in.close();
      }
    } catch (IOException ex) {
      String msg =
          ("I/O ERROR: \n"
              + "  While reading from file ("
              + file
              + ") during Glue decoding of: "
              + title
              + "\n"
              + "    "
              + ex.getMessage());
      LogMgr.getInstance().log(LogMgr.Kind.Glu, LogMgr.Level.Severe, msg);
      throw new GlueException(msg);
    } catch (GlueException ex) {
      String msg =
          ("While reading from file ("
              + file
              + "), unable to Glue decode: "
              + title
              + "\n"
              + "  "
              + ex.getMessage());
      LogMgr.getInstance().log(LogMgr.Kind.Glu, LogMgr.Level.Severe, msg);
      throw new GlueException(msg);
    } catch (Exception ex) {
      String msg = Exceptions.getFullMessage("INTERNAL ERROR:", ex, true, true);
      LogMgr.getInstance().log(LogMgr.Kind.Glu, LogMgr.Level.Severe, msg);
      throw new GlueException(msg);
    }
  }