]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - fres/cbroker/fcb.c
forb: executable resources and fcb changed into dynamic libs
[frescor/frsh.git] / fres / cbroker / fcb.c
index 9d5564a683df719a1640a7f71d73675f9c606a3d..f931d2eb4573fe4aa0eec574baf91772f455ed1d 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);
@@ -1457,7 +1469,6 @@ void peer_dead_callback(const forb_orb peer_orb, const char *orb_id)
 }
 
 static struct option long_opts[] = {
-    { "daemon",   optional_argument, NULL, 'd' },
     { "loglevel", required_argument, NULL, 'l' },
     { 0, 0, 0, 0}
 };
@@ -1466,7 +1477,6 @@ static void
 usage(void)
 {
        printf("usage: fcb [ options ]\n");
-       printf("  -d, --daemon [pid-file]   go to background after FORB initialization\n");
        printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
 }
 
@@ -1476,9 +1486,8 @@ int print_log_domain(ul_log_domain_t *domain, void *context)
        return 0;
 }
 
-int main(int argc, char *argv[])
+int forb_main(forb_orb orb, int argc, char *argv[])
 {
-       forb_orb orb;
        struct fcb fcb_data;
        fres_contract_broker fcb;
        forb_executor_t executor;
@@ -1495,7 +1504,7 @@ int main(int argc, char *argv[])
        };
        int  opt;
 
-       while ((opt = getopt_long(argc, argv, "d::l:", &long_opts[0], NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "hl:", &long_opts[0], NULL)) != EOF) {
                switch (opt) {
                        case 'l':
                                if (*optarg == '?') {
@@ -1509,10 +1518,6 @@ int main(int argc, char *argv[])
                                                error(1, EINVAL, "Error parsing -l argument at char %d\n", ret);
                                }
                                break;
-                       case 'd':
-                               opt_daemon = true;
-                               opt_pidfile = optarg;
-                               break;
                        case 'h':
                        /*default:*/
                                usage();
@@ -1526,9 +1531,6 @@ int main(int argc, char *argv[])
        if (opt_daemon)
                forb_daemon_prepare(opt_pidfile);
 
-       orb = forb_init(&argc, &argv, &attr);
-       if (!orb) error(1, errno, "FORB initialization failed");
-
 #if CONFIG_FCB_INET && !CONFIG_FORB_PROTO_INET_DEFAULT
        ret = register_inet_port(orb);
        if (ret) error(0, errno, "INET port registration failed");