コード例 #1
0
ファイル: jmsg_host.cpp プロジェクト: oar-team/simgrid-batsim
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEnv * env, jobject jhost)
{
  msg_host_t host = jhost_get_native(env, jhost);
  jobject jstorage;
  jstring jname;

  if (!host) {
    jxbt_throw_notbound(env, "host", jhost);
    return 0;
  }

  int index = 0;
  jobjectArray jtable;
  xbt_dict_t dict =  MSG_host_get_mounted_storage_list(host);
  int count = xbt_dict_length(dict);
  jclass cls = env->FindClass("org/simgrid/msg/Storage");

  jtable = env->NewObjectArray((jsize) count, cls, nullptr);

  if (!jtable) {
   jxbt_throw_jni(env, "Storages table allocation failed");
   return nullptr;
  }

  xbt_dict_cursor_t cursor=nullptr;
  const char* mount_name;
  const char* storage_name;

  xbt_dict_foreach(dict,cursor,mount_name,storage_name) {
    jname = env->NewStringUTF(storage_name);
    jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
    env->SetObjectArrayElement(jtable, index, jstorage);
    index++;
  }
コード例 #2
0
void print_TIDestroyContainer(paje_event_t event)
{
  if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) {
    FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((destroyContainer_t) event->data)->container->name);
    fclose(f);
  }
  xbt_dict_remove(tracing_files, ((destroyContainer_t) event->data)->container->name);
}
コード例 #3
0
static void display_storage_properties(msg_storage_t storage){
  xbt_dict_cursor_t cursor = NULL;
  char *key, *data;
  xbt_dict_t props = MSG_storage_get_properties(storage);
  if (xbt_dict_length(props) > 0){
    XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage));
    xbt_dict_foreach(props, cursor, key, data)
    XBT_INFO("\t\t'%s' -> '%s'", key, data);
  }else{
  XBT_INFO("\tNo property attached.");
  }
}
コード例 #4
0
ファイル: flatifier.c プロジェクト: rosacris/simgrid
int main(int argc, char **argv)
{
  char *platformFile = NULL;
  int totalHosts, totalLinks;
  unsigned int i;
  xbt_dict_t props = NULL;
  xbt_dict_cursor_t cursor = NULL;
  xbt_lib_cursor_t cursor_src = NULL;
  xbt_lib_cursor_t cursor_dst = NULL;
  char *src,*dst,*key,*data;
  char **value;
  xbt_ex_t e;

  const SD_workstation_t *hosts;
  const SD_link_t *links;

  SD_init(&argc, argv);

  platformFile = argv[1];
  XBT_DEBUG("%s", platformFile);
  TRY {
    SD_create_environment(platformFile);
  } CATCH(e) {
    xbt_die("Error while loading %s: %s",platformFile,e.msg);
  }

  printf("<?xml version='1.0'?>\n");
  printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n");
  printf("<platform version=\"3\">\n");
  printf("<AS id=\"AS0\" routing=\"Full\">\n");

  // Hosts
  totalHosts = SD_workstation_get_number();
  hosts = SD_workstation_get_list();
  qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t),
        name_compare_hosts);

  for (i = 0; i < totalHosts; i++) {
    printf("  <host id=\"%s\" power=\"%.0f\"",
           SD_workstation_get_name(hosts[i]),
           SD_workstation_get_power(hosts[i]));
    props = SD_workstation_get_properties(hosts[i]);
    if (props && xbt_dict_length(props) > 0) {
      printf(">\n");
      xbt_dict_foreach(props, cursor, key, data) {
        printf("    <prop id=\"%s\" value=\"%s\"/>\n", key, data);
      }
      printf("  </host>\n");
    } else {
コード例 #5
0
ファイル: jmsg_as.cpp プロジェクト: RockyMeadow/simgrid
JNIEXPORT jobjectArray JNICALL
Java_org_simgrid_msg_As_getSons(JNIEnv * env, jobject jas) {
  int index = 0;
  jobjectArray jtable;
  jobject tmp_jas;
  msg_as_t tmp_as;
  msg_as_t self_as = jas_get_native(env, jas);
  
  xbt_dict_t dict = MSG_environment_as_get_routing_sons(self_as);
  int count = xbt_dict_length(dict);
  jclass cls = env->FindClass("org/simgrid/msg/As");

  if (!cls) {
    return NULL;
  }

  jtable = env->NewObjectArray((jsize) count, cls, NULL);

  if (!jtable) {
    jxbt_throw_jni(env, "Hosts table allocation failed");
    return NULL;
  }

  xbt_dict_cursor_t cursor=NULL;
  char *key;

  xbt_dict_foreach(dict,cursor,key,tmp_as) {
    tmp_jas = jas_new_instance(env);
    if (!tmp_jas) {
      jxbt_throw_jni(env, "java As instantiation failed");
      return NULL;
    }
    tmp_jas = jas_ref(env, tmp_jas);
    if (!tmp_jas) {
      jxbt_throw_jni(env, "new global ref allocation failed");
      return NULL;
    }
    jas_bind(tmp_jas, tmp_as, env);

    env->SetObjectArrayElement(jtable, index, tmp_jas);
    index++;

  }
コード例 #6
0
ファイル: network_smpi.cpp プロジェクト: simgrid/simgrid
void NetworkSmpiModel::gapRemove(Action *lmm_action)
{
    xbt_fifo_t fifo;
    size_t size;
    NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_action);

    if (sg_sender_gap > 0.0 && action->senderLinkName_
            && action->senderFifoItem_) {
        fifo =
            (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup,
                                              action->senderLinkName_);
        xbt_fifo_remove_item(fifo, action->senderFifoItem_);
        size = xbt_fifo_size(fifo);
        if (size == 0) {
            xbt_fifo_free(fifo);
            xbt_dict_remove(gap_lookup, action->senderLinkName_);
            size = xbt_dict_length(gap_lookup);
            if (size == 0) {
                xbt_dict_free(&gap_lookup);
            }
        }
    }
}
コード例 #7
0
ファイル: host.cpp プロジェクト: krytarowski/simgrid
size_t sg_host_count()
{
  return xbt_dict_length(host_list);
}
コード例 #8
0
ファイル: dict.c プロジェクト: apargupta/simgrid
/**
 * \brief test if the dict is empty or not
 */
XBT_INLINE int xbt_dict_is_empty(xbt_dict_t dict)
{
    return !dict || (xbt_dict_length(dict) == 0);
}
コード例 #9
0
ファイル: msg_host.cpp プロジェクト: luizabeltrame/simgrid
/** \ingroup m_host_management
 * \brief Return the current number MSG hosts.
 */
int MSG_get_host_number(void)
{
  return xbt_dict_length(host_list);
}