Exemplo n.º 1
0
 /**
  * Initialize it with assigning it a new ControlContext and a defaultMethod with serviceType as
  * "sorcer.core.provider.jobber.ServiceJobber" name as "service" and providerName "*"
  *
  * @throws sorcer.service.SignatureException
  */
 private void init() {
   NetSignature s = new NetSignature("service", Jobber.class);
   // Needs to be RemoteJobber for Cataloger to find it
   // s.setServiceType(Jobber.class.getName());
   s.setProviderName(null);
   s.setType(Signature.Type.SRV);
   signatures.add(s); // Add the signature
 }
Exemplo n.º 2
0
  // Made private so that other classes just calls execExertion and not
  // execTask
  private void execTask(NetTask task) throws ExertionException, SignatureException {

    logger.log(Level.INFO, "start executing task");
    try {
      Service provider =
          ProviderAccessor.getProvider(
              task.getProcessSignature().getProviderName(), task.getServiceType());
      logger.log(Level.INFO, "got a provider:" + provider);

      if (provider == null) {
        String msg = null;
        // get the PROCESS Method and grab provider name + interface
        NetSignature method = (NetSignature) task.getProcessSignature();
        msg =
            "No Provider available. Provider Name: "
                + method.getProviderName()
                + " Provider interface: "
                + method.getServiceType();
        System.err.println(msg);
        throw new ExertionException(msg, task);
      } else {
        // setTaskProvider(task, provider.getProviderName());
        logger.log(Level.INFO, "Servicing task now ..............");
        MonitoringSession session = (MonitoringSession) (task.getMonitorSession());
        session.init((Monitorable) provider, LEASE_RENEWAL_PERIOD, DEFAULT_TIMEOUT_PERIOD);
        lrm.renewUntil(session.getLease(), Lease.ANY, null);

        task.setService(provider);
        provider.service(task, null);
      }
    } catch (RemoteException re) {
      re.printStackTrace();
      logger.log(Level.SEVERE, "dispatcher execution failed for task: " + task);
      throw new ExertionException("Remote Exception while executing task");
    } catch (MonitorException mse) {
      mse.printStackTrace();
      logger.log(Level.SEVERE, "dispatcher execution failed for task: " + task);
      throw new ExertionException("Remote Exception while executing task");
    } catch (TransactionException te) {
      te.printStackTrace();
      logger.log(Level.SEVERE, "dispatcher execution failed for task: " + task);
      throw new ExertionException("Remote Exception while executing task");
    }
  }