static void update_stats (struct GNUNET_CONTAINER_MultiHashMap *m)
{
GNUNET_assert (NULL != m);
- GNUNET_assert (NULL != GSE_stats);
+ GNUNET_assert (NULL != GED_stats);
if (m == nodes_active)
{
- GNUNET_STATISTICS_set (GSE_stats, "# nodes active",
+ GNUNET_STATISTICS_set (GED_stats, "# nodes active",
GNUNET_CONTAINER_multihashmap_size(m), GNUNET_NO);
}
else if (m == nodes_inactive)
{
- GNUNET_STATISTICS_set (GSE_stats, "# nodes inactive",
+ GNUNET_STATISTICS_set (GED_stats, "# nodes inactive",
GNUNET_CONTAINER_multihashmap_size(m), GNUNET_NO);
}
else if (m == nodes_requested)
{
- GNUNET_STATISTICS_set (GSE_stats, "# nodes requested",
+ GNUNET_STATISTICS_set (GED_stats, "# nodes requested",
GNUNET_CONTAINER_multihashmap_size(m), GNUNET_NO);
}
else
GNUNET_i2s (&n->id));
/* Tell the scheduler to add a node with an experiment */
- GNUNET_EXPERIMENTATION_scheduler_add (n, e);
+ GED_scheduler_add (n, e);
counter ++;
}
for (c1 = 0; c1 < n->issuer_count; c1++)
{
- GNUNET_EXPERIMENTATION_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb);
+ GED_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb);
}
}
ic_accepted = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id))
ic_accepted ++;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Request from peer `%s' with %u issuers, we accepted %u issuer \n"),
c2 = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id))
{
n->issuer_id[c2] = rmi[c1].issuer_id;
c2 ++;
ic_accepted = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id))
ic_accepted ++;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Response from peer `%s' with %u issuers, we accepted %u issuer \n"),
c2 = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id))
{
n->issuer_id[c2] = rmi[c1].issuer_id;
c2 ++;
node_make_active (n);
}
+/**
+ * Handle a response
+ *
+ * @param peer the source
+ * @param message the message
+ */
+static void handle_start (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message)
+{
+ GED_scheduler_handle_start (NULL, NULL);
+}
+
+/**
+ * Handle a response
+ *
+ * @param peer the source
+ * @param message the message
+ */
+static void handle_start_ack (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message)
+{
+ GED_scheduler_handle_start_ack (NULL, NULL);
+}
+
+/**
+ * Handle a response
+ *
+ * @param peer the source
+ * @param message the message
+ */
+static void handle_stop (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message)
+{
+ GED_scheduler_handle_stop (NULL, NULL);
+}
+
/**
* Method called whenever a given peer connects.
*
case GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE:
handle_response (other, message);
break;
+ case GNUNET_MESSAGE_TYPE_EXPERIMENTATION_START:
+ handle_start (other, message);
+ break;
+ case GNUNET_MESSAGE_TYPE_EXPERIMENTATION_START_ACK:
+ handle_start_ack (other, message);
+ break;
+ case GNUNET_MESSAGE_TYPE_EXPERIMENTATION_STOP:
+ handle_stop (other, message);
+ break;
default:
break;
}
return GNUNET_OK;
}
+#define FAST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-void
-GNUNET_EXPERIMENT_nodes_request_start (struct Node *n, struct Experiment *e)
+struct GNUNET_EXPERIMENTATION_start_message
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending start request to peer `%s' for experiment `%s'\n"),
+ struct GNUNET_MessageHeader header;
+};
+
+struct ExperimentStartCtx
+{
+ struct ExperimentStartCtx *prev;
+ struct ExperimentStartCtx *next;
+
+ struct Node *n;
+ struct Experiment *e;
+};
+
+size_t node_experiment_start_cb (void *cls, size_t bufsize, void *buf)
+{
+ struct ExperimentStartCtx *e_ctx = cls;
+ struct GNUNET_EXPERIMENTATION_start_message msg;
+
+ GNUNET_CONTAINER_DLL_remove (e_ctx->n->e_req_head, e_ctx->n->e_req_tail, e_ctx);
+ e_ctx->n->cth = NULL;
+ if (NULL == buf)
+ {
+ GNUNET_free (e_ctx);
+ return 0;
+ }
+
+ size_t size = sizeof (struct GNUNET_EXPERIMENTATION_start_message);
+ msg.header.size = htons (size);
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_START);
+
+ memcpy (buf, &msg, size);
+ GNUNET_free (e_ctx);
+ return size;
+}
+
+int
+GED_nodes_rts (struct Node *n)
+{
+ if (NULL == n->cth)
+ return GNUNET_YES;
+ else
+ return GNUNET_NO;
+
+}
+
+/**
+ * Request a experiment to start with a node
+ *
+ * @return GNUNET_NO if core was busy with sending, GNUNET_OK otherwise
+ */
+int
+GED_nodes_request_start (struct Node *n, struct Experiment *e)
+{
+ struct ExperimentStartCtx *e_ctx;
+
+ if (NULL != n->cth)
+ {
+ GNUNET_break (0); /* should call rts before */
+ return GNUNET_NO;
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending experiment start request to peer `%s' for experiment `%s'\n"),
GNUNET_i2s(&n->id), e->name);
+
+ e_ctx = GNUNET_malloc (sizeof (struct ExperimentStartCtx));
+ e_ctx->n = n;
+ e_ctx->e = e;
+ n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO, 0, FAST_TIMEOUT, &n->id,
+ sizeof (struct GNUNET_EXPERIMENTATION_start_message),
+ &node_experiment_start_cb, e_ctx);
+ if (NULL == n->cth)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Cannot send experiment start request to peer `%s' for experiment `%s'\n"),
+ GNUNET_i2s(&n->id), e->name);
+ GNUNET_free (e_ctx);
+ }
+ GNUNET_CONTAINER_DLL_insert (n->e_req_head, n->e_req_tail, e_ctx);
+
+ return GNUNET_OK;
}
* Start the nodes management
*/
void
-GNUNET_EXPERIMENTATION_nodes_start ()
+GED_nodes_start ()
{
/* Connecting to core service to find partners */
- ch = GNUNET_CORE_connect (GSE_cfg, NULL,
+ ch = GNUNET_CORE_connect (GED_cfg, NULL,
&core_startup_handler,
&core_connect_handler,
&core_disconnect_handler,
* Stop the nodes management
*/
void
-GNUNET_EXPERIMENTATION_nodes_stop ()
+GED_nodes_stop ()
{
if (NULL != ch)
{