|
@@ -21,6 +21,7 @@
|
|
|
|
|
|
myco_agent *first_agent = NULL;
|
|
|
myco_resource *first_resource = NULL;
|
|
|
+in_addr_t myco_daemon_node_ip;
|
|
|
|
|
|
myco_agent *myco_daemon_find_agent(const char *agent_name) {
|
|
|
myco_agent *current_agent;
|
|
@@ -192,6 +193,7 @@ int myco_daemon_register_resource(message msg) {
|
|
|
first_resource->transfer_locked = 1;
|
|
|
first_resource->transactional = msg.resource_transactional;
|
|
|
first_resource->version = 0;
|
|
|
+ first_resource->node_ip = myco_daemon_node_ip;
|
|
|
} else {
|
|
|
// Insert as last element
|
|
|
current_resource = first_resource;
|
|
@@ -210,6 +212,7 @@ int myco_daemon_register_resource(message msg) {
|
|
|
current_resource->next->read_locked = 0;
|
|
|
current_resource->next->transactional = msg.resource_transactional;
|
|
|
current_resource->next->version = 0;
|
|
|
+ current_resource->next->node_ip = myco_daemon_node_ip;
|
|
|
}
|
|
|
|
|
|
sprintf(msg.message, "SUCCESS: resource %s registered\n", msg.resource_name);
|
|
@@ -300,7 +303,11 @@ int myco_daemon_request_resource(message msg) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- // TODO: Handle case where resource is on another node (another agent)
|
|
|
+ // Check if resource resides on same node
|
|
|
+ printf("\n The adress is: %d\n", current_resource->node_ip);
|
|
|
+
|
|
|
+ // TODO: Handle case where resource is on another node
|
|
|
+
|
|
|
|
|
|
// If on same node, send information
|
|
|
msg.sender_pid = current_resource->pid;
|
|
@@ -509,7 +516,7 @@ int myco_daemon_unlock_resource(message msg) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-int myco_daemon_connect(char* ip, int port) {
|
|
|
+int myco_daemon_connect(const char* ip, int port) {
|
|
|
struct sockaddr_in address;
|
|
|
int mysocket = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
|
|
address.sin_family = AF_INET;
|
|
@@ -520,13 +527,14 @@ int myco_daemon_connect(char* ip, int port) {
|
|
|
return mysocket;
|
|
|
}
|
|
|
|
|
|
-int myco_daemon_start(pid) {
|
|
|
+int myco_daemon_start(pid_t pid, const char *node_ip, const char *indexer_ip) {
|
|
|
+ in_addr_t myco_daemon_node_ip = inet_network(node_ip);
|
|
|
char *buffer = malloc (1024);
|
|
|
int daemon_message_queue_id;
|
|
|
message msg = {0};
|
|
|
|
|
|
// Connect to indexer
|
|
|
- int socket = myco_daemon_connect("127.0.0.1", 15000);
|
|
|
+ int socket = myco_daemon_connect(indexer_ip, 15000);
|
|
|
|
|
|
// Create message queue
|
|
|
daemon_message_queue_id = myco_create_global_message_queue();
|