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);
  }
  public void execute(HereIsLocalConsumersStatusResponseTO response, ServiceManager manager) {
    ServiceID clientID = ServiceID.parse(response.getClientAddress());
    PeerStatusProviderClient client =
        (PeerStatusProviderClient) manager.getStub(clientID, PeerStatusProviderClient.class);

    client.hereIsLocalConsumersStatus(
        ServiceID.parse(response.getPeerAddress()), response.getLocalConsumersInfo());
  }
  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("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);
  }
  public void execute(DSHereAreDiscoveryServicesResponseTO response, ServiceManager manager) {
    Set<DiscoveryServiceInfo> discoveryServices = response.getDiscoveryServices();

    List<ServiceID> dsIDs = new ArrayList<ServiceID>();

    for (DiscoveryServiceInfo ds : discoveryServices) {
      dsIDs.add(ServiceID.parse(ds.getDsAddress()));
    }

    DiscoveryService ds =
        (DiscoveryService)
            manager.getStub(ServiceID.parse(response.getStubAddress()), DiscoveryService.class);

    ds.hereAreDiscoveryServices(dsIDs);
  }
  @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);
  }
  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);
  }