Search in sources :

Example 1 with ReservedWorker

use of org.datatransferproject.types.client.transfer.ReservedWorker in project data-transfer-project by google.

the class GetReservedWorkerAction method handle.

@Override
public ReservedWorker handle(GetReservedWorker workerRequest) {
    String id = workerRequest.getId();
    UUID jobId = decodeJobId(id);
    PortabilityJob job = jobStore.findJob(jobId);
    Preconditions.checkNotNull(job, "Couldn't lookup worker for job " + id + " because the job doesn't exist");
    if (job.jobAuthorization().state() != CREDS_ENCRYPTION_KEY_GENERATED) {
        monitor.debug(() -> format("Job %s has not entered state CREDS_ENCRYPTION_KEY_GENERATED yet", jobId), jobId);
        return new ReservedWorker(null);
    }
    monitor.debug(() -> format("Got job %s in state CREDS_ENCRYPTION_KEY_GENERATED, returning its public key", jobId), jobId, EventCode.API_GOT_RESERVED_WORKER);
    return new ReservedWorker(job.jobAuthorization().authPublicKey());
}
Also used : PortabilityJob(org.datatransferproject.spi.cloud.types.PortabilityJob) GetReservedWorker(org.datatransferproject.types.client.transfer.GetReservedWorker) ReservedWorker(org.datatransferproject.types.client.transfer.ReservedWorker) UUID(java.util.UUID)

Example 2 with ReservedWorker

use of org.datatransferproject.types.client.transfer.ReservedWorker in project data-transfer-project by google.

the class ReserveWorkerAction method handle.

@Override
public ReservedWorker handle(ReserveWorker reserveWorker) {
    String id = reserveWorker.getId();
    Preconditions.checkNotNull(id, "transfer job ID required for ReserveWorkerAction");
    UUID jobId = decodeJobId(id);
    updateStateToCredsAvailable(jobId);
    // this was successful
    return new ReservedWorker("");
}
Also used : ReservedWorker(org.datatransferproject.types.client.transfer.ReservedWorker) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)2 ReservedWorker (org.datatransferproject.types.client.transfer.ReservedWorker)2 PortabilityJob (org.datatransferproject.spi.cloud.types.PortabilityJob)1 GetReservedWorker (org.datatransferproject.types.client.transfer.GetReservedWorker)1