Search in sources :

Example 1 with Person

use of org.hl7.fhir.dstu3.model.Person in project compss by bsc-wdc.

the class Redis method testMergeReduce.

public static void testMergeReduce() {
    // Init
    Person[] people = new Person[4];
    for (int i = 0; i < people.length; ++i) {
        String id = "person_" + UUID.randomUUID().toString();
        System.out.println("[LOG][PSCO_MR] Person " + i + " BeginId = " + id);
        people[i] = new Person("PName" + i, i, i);
        people[i].makePersistent(id);
    }
    // Map
    for (int i = 0; i < people.length; ++i) {
        people[i] = RedisImpl.taskMap("NewName" + i, people[i]);
    }
    // Reduce
    LinkedList<Integer> q = new LinkedList<Integer>();
    for (int i = 0; i < people.length; i++) {
        q.add(i);
    }
    int x = 0;
    while (!q.isEmpty()) {
        x = q.poll();
        int y;
        if (!q.isEmpty()) {
            y = q.poll();
            people[x] = RedisImpl.taskReduce(people[x], people[y]);
            q.add(x);
        }
    }
    // Get (sync) and write result
    Person p1 = people[0];
    String name = p1.getName();
    int age = p1.getAge();
    int numC = p1.getNumComputers();
    System.out.println("[LOG][PSCO_MR] Person " + name + " with age " + age + " has " + numC + " computers");
    System.out.println("[LOG][PSCO_MR] EndId = " + p1.getID());
}
Also used : Person(model.Person) LinkedList(java.util.LinkedList)

Example 2 with Person

use of org.hl7.fhir.dstu3.model.Person in project compss by bsc-wdc.

the class Redis method testPSCOTarget.

private static void testPSCOTarget() {
    String id = "person_" + UUID.randomUUID().toString();
    Person p = new Person("PName1", 1, 1);
    p.makePersistent(id);
    // Invoke 2 times to check if parameter is well returned from worker
    p.taskPSCOTarget();
    p.taskPSCOTarget();
    String name = p.getName();
    int age = p.getAge();
    int numC = p.getNumComputers();
    System.out.println("[LOG][PSCO_TARGET] Person " + name + " with age " + age + " has " + numC + " computers");
    System.out.println("[LOG][PSCO_TARGET] BeginId = " + id + " EndId = " + p.getID());
}
Also used : Person(model.Person)

Example 3 with Person

use of org.hl7.fhir.dstu3.model.Person in project compss by bsc-wdc.

the class Redis method testPSCOInOutTaskPersisted.

private static void testPSCOInOutTaskPersisted() {
    Person p = new Person("PName2", 2, 2);
    String id = RedisImpl.taskPSCOInOutTaskPersisted(p);
    String name = p.getName();
    int age = p.getAge();
    int numC = p.getNumComputers();
    System.out.println("[LOG][PSCO_INOUT_TP] Person " + name + " with age " + age + " has " + numC + " computers");
    System.out.println("[LOG][PSCO_INOUT_TP] BeginId = " + id + " EndId = " + p.getID());
}
Also used : Person(model.Person)

Example 4 with Person

use of org.hl7.fhir.dstu3.model.Person in project compss by bsc-wdc.

the class Redis method testPSCOIn.

private static void testPSCOIn() {
    String id = "person_" + UUID.randomUUID().toString();
    Person p = new Person("PName1", 1, 1);
    p.makePersistent(id);
    System.out.println("Object p has id " + p.getID());
    RedisImpl.taskPSCOIn(p);
}
Also used : Person(model.Person)

Example 5 with Person

use of org.hl7.fhir.dstu3.model.Person in project compss by bsc-wdc.

the class Main method produceSpawnConsumers.

private static void produceSpawnConsumers(int numProducers, int producerSleep, int consumerSleep) throws RegistrationException, IOException, BackendException {
    // Create stream
    PscoDistroStream<Person> pds = new PscoDistroStream<>(ConsumerMode.AT_MOST_ONCE);
    // Create producer task
    for (int i = 0; i < numProducers; ++i) {
        Tasks.writePscos(pds, producerSleep);
    }
    // Check stream status and generate consumers
    Integer[] partialPscos = new Integer[MAX_ENTRIES];
    int pos = 0;
    while (!pds.isClosed()) {
        List<Person> newPscos = pds.poll();
        for (Person p : newPscos) {
            System.out.println("Sending " + p.getID() + ":" + p.getName() + ":" + p.getAge() + " to a process task");
            partialPscos[pos] = Tasks.processPsco(p);
            pos = pos + 1;
        }
        // Sleep between polls
        try {
            Thread.sleep(consumerSleep);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
    // Although the stream is closed, there can still be pending events to process
    List<Person> newPscos = pds.poll();
    for (Person p : newPscos) {
        System.out.println("Sending " + p.getID() + ":" + p.getName() + ":" + p.getAge() + " to a process task");
        partialPscos[pos] = Tasks.processPsco(p);
        pos = pos + 1;
    }
    // Get all processed values
    Integer totalPscos = 0;
    for (int i = 0; i < pos; ++i) {
        if (partialPscos[i] != null) {
            totalPscos = totalPscos + partialPscos[i];
        }
    }
    // Wait for tasks completion
    System.out.println("[LOG] TOTAL NUMBER OF PROCESSED PSCOS: " + totalPscos);
}
Also used : Person(model.Person) PscoDistroStream(es.bsc.distrostreamlib.api.pscos.PscoDistroStream)

Aggregations

Test (org.junit.Test)181 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)54 Date (java.util.Date)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)48 Person (org.hl7.fhir.r4.model.Person)47 Person (model.Person)44 Person (com.google.api.services.people.v1.model.Person)38 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)37 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)32 Reference (org.hl7.fhir.r4.model.Reference)31 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)30 StringParam (ca.uhn.fhir.rest.param.StringParam)30 VCard (ezvcard.VCard)30 Person (org.openmrs.Person)29 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)23 List (java.util.List)22 Collectors (java.util.stream.Collectors)22 Person (org.hl7.fhir.dstu3.model.Person)22 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)22 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)21