]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Started implementation of frsh_transaction_alloc_vres()
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 25 Jun 2010 14:41:17 +0000 (16:41 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 25 Jun 2010 14:41:17 +0000 (16:41 +0200)
fres/cbroker/fcb.c
fres/cbroker/fcb.idl
fres/contract/fres_error.c
fres/contract/fres_error.h
frsh_api/frsh_transaction.c
frsh_api/tests/trans_nego.c

index 40b17ebad8ebc2f8812a808b8247dbaaa7dc469a..bd0f5cba892ac6ee48d80df7f49241ba7540370e 100644 (file)
@@ -1309,10 +1309,23 @@ wait_transaction(fres_contract_broker _obj,
 
 CORBA_long
 allocate_transaction_vres(fres_contract_broker _obj,
+                         const CORBA_char * name,
                          const CORBA_long id,
                          CORBA_Environment *ev)
 {
-       return FRSH_ERR_NOT_IMPLEMENTED;
+       struct fcb *fcb = o2fcb(_obj);
+       struct fcb_transaction *ft;
+       int ret;
+       char * const n = (char * const)&name;
+
+       ft = fcb_transaction_find(fcb, &n);
+       if (!ft) {
+               ret = FRES_ERR_TRANSACTION_NOT_FOUND;
+               goto err;
+       }
+       ret = 0;
+err:
+       return ret;
 }
 
 
index 70eb59a96e1e7b805b44294f89b4ad6e3d67ef3a..34cda1a9c9a63875fe318c4be41fd2d9ae14a938 100644 (file)
@@ -158,7 +158,7 @@ module fres {
                long negotiate_transaction(in transaction_t transaction);
                long wait_transaction(in string name,
                                      out transaction_t transaction);
-               long allocate_transaction_vres(in long id);
+               long allocate_transaction_vres(in string name, in long id);
        };
 };
 
index c66d8930fbd7d3629ab199cb81251fc57bdaced2..64ec91c42cb166dc1016ec2231681614adce1478 100644 (file)
@@ -127,6 +127,7 @@ int fres_strerror (int error, char *message, size_t size)
                MSG(VRES_ALREADY_ALLOCATED);
                MSG(VRES_PART_OF_TRANSACTION);
                MSG(SPARE_CAPACITY_NOT_SUPPORTED);
+               MSG(TRANSACTION_NOT_FOUND);
        }
 
        if (s == NULL) return FRSH_ERR_BAD_ARGUMENT;
index 29f1430bcf02f2c4ac8d6ef232dd348017439117..690895c35fb5a533a352d7365aefd951d5a6fb1f 100644 (file)
@@ -96,6 +96,7 @@ enum fres_error {
        FRES_ERR_VRES_ALREADY_ALLOCATED,
        FRES_ERR_VRES_PART_OF_TRANSACTION,
        FRES_ERR_SPARE_CAPACITY_NOT_SUPPORTED,
+       FRES_ERR_TRANSACTION_NOT_FOUND,
 };
 
 int fres_strerror (int error, char *message, size_t size);
index da64aead3f13d6b9d7a67608256bd75587cc6c1f..e1be8add87977dcbd5e1a0c4fe9827064b11ca95 100644 (file)
@@ -84,6 +84,7 @@ frsh_transaction_negotiate(frsh_transaction_t *trans)
 {
        int ret;
        struct forb_env env;
+
        if (!trans || !*trans) {
                ret = FRSH_ERR_BAD_ARGUMENT;
                goto err;
@@ -113,8 +114,17 @@ frsh_transaction_wait_for_name(frsh_transaction_t *transaction,
 
 int
 frsh_transaction_alloc_vres(frsh_transaction_t *t,
-                           int id,
+                           int index,
                            frsh_vres_id_t *vres)
 {
-       return FRSH_ERR_NOT_IMPLEMENTED;
+       int ret;
+       struct forb_env env;
+       ret = fres_contract_broker_allocate_transaction_vres(
+               frsh_forb_global.fcb, (*t)->name, index, &env);
+       if (forb_exception_occurred(&env)) {
+               ret = fres_forbex2err(&env);
+               goto err;
+       }
+err:
+       return ret;
 }
index 1fba70875a1b9a6daf2bb3b7f558aeed2ead3294..b5a1a75317468e88a9e389a994bd1858737008b9 100644 (file)
@@ -36,9 +36,10 @@ WVTEST_MAIN("transaction negotiation")
 
                WVFRSH(frsh_transaction_add_contract(&t, &contract[i], i));
        }
+       //WVPASS(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_1, &vres1) == FRES_ERR_TRANSACTION_NOT_FOUND);
        WVFRSH(frsh_transaction_negotiate(&t));
-#if 0  
 
+#if 0  
        WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_1, &vres1));
        WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_2, &vres2));
        /* TEST_CONTRACT_3 is allocated in trans_nego2.c */