コード例 #1
0
  public void disposeWorker(WorkerEntry workerEntry, List<IResponseTO> responses) {
    ServiceID serviceID = workerEntry.getServiceID();

    responses.add(new LoggerResponseTO("Worker dispose: " + serviceID, LoggerResponseTO.DEBUG));

    workerEntry.dispose();

    WorkerDAO workerDAO = BrokerDAOFactory.getInstance().getWorkerDAO();
    String wAddress = StringUtil.deploymentIDToAddress(workerEntry.getWorkerID());

    DisposeWorkerResponseTO disposeTO = new DisposeWorkerResponseTO();
    disposeTO.setPeerAddress(StringUtil.deploymentIDToAddress(workerEntry.getPeerID()));
    disposeTO.setWorkerAddress(wAddress);
    disposeTO.setWorkerPublicKey(workerDAO.getWorkerPublicKey(wAddress));
    responses.add(disposeTO);

    responses.add(new LoggerResponseTO("Stub to be released: " + wAddress, LoggerResponseTO.INFO));

    ReleaseResponseTO releaseTO = new ReleaseResponseTO();
    releaseTO.setStubAddress(wAddress);
    responses.add(releaseTO);

    workerDAO.removeWorker(wAddress);
    WorkerInfo.getInstance().removeWorker(workerEntry.getServiceID().getContainerID().toString());
  }
コード例 #2
0
  /**
   * @param job
   * @param workerEntry
   */
  private void unwantWorker(Job job, WorkerEntry workerEntry, List<IResponseTO> responses) {

    responses.add(
        new LoggerResponseTO(
            "Worker unwanted: " + workerEntry.getWorkerID(), LoggerResponseTO.DEBUG));

    job.unwantWorker(workerEntry);
    workerEntry.unwant();

    RequestSpecification spec = workerEntry.getRequestSpecification();

    String peerAddress = StringUtil.deploymentIDToAddress(workerEntry.getPeerID());
    String workerAddress = StringUtil.deploymentIDToAddress(workerEntry.getWorkerID());
    Integer jobId = Integer.parseInt("" + spec.getJobId());

    JobSpecification jobSpec = BrokerDAOFactory.getInstance().getJobDAO().getJobSpec(jobId);

    UnwantWorkerResponseTO unwantWorkerTO = new UnwantWorkerResponseTO();
    unwantWorkerTO.setJobID(jobId);
    unwantWorkerTO.setJobSpec(jobSpec);
    unwantWorkerTO.setMaxFails(spec.getMaxFails());
    unwantWorkerTO.setMaxReplicas(spec.getMaxReplicas());
    unwantWorkerTO.setPeerAddress(peerAddress);
    unwantWorkerTO.setRequestID(spec.getRequestId());
    unwantWorkerTO.setRequiredWorkers(spec.getRequiredWorkers());

    unwantWorkerTO.setWorkerAddress(workerAddress);

    WorkerDAO workerDAO = BrokerDAOFactory.getInstance().getWorkerDAO();

    String workerPublicKey = workerDAO.getWorkerPublicKey(workerAddress);
    unwantWorkerTO.setWorkerPublicKey(workerPublicKey);

    responses.add(unwantWorkerTO);

    ReleaseResponseTO releaseTO = new ReleaseResponseTO();
    releaseTO.setStubAddress(workerAddress);

    responses.add(releaseTO);

    workerDAO.removeWorker(workerAddress);

    WorkerInfo.getInstance().removeWorker(workerEntry.getServiceID().getContainerID().toString());
  }
コード例 #3
0
  public List<IResponseTO> execute(NotifyRemoteWorkerProviderRecoveryRequestTO request) {
    List<IResponseTO> responses = new ArrayList<IResponseTO>();

    if (CertificationUtils.getCertSubjectDN(request.getMyCertPath())
        .equals(CertificationUtils.getCertSubjectDN(request.getRwpCertPath()))) {

      LoggerResponseTO loggerResponse =
          new LoggerResponseTO(
              DiscoveryServiceClientMessages.getSameCertificateDNMessage(request.getRwpAddress()),
              LoggerResponseTO.DEBUG);
      responses.add(loggerResponse);

      ReleaseResponseTO releaseTO = new ReleaseResponseTO();
      releaseTO.setStubAddress(request.getRwpAddress());

      responses.add(releaseTO);

      return responses;
    }

    Collection<CertificateCRLPair> receivedPeersCAsData =
        PeerDAOFactory.getInstance().getPeerCertificationDAO().getReceivedPeersCAsData();

    if (receivedPeersCAsData != null && !receivedPeersCAsData.isEmpty()) {

      if (!CertificationUtils.isCertificateValid(request.getRwpCertPath())) {

        LoggerResponseTO loggerResponse =
            new LoggerResponseTO(
                DiscoveryServiceClientMessages.getInvalidCertPathMessage(request.getRwpAddress()),
                LoggerResponseTO.WARN);
        responses.add(loggerResponse);

        ReleaseResponseTO releaseTO = new ReleaseResponseTO();
        releaseTO.setStubAddress(request.getRwpAddress());

        responses.add(releaseTO);

        return responses;
      }

      if (!CertificationUtils.isCertPathIssuedByCA(
          request.getRwpCertPath(), receivedPeersCAsData)) {

        LoggerResponseTO loggerResponse =
            new LoggerResponseTO(
                DiscoveryServiceClientMessages.getNonIssuedCertPathMessage(request.getRwpAddress()),
                LoggerResponseTO.WARN);
        responses.add(loggerResponse);

        ReleaseResponseTO releaseTO = new ReleaseResponseTO();
        releaseTO.setStubAddress(request.getRwpAddress());

        responses.add(releaseTO);

        return responses;
      }
    }

    DiscoveryServiceClientDAO dao = PeerDAOFactory.getInstance().getDiscoveryServiceClientDAO();
    dao.addRemoteWorkerProviderAddress(request.getRwpAddress());

    PeerControl.getInstance()
        .insertPeer(
            responses,
            request.getRwpUserAtServer(),
            CertificationUtils.getCertSubjectDN(request.getRwpCertPath()));

    return responses;
  }