Beispiel #1
0
  @Override
  public Task doTask(Transaction txn, Arg... args)
      throws ExertionException, SignatureException, RemoteException {
    try {
      // update the scope of target
      if (target.getScope() == null) {
        target.setScope(scope);
      } else {
        target.getScope().append(scope);
      }

      ReturnPath rp = (ReturnPath) target.getContext().getReturnPath();

      if (condition == null) {
        for (int i = 0; i < max - min; i++) {
          target = target.exert(txn);
          if (rp != null && rp.path != null) {
            scope.putValue(target.getName(), target.getContext().getReturnValue());
          }
        }
        return this;
      } else if (condition != null && max - min == 0) {
        if (target instanceof Model) {
          Context cxt = condition.getConditionalContext();
          condition.setConditionalContext((Context) target);
          if (cxt != null && cxt.size() > 0) {
            ((Context) target).append(cxt);
          }
        }
        while (condition.isTrue()) {
          if (target instanceof Exertion) {
            Signature sig = target.getProcessSignature();
            if (sig != null && sig.getVariability() != null) {
              target.getContext().append(condition.getConditionalContext());
            }
            target = target.exert(txn, args);
            if (sig != null && sig.getVariability() != null) {
              ((Task) target).updateConditionalContext(condition);
            }
          } else {
            if (target instanceof SrvModel) ((SrvModel) target).clearOutputs();
            target = target.exert(txn, args);
          }
        }
      } else if (condition != null && max - min > 0) {
        // exert min times
        for (int i = 0; i < min; i++) {
          target = target.exert(txn, args);
        }
        for (int i = 0; i < max - min; i++) {
          target = target.exert(txn);
          if (condition.isTrue()) target = target.exert(txn, args);
          else return this;
        }
      }
    } catch (Exception e) {
      throw new ExertionException(e);
    }
    return this;
  }
Beispiel #2
0
  private void printRecords(Store type) throws RemoteException, MonitorException {
    if (dataStorers == null || dataStorers.length == 0) {
      findStorers();
    }
    Map<Uuid, ObjectInfo> all;
    if (selectedDataStorer >= 0) {
      out.println(
          "From Data Storage: "
              + AttributesUtil.getProviderName(dataStorers[selectedDataStorer].attributeSets)
              + " at: "
              + AttributesUtil.getHostName(dataStorers[selectedDataStorer].attributeSets));
      //			all = ((StorageManagement) dataStorers[selectedDataStorer].service)
      //					.getMonitorableExertionInfo(type,
      //							NetworkShell.getPrincipal());

      Context cxt = null;
      try {
        store("test-only");
        out.println("XXXXXXXXXXXXX service item: " + dataStorers[selectedDataStorer]);
        out.println(
            "XXXXXXXXXXXXX service: " + (DatabaseStorer) dataStorers[selectedDataStorer].service);
        out.println(
            "XXXXXXXXXXXXX interfaces: "
                + Arrays.toString(
                    dataStorers[selectedDataStorer].service.getClass().getInterfaces()));
        out.println(
            "XXXXXXXXXXXXX name: "
                + ((Provider) dataStorers[selectedDataStorer].service).getProviderName());
        try {
          cxt =
              ((DatabaseStorer) dataStorers[selectedDataStorer].service)
                  .contextList(SdbUtil.getListContext(Store.object));
        } catch (MalformedURLException e) {
          e.printStackTrace();
        }
        out.println("XXXXXXXXXXXXX context: " + cxt);
        try {
          store("test-only");
          List<String> records = list(Store.object);
          out.println("XXXXXXXXXXXXX records; " + records);
        } catch (ExertionException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (SignatureException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        out.println(cxt.getValue(DatabaseStorer.store_content_list));
        //			} catch (ExertionException e) {
        //				e.printStackTrace();
        //			} catch (SignatureException e) {
        //				e.printStackTrace();
      } catch (ContextException e) {
        e.printStackTrace();
      }

    } else {
      Map<Uuid, ObjectInfo> ri = null;
      all = new HashMap<Uuid, ObjectInfo>();
      for (int i = 0; i < dataStorers.length; i++) {
        out.println(
            "From Data Storage "
                + AttributesUtil.getProviderName(dataStorers[i].attributeSets)
                + " at: "
                + AttributesUtil.getHostName(dataStorers[i].attributeSets));

        DatabaseStorer emx = (DatabaseStorer) dataStorers[i].service;
        //				ri = emx.getMonitorableExertionInfo(type,
        //						NetworkShell.getPrincipal());
        if (ri != null && ri.size() > 0) {
          all.putAll(ri);
        }
        // populate exertion/EMX map
        dataStorerMap.clear();
        for (ObjectInfo ei : ri.values()) {
          dataStorerMap.put(ei.uuid, dataStorers[i]);
        }
      }
    }
    //		if (all.size() == 0) {
    //			out.println("No monitored exertions at this time.");
    //			return;
    //		}
    //		recordInfos = new RecordInfo[all.size()];
    //		all.values().toArray(recordInfos);
    //		printRecordInfos(recordInfos);
  }