Esempio n. 1
0
 public boolean check(AssociationDescriptor descriptor, ServiceElement element) {
   return (ServiceElementUtil.matchesServiceElement(
       element,
       descriptor.getName(),
       descriptor.getInterfaceNames(),
       descriptor.getOperationalStringName()));
 }
Esempio n. 2
0
 /*
  * Get matching ServiceElement count
  */
 private static int getCount(
     ServiceElement sElem, ServiceElement[] elems, AssociationType type, StringBuffer b) {
   int found = 0;
   for (ServiceElement elem : elems) {
     AssociationDescriptor[] ads = ServiceElementUtil.getAssociationDescriptors(elem, type);
     for (AssociationDescriptor ad : ads) {
       if (matches(ad, new ServiceElement[] {sElem})) {
         if (found > 0) b.append(", ");
         found++;
         b.append(elem.getName());
       }
     }
   }
   return (found);
 }
Esempio n. 3
0
  /**
   * This method verifies whether the InstantiatorResource can support any declared service
   * associated requirements
   *
   * @param sElem The ServiceElement
   * @param type The AssociationType type
   * @param ir The InstantiatorResource
   * @param known An array of InstantiatorResource instances that contain the ServiceElement, may be
   *     null
   * @return Return true if the provided InstantiatorResource meets service declared requirements
   */
  private static boolean meetsAssociatedRequirements(
      ServiceElement sElem,
      AssociationType type,
      InstantiatorResource ir,
      InstantiatorResource[] known) {
    boolean provisionable = true;
    StringBuilder errorLog = new StringBuilder();

    AssociationDescriptor[] aDescs = ServiceElementUtil.getAssociationDescriptors(sElem, type);

    /* Check in process elements, to see if they match any of the service's
     * opposed requirements */
    for (AssociationDescriptor aDesc : aDescs) {
      if (matches(aDesc, ir.getServiceElementsInprocess(sElem))) {
        provisionable = false;
        break;
      }
    }

    /* Check running elements, to see if they match any of the service's
     * opposed requirements */
    if (provisionable) {
      for (AssociationDescriptor aDesc : aDescs) {
        if (matches(aDesc, ir.getServiceElements())) {
          provisionable = false;
          break;
        }
      }
    }
    if (!provisionable) {
      String provType = sElem.getProvisionType().toString();
      errorLog
          .append("Do not allocate ")
          .append(provType)
          .append(" service " + "[")
          .append(sElem.getName())
          .append("] to ")
          .append(ir.getName())
          .append(" at [")
          .append(ir.getHostAddress())
          .append("], ");
      errorLog.append(type.toString()).append(", services detected: ");
      for (int i = 0; i < aDescs.length; i++) {
        if (i > 0) errorLog.append(", ");
        errorLog.append("[").append(i + 1).append("] ").append(aDescs[i].getName());
      }
    }

    /* Check if any in process or running elements have an opposed or
     * isolated requirement to the service that needs to be provisioned */
    if (provisionable) {
      StringBuffer b = new StringBuffer();
      int found = getCount(sElem, ir.getServiceElements(), type, b);
      if (found == 0) {
        found = getCount(sElem, ir.getServiceElementsInprocess(sElem), type, b);
      }
      if (found > 0) {
        String provType = sElem.getProvisionType().toString();
        provisionable = false;
        errorLog
            .append("Do not allocate ")
            .append(provType)
            .append(" service " + "[")
            .append(sElem.getName())
            .append("] to ")
            .append(ir.getName())
            .append(" at [")
            .append(ir.getHostAddress())
            .append("], ")
            .append("id ")
            .append("[")
            .append(ir.getInstantiatorUuid())
            .append("], ")
            .append(found);
        errorLog.append(" service(s) have ").append(type.toString()).append(" associations: ");
        errorLog.append("{").append(b.toString()).append("}");
      }
    }

    if (provisionable && known != null && aDescs.length > 0) {
      if (inKnownSet(ir, known)) provisionable = false;
    }

    if (!provisionable && logger.isLoggable(Level.FINER)) logger.finer(errorLog.toString());

    return (provisionable);
  }