コード例 #1
0
static gint compare_target(const Target **l, const Target **r)
{
    const Target *left = *l;
    const Target *right = *r;
    
    gchar *left_target_property = find_target_key(left);
    gchar *right_target_property = find_target_key(right);
    
    return g_strcmp0(left_target_property, right_target_property);
}
コード例 #2
0
static int compare_target_keys(const char *key, const Target **r)
{
    const Target *right = *r;
    gchar *right_target_property = find_target_key(right);
    
    return g_strcmp0(key, right_target_property);
}
コード例 #3
0
void complete_send_snapshots_to_target(void *data, Target *target, ProcReact_Status status, int result)
{
    if(status != PROCREACT_STATUS_OK || !result)
    {
        gchar *target_key = find_target_key(target);
        g_printerr("[target: %s]: Cannot retrieve snapshots!\n", target_key);
    }
}
コード例 #4
0
pid_t send_snapshots_to_target(void *data, Target *target)
{
    pid_t pid = fork();
    
    if(pid == 0)
    {
        SendSnapshotsData *send_snapshots_data = (SendSnapshotsData*)data;
        
        gchar *target_key = find_target_key(target);
        GPtrArray *snapshots_per_target_array = find_snapshot_mappings_per_target(send_snapshots_data->snapshots_array, target_key);
        unsigned int i;
        int exit_status = 0;
        ProcReact_Status status;
        
        for(i = 0; i < snapshots_per_target_array->len; i++)
        {
            SnapshotMapping *mapping = g_ptr_array_index(snapshots_per_target_array, i);
        
            g_print("[target: %s]: Sending snapshots of component: %s deployed to container: %s\n", mapping->target, mapping->component, mapping->container);
            exit_status = procreact_wait_for_exit_status(exec_copy_snapshots_to(target->client_interface, mapping->target, mapping->container, mapping->component, send_snapshots_data->all), &status);
        
            if(status != PROCREACT_STATUS_OK)
            {
                exit_status = 1;
                break;
            }
            else if(exit_status != 0)
                break;
        }
    
        g_ptr_array_free(snapshots_per_target_array, TRUE);
        
        exit(exit_status);
    }
    
    return pid;
}
コード例 #5
0
ファイル: edgestable.c プロジェクト: rimmington/disnix
GHashTable *generate_edges_table(const GPtrArray *activation_array, GPtrArray *targets_array)
{    
    unsigned int i;
    
    /* Create empty hash table */
    GHashTable *edges_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, destroy_value);

    for(i = 0; i < activation_array->len; i++)
    {
	/* Retrieve the current mapping from the array */
	ActivationMapping *mapping = g_ptr_array_index(activation_array, i);
	
	/* Retrieve the target property */
	Target *target = find_target(targets_array, mapping->target);
	gchar *target_key = find_target_key(target);
	
	/* Generate an edge table key, which consist of Nix store component:targetProperty */
	gchar *mapping_key = compose_mapping_key(mapping, target_key);
	
	/* Retrieve the dependency array of the mapping from the edges table */
	GPtrArray *dependency_array = g_hash_table_lookup(edges_table, mapping_key);
	
	/* If the dependency array does not exists, create one and add it to the table */
	if(dependency_array == NULL)
	{
	    unsigned int j;
	    GPtrArray *depends_on = mapping->depends_on;
	    
	    /* Create new dependency array */
	    dependency_array = g_ptr_array_new();
	    
	    /* Create a list of mapping values for each dependency */
	    for(j = 0; j < depends_on->len; j++)
	    {
		ActivationMapping *actual_mapping;
		gchar *mapping_value, *target_key;
		Target *target;
		
		/* Retrieve current dependency from the array */
		ActivationMappingKey *dependency = g_ptr_array_index(depends_on, j);
		
		/* Find the activation mapping in the activation array */
		actual_mapping = find_activation_mapping(activation_array, dependency);
		
		/* Get the target interface */
		target = find_target(targets_array, actual_mapping->target);
		target_key = find_target_key(target);
		
		/* Generate mapping value from the service key and target property */
		mapping_value = compose_mapping_key(actual_mapping, target_key);
		
		/* Add mapping value to the dependency array */
		g_ptr_array_add(dependency_array, mapping_value);
	    }
	    
	    /* Associate the dependency array to the given mapping */
	    g_hash_table_insert(edges_table, mapping_key, dependency_array);
	}
    }

    /* Return the generated egdes table */
    return edges_table;
}