From: Michal Sojka Date: Fri, 25 Jun 2010 21:46:56 +0000 (+0200) Subject: fcb: Do not allow multiple allocations of the same VRES (within a transaction) X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/frsh.git/commitdiff_plain/aaa70a5330b36387e53ccc5d1afda3cc2ddddbf3?hp=432bcd17d464e2d90d324feaa8cca415391c5fa1 fcb: Do not allow multiple allocations of the same VRES (within a transaction) --- diff --git a/fres/cbroker/fcb.c b/fres/cbroker/fcb.c index 9d5564a..b63e014 100644 --- a/fres/cbroker/fcb.c +++ b/fres/cbroker/fcb.c @@ -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); diff --git a/frsh_api/tests/trans_nego2.c b/frsh_api/tests/trans_nego2.c index e893727..53b852d 100644 --- a/frsh_api/tests/trans_nego2.c +++ b/frsh_api/tests/trans_nego2.c @@ -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(); }