Commit f0ea7615 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Changed async recall calls payload (used view with include params instead of custom protocol)

parent ecb8bc95
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class JobService {
            Transfer transfer = uriService.getTransfer(job);

            ExecutionPhase phase;
            if (transfer.getProtocols().stream().anyMatch(p -> "ia2:async-recall".equals(p.getUri()))) {
            if (isAsyncRecall(transfer)) {
                // Async recall from tape jobs are queued. They will be started by VOSpace transfer service
                phase = ExecutionPhase.QUEUED;
            } else {
@@ -132,11 +132,13 @@ public class JobService {

    private Transfer handlePullToVoSpace(JobSummary job, Transfer transfer) {

        for (Protocol protocol : transfer.getProtocols()) {
            switch (protocol.getUri()) {
                case "ia2:async-recall":
        if (isAsyncRecall(transfer)) {
            asyncTransfService.startJob(job);
            return transfer;
        }

        for (Protocol protocol : transfer.getProtocols()) {
            switch (protocol.getUri()) {
                case "ivo://ivoa.net/vospace/core#httpget":
                    if (transfer.getTarget().size() != 1) {
                        throw new InvalidArgumentException("Invalid target size for pullToVoSpace: " + transfer.getTarget().size());
@@ -158,6 +160,11 @@ public class JobService {
        throw new InvalidArgumentException("Transfer contains no protocols");
    }

    private boolean isAsyncRecall(Transfer transfer) {
        return transfer.getView() != null
                && "ivo://ia2.inaf.it/vospace/views#async-recall".equals(transfer.getView().getUri());
    }
    
    private void handleMoveNode(JobSummary jobSummary, Transfer transfer) {
        // User data must be extracted before starting the new thread
        // to avoid the "No thread-bound request found" exception
+22 −7
Original line number Diff line number Diff line
@@ -5,12 +5,14 @@
 */
package it.inaf.oats.vospace;

import it.inaf.oats.vospace.datamodel.Views;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.ivoa.xml.uws.v1.JobSummary;
import net.ivoa.xml.vospace.v2.Protocol;
import net.ivoa.xml.vospace.v2.Param;
import net.ivoa.xml.vospace.v2.Transfer;
import net.ivoa.xml.vospace.v2.View;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
@@ -26,7 +28,7 @@ import redis.clients.jedis.Jedis;
@ExtendWith(MockitoExtension.class)
public class AsyncTransferServiceTest {

    private static final String JSON_JOB = "{\"jobId\":\"job_id\",\"runId\":null,\"ownerId\":null,\"phase\":null,\"quote\":null,\"creationTime\":null,\"startTime\":null,\"endTime\":null,\"executionDuration\":0,\"destruction\":null,\"parameters\":null,\"results\":[],\"errorSummary\":null,\"jobInfo\":{\"transfer\":{\"target\":[\"vos://example.com!vospace/my-node\"],\"direction\":\"pullToVoSpace\",\"view\":null,\"protocols\":[],\"keepBytes\":null,\"version\":null,\"param\":[]}},\"version\":null}\n";
    private static final String JSON_JOB = "{\"jobId\":\"job_id\",\"runId\":null,\"ownerId\":null,\"phase\":null,\"quote\":null,\"creationTime\":null,\"startTime\":null,\"endTime\":null,\"executionDuration\":0,\"destruction\":null,\"parameters\":null,\"results\":[],\"errorSummary\":null,\"jobInfo\":{\"transfer\":{\"target\":[\"vos://example.com!vospace/my-node\"],\"direction\":\"pullToVoSpace\",\"view\":{\"param\":[{\"value\":\"file1.txt\",\"uri\":\"ivo://ia2.inaf.it/vospace/views#async-recall/include\"},{\"value\":\"file2.txt\",\"uri\":\"ivo://ia2.inaf.it/vospace/views#async-recall/include\"}],\"uri\":\"ivo://ia2.inaf.it/vospace/views#async-recall\",\"original\":true},\"protocols\":[],\"keepBytes\":false,\"version\":null,\"param\":[]}},\"version\":null}";

    @Test
    public void testRedisRpc() {
@@ -61,11 +63,24 @@ public class AsyncTransferServiceTest {
    private JobSummary getFakeJob() {
        Transfer transfer = new Transfer();
        transfer.setDirection("pullToVoSpace");
        Protocol protocol = new Protocol();
        protocol.setUri("ia2:async-recall");
        transfer.getProtocols().add(protocol);

        transfer.setTarget(Arrays.asList("vos://example.com!vospace/my-node"));

        View view = new View();
        view.setUri(Views.ASYNC_RECALL_VIEW_URI);

        Param p1 = new Param();
        p1.setUri(Views.ASYNC_RECALL_VIEW_URI + "/include");
        p1.setValue("file1.txt");
        view.getParam().add(p1);

        Param p2 = new Param();
        p2.setUri(Views.ASYNC_RECALL_VIEW_URI + "/include");
        p2.setValue("file2.txt");
        view.getParam().add(p2);

        transfer.setView(view);

        JobSummary job = new JobSummary();
        job.setJobId("job_id");

+5 −3
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 */
package it.inaf.oats.vospace;

import it.inaf.oats.vospace.datamodel.Views;
import it.inaf.oats.vospace.exception.NodeBusyException;
import it.inaf.oats.vospace.persistence.JobDAO;
import java.util.ArrayList;
@@ -15,6 +16,7 @@ import net.ivoa.xml.uws.v1.ExecutionPhase;
import net.ivoa.xml.uws.v1.JobSummary;
import net.ivoa.xml.vospace.v2.Protocol;
import net.ivoa.xml.vospace.v2.Transfer;
import net.ivoa.xml.vospace.v2.View;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -229,9 +231,9 @@ public class JobServiceTest {
    private Transfer getTapeTransfer() {
        Transfer transfer = new Transfer();
        transfer.setDirection("pullToVoSpace");
        Protocol protocol = new Protocol();
        protocol.setUri("ia2:async-recall");
        transfer.getProtocols().add(protocol);
        View view = new View();
        view.setUri(Views.ASYNC_RECALL_VIEW_URI);
        transfer.setView(view);
        return transfer;
    }

+5 −1
Original line number Diff line number Diff line
<vos:transfer xmlns:vos="http://www.ivoa.net/xml/VOSpace/v2.0" version="2.1">
    <vos:target>vos://example.com!vospace/mynode</vos:target>
    <vos:direction>pullToVoSpace</vos:direction>
    <vos:protocol uri="ia2:async-recall" />
    <vos:view uri="ivo://ia2.inaf.it/vospace/views#async-recall">
        <vos:param uri="ivo://ia2.inaf.it/vospace/views#async-recall/include">test1.txt</vos:param>
        <vos:param uri="ivo://ia2.inaf.it/vospace/views#async-recall/include">test2.txt</vos:param>
        <vos:param uri="ivo://ia2.inaf.it/vospace/views#async-recall/include">test3.txt</vos:param>
    </vos:view>
</vos:transfer>
 No newline at end of file