]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
fcb: Do not allow multiple allocations of the same VRES (within a transaction)
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 25 Jun 2010 21:46:56 +0000 (23:46 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 25 Jun 2010 21:46:56 +0000 (23:46 +0200)
fres/cbroker/fcb.c
frsh_api/tests/trans_nego2.c

index 9d5564a683df719a1640a7f71d73675f9c606a3d..b63e014971767298d9df75706a1f19ab9b9da51c 100644 (file)
@@ -1271,6 +1271,13 @@ negotiate_transaction(fres_contract_broker _obj,
                fcb_remember_schedulable_contracts(fcb, schedulable_contracts);
                forb_sequence_free(schedulable_contracts, fres_contract_ptr_destroy);
        }
+       /* TODO: After we distinguish between APP and a real
+        * allocator, allocate VRESes (and perform mode change) here.
+        * Only if the resource allocator is not known at this point,
+        * wait with allocation the same way as it is done now. For
+        * this we will need more information about allocators i.e.
+        * its type (centralized, distributed, in app, ...). Too
+        * compilcated ;-( */
 
        ft = fcb_transaction_new(transaction->name);
        if (!ft) {
@@ -1358,6 +1365,11 @@ allocate_transaction_vres(fres_contract_broker _obj,
        fc = tran_contract_indx2item(ft, index);
        if (!fc) GOTO(err, FRSH_ERR_TOO_LARGE);
 
+       /* TODO: If we allow migration of task between resources (due
+        * to spare capacity reallocation), the following check will
+        * need reworking/enhancing. */
+       if (fc->ra) GOTO(err, FRES_ERR_VRES_ALREADY_ALLOCATED);
+
        if (!get_fc_res_key(fc, &key))
                GOTO(err, FRSH_ERR_RESOURCE_ID_INVALID);
        resource = fcb_resource_find(fcb, &key);
index e89372707d1ae5a7fc9cea7f0285f77d945c13a1..53b852deb7da5fcadd50ca4f3155f07bc890225e 100644 (file)
@@ -6,15 +6,18 @@
 WVTEST_MAIN("transaction negotiation - remote part")
 {
        frsh_transaction_t t;
-       frsh_vres_id_t vres;
+       frsh_vres_id_t vres1, vres2;
        
        WVFRSH(frsh_init());
        WVFRSH(fra_dummy_init_and_activate_id(1));
+       WVFRSH(fra_dummy_init_and_activate_id(2));
 #if 0
        WVFRSH(frsh_transaction_wait_for_name(&t, "test"));
-       WVPASS(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_2, &vres3) ==
-              FRES_ERR_VRES_ALREADY_ALLOCATED);
-       WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_3, &vres3));
+#else
+       WVFRSH(frsh_transaction_init(&t, "test"));
 #endif 
+       WVPASS(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_1, &vres1) ==
+              FRES_ERR_VRES_ALREADY_ALLOCATED);
+       WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_2, &vres2));
        frsh_destroy();
 }