Beispiel #1
0
bool redis_builder::load(const char* conf, size_t replicas)
{
	acl::string buf;

	// load xml information from local file
	if (acl::ifstream::load(conf, &buf) == false)
	{
		printf("%s: load configure error: %s, file: %s\r\n",
			__FUNCTION__, acl::last_serror(), conf);
		return false;
	}
	/* <xml>
	 *   <node addr="ip:port">
	 *     <node addr="ip:port" />
	 *     <node addr="ip:port" />
	 *     ...
	 *   </node>
	 *   <node addr="ip:port">
	 *     <node addr="ip:port" />
	 *     <node addr="ip:port" />
	 *     ...
	 *   </node>
	 *   ...
	 * </xml>
	 */
	// parse the xml data
	acl::xml xml(buf.c_str());

	if (replicas > 0)
		return create_cluster(xml, replicas);
	else
		return create_cluster(xml);
}
int main(int argc, char** argv) {
    int LCS_threshold=0,n=0,i=0,j=0;
    char clustername[10];
    create_cluster();
    display_clusters();
    printf("NC_LCS=%d",((int)large_cluster(cnode)));
    printf("\nEnter the LCS threshold:");
    scanf("%d",&LCS_threshold);
    printf("\nEnter the cluster name:");
    scanf("%s",clustername);
    n=num_of_clusters;
    for(i=0;i<n;i++)
    {
       if((strcmp((cnode+i)->cname,clustername)==0))
       {
           for(j=0;j<((cnode+i)->num_of_pages);j++)
           {
               
               printf("\n%s",(((cnode+i)->pagelink)+j)->pname);
           }
       }
        
    }
  
    free_clusters();


    return (EXIT_SUCCESS);
}
Beispiel #3
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  const Pair items[] = { { "apple", 1 }, { "orange", 2 }, { "banana", 3 }, { "mango", 4 }, { NULL, 0 } };

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                'class': 'SimpleStrategy', 'replication_factor': '3' };");

  execute_query(session,
                "CREATE TABLE examples.maps (key text, \
                items map<text, int>, \
                PRIMARY KEY (key))");


  insert_into_maps(session, "test", items);
  select_from_maps(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Beispiel #4
0
void
cluster(point ps[], int n, int k, int cs[])
{

    ld **distances;	// all the edge weights
    void *clusters[n];	// array of pointers to clusters.
    //  note that the indexes of the array are
    //  the same as the indexes of the points
    int point1, point2;	// temporary variables that should store
    // the next pair of closest points

    // allocate memory for the arrays
    distances	= (ld **) smalloc(sizeof(ld *) * n);

    // pre-calculate all the edge weights (distances
    // between every point and every other point)
    get_distances(distances, ps, n);

    // initialize each cluster to have just 1 point
    for(int i = 0; i < n; i++) {
        clusters[i] = create_cluster(i);
    }

    // keep merging clusters until we're down to k clusters
    for(int num_clusters = n; num_clusters > k; num_clusters--) {
        // find the 2 closest clusters that aren't connected
        next_shortest_edge(&point1, &point2, distances, n, clusters);
        // merge them
        merge_clusters(clusters[point1], clusters[point2]);
    }

    // convert the crazy cluster numbers to normal ones
    normalize_clusters(cs, n, clusters);

}
Beispiel #5
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  Basic input = { cass_true, 0.001f, 0.0002, 1, 2 };
  Basic output;
  const CassPrepared* prepared = NULL;
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.basic (key text, \
                                              bln boolean, \
                                              flt float, dbl double,\
                                              i32 int, i64 bigint, \
                                              PRIMARY KEY (key));");

  insert_into_basic(session, "prepared_test", &input);

  if (prepare_select_from_basic(session, &prepared) == CASS_OK) {
    select_from_basic(session, prepared, "prepared_test", &output);

    assert(input.bln == output.bln);
    assert(input.flt == output.flt);
    assert(input.dbl == output.dbl);
    assert(input.i32 == output.i32);
    assert(input.i64 == output.i64);
    cass_prepared_free(prepared);
  }

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Beispiel #6
0
/*
** COMMAND:  test-create-clusters
**
** Create clusters for all unclustered artifacts if the number of unclustered
** artifacts exceeds the current clustering threshold.
*/
void test_createcluster_cmd(void){
  if( g.argc==3 ){
    db_open_repository(g.argv[2]);
  }else{
    db_find_and_open_repository(0, 0);
    if( g.argc!=2 ){
      usage("?REPOSITORY-FILENAME?");
    }
    db_close(1);
    db_open_repository(g.zRepositoryName);
  }
  db_begin_transaction();
  create_cluster();
  db_end_transaction(0);  
}
Beispiel #7
0
redis_commands::redis_commands(const char* addr, const char* passwd,
	int conn_timeout, int rw_timeout, bool prefer_master,
	const char* cmds_file)
	: conn_timeout_(conn_timeout)
	, rw_timeout_(rw_timeout)
	, prefer_master_(prefer_master)
	, all_cmds_perm_("yes")
{
	if (passwd && *passwd)
		passwd_ = passwd;

	set_addr(addr, addr_);
	conns_ = NULL;

	init(cmds_file);
	create_cluster();
}
Beispiel #8
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  uuid_gen = cass_uuid_gen_new();

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  schema_meta = cass_session_get_schema_meta(session);

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' }");
Beispiel #9
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  Basic input = { cass_true, 0.001f, 0.0002, 1, 2 };
  Basic output;

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.basic (key text, \
                                              bln boolean, \
                                              flt float, dbl double,\
                                              i32 int, i64 bigint, \
                                              PRIMARY KEY (key));");

  insert_into_basic(session, "test", &input);
  select_from_basic(session, "test", &output);

  assert(input.bln == output.bln);
  assert(input.flt == output.flt);
  assert(input.dbl == output.dbl);
  assert(input.i32 == output.i32);
  assert(input.i64 == output.i64);

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Beispiel #10
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  char* hosts = "127.0.0.1";

  const char* items[] = { "apple", "orange", "banana", "mango", NULL };

  cass_cluster_set_protocol_version(cluster, 2);

  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '1' };");

  execute_query(session,
                "CREATE TABLE examples.collections (key text, \
                                                    items set<text>, \
                                                    PRIMARY KEY (key))");


  insert_into_collections(session, "test", items);
  select_from_collections(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Beispiel #11
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  const CassPrepared* prepared = NULL;

  Pair pairs[] = { {"a", "1"}, {"b", "2"}, { NULL, NULL} };

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.pairs (key text, \
                                              value text, \
                                              PRIMARY KEY (key));");

  if (prepare_insert_into_batch(session, &prepared) == CASS_OK) {
    insert_into_batch_with_prepared(session, prepared, pairs);
  }

  cass_prepared_free(prepared);

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Beispiel #12
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  uuid_gen = cass_uuid_gen_new();

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  schema_meta = cass_session_get_schema_meta(session);

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' }");
Beispiel #13
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.date_time (key text PRIMARY KEY,  d date, t time)");

  insert_into(session, "test");
  select_from(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Beispiel #14
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.async (key text, \
                                              bln boolean, \
                                              flt float, dbl double,\
                                              i32 int, i64 bigint, \
                                              PRIMARY KEY (key));");

  execute_query(session, "USE examples");

  insert_into_async(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Beispiel #15
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();

  uuid_gen = cass_uuid_gen_new();

  uv_mutex_init(&mutex);
  uv_cond_init(&cond);

  connect_session(session, cluster, on_session_connect);

  /* Code running in parallel with queries */

  wait_exit();

  uv_cond_destroy(&cond);
  uv_mutex_destroy(&mutex);

  cass_cluster_free(cluster);
  cass_uuid_gen_free(uuid_gen);
  cass_session_free(session);

  return 0;
}
int main() { 
	char sql[1024];
	time_t start, stop;

	FILE *fp = fopen("/Users/carybourgeois/flights_exercise/flights_from_pg.csv", "r") ; 
	
	CassError rc = CASS_OK;
	CassCluster* cluster = create_cluster();
	CassSession* session = NULL;
	CassFuture* close_future = NULL;

	rc = connect_session(cluster, &session);
	if(rc != CASS_OK) {
		return -1;
	}
	
	execute_stmt(session, 
					"CREATE KEYSPACE IF NOT EXISTS exercise WITH \
						replication = {'class': 'SimpleStrategy','replication_factor': '1'};");
						
	execute_stmt(session,
					"USE exercise;");
						
	execute_stmt(session,
					"DROP TABLE IF EXISTS flights;");
					
	execute_stmt(session,
					"CREATE TABLE flights ( \
						id int, year int, day_of_month int, fl_date varchar, \
						airline_id int, carrier varchar, fl_num int, origin_airport_id int, \
						origin varchar, origin_city_name varchar, origin_state_abr varchar, dest varchar, \
						dest_city_name varchar, dest_state_abr varchar, dep_time int, arr_time int, \
						actual_elapsed_time int, air_time int, distance int, air_time_grp int, \
						PRIMARY KEY (carrier, origin, air_time_grp, id));");

 	time(&start);
 	
 	if ( fp != NULL ) {
 		int i = 0;  
   		while(!feof(fp)) {           
        	i++;
                  
   			fscanf(fp, "%d, %d, %d, %[^,], %d, %[^,], %d, %d, %[^,], %[^,], %[^,], %[^,], %[^,], %[^,], %d, %d, %d, %d, %d \n", 
      			&Flight.id, &Flight.year, &Flight.day_of_month, Flight.fl_date, 
      			&Flight.airline_id, Flight.carrier, &Flight.fl_num, &Flight.origin_airport_id,
      			Flight.origin, Flight.origin_city_name, Flight.origin_state_abr, Flight.dest,
      			Flight.dest_city_name, Flight.dest_state_abr, &Flight.dep_time, &Flight.arr_time,
      			&Flight.actual_elapsed_time, &Flight.air_time, &Flight.distance);
      
    		sprintf(sql, "INSERT INTO flights (id, year, day_of_month, fl_date, airline_id, carrier, fl_num, origin_airport_id, origin, origin_city_name, origin_state_abr, dest, dest_city_name, dest_state_abr, dep_time, arr_time, actual_elapsed_time, air_time, distance, air_time_grp) VALUES (%d, %d, %d, \'%s\', %d, \'%s\', %d, %d, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', %d, %d, %d, %d, %d, %d);\n", 
        		Flight.id, Flight.year, Flight.day_of_month, Flight.fl_date, 
      			Flight.airline_id, Flight.carrier, Flight.fl_num, Flight.origin_airport_id,
      			Flight.origin, Flight.origin_city_name, Flight.origin_state_abr, Flight.dest,
      			Flight.dest_city_name, Flight.dest_state_abr, Flight.dep_time, Flight.arr_time,
      			Flight.actual_elapsed_time, Flight.air_time, Flight.distance, Flight.air_time/10 );
      			
      		/* printf("%s", sql); */
      		execute_stmt(session, sql);
           
        	/* if (i > 999) break; */
                               
		}  /* EOF */ 
		printf("%d Records loaded.\n", i);
   
	}  /* File exists */ 
	
	time(&stop);
 
    printf("%.f Seconds total load time.\n", difftime(start, stop));   
   
	close_future = cass_session_close(session);
  	cass_future_wait(close_future);
	cass_future_free(close_future);
	cass_cluster_free(cluster);
	
	fclose( fp ); 
	
	return 0;   
  
}
Beispiel #17
0
int main() {
  int i;
  CassMetrics metrics;
  uv_thread_t threads[NUM_THREADS];
  CassCluster* cluster = NULL;
  CassSession* session = NULL;
  CassFuture* close_future = NULL;

  status_init(&status, NUM_THREADS);

  cass_log_set_level(CASS_LOG_INFO);

  cluster = create_cluster();
  uuid_gen = cass_uuid_gen_new();
  session = cass_session_new();

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "INSERT INTO songs (id, title, album, artist, tags) VALUES "
                "(a98d21b2-1900-11e4-b97b-e5e358e71e0d, "
                "'La Petite Tonkinoise', 'Bye Bye Blackbird', 'Joséphine Baker', { 'jazz', '2013' });");


  for (i = 0; i < NUM_THREADS; ++i) {
#if DO_SELECTS
    uv_thread_create(&threads[i], run_select_queries, (void*)session);
#else
    uv_thread_create(&threads[i], run_insert_queries, (void*)session);
#endif
  }

  while (status_wait(&status, 5) > 0) {
    cass_session_get_metrics(session, &metrics);
    printf("rate stats (requests/second): mean %f 1m %f 5m %f 10m %f\n",
           metrics.requests.mean_rate,
           metrics.requests.one_minute_rate,
           metrics.requests.five_minute_rate,
           metrics.requests.fifteen_minute_rate);
  }

  cass_session_get_metrics(session, &metrics);
  printf("final stats (microseconds): min %llu max %llu median %llu 75th %llu 95th %llu 98th %llu 99th %llu 99.9th %llu\n",
         (unsigned long long int)metrics.requests.min, (unsigned long long int)metrics.requests.max,
         (unsigned long long int)metrics.requests.median, (unsigned long long int)metrics.requests.percentile_75th,
         (unsigned long long int)metrics.requests.percentile_95th, (unsigned long long int)metrics.requests.percentile_98th,
         (unsigned long long int)metrics.requests.percentile_99th, (unsigned long long int)metrics.requests.percentile_999th);

  for (i = 0; i < NUM_THREADS; ++i) {
    uv_thread_join(&threads[i]);
  }

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);
  cass_cluster_free(cluster);
  cass_uuid_gen_free(uuid_gen);

  status_destroy(&status);

  return 0;
}
Beispiel #18
0
/*
** Core function to rebuild the information in the derived tables of a
** fossil repository from the blobs. This function is shared between
** 'rebuild_database' ('rebuild') and 'reconstruct_cmd'
** ('reconstruct'), both of which have to regenerate this information
** from scratch.
**
** If the randomize parameter is true, then the BLOBs are deliberately
** extracted in a random order.  This feature is used to test the
** ability of fossil to accept records in any order and still
** construct a sane repository.
*/
int rebuild_db(int randomize, int doOut, int doClustering){
  Stmt s;
  int errCnt = 0;
  char *zTable;
  int incrSize;

  bag_init(&bagDone);
  ttyOutput = doOut;
  processCnt = 0;
  if (ttyOutput && !g.fQuiet) {
    percent_complete(0);
  }
  rebuild_update_schema();
  for(;;){
    zTable = db_text(0,
       "SELECT name FROM sqlite_master /*scan*/"
       " WHERE type='table'"
       " AND name NOT IN ('blob','delta','rcvfrom','user',"
                         "'config','shun','private','reportfmt',"
                         "'concealed','accesslog','modreq')"
       " AND name NOT GLOB 'sqlite_*'"
       " AND name NOT GLOB 'fx_*'"
    );
    if( zTable==0 ) break;
    db_multi_exec("DROP TABLE %Q", zTable);
    free(zTable);
  }
  db_multi_exec(zRepositorySchema2);
  ticket_create_table(0);
  shun_artifacts();

  db_multi_exec(
     "INSERT INTO unclustered"
     " SELECT rid FROM blob EXCEPT SELECT rid FROM private"
  );
  db_multi_exec(
     "DELETE FROM unclustered"
     " WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
  );
  db_multi_exec(
    "DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')"
  );

  /* The following should be count(*) instead of max(rid). max(rid) is
  ** an adequate approximation, however, and is much faster for large
  ** repositories. */
  totalSize = db_int(0, "SELECT max(rid) FROM blob");
  incrSize = totalSize/100;
  totalSize += incrSize*2;
  db_prepare(&s,
     "SELECT rid, size FROM blob /*scan*/"
     " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
     "   AND NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)"
  );
  manifest_crosslink_begin();
  while( db_step(&s)==SQLITE_ROW ){
    int rid = db_column_int(&s, 0);
    int size = db_column_int(&s, 1);
    if( size>=0 ){
      Blob content;
      content_get(rid, &content);
      rebuild_step(rid, size, &content);
    }
  }
  db_finalize(&s);
  db_prepare(&s,
     "SELECT rid, size FROM blob"
     " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
  );
  while( db_step(&s)==SQLITE_ROW ){
    int rid = db_column_int(&s, 0);
    int size = db_column_int(&s, 1);
    if( size>=0 ){
      if( !bag_find(&bagDone, rid) ){
        Blob content;
        content_get(rid, &content);
        rebuild_step(rid, size, &content);
      }
    }else{
      db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
      rebuild_step_done(rid);
    }
  }
  db_finalize(&s);
  manifest_crosslink_end(MC_NONE);
  rebuild_tag_trunk();
  if( ttyOutput && !g.fQuiet && totalSize>0 ){
    processCnt += incrSize;
    percent_complete((processCnt*1000)/totalSize);
  }
  if( doClustering ) create_cluster();
  if( ttyOutput && !g.fQuiet && totalSize>0 ){
    processCnt += incrSize;
    percent_complete((processCnt*1000)/totalSize);
  }
  if(!g.fQuiet && ttyOutput ){
    percent_complete(1000);
    fossil_print("\n");
  }
  return errCnt;
}
/*
 * Testing distribute_work_2_gp_segments
 */
