예제 #1
0
GError*
meta0_assign_prefix_to_meta1(struct meta0_backend_s *m0, gchar *ns_name, gboolean nocheck)
{
	// GET meta1 list from conscience
	GList *working_m1list = NULL;
	GSList *unref_m1list = NULL;
	GError *error;
	GPtrArray *new_meta1ref = NULL;

	GRID_INFO("START Assign prefix");

	error = _initContext(m0);
	if (error) {
		goto errorLabel;
	}

	// build working list , list sorted by score
	error = _init_assign(ns_name,&working_m1list,&unref_m1list);
	if ( error ) {
		goto errorLabel;
	}
	if ( nocheck ) {
		error =_check(working_m1list);
		if ( error ) {
			goto errorLabel;
		}
	}

	error = _assign(working_m1list,unref_m1list);	
	if ( error ) {
		goto errorLabel;
	}

	new_meta1ref = _updated_meta1ref();
	error = meta0_backend_assign(m0, context->array_meta1_by_prefix, new_meta1ref,FALSE);
	if ( error ) {
		GRID_ERROR("failed to update BDD :(%d) %s", error->code, error->message);
		goto errorLabel;
	}
	context->lastAssignTime=g_date_time_new_now_local();

errorLabel :
	_resetContext();
	if (new_meta1ref) {
		meta0_utils_array_meta1ref_clean(new_meta1ref);
	}
	if (working_m1list) {
		g_list_free(working_m1list);
		working_m1list=NULL;
	}
	if (unref_m1list) {
		g_slist_free(unref_m1list);
		unref_m1list=NULL;
	}
	GRID_INFO("END ASSIGN");

	return error;
}
예제 #2
0
void Application::init( int argc, char *argv[])
{
  /// the initialization order matters
  _initContext( argc, argv);
  _initOpenGL( argc, argv);
  _initCUDA( argc, argv);
  _initObject( argc, argv);

  if (NULL == m_Context)
  {
    fprintf( stderr, "Error: Context has not been initialized. Exit.\n");
    exit( EXIT_FAILURE );
  }
  
  m_bInitialized = true;
}
예제 #3
0
GError*
meta0_assign_disable_meta1(struct meta0_backend_s *m0, gchar *ns_name, char **m1urls, gboolean nocheck)
{
	GList *working_m1list = NULL;
	GSList *unref_m1list = NULL;
	GPtrArray *new_meta1ref = NULL;
	GError *error;

	gchar * urls = g_strjoinv(" ",m1urls);
	GRID_INFO("START disable meta1 %s",urls);
	g_free(urls);

	error = _initContext(m0);
	if (error)
		goto errorLabel;

	if ( nocheck ) {
		error =_check(NULL);
		if ( error )
			goto errorLabel;
	}

	error =_unref_meta1(m1urls);
	if ( error )
		goto errorLabel;

	error = _init_assign(ns_name,&working_m1list,&unref_m1list);
	if ( error )
		goto errorLabel;

	error = _assign(working_m1list,unref_m1list);
	if ( error )
		goto errorLabel;

	new_meta1ref = _updated_meta1ref();
	error = meta0_backend_assign(m0, context->array_meta1_by_prefix, new_meta1ref ,FALSE);
	if ( error ) {
		GRID_ERROR("failed to update BDD :(%d) %s", error->code, error->message);
		goto errorLabel;
	}

	context->lastAssignTime=g_date_time_new_now_local();

errorLabel :
	_resetContext();
	if (new_meta1ref) {
		meta0_utils_array_meta1ref_clean(new_meta1ref);
	}
	if (working_m1list) {
		g_list_free(working_m1list);
		working_m1list=NULL;
	}
	if (unref_m1list) {
		g_slist_free(unref_m1list);
		unref_m1list=NULL;
	}
	GRID_INFO("END DISABLE META1");

	return error;

}
예제 #4
0
GError*
meta0_assign_fill(struct meta0_backend_s *m0, gchar *ns_name, guint replicas,
		gboolean nodist)
{
	GError *error;
	GList *working_m1list = NULL;
	GSList *unref_m1list = NULL;
	GPtrArray *new_meta1ref = NULL;
	guint idx;
	struct meta0_assign_meta1_s *d_aM1;

	GRID_INFO("START fill meta0 db , replica %d",replicas);

	error = _initContext(m0);
	if (error)
		goto errorLabel;
	context->replica=replicas;

	error = _init_assign(ns_name,&working_m1list,&unref_m1list);
	if ( error )
		goto errorLabel;

	error =_check(NULL);
	if ( error )
		goto errorLabel;

	while (replicas--) {
		for (idx=0; idx<65536 ;idx++) {
			working_m1list=g_list_sort(working_m1list,meta0_assign_sort_by_score);
			d_aM1 =_select_dest_assign_m1(working_m1list,NULL,(guint8*)(&idx),TRUE, nodist);
			if ( ! d_aM1 ) {
				error = NEWERROR(0, "Not enough META1 to meet the requirements (distance, number) (happened at prefix %u)", idx);
				goto errorLabel;
			}

			meta0_utils_array_add(context->array_meta1_by_prefix,(guint8*)(&idx),d_aM1->addr);

			_increase_score(d_aM1);
		}
	}

	new_meta1ref = _updated_meta1ref();
	error = meta0_backend_assign(m0, context->array_meta1_by_prefix, new_meta1ref,TRUE);
	if ( error ) {
		GRID_ERROR("failed to update BDD :(%d) %s", error->code, error->message);
		goto errorLabel;
	}

	context->lastAssignTime=g_date_time_new_now_local();

errorLabel :
	_resetContext();
	if (new_meta1ref) {
		meta0_utils_array_meta1ref_clean(new_meta1ref);
	}
	if (working_m1list) {
		g_list_free(working_m1list);
		working_m1list=NULL;
	}
	if (unref_m1list) {
		g_slist_free(unref_m1list);
		unref_m1list=NULL;
	}
	GRID_INFO("END FILL");

	return error;
}