public void reportReplicaAccounting(GridProcessAccounting replicaAccounting) {
    ReportReplicaAccountingRequestTO to = new ReportReplicaAccountingRequestTO();
    to.setUserPublicKey(serviceManager.getSenderPublicKey());
    to.setAccounting(replicaAccounting);

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void hereIsRemoteWorkerProviderList(List<String> workerProviders) {
    HereIsRemoteWorkerProviderListRequestTO to = new HereIsRemoteWorkerProviderListRequestTO();
    to.setSenderAddress(serviceManager.getSenderServiceID().toString());
    to.setWorkerProviders(workerProviders);

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void hereIsJobStats(JobStatusInfo jobStatusInfo) {
    HereIsJobStatsRequestTO to = new HereIsJobStatsRequestTO();
    to.setJobStatusInfo(jobStatusInfo);
    to.setMyId(serviceManager.getMyDeploymentID().toString());

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void getRemoteWorkerProviders(
      @MonitoredBy(DiscoveryServiceConstants.DS_OBJECT_NAME) DiscoveryServiceClient dsClient,
      int maxResponseSize) {
    GetRemoteWorkerProvidersRequestTO to = new GetRemoteWorkerProvidersRequestTO();

    ServiceID serviceID = serviceManager.getStubDeploymentID(dsClient).getServiceID();

    to.setClientAddress(serviceID.toString());
    to.setClientUserAtServer(serviceID.getContainerID().getUserAtServer().toString());
    to.setMyAddress(
        serviceManager
            .getObjectDeploymentID(DiscoveryServiceConstants.DS_OBJECT_NAME)
            .getServiceID()
            .toString());
    to.setMaxResponseSize(maxResponseSize);
    to.setOverloadThreshold(
        serviceManager
            .getContainerContext()
            .parseIntegerProperty(DiscoveryServiceConfiguration.PROP_OVERLOAD_THRESHOLD));
    to.setDsMaxResponse(
        serviceManager
            .getContainerContext()
            .parseIntegerProperty(DiscoveryServiceConfiguration.PROP_MAX_RESPONSE_SIZE));

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  /**
   * Processes the login request of a Broker client. Returns to the client the result of the login
   * operation, and in case of successful login the stub to the Accounting object.
   *
   * @param workerProviderClient The client callback
   * @param brokerPublicKey The PublicKey Object of the Broker requesting login
   */
  @Req("REQ108")
  public void login(
      @MonitoredBy(PeerConstants.LOCAL_WORKER_PROVIDER)
          LocalWorkerProviderClient workerProviderClient) {

    LoginRequestTO to = new LoginRequestTO();
    to.setSenderPublicKey(serviceManager.getSenderPublicKey());

    DeploymentID workerProviderClientID = serviceManager.getStubDeploymentID(workerProviderClient);
    to.setWorkerProviderClientAddress(workerProviderClientID.getServiceID().toString());
    to.setUserName(workerProviderClientID.getUserName());
    to.setServerName(workerProviderClientID.getServerName());

    ModuleContext containerContext = serviceManager.getContainerContext();

    to.setMyUserAtServer(getUserAtServer(containerContext));
    to.setFilePath(containerContext.getProperty(PeerConfiguration.PROP_RANKINGFILE));
    to.setDescription(containerContext.getProperty(PeerConfiguration.PROP_DESCRIPTION));
    to.setEmail(containerContext.getProperty(PeerConfiguration.PROP_EMAIL));
    to.setLabel(containerContext.getProperty(PeerConfiguration.PROP_LABEL));
    to.setLatitude(containerContext.getProperty(PeerConfiguration.PROP_LATITUDE));
    to.setLongitude(containerContext.getProperty(PeerConfiguration.PROP_LONGITUDE));
    to.setMyCertSubjectDN(CertificationUtils.getCertSubjectDN(serviceManager.getMyCertPath()));

    to.setOnDemandPeer(
        serviceManager.getContainerContext().isEnabled(PeerConfiguration.PROP_ONDEMAND_PEER));

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  @RecoveryNotification
  public void dsClientIsUp(
      DiscoveryServiceClient discoveryServiceClient, DeploymentID providerDID) {
    DSClientIsUpRequestTO to = new DSClientIsUpRequestTO();
    to.setClientUserAtServer(providerDID.getContainerID().getUserAtServer().toString());

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void getDiscoveryServices(
      @MonitoredBy(DiscoveryServiceConstants.DS_MONITOR) DiscoveryService discoveryService) {
    DSGetDiscoveryServicesRequestTO to = new DSGetDiscoveryServicesRequestTO();

    to.setDsAddress(serviceManager.getStubDeploymentID(discoveryService).getServiceID().toString());

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void requestWorkers(RequestSpecification requestSpec, String publicKey) {
    RequestWorkersRequestTO request = new RequestWorkersRequestTO();
    request.setRequestSpec(requestSpec);
    request.setBrokerPublicKey(publicKey);
    request.setMyPublicKey(serviceManager.getMyPublicKey());
    request.setMyCertPath(serviceManager.getMyCertPath());

    OurGridRequestControl.getInstance().execute(request, serviceManager);
  }
  @Req("REQ116")
  public void updateRequest(RequestSpecification requestSpec) {

    UpdateRequestRequestTO to = new UpdateRequestRequestTO();
    to.setRequestSpec(requestSpec);
    to.setBrokerPublicKey(serviceManager.getSenderPublicKey());
    to.setMyCertPathDN(CertificationUtils.getCertSubjectDN(serviceManager.getMyCertPath()));

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  @Req("REQ117")
  public void pauseRequest(long requestID) {
    PauseRequestRequestTO to = new PauseRequestRequestTO();

    String brokerPublicKey = serviceManager.getSenderPublicKey();
    to.setBrokerPublicKey(brokerPublicKey);
    to.setRequestId(requestID);

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void leaveCommunity(
      @MonitoredBy(DiscoveryServiceConstants.DS_OBJECT_NAME) DiscoveryServiceClient dsClient) {
    LeaveCommunityRequestTO to = new LeaveCommunityRequestTO();

    ServiceID serviceID = serviceManager.getStubDeploymentID(dsClient).getServiceID();

    to.setClientAddress(serviceID.toString());
    to.setClientUserAtServer(serviceID.getContainerID().getUserAtServer());

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  @Req("REQ014")
  public void finishRequest(RequestSpecification requestSpec) {

    FinishRequestRequestTO to = new FinishRequestRequestTO();

    String brokerPublicKey = serviceManager.getSenderPublicKey();
    to.setBrokerPublicKey(brokerPublicKey);
    to.setRequestSpec(requestSpec);
    to.setMyCertPathDN(CertificationUtils.getCertSubjectDN(serviceManager.getMyCertPath()));

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  @FailureNotification
  public void dsClientIsDown(
      DiscoveryServiceClient discoveryServiceClient, DeploymentID monitorableID) {
    DSClientIsDownRequestTO to = new DSClientIsDownRequestTO();

    to.setClientAddress(monitorableID == null ? null : monitorableID.getServiceID().toString());
    to.setClientUserAtServer(
        monitorableID == null
            ? null
            : monitorableID.getServiceID().getContainerID().getUserAtServer());

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  @Req("REQ016")
  public void unwantedWorker(ServiceID workerID, RequestSpecification requestSpec) {

    UnwantedWorkerRequestTO to = new UnwantedWorkerRequestTO();
    to.setRequestSpec(requestSpec);
    to.setSenderPublicKey(serviceManager.getSenderPublicKey());

    if (workerID != null) {
      to.setWorkerAddress(workerID.toString());
      to.setWorkerPublicKey(workerID.getPublicKey());
    }

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  @Req("REQ015")
  public void disposeWorker(ServiceID workerServiceID) {

    String brokerPublicKey = serviceManager.getSenderPublicKey();

    DisposeWorkerRequestTO to = new DisposeWorkerRequestTO();
    to.setBrokerPublicKey(brokerPublicKey);

    if (workerServiceID != null) {
      to.setWorkerAddress(workerServiceID.toString());
      to.setWorkerUserAtServer(workerServiceID.getContainerID().getUserAtServer());
      to.setWorkerPublicKey(workerServiceID.getPublicKey());
    }

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  /**
   * Notifies that a Broker has failed
   *
   * @param monitorable The Broker that has failed.
   * @param monitorableID The DeploymentID of the Broker that has failed.
   */
  @FailureNotification
  public void doNotifyFailure(LocalWorkerProviderClient monitorable, DeploymentID monitorableID) {
    NotifyLocalWorkerProviderClientFailureRequestTO to =
        new NotifyLocalWorkerProviderClientFailureRequestTO();

    String myCertPathDN = CertificationUtils.getCertSubjectDN(serviceManager.getMyCertPath());
    String brokerContainerID = monitorableID.getContainerID().toString();
    String brokerUserAtServer = monitorableID.getContainerID().getUserAtServer();
    String brokerPublicKey = monitorableID.getPublicKey();
    String brokerAddress = monitorableID.getServiceID().toString();

    to.setMyCertPathDN(myCertPathDN);
    to.setBrokerContainerID(brokerContainerID);
    to.setBrokerUserAtServer(brokerUserAtServer);
    to.setBrokerPublicKey(brokerPublicKey);
    to.setBrokerAddress(brokerAddress);

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void hereAreDiscoveryServices(List<ServiceID> discoveryServicesID) {
    HereAreDiscoveryServicesRequestTO to = new HereAreDiscoveryServicesRequestTO();

    List<String> dsAddresses = new ArrayList<String>();

    for (ServiceID id : discoveryServicesID) {
      dsAddresses.add(id.toString());
    }

    to.setDiscoveryServicesAddresses(dsAddresses);
    to.setMyAddress(
        serviceManager
            .getObjectDeploymentID(DiscoveryServiceConstants.DS_OBJECT_NAME)
            .getServiceID()
            .toString());
    to.setSenderAddress(serviceManager.getSenderServiceID().toString());

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }
  public void getDiscoveryServices(
      @MonitoredBy(DiscoveryServiceConstants.DS_OBJECT_NAME)
          DiscoveryServiceClient discoveryServiceClient) {

    DSClientGetDiscoveryServicesRequestTO to = new DSClientGetDiscoveryServicesRequestTO();

    DeploymentID stubDeploymentID = serviceManager.getStubDeploymentID(discoveryServiceClient);
    to.setClientAddress(stubDeploymentID.getServiceID().toString());
    to.setClientUserAtServer(stubDeploymentID.getContainerID().getUserAtServer());
    to.setMyAddress(
        serviceManager
            .getObjectDeploymentID(DiscoveryServiceConstants.DS_OBJECT_NAME)
            .getServiceID()
            .toString());
    to.setOverloadThreshold(
        serviceManager
            .getContainerContext()
            .parseIntegerProperty(DiscoveryServiceConfiguration.PROP_OVERLOAD_THRESHOLD));

    OurGridRequestControl.getInstance().execute(to, serviceManager);
  }