diff --git a/netmist/make-netmist.in b/netmist/make-netmist.in index db0b7f9..0504ab6 100644 --- a/netmist/make-netmist.in +++ b/netmist/make-netmist.in @@ -49,7 +49,7 @@ BUILD_DIR := ../../build/$(PROD)/$(OS)/$(ARCH) BINS = $(addprefix $(BUILD_DIR)/,netmist) $(addprefix $(BUILD_DIR)/,netmist_monitor) $(addprefix $(BUILD_DIR)/,netmist_modify) $(addprefix $(BUILD_DIR)/,pump_carbon) $(addprefix $(BUILD_DIR)/,pump_csv) -NETMIST_OBJS += $(addprefix $(BUILD_DIR)/,netmist.o netmist_if.o netmist_prime.o netmist_nodeManager.o netmist_client.o netmist_structures.o netmist_logger.o netmist_utils.o netmist_copyright.o netmist_random.o workload.o mix_table.o netmist_fdcache.o netmist_version.o netmist_fsm.o netmist_thread.o netmist_vfs_paths_abs.o) +NETMIST_OBJS += $(addprefix $(BUILD_DIR)/,netmist.o netmist_if.o netmist_prime.o netmist_nodeManager.o netmist_client.o netmist_structures.o netmist_logger.o netmist_hashtable.o netmist_utils.o netmist_copyright.o netmist_random.o workload.o mix_table.o netmist_fdcache.o netmist_version.o netmist_fsm.o netmist_thread.o netmist_vfs_paths_abs.o) MONITOR_OBJS := $(addprefix $(BUILD_DIR)/,netmist_monitor.o) MODIFY_OBJS := $(addprefix $(BUILD_DIR)/,netmist_modify.o) PUMP_CARBON_OBJS := $(addprefix $(BUILD_DIR)/,pump_carbon.o) diff --git a/netmist/netmist_structures.c b/netmist/netmist_structures.c index a3a438f..321c220 100644 --- a/netmist/netmist_structures.c +++ b/netmist/netmist_structures.c @@ -36,6 +36,7 @@ /* This is different for the various versions. */ #include +#include "netmist_hashtable.h" #include "netmist_utils.h" #include "netmist_structures.h" #include "netmist_logger.h" @@ -102,7 +103,7 @@ static nodeManager **nodeManager_array = NULL; /* * Only used by nodeManager program */ -client_ids **client_array = NULL; +static void *client_array = NULL; struct _workdirs { @@ -609,7 +610,7 @@ nm_add_nodeManager_object (char *name, int id, int pid, int port, int listen_socket, int prime_socket, int num_clients, int *client_id_list) { - int i, hash; + int i; client_ids *client_node; /* @@ -647,9 +648,8 @@ nm_add_nodeManager_object (char *name, int id, int pid, int port, return NODEMANAGER_FAILURE; } - client_array = - (client_ids **) my_malloc2 (sizeof (client_ids *) * - MAXCLIENTS_PER_NM); + client_array = create_hash_table(MAXCLIENTS_PER_NM); + if (client_array == NULL) { log_file (LOG_ERROR, "malloc failure in %s\n", __FUNCTION__); @@ -669,10 +669,13 @@ nm_add_nodeManager_object (char *name, int id, int pid, int port, } client_node->client_id = client_id_list[i]; - /* Add to hash for faster lookup */ - hash = (client_node->client_id) % MAXCLIENTS_PER_NM; - client_array[hash] = client_node; + if (add_hash_entry(client_array, client_node->client_id, + (void *)client_node) != HASH_SUCCESS) + { + log_file (LOG_ERROR, "\nclients: failed to add entry in hashtable\n"); + return NODEMANAGER_FAILURE; + } /* * Add to the front of the linked list @@ -698,18 +701,13 @@ nm_add_nodeManager_object (char *name, int id, int pid, int port, int get_nm_client_port (int client_id) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; - + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { return 0; } - - return (curr_client->client_port); } @@ -722,11 +720,9 @@ get_nm_client_port (int client_id) int set_nm_client_port (int client_id, int port) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -745,11 +741,9 @@ set_nm_client_port (int client_id, int port) int get_nm_client_pid (int client_id) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -768,11 +762,9 @@ get_nm_client_pid (int client_id) int set_nm_client_pid (int client_id, int pid) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -791,11 +783,9 @@ set_nm_client_pid (int client_id, int pid) int get_nm_client_socket (int client_id) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -814,11 +804,9 @@ get_nm_client_socket (int client_id) int set_nm_client_socket (int client_id, int socket) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -838,11 +826,9 @@ set_nm_client_socket (int client_id, int socket) int set_nm_client_keepalive (int client_id, unsigned int keepalive) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -873,11 +859,9 @@ set_nm_prime_keepalive (unsigned int keepalive) int get_nm_client_files (int client_id) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -896,12 +880,9 @@ get_nm_client_files (int client_id) int set_nm_client_files (int client_id, int files) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; - + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { return NODEMANAGER_FAILURE; @@ -919,11 +900,9 @@ set_nm_client_files (int client_id, int files) int get_nm_client_dirs (int client_id) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { @@ -942,11 +921,9 @@ get_nm_client_dirs (int client_id) int set_nm_client_dirs (int client_id, int dirs) { - int hash; client_ids *curr_client; - hash = client_id % MAXCLIENTS_PER_NM; - curr_client = client_array[hash]; + curr_client = (client_ids *) lookup_hash_entry(client_array, client_id); if (curr_client == NULL) { --- a/netmist/netmist_defines.h 2021-03-08 13:10:11.457972656 -0600 +++ b/netmist/netmist_defines.h 2021-03-17 11:39:38.408944513 -0500 @@ -302,7 +302,10 @@ #define RECV_POLL_TIMEOUT -1 #endif -#define KEEPALIVE_POLL_TIMEOUT 300000 /* Poll timeout is 5 mins */ +/*#define KEEPALIVE_POLL_TIMEOUT 300000 Poll timeout is 5 mins */ + +/* 5 X bigger than keepalive, and scales with respect to keepalive */ +#define KEEPALIVE_POLL_TIMEOUT ((cmdline.keepalive * 1000)* 5) #define KEEPALIVE_SCAN_FREQ 3 #define KEEPALIVE_MISSED_COUNT 2 --- /tmp/netmist_version.c 2021-03-31 07:26:20.796147089 -0500 +++ netmist_version.c 2021-03-22 22:46:18.860580019 -0500 @@ -1,4 +1,4 @@ #include "netmist_version.h" -char *git_date = "Tue Nov 3 16:41:01 CST 2020"; -char *git_sha = "b14f6dd081899c693e96da008b2fec8d51d70757"; -char *git_version = "$Revision: 2511 $"; +char *git_date = "Tue Mar 16 08:33:11 CDT 2021"; +char *git_sha = "849bce769b069f7570d073e5248cb7f15e575fa7"; +char *git_version = "$Revision: 2512 $";