Пример #1
0
  private String getStaticValueOfAssignedSetting(
      RequestedFederationScenario scenario,
      ResourceRequest resReq,
      ResourceSettingInstance assignedSetting) {
    if ((assignedSetting.getStaticValue() != null)
        && assignedSetting.getAssignSetting().size()
            == 0) // if there is available only the static value
    return assignedSetting
          .getStaticValue(); // we currently search only for the next assigned resource
    else if ((resReq.getRuntimeInfo() != null)
        && (resReq.getRuntimeInfo().getStatus() == RuntimeElementStatus.ONLINE)) {
      // ask resource proxy, if it is possible to update its values and then return the value!
      String officeName =
          ((Office) resReq.getRefOfferedResource().getImplOfferedService().eContainer()).getName();

      for (IProvisionResource p : Activator.getDefault().getProvisionPlugins()) {
        if (p.supportsOffice(officeName)) {
          String val = p.readResource(officeName, scenario, resReq, assignedSetting, true);
          assignedSetting.setStaticValue(val);
          return val;
        }
      }
    }
    //		else { //else dig further to the next setting
    //			for (SettingInstance s : assignedSetting.getAssignSetting() ) {
    //				return getStaticValueOfAssignedSetting(s);
    //			}
    //		}

    return null;
  }
Пример #2
0
  private IStatus runProvisionJob(IProgressMonitor monitor) {
    RuntimeElement rtInfo = resourceReq.getRuntimeInfo();

    broadcastResourceStatus(RuntimeElementStatus.OFFLINE);
    Random r1 = new Random();
    ScenarioSolver solver = new ScenarioSolver();
    if (!solver.resourceRequestHasAllAssignementsResolved(
        scenario, resourceReq)) { // r1.nextInt(20)>5 ){//ResourceSettingsAreNotOK ){	
      broadcastResourceStatus(RuntimeElementStatus.WAITING);

      Random r = new Random();
      this.schedule(1000 * r.nextInt(60) + 1000); // reschedule the job in 60random seconds
      System.out.println("RESCHEDULED : " + resourceReq.getName());
      return Status.OK_STATUS;
    }

    monitor.beginTask("Provisioning " + resourceReq.getName(), 1);
    if (monitor.isCanceled()) {
      parentJob.NotifyResJobFinished(this);
      System.out.println("ProvisionResourceJob, Cancel provisioning : " + resourceReq.getName());
      broadcastResourceStatus(RuntimeElementStatus.UNKNOWN);
      return Status.CANCEL_STATUS;
    }

    String guid = "";
    String officeName =
        ((Office) resourceReq.getRefOfferedResource().getImplOfferedService().eContainer())
            .getName();
    for (IProvisionResource p : Activator.getDefault().getProvisionPlugins()) {
      if (p.supportsOffice(officeName)) {
        broadcastResourceStatus(RuntimeElementStatus.STARTING);
        guid = p.provisionResource(officeName, scenario, resourceReq);
        rtInfo.setGUID(guid);
      }
    }

    //		try {
    //			Random r = new Random();
    //			Thread.sleep(1000 * r.nextInt(10) );
    //			guid="temp";
    //			rtInfo.setGUID(guid+"."+resourceReq.getName());
    //		} catch (InterruptedException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}

    if ("".equals(guid)) broadcastResourceStatus(RuntimeElementStatus.ERROR);
    else broadcastResourceStatus(RuntimeElementStatus.ONLINE);

    monitor.worked(1);

    monitor.done();
    parentJob.NotifyResJobFinished(this);

    return Status.OK_STATUS;
  }
Пример #3
0
  private IStatus runShutDownResourceJob(IProgressMonitor monitor) {
    RuntimeElement rtInfo = resourceReq.getRuntimeInfo();

    monitor.beginTask("Shutting down " + resourceReq.getName(), 1);
    if (monitor.isCanceled()) {
      parentJob.NotifyResJobFinished(this);
      System.out.println("ProvisionResourceJob, Cancel provisioning : " + resourceReq.getName());
      broadcastResourceStatus(RuntimeElementStatus.UNKNOWN);
      ;
      return Status.CANCEL_STATUS;
    }

    String guid = "";
    String officeName =
        ((Office) resourceReq.getRefOfferedResource().getImplOfferedService().eContainer())
            .getName();
    for (IProvisionResource p : Activator.getDefault().getProvisionPlugins()) {
      if (p.supportsOffice(officeName)) {
        if ((rtInfo.getStatus() != RuntimeElementStatus.NOT_EXISTS)) {

          try {
            Random r = new Random();
            Thread.sleep(1000 * r.nextInt(60)); // sleep randomly..shutdown to avoid collisions.
          } catch (InterruptedException e) {
            e.printStackTrace();
          }

          guid = p.deleteResource(officeName, scenario, resourceReq);
        }
        rtInfo.setGUID(guid);
      }
    }

    broadcastResourceStatus(RuntimeElementStatus.NOT_EXISTS);

    monitor.worked(1);

    monitor.done();
    System.out.println("ProvisionResourceJob, OK Provisioning : " + resourceReq.getName());
    parentJob.NotifyResJobFinished(this);

    return Status.OK_STATUS;
  }