示例#1
0
int restore(const gchar *manifest_file, const unsigned int max_concurrent_transfers, const int transfer_only, const int all, const gchar *old_manifest, const gchar *coordinator_profile_path, gchar *profile, const gboolean no_upgrade, const gchar *container_filter, const gchar *component_filter)
{
    /* Generate a distribution array from the manifest file */
    Manifest *manifest = open_provided_or_previous_manifest_file(manifest_file, coordinator_profile_path, profile, MANIFEST_SNAPSHOT_FLAG, container_filter, component_filter);
    
    if(manifest == NULL)
    {
        g_print("[coordinator]: Error while opening manifest file!\n");
        return 1;
    }
    else
    {
        int exit_status;
        GPtrArray *snapshots_array;
        gchar *old_manifest_file;
        
        if(old_manifest == NULL)
            old_manifest_file = determine_previous_manifest_file(coordinator_profile_path, profile);
        else
            old_manifest_file = g_strdup(old_manifest);
        
        if(no_upgrade || old_manifest_file == NULL)
        {
            g_printerr("[coordinator]: Sending snapshots of all components...\n");
            snapshots_array = manifest->snapshots_array;
        }
        else
        {
            GPtrArray *old_snapshots_array = create_snapshots_array(old_manifest_file, container_filter, component_filter);
            g_printerr("[coordinator]: Snapshotting state of moved components...\n");
            snapshots_array = subtract_snapshot_mappings(manifest->snapshots_array, old_snapshots_array);
            delete_snapshots_array(old_snapshots_array);
        }
        
        if(send_snapshots(snapshots_array, manifest->target_array, max_concurrent_transfers, all) /* First, send the snapshots to the remote machines */
          && (transfer_only || restore_services(snapshots_array, manifest->target_array))) /* Then, restore them on the remote machines */
            exit_status = 0;
        else
            exit_status = 1;
        
        /* Cleanup */
        g_free(old_manifest_file);
        
        if(!no_upgrade && old_manifest_file != NULL)
            g_ptr_array_free(snapshots_array, TRUE);
    
        delete_manifest(manifest);

        /* Return the exit status */
        return exit_status;
    }
}
示例#2
0
int generate_graph(const gchar *manifest_file, const gchar *coordinator_profile_path, gchar *profile, int no_containers)
{
    Manifest *manifest = open_provided_or_previous_manifest_file(manifest_file, coordinator_profile_path, profile, MANIFEST_ACTIVATION_FLAG | MANIFEST_TARGETS_FLAG, NULL, NULL);

    if(manifest == NULL)
    {
        g_printerr("Cannot open any manifest file!\n");
        g_printerr("Please provide a valid manifest as command-line parameter!\n");
        return 1;
    }
    else
    {
        int exit_status;

        if(check_manifest(manifest))
        {
            /* Creates a table which maps each target onto a list of mappings */
            GHashTable *cluster_table = generate_cluster_table(manifest->activation_array, manifest->target_array);

            /* Creates a table which associates each mapping to its inter-dependencies that have a strict ordering requirement */
            GHashTable *edges_depends_on_table = generate_edges_table(manifest->activation_array, manifest->target_array, TRUE);

            /* Creates a table which associates each mapping to its inter-dependencies that have no strict ordering requirement */
            GHashTable *edges_connects_to_table = generate_edges_table(manifest->activation_array, manifest->target_array, FALSE);

            g_print("digraph G {\n");

            print_cluster_table(cluster_table, no_containers); /* Generate clusters with nodes from the cluster table */

            /* Generate edges from the edges table */
            print_edges_table(edges_depends_on_table, TRUE);
            print_edges_table(edges_connects_to_table, FALSE);

            g_print("}\n");

            /* Cleanup */
            destroy_cluster_table(cluster_table);
            destroy_edges_table(edges_connects_to_table);
            destroy_edges_table(edges_depends_on_table);

            exit_status = 0;
        }
        else
            exit_status = 1;

        delete_manifest(manifest);

        return exit_status;
    }
}