@Override
  /**
   * Create non-ServiceEntity object in SL probe. Checks if there exists another object with the
   * same name but a different class Else returns the existing object or creates using the Factory
   * instance for that class
   */
  protected VMTRootObject createObject(EClass ecls, String name) {
    VMTRootObject obj = null;

    if (name2obj.containsKey(name)) {
      if (name2obj.get(name).eClass().equals(ecls)) {
        obj = name2obj.get(name);
      } else {
        return handleObjectCreationDuplication(obj, ecls, name);
      }
    } else {
      obj = REPOSMAN.getObject(name);
      if (obj != null) {
        if (!obj.eClass().equals(ecls)) {
          return handleObjectCreationDuplication(obj, ecls, name);
        }
      } else {
        obj = (VMTRootObject) ecls.getEPackage().getEFactoryInstance().create(ecls);
        obj.setName(name);
        DISCMAN.incrementCount((VMTManagedEntity) obj);
      }

      name2obj.put(name, obj);
    }

    return obj;
  }
Ejemplo n.º 2
0
  /**
   * createObject handles if the probe created an object with same UUID as another existing object
   *
   * @param ecls
   * @param entityName
   * @param entityUuid
   * @return VMTRootobject
   */
  private VMTRootObject createObject(EClass ecls, String entityName, String entityUuid) {
    VMTRootObject obj = null;
    VMTRootObject newObj = null;
    String finalUuid = null;
    if (entityUuid != null) {
      finalUuid = REPOSMAN.hashUuid(entityUuid);
    }

    obj = name2obj.get(entityName);

    if (obj == null) {
      // this is an initial discovery, check if a different probe created an object with the same
      // uuid
      obj = REPOSMAN.getObject(finalUuid);
      if (obj != null) {
        // This object was created by a different probe
        if (!obj.eClass().equals(ecls)) {
          newObj = createObject(ecls, entityName, finalUuid + entityName);
          handleSameUUID(
              (VMTManagedEntity) obj,
              (VMTManagedEntity) newObj,
              entityName,
              ecls,
              false,
              VMTSeverity.MAJOR);
        } else {
          if (logger.isTraceEnabled() && obj instanceof VirtualApplication)
            logger.trace(
                target.getNameOrAddress()
                    + "### : "
                    + obj.toVMTString()
                    + " already was created by another probe with uuid "
                    + obj.getUuid());
        }
      } else {
        // This is the first object created with such a uuid
        obj = (VMTRootObject) ecls.getEPackage().getEFactoryInstance().create(ecls);
        if (finalUuid != null) obj.setUuid(finalUuid);
        obj.setName(entityName);
        if (logger.isTraceEnabled() && obj instanceof VirtualApplication)
          logger.trace(
              target.getNameOrAddress()
                  + ": created NEW object "
                  + obj.toVMTString()
                  + " with uuid "
                  + obj.getUuid());
        DISCMAN.incrementCount((VMTManagedEntity) obj);
      }
    } else if (!obj.eClass().equals(ecls)) {
      // object of a different class with the same uuid was created by this probe
      //			newObj = createObject(ecls, entityName, finalUuid + entityName);
      //			handleSameUUID((VMTManagedEntity)obj, (VMTManagedEntity)newObj, finalUuid, ecls,
      // VMTSeverity.WARNING);
      handleSameUUID((VMTManagedEntity) obj, null, entityName, ecls, false, VMTSeverity.MAJOR);
      newObj = null;
    }

    if (newObj != null) obj = newObj;

    name2obj.put(entityName, obj);
    return obj;
  } // end createObject()