static void test__distribute_work_to_gp_segments(TestInputData *input)
{
	List **segs_allocated_data = NULL;
	List * input_fragments_list = NIL;
	char** array_of_segs = NULL;
	bool *array_of_primaries;
	int total_segs;
	bool cluster_size_not_exceeded = input->m_num_hosts_in_cluster <=  65025;
	
	assert_true(cluster_size_not_exceeded);
	/*  
	 * 1. Initialize the test input parameters
	 * We are testing an N hosts cluster. The size of the cluster is set in this section - section 1. 
	 * Basic test assumptions:
	 * a. There is one datanode on each host in the cluster
	 * b. There are Hawq segments on each host in the cluster.
	 * c. There is an equal number of Hawq segments on each host - hardcoded in this section
	 */
	int num_hosts_in_cluster = input->m_num_hosts_in_cluster; /* cluster size musn't exceed 65025 - see function create_cluster() */
	int num_data_fragments = input->m_num_data_fragments; /* number of fragments in the data we intend to allocate between the hawq segments */
	int num_active_data_nodes = input->m_num_active_data_nodes; /* number of datanodes that hold the 'querried' data - there one datanode om each cluster host - so there are <num_hosts_in_cluster> datanodes */
	int num_of_fragment_replicas = input->m_num_of_fragment_replicas;
	int num_segments_on_host = input->m_num_segments_on_host;/* number of Hawq segments on each cluster host - we assume all cluster hosts have Hawq segments installed */
	int num_working_segs = input->m_num_working_segs; /* the subset of Hawq segments that will do the processing  - not all the Hawqs segments in the cluster are involved */
	bool enable_print_input_cluster = input->m_enable_print_input_cluster;
	bool enable_print_input_fragments = input->m_enable_print_input_fragments;
	bool enable_print_input_segments = input->m_enable_print_input_segments;
	bool enable_print_allocated_fragments = input->m_enable_print_allocated_fragments;
		
	/* 2. Create the cluster */
	char **cluster = create_cluster(num_hosts_in_cluster);
	
	if (enable_print_input_cluster)
		print_cluster(cluster, num_hosts_in_cluster);
	 	
	/* 3. Input - data fragments */
	input_fragments_list = spread_fragments_in_cluster(num_data_fragments, /* number of fragments in the data we are about to allocate */
													   num_active_data_nodes, /* hosts */
													   num_of_fragment_replicas, /* replicas */
													   cluster, /* the whole cluster*/
													   num_hosts_in_cluster/* the number of hosts in the cluster */);
	if (enable_print_input_fragments)
		print_fragment_list(input_fragments_list); 
	
	/* 4. Input - hawq segments */
	total_segs = num_hosts_in_cluster * num_segments_on_host;
	array_of_segs = create_array_of_segs(cluster, num_hosts_in_cluster, num_segments_on_host);	
	array_of_primaries = create_array_of_primaries(total_segs);
		
	buildCdbComponentDatabases(total_segs, array_of_segs, array_of_primaries);	
	if (enable_print_input_segments)
		print_segments_list();
		
	/* 5. The actual unitest of distribute_work_2_gp_segments() */
	segs_allocated_data = distribute_work_2_gp_segments(input_fragments_list, total_segs, num_working_segs);
	if (enable_print_allocated_fragments)
		print_allocated_fragments(segs_allocated_data, total_segs);
	
	/* 6. The validations - verifying that the expected output was obtained */
	validate_total_fragments_allocated(segs_allocated_data, total_segs, num_data_fragments);
	validate_max_load_per_segment(segs_allocated_data, total_segs, num_working_segs, num_data_fragments);
	validate_all_working_segments_engagement(segs_allocated_data, total_segs, num_working_segs, num_data_fragments, num_hosts_in_cluster);
	
	/* 7. Cleanup */
	restoreCdbComponentDatabases();
	clean_cluster(cluster, num_hosts_in_cluster);
	clean_array_of_segs(array_of_segs, total_segs);
	clean_allocated_fragments(segs_allocated_data, total_segs);
	pfree(array_of_primaries);
}