return 0;
}
+static int
+reject_transactions(struct fcb_contract *fcb_contracts[], int num)
+{
+ int i;
+ for (i = 0; i < num; i++) {
+ if (fcb_contracts[i]->transaction)
+ return FRES_ERR_VRES_PART_OF_TRANSACTION;
+ }
+ return 0;
+}
CORBA_long
negotiate_contracts(fres_contract_broker obj,
contracts->_buffer, num);
if (ret)
goto err_free_fcb_contracts;
+
+ ret = reject_transactions(fcb_contracts, num);
+ if (ret)
+ goto err_free_fcb_contracts;
ret = check_and_setup_resource(fcb, fcb_contracts, &resource,
&app, num);
if (ret)
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) {
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);
}
static struct option long_opts[] = {
- { "daemon", optional_argument, NULL, 'd' },
{ "loglevel", required_argument, NULL, 'l' },
{ 0, 0, 0, 0}
};
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");
}
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;
};
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 == '?') {
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();
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");