[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24253 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24253 - gnunet/src/testbed |
Date: |
Wed, 10 Oct 2012 17:37:41 +0200 |
Author: harsha
Date: 2012-10-10 17:37:40 +0200 (Wed, 10 Oct 2012)
New Revision: 24253
Modified:
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/testbed_api.c
gnunet/src/testbed/testbed_api.h
Log:
checkpoint save
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-10-10 10:59:34 UTC (rev
24252)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-10-10 15:37:40 UTC (rev
24253)
@@ -81,11 +81,6 @@
struct GNUNET_TESTING_System *system;
/**
- * Event mask of event to be responded in this context
- */
- uint64_t event_mask;
-
- /**
* Our host id according to this context
*/
uint32_t host_id;
@@ -328,6 +323,11 @@
*/
struct GNUNET_TESTBED_Controller *controller;
+ /**
+ * The id of the remote host this peer is running on
+ */
+ uint32_t remote_host_id;
+
} remote;
} details;
@@ -537,7 +537,73 @@
};
+/**
+ * Context information to used during operations which forward the overlay
+ * connect message
+ */
+struct ForwardedOverlayConnectContext
+{
+ /**
+ * The gateway controller to which this operation is forwarded to
+ */
+ struct GNUNET_TESTBED_Controller *gateway;
+ /**
+ * The gateway controller through which peer2's controller can be reached
+ */
+ struct GNUNET_TESTBED_Controller *gateway2;
+
+ /**
+ * Handle for sub-operations
+ */
+ struct GNUNET_TESTBED_Operation *sub_op;
+
+ /**
+ * Enumeration of states for this context
+ */
+ enum FOCCState {
+
+ /**
+ * The initial state
+ */
+ FOCC_INIT = 0,
+
+ /**
+ * State where we attempt to get peer2's controller configuration
+ */
+ FOCC_GET_CFG,
+
+ /**
+ * State where we attempt to link the controller of peer 1 to the
controller
+ * of peer2
+ */
+ FOCC_LINK,
+
+ /**
+ * State where we attempt to do the overlay connection again
+ */
+ FOCC_OL_CONNECT
+
+ } state;
+
+ /**
+ * the id of peer 1
+ */
+ uint32_t peer1;
+
+ /**
+ * The id of peer 2
+ */
+ uint32_t peer2;
+
+ /**
+ * Id of the host where peer2 is running
+ */
+ uint32_t peer2_host_id;
+};
+
+
+
/**
* The master context; generated with the first INIT message
*/
@@ -607,6 +673,11 @@
static struct GNUNET_CONTAINER_MultiHashMap *ss_map;
/**
+ * The event mask for the events we listen from sub-controllers
+ */
+static uint64_t event_mask;
+
+/**
* The size of the host list
*/
static uint32_t host_list_size;
@@ -876,6 +947,8 @@
{
struct Route *route;
+ if (route_list_size <= host_id)
+ return NULL;
while (NULL != (route = route_list[host_id]))
{
if (route->thru == master_context->host_id)
@@ -1135,7 +1208,23 @@
slave_event_callback (void *cls,
const struct GNUNET_TESTBED_EventInformation *event)
{
- GNUNET_break (0);
+ struct ForwardedOverlayConnectContext *focc;
+ struct GNUNET_CONFIGURATION_Handle *slave_cfg;
+
+ /* We currently only get here when doing overlay connect operations and that
+ too while trying out sub operations */
+ if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type)
+ return;
+ focc = event->details.operation_finished.op_cls;
+ switch (focc->state)
+ {
+ case FOCC_GET_CFG:
+ slave_cfg = event->details.operation_finished.generic;
+ GNUNET_break (0); /* FIXME */
+ GNUNET_CONFIGURATION_destroy (slave_cfg);
+ default:
+ GNUNET_assert (0);
+ }
}
@@ -1170,7 +1259,7 @@
}
slave->controller =
GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id],
- master_context->event_mask,
+ event_mask,
&slave_event_callback, slave);
if (NULL != slave->controller)
{
@@ -1252,7 +1341,6 @@
GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL,
0);
host_list_add (host);
- master_context->event_mask = GNUNET_ntohll (msg->event_mask);
GNUNET_SERVER_client_keep (client);
LOG_DEBUG ("Created master context with host ID: %u\n",
master_context->host_id);
@@ -1543,7 +1631,7 @@
{
slave->controller =
GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id],
- master_context->event_mask,
+ event_mask,
&slave_event_callback, slave);
slave->cfg = cfg;
if (NULL != slave->controller)
@@ -1638,6 +1726,7 @@
struct ForwardedOperationContext *fo_ctxt = cls;
/* send error msg to client */
+ GNUNET_free (fo_ctxt->cls);
send_operation_fail_msg (fo_ctxt->client, fo_ctxt->operation_id, "Timedout");
GNUNET_SERVER_client_drop (fo_ctxt->client);
GNUNET_TESTBED_forward_operation_msg_cancel_ (fo_ctxt->opc);
@@ -1658,7 +1747,7 @@
struct ForwardedOperationContext *fo_ctxt = cls;
const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *success_msg;
struct GNUNET_MessageHeader *dup_msg;
- struct Peer *peer;
+ struct Peer *remote_peer;
uint16_t msize;
GNUNET_SCHEDULER_cancel (fo_ctxt->timeout_task);
@@ -1666,12 +1755,11 @@
{
success_msg =
(const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *) msg;
- peer = GNUNET_malloc (sizeof (struct Peer));
- peer->is_remote = GNUNET_YES;
- peer->id = ntohl (success_msg->peer_id);
GNUNET_assert (NULL != fo_ctxt->cls);
- peer->details.remote.controller = fo_ctxt->cls;
- peer_list_add (peer);
+ remote_peer = fo_ctxt->cls;
+ GNUNET_assert (remote_peer->details.remote.remote_host_id
+ == ntohl (success_msg->peer_id));
+ peer_list_add (remote_peer);
}
msize = ntohs (msg->size);
dup_msg = GNUNET_malloc (msize);
@@ -1803,21 +1891,25 @@
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
+
+ peer = GNUNET_malloc (sizeof (struct Peer));
+ peer->is_remote = GNUNET_YES;
+ peer->id = peer_id;
+ peer->details.remote.controller = slave_list[route->dest]->controller;
+ peer->details.remote.remote_host_id = host_id;
fo_ctxt = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
GNUNET_SERVER_client_keep (client);
fo_ctxt->client = client;
fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
- fo_ctxt->cls = slave_list[route->dest]->controller;
+ fo_ctxt->cls = peer; //slave_list[route->dest]->controller;
fo_ctxt->opc =
- GNUNET_TESTBED_forward_operation_msg_ (slave_list
- [route->dest]->controller,
+ GNUNET_TESTBED_forward_operation_msg_ (slave_list
[route->dest]->controller,
fo_ctxt->operation_id,
&msg->header,
peer_create_success_cb, fo_ctxt);
fo_ctxt->timeout_task =
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &peer_create_forward_timeout,
fo_ctxt);
-
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -2411,6 +2503,55 @@
/**
+ * Callback to be called when forwarded overlay connection operation has a
reply
+ * from the sub-controller successfull. We have to relay the reply msg back to
+ * the client
+ *
+ * @param cls ForwardedOperationContext
+ * @param msg the peer create success message
+ */
+static void
+forwarded_overlay_connect_listener (void *cls,
+ const struct GNUNET_MessageHeader *msg)
+{
+ struct ForwardedOperationContext *fopc = cls;
+ struct ForwardedOverlayConnectContext *focc;
+
+ focc = fopc->cls;
+ if (NULL == focc)
+ {
+ forwarded_operation_reply_relay (cls, msg);
+ return;
+ }
+ switch (focc->state)
+ {
+ case FOCC_INIT:
+ if (GNUNET_MESSAGE_TYPE_TESTBED_NEEDCONTROLLERCONFIG != ntohs (msg->type))
+ {
+ GNUNET_break (0); /* Something failed; you may check output of
sub-controllers */
+ forwarded_operation_reply_relay (cls, msg);
+ return;
+ }
+ GNUNET_assert (NULL == focc->sub_op);
+ focc->state = FOCC_GET_CFG;
+ focc->sub_op = GNUNET_TESTBED_get_slave_config_ (focc, focc->gateway2,
+ focc->peer2_host_id);
+ /* FIXME */
+ GNUNET_break (0);
+ break;
+ /* focc->op = GNUNET_TESTBED_controller_link (focc, */
+ /* focc->gateway, */
+ /* slave_list[peer2_host_id], */
+ /*
slave_list[peer_list[focc->peer1]->remote_host_id], */
+ /* slave_list */
+
+ default:
+ GNUNET_assert (0);
+ }
+}
+
+
+/**
* Handler for GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT messages
*
* @param cls NULL
@@ -2429,28 +2570,55 @@
struct Peer *peer;
uint64_t operation_id;
uint32_t p1;
- uint32_t p2;
+ uint32_t p2;
+ uint32_t peer2_host_id;
+
msg = (const struct GNUNET_TESTBED_OverlayConnectMessage *) message;
p1 = ntohl (msg->peer1);
p2 = ntohl (msg->peer2);
+ peer2_host_id = ntohl (msg->peer2_host_id);
GNUNET_assert (p1 < peer_list_size);
GNUNET_assert (NULL != peer_list[p1]);
peer = peer_list[p1];
- operation_id = GNUNET_ntohll (msg->operation_id);
+ operation_id = GNUNET_ntohll (msg->operation_id);
if (GNUNET_YES == peer->is_remote)
{
struct ForwardedOperationContext *fopc;
+ struct Route *route_to_peer2_host;
+ struct Route *route_to_peer1_host;
+ LOG_DEBUG ("Forwarding overlay connect\n");
+ GNUNET_SERVER_client_keep (client);
fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
- GNUNET_SERVER_client_keep (client);
fopc->client = client;
fopc->operation_id = operation_id;
- LOG_DEBUG ("Forwarding overlay connect\n");
+ route_to_peer2_host = NULL;
+ route_to_peer1_host = NULL;
+ route_to_peer2_host = find_dest_route (peer2_host_id);
+ if (NULL != route_to_peer2_host)
+ {
+ route_to_peer1_host =
+ find_dest_route (peer_list[p1]->details.remote.remote_host_id);
+ GNUNET_assert (NULL != route_to_peer1_host);
+ if (route_to_peer2_host->dest != route_to_peer1_host->dest)
+ {
+ struct ForwardedOverlayConnectContext *focc;
+
+ focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext));
+ focc->gateway = peer->details.remote.controller;
+ focc->gateway2 = slave_list[route_to_peer2_host->dest]->controller;
+ focc->peer1 = p1;
+ focc->peer2 = p2;
+ focc->peer2_host_id = peer2_host_id;
+ focc->state = FOCC_INIT;
+ fopc->cls = focc;
+ }
+ }
fopc->opc =
GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller,
operation_id, message,
- &forwarded_operation_reply_relay,
+
&forwarded_overlay_connect_listener,
fopc);
fopc->timeout_task =
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &forwarded_operation_timeout,
@@ -2466,10 +2634,7 @@
occ->peer = peer_list[p1];
occ->op_id = GNUNET_ntohll (msg->operation_id);
if ((p2 >= peer_list_size) || (NULL == peer_list[p2]))
- {
- uint32_t peer2_host_id;
-
- peer2_host_id = ntohl (msg->peer2_host_id);
+ {
if ((peer2_host_id >= slave_list_size)
|| (NULL ==slave_list[peer2_host_id]))
{
@@ -2945,6 +3110,7 @@
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&shutdown_task, NULL);
LOG_DEBUG ("Testbed startup complete\n");
+ event_mask = GNUNET_TESTBED_ET_OPERATION_FINISHED;
}
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2012-10-10 10:59:34 UTC (rev 24252)
+++ gnunet/src/testbed/testbed_api.c 2012-10-10 15:37:40 UTC (rev 24253)
@@ -1838,31 +1838,24 @@
* @return the operation handle
*/
struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_controller_link_2 (void *op_cls,
- struct GNUNET_TESTBED_Controller *master,
- struct GNUNET_TESTBED_Host *delegated_host,
- struct GNUNET_TESTBED_Host *slave_host,
- const char *sxcfg, size_t sxcfg_size,
- size_t scfg_size, int is_subordinate)
+GNUNET_TESTBED_controller_link_2_ (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
+ uint32_t delegated_host_id,
+ uint32_t slave_host_id,
+ const char *sxcfg, size_t sxcfg_size,
+ size_t scfg_size, int is_subordinate)
{
struct OperationContext *opc;
struct GNUNET_TESTBED_ControllerLinkMessage *msg;
struct ControllerLinkData *data;
uint16_t msg_size;
- GNUNET_assert (GNUNET_YES ==
- GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
- if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host)))
- GNUNET_assert (GNUNET_YES ==
- GNUNET_TESTBED_is_host_registered_ (slave_host, master));
msg_size = sxcfg_size + sizeof (struct GNUNET_TESTBED_ControllerLinkMessage);
msg = GNUNET_malloc (msg_size);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS);
msg->header.size = htons (msg_size);
- msg->delegated_host_id = htonl (GNUNET_TESTBED_host_get_id_
(delegated_host));
- msg->slave_host_id =
- htonl (GNUNET_TESTBED_host_get_id_
- ((NULL != slave_host) ? slave_host : master->host));
+ msg->delegated_host_id = htonl (delegated_host_id);
+ msg->slave_host_id = htonl (slave_host_id);
msg->config_size = htons ((uint16_t) scfg_size);
msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
memcpy (&msg[1], sxcfg, sxcfg_size);
@@ -1886,6 +1879,56 @@
/**
+ * Same as the GNUNET_TESTBED_controller_link, however expects configuration in
+ * serialized and compressed
+ *
+ * @param op_cls the operation closure for the event which is generated to
+ * signal success or failure of this operation
+ * @param master handle to the master controller who creates the association
+ * @param delegated_host requests to which host should be delegated; cannot be
NULL
+ * @param slave_host which host is used to run the slave controller; use NULL
to
+ * make the master controller connect to the delegated host
+ * @param sxcfg serialized and compressed configuration
+ * @param sxcfg_size the size sxcfg
+ * @param scfg_size the size of uncompressed serialized configuration
+ * @param is_subordinate GNUNET_YES if the controller at delegated_host should
+ * be started by the slave controller; GNUNET_NO if the slave
+ * controller has to connect to the already started delegated
+ * controller via TCP/IP
+ * @return the operation handle
+ */
+struct GNUNET_TESTBED_Operation *
+GNUNET_TESTBED_controller_link_2 (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
+ struct GNUNET_TESTBED_Host *delegated_host,
+ struct GNUNET_TESTBED_Host *slave_host,
+ const char *sxcfg, size_t sxcfg_size,
+ size_t scfg_size, int is_subordinate)
+{
+ uint32_t delegated_host_id;
+ uint32_t slave_host_id;
+
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
+ delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
+ slave_host_id =
+ GNUNET_TESTBED_host_get_id_ ((NULL != slave_host)
+ ? slave_host : master->host);
+ if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host)))
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_TESTBED_is_host_registered_ (slave_host, master));
+
+ return GNUNET_TESTBED_controller_link_2_ (op_cls,
+ master,
+ delegated_host_id,
+ slave_host_id,
+ sxcfg, sxcfg_size,
+ scfg_size, is_subordinate);
+ GNUNET_break (0);
+}
+
+
+/**
* Compresses given configuration using zlib compress
*
* @param config the serialized configuration
@@ -1973,32 +2016,27 @@
/**
- * Function to acquire the configuration of a running slave controller. The
- * completion of the operation is signalled through the controller_cb from
- * GNUNET_TESTBED_controller_connect(). If the operation is successful the
- * handle to the configuration is available in the generic pointer of
- * operation_finished field of struct GNUNET_TESTBED_EventInformation.
+ * Like GNUNET_TESTBED_get_slave_config(), however without the host
registration
+ * check. Another difference is that this function takes the id of the slave
+ * host.
*
* @param op_cls the closure for the operation
* @param master the handle to master controller
* @param slave_host the host where the slave controller is running; the handle
* to the slave_host should remain valid until this operation is
* cancelled or marked as finished
- * @return the operation handle; NULL if the slave_host is not registered at
- * master
+ * @return the operation handle;
*/
struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_get_slave_config (void *op_cls,
- struct GNUNET_TESTBED_Controller *master,
- struct GNUNET_TESTBED_Host *slave_host)
-{
+GNUNET_TESTBED_get_slave_config_ (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
+ uint32_t slave_host_id)
+{
struct OperationContext *opc;
struct GetSlaveConfigData *data;
- if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master))
- return NULL;
data = GNUNET_malloc (sizeof (struct GetSlaveConfigData));
- data->slave_id = GNUNET_TESTBED_host_get_id_ (slave_host);
+ data->slave_id = slave_host_id;
data->op_cls = op_cls;
opc = GNUNET_malloc (sizeof (struct OperationContext));
opc->state = OPC_STATE_INIT;
@@ -2016,6 +2054,33 @@
/**
+ * Function to acquire the configuration of a running slave controller. The
+ * completion of the operation is signalled through the controller_cb from
+ * GNUNET_TESTBED_controller_connect(). If the operation is successful the
+ * handle to the configuration is available in the generic pointer of
+ * operation_finished field of struct GNUNET_TESTBED_EventInformation.
+ *
+ * @param op_cls the closure for the operation
+ * @param master the handle to master controller
+ * @param slave_host the host where the slave controller is running; the handle
+ * to the slave_host should remain valid until this operation is
+ * cancelled or marked as finished
+ * @return the operation handle; NULL if the slave_host is not registered at
+ * master
+ */
+struct GNUNET_TESTBED_Operation *
+GNUNET_TESTBED_get_slave_config (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
+ struct GNUNET_TESTBED_Host *slave_host)
+{
+ if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master))
+ return NULL;
+ return GNUNET_TESTBED_get_slave_config_ (op_cls, master,
+ GNUNET_TESTBED_host_get_id_
(slave_host));
+}
+
+
+/**
* Ask the testbed controller to write the current overlay topology to
* a file. Naturally, the file will only contain a snapshot as the
* topology may evolve all the time.
Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h 2012-10-10 10:59:34 UTC (rev 24252)
+++ gnunet/src/testbed/testbed_api.h 2012-10-10 15:37:40 UTC (rev 24253)
@@ -435,5 +435,23 @@
uint64_t
GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller);
+
+/**
+ * Like GNUNET_TESTBED_get_slave_config(), however without the host
registration
+ * check. Another difference is that this function takes the id of the slave
+ * host.
+ *
+ * @param op_cls the closure for the operation
+ * @param master the handle to master controller
+ * @param slave_host the host where the slave controller is running; the handle
+ * to the slave_host should remain valid until this operation is
+ * cancelled or marked as finished
+ * @return the operation handle;
+ */
+struct GNUNET_TESTBED_Operation *
+GNUNET_TESTBED_get_slave_config_ (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
+ uint32_t slave_host_id);
+
#endif
/* end of testbed_api.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24253 - gnunet/src/testbed,
gnunet <=