Exemplo n.º 1
0
  private void checkStartup(
      Map<String, ServiceData> map,
      List<ServiceData> start,
      ServiceData sd,
      Set<ServiceData> cyclic) {
    if (sd.after.isEmpty() || start.contains(sd)) return;

    if (cyclic.contains(sd)) {
      reporter.error("Cyclic dependency for " + sd.name);
      return;
    }

    cyclic.add(sd);

    for (String dependsOn : sd.after) {
      if (dependsOn.equals("boot")) continue;

      ServiceData deps = map.get(dependsOn);
      if (deps == null) {
        reporter.error("No such service " + dependsOn + " but " + sd.name + " depends on it");
      } else {
        checkStartup(map, start, deps, cyclic);
      }
    }
    start.add(sd);
  }
  private static void checkGarbageCollectionNotificationInfoContent(
      GarbageCollectionNotificationInfo notif) throws Exception {
    System.out.println("GC notification for " + notif.getGcName());
    System.out.print("Action: " + notif.getGcAction());
    System.out.println(" Cause: " + notif.getGcCause());
    GcInfo info = notif.getGcInfo();
    System.out.print("GC Info #" + info.getId());
    System.out.print(" start:" + info.getStartTime());
    System.out.print(" end:" + info.getEndTime());
    System.out.println(" (" + info.getDuration() + "ms)");
    Map<String, MemoryUsage> usage = info.getMemoryUsageBeforeGc();

    List<String> pnames = new ArrayList<String>();
    for (Map.Entry entry : usage.entrySet()) {
      String poolname = (String) entry.getKey();
      pnames.add(poolname);
      MemoryUsage busage = (MemoryUsage) entry.getValue();
      MemoryUsage ausage = (MemoryUsage) info.getMemoryUsageAfterGc().get(poolname);
      if (ausage == null) {
        throw new RuntimeException("After Gc Memory does not exist" + " for " + poolname);
      }
      System.out.println("Usage for pool " + poolname);
      System.out.println("   Before GC: " + busage);
      System.out.println("   After GC: " + ausage);
    }

    // check if memory usage for all memory pools are returned
    List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
    for (MemoryPoolMXBean p : pools) {
      if (!pnames.contains(p.getName())) {
        throw new RuntimeException(
            "GcInfo does not contain " + "memory usage for pool " + p.getName());
      }
    }
  }
Exemplo n.º 3
0
 public boolean testContainsAddNew() {
   description = "after adding an object to new list,it is contained";
   precondition = new Boolean(li.isEmpty());
   Object e = new Object();
   li.add(0, e);
   return li.contains(e) == true;
 }
  /**
   * Expires a specific <tt>Content</tt> of this <tt>Conference</tt> (i.e. if the specified
   * <tt>content</tt> is not in the list of <tt>Content</tt>s of this <tt>Conference</tt>, does
   * nothing).
   *
   * @param content the <tt>Content</tt> to be expired by this <tt>Conference</tt>
   */
  public void expireContent(Content content) {
    boolean expireContent;

    synchronized (contents) {
      if (contents.contains(content)) {
        contents.remove(content);
        expireContent = true;
      } else expireContent = false;
    }
    if (expireContent) content.expire();
  }
Exemplo n.º 5
0
  /** this is really for embedded objects */
  int putObject(String name, BSONObject o) {

    if (o == null) throw new NullPointerException("can't save a null object");

    if (DEBUG)
      System.out.println(
          "putObject : " + name + " [" + o.getClass() + "]" + " # keys " + o.keySet().size());

    final int start = _buf.getPosition();

    byte myType = OBJECT;
    if (o instanceof List) myType = ARRAY;

    if (handleSpecialObjects(name, o)) return _buf.getPosition() - start;

    if (name != null) {
      _put(myType, name);
    }

    final int sizePos = _buf.getPosition();
    _buf.writeInt(0); // leaving space for this.  set it at the end

    List transientFields = null;
    boolean rewriteID = myType == OBJECT && name == null;

    if (myType == OBJECT) {
      if (rewriteID && o.containsField("_id")) _putObjectField("_id", o.get("_id"));

      {
        Object temp = o.get("_transientFields");
        if (temp instanceof List) transientFields = (List) temp;
      }
    }

    // TODO: reduce repeated code below.
    if (o instanceof Map) {
      for (Entry<String, Object> e : ((Map<String, Object>) o).entrySet()) {

        if (rewriteID && e.getKey().equals("_id")) continue;

        if (transientFields != null && transientFields.contains(e.getKey())) continue;

        _putObjectField(e.getKey(), e.getValue());
      }
    } else {
      for (String s : o.keySet()) {

        if (rewriteID && s.equals("_id")) continue;

        if (transientFields != null && transientFields.contains(s)) continue;

        Object val = o.get(s);

        _putObjectField(s, val);
      }
    }
    _buf.write(EOO);

    _buf.writeInt(sizePos, _buf.getPosition() - sizePos);
    return _buf.getPosition() - start;
  }
Exemplo n.º 6
0
 /**
  * Performs basic sanity check of argument.
  *
  * @return <code>true</code> if value is one of {@link #choices()}.
  */
 public boolean isValid(String value) {
   return choices.contains(value);
 }
Exemplo n.º 7
0
 /**
  * Adds a specific <tt>UserCapsNodeListener</tt> to the list of <tt>UserCapsNodeListener</tt>s
  * interested in events notifying about changes in the list of user caps nodes of this
  * <tt>EntityCapsManager</tt>.
  *
  * @param listener the <tt>UserCapsNodeListener</tt> which is interested in events notifying about
  *     changes in the list of user caps nodes of this <tt>EntityCapsManager</tt>
  */
 public void addUserCapsNodeListener(UserCapsNodeListener listener) {
   if (listener == null) throw new NullPointerException("listener");
   synchronized (userCapsNodeListeners) {
     if (!userCapsNodeListeners.contains(listener)) userCapsNodeListeners.add(listener);
   }
 }
Exemplo n.º 8
-21
  /**
   * Returns all the classes related to <code>type</code> by a {@link Connection}
   *
   * @param type The given {@link Model} interface.
   * @return A list that contains all the models in a relationship with <code>type</code> interface.
   */
  protected List<Class> getAllReleatedClasses(Class type) {

    if (relatedClasses.containsKey(type)) return relatedClasses.get(type);

    List<Class> related = new ArrayList<Class>();
    Method[] getters = CommonStatic.getDeclaredGetters(type);

    for (Method g : getters)
      if (g.isAnnotationPresent(Connection.class)) {

        Class t = g.getReturnType();
        t = t.isArray() ? t.getComponentType() : t;

        if (!related.contains(t)) related.add(t);
      }

    relatedClasses.put(type, related);

    return related;
  }