Skip to content

Commit

Permalink
Finished some of the local callbacks for the routing functions.
Browse files Browse the repository at this point in the history
git-svn-id: https://subversion.cs.uiuc.edu/svn/bang/eoh2009@28 69d76c3e-0761-0410-948c-9895a8bb34fc
  • Loading branch information
nbysani2 committed Jan 24, 2009
1 parent 776ace0 commit 29b0259
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
9 changes: 5 additions & 4 deletions src/base/bang-module-api.c
Expand Up @@ -142,11 +142,12 @@ void BANG_request_job(BANG_module_info *info, int id) {
}

void BANG_finished_request(BANG_module_info *info, BANG_job *job) {
uuid_t route;
get_uuid_from_id(route,job->authority,info);
uuid_t auth,peer;
get_uuid_from_id(auth,job->authority,info);
get_uuid_from_id(peer,job->peer,info);

if (!uuid_is_null(route)) {
BANG_route_finished_job(route,job);
if (!uuid_is_null(auth)) {
BANG_route_finished_job(auth,peer,job);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/base/bang-module-api.h
Expand Up @@ -49,6 +49,13 @@ typedef struct {
} BANG_module_info;

/**
* \page BANG_job
* There are 4 states a job can be in:
* -an authority telling a peer that a job is available
* -a peer requesting a job from an authority
* -an authority sending a job to a peer
* -a peer sending a finished job to an authority
*
* A job to be sent to be a peer, so that it the "data" can be worked
* on, and sent as a job back, with the "data" finished.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/base/bang-module.h
Expand Up @@ -38,6 +38,8 @@ void* BANG_get_symbol(BANG_module *module, char *symbol);
*/
void BANG_run_module(BANG_module *module);

void BANG_module_callback_job(const BANG_module *module, uuid_t auth, uuid_t peer);

/**
* \param module The module of the peer.
* \param auth The uuid of the authority saying a job is available.
Expand All @@ -56,4 +58,6 @@ void BANG_module_callback_job_available(const BANG_module *module, uuid_t auth,
* \brief A callback to tell the authority that the uuid peer wants a job.
*/
void BANG_module_callback_job_request(const BANG_module *module, uuid_t auth, uuid_t peer);

void BANG_module_callback_job_finished(const BANG_module *module, uuid_t auth, uuid_t peer);
#endif
26 changes: 18 additions & 8 deletions src/base/bang-routing.c
Expand Up @@ -45,11 +45,15 @@ void BANG_route_job(uuid_t authority, uuid_t peer, BANG_job *job) {
assert(!uuid_is_null(peer));
assert(job != NULL);

/* Get the information about the peer, because we are routing to
* a peer. */
sqlite3_stmt *get_peer_route = prepare_select_statement(peer);

if (sqlite3_step(get_peer_route) == SQLITE_ROW) {
if (sqlite3_column_int(get_peer_route,1) == REMOTE_ROUTE) {
/* TODO: Make a request to peer. */
/* TODO: Make a request to peer.
* Make a non-shitty request.
* */
BANG_request request;
request.type = BANG_SEND_JOB_REQUEST;
/* We are being a little presumptuous, and constructing the actual message
Expand All @@ -75,25 +79,27 @@ void BANG_route_job(uuid_t authority, uuid_t peer, BANG_job *job) {


} else {
/* const BANG_module *module = */sqlite3_column_blob(get_peer_route,2);
/* TODO: Callback peer with job */
const BANG_module *module = sqlite3_column_blob(get_peer_route,2);
BANG_module_callback_job(module,authority,peer);
}
}
}

/* COPY AND PASTE FUNCTIONS... must find better way.. */
void BANG_route_finished_job(uuid_t uuid, BANG_job *job) {
assert(!uuid_is_null(uuid));
void BANG_route_finished_job(uuid_t auth, uuid_t peer, BANG_job *job) {
assert(!uuid_is_null(auth));
assert(job != NULL);

sqlite3_stmt *get_peer_route = prepare_select_statement(uuid);
/* Get the information about the authority, because we are routing
* to an authority. */
sqlite3_stmt *get_peer_route = prepare_select_statement(auth);

if (sqlite3_step(get_peer_route) == SQLITE_ROW) {
if (sqlite3_column_int(get_peer_route,1) == REMOTE_ROUTE) {
/* TODO: Make a request to remote peer. */
} else {
/* const BANG_module *module = */sqlite3_column_blob(get_peer_route,2);
/* TODO: Callback local peer with job */
const BANG_module *module = sqlite3_column_blob(get_peer_route,2);
BANG_module_callback_job_finished(module,auth,peer);
}
}
}
Expand All @@ -104,6 +110,8 @@ void BANG_route_request_job(uuid_t peer, uuid_t authority) {
* authority to give us a job.
*/

/* Get the information about the authority, because we are routing
* to an authority. */
sqlite3_stmt *get_auth_route = prepare_select_statement(authority);

if (sqlite3_step(get_auth_route) == SQLITE_ROW) {
Expand All @@ -120,6 +128,8 @@ void BANG_route_assertion_of_authority(uuid_t authority, uuid_t peer) {
assert(!uuid_is_null(authority));
assert(!uuid_is_null(peer));

/* Get the information about the peer, because we are routing
* to an authority. */
sqlite3_stmt *get_peer_route = prepare_select_statement(peer);

if (sqlite3_step(get_peer_route) == SQLITE_ROW) {
Expand Down
4 changes: 2 additions & 2 deletions src/base/bang-routing.h
Expand Up @@ -31,12 +31,12 @@ void BANG_route_job(uuid_t authority, uuid_t peer, BANG_job *job);
void BANG_route_job_to_uuids(uuid_t authority, uuid_t *peers, BANG_job *job);

/**
* \param uuid The route to send a finished job through.
* \param auth The route to send a finished job through.
* \param job The finished job to route.
*
* \brief Routes a finished job through a route.
*/
void BANG_route_finished_job(uuid_t uuid, BANG_job *job);
void BANG_route_finished_job(uuid_t auth, uuid_t peer, BANG_job *job);

/**
* \param uuid The route to request a job from.
Expand Down

0 comments on commit 29b0259

Please sign in to comment.