Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
updating gras prop example
authorquasar <quasar@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 5 Nov 2007 10:36:16 +0000 (10:36 +0000)
committerquasar <quasar@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 5 Nov 2007 10:36:16 +0000 (10:36 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4965 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/gras/properties/gras_prop.c
examples/gras/properties/gras_prop.mk [deleted file]
examples/gras/properties/gras_prop_deployment.xml
examples/gras/properties/gras_prop_platform.xml [deleted file]

index 3e03f0a..fa74db4 100644 (file)
@@ -1,6 +1,8 @@
-#include <gras.h>
+/*     $Id$     */
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(property,"Simple Property example");
+#include "gras.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Simple Property example");
 
 
 int client(int argc, char *argv[]) {
@@ -17,13 +19,31 @@ int client(int argc, char *argv[]) {
   }
  
   /* Try to get a property that does not exist */
-  char *noexist=xbt_strdup("Nonexisent");
+  char *noexist="Nonexisent";
   const char *value = gras_process_property_value(noexist);
   if ( value == NULL) 
     INFO1("Process property: %s is undefined", noexist);
   else
     INFO2("Process property: %s has value: %s", noexist, value);
-  
+   /* Modify an existing property. First check it exists */\
+    INFO0("Trying to modify a process property");
+    char *exist="otherprop";
+    value = gras_process_property_value(exist);
+    if ( value == NULL) 
+      INFO1("\tProperty: %s is undefined", exist);
+    else {
+      INFO2("\tProperty: %s old value: %s", exist, value);
+      xbt_dict_set(props, exist, strdup("newValue"), free);  
+    }
+    /* Test if we have changed the value */
+    value = gras_process_property_value(exist);
+    if ( value == NULL) 
+      INFO1("\tProperty: %s is undefined", exist);
+    else
+      INFO2("\tProperty: %s new value: %s", exist, value);
   gras_exit();
   return 0;
 }
@@ -42,7 +62,7 @@ int server(int argc, char *argv[]) {
   }
  
   /* Try to get a property that does not exist */
-  char *noexist=xbt_strdup("Nonexisent");
+  char *noexist="Nonexisent";
   const char *value = gras_os_host_property_value(noexist);
   if ( value == NULL) 
     INFO1("Host property: %s is undefined", noexist);
diff --git a/examples/gras/properties/gras_prop.mk b/examples/gras/properties/gras_prop.mk
deleted file mode 100644 (file)
index 4f7c6fd..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-
-####
-#### THIS FILE WAS GENERATED, DO NOT EDIT BEFORE RENAMING IT
-####
-
-
-## Variable declarations
-PROJECT_NAME=gras_prop
-DISTDIR=gras-$(PROJECT_NAME)
-
-# Set the GRAS_ROOT environment variable to the path under which you installed SimGrid
-# Compilation will fail if you don't do so
-GRAS_ROOT?= $(shell echo "\"<<<< GRAS_ROOT undefined !!! >>>>\"")
-
-# You can fiddle the following to make it fit your taste
-INCLUDES = -I$(GRAS_ROOT)/include
-CFLAGS ?= -O3 -w -g
-LIBS_SIM = -lm  -L$(GRAS_ROOT)/lib/ -lsimgrid
-LIBS_RL = -lm  -L$(GRAS_ROOT)/lib/ -lgras
-LIBS = 
-
-PRECIOUS_C_FILES ?= gras_prop.c
-GENERATED_C_FILES = _gras_prop_simulator.c _gras_prop_client.c _gras_prop_server.c 
-OBJ_FILES = $(patsubst %.c,%.o,$(PRECIOUS_C_FILES))
-BIN_FILES = gras_prop_simulator gras_prop_client gras_prop_server 
-
-## By default, build all the binaries
-all: $(BIN_FILES)
-
-
-## generate temps: regenerate the source file each time the deployment file changes
-_gras_prop_client.c _gras_prop_server.c _gras_prop_simulator.c: gras_prop_deployment.xml
-       gras_stub_generator gras_prop gras_prop_deployment.xml >/dev/null
-
-## Generate the binaries
-gras_prop_simulator: _gras_prop_simulator.o $(OBJ_FILES)
-       $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_SIM) $(LIBS) $(LDADD) -o $@ 
-gras_prop_client : _gras_prop_client.o $(OBJ_FILES)
-       $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_RL) $(LIBS) $(LDADD) -o $@ 
-gras_prop_server : _gras_prop_server.o $(OBJ_FILES)
-       $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_RL) $(LIBS) $(LDADD) -o $@ 
-
-%: %.o
-       $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ 
-
-%.o: %.c
-       $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
-
-## Rules for tarballs and cleaning
-DIST_FILES= $(EXTRA_DIST) $(GENERATED_C_FILES) $(PRECIOUS_C_FILES) gras_prop.mk 
-distdir: $(DIST_FILES)
-       rm -rf $(DISTDIR)
-       mkdir -p $(DISTDIR)
-       cp $^ $(DISTDIR)
-
-dist: clean distdir
-       tar c $(DISTDIR) | gzip -c9 > $(DISTDIR).tar.gz
-
-clean:
-       rm -f $(CLEANFILES) $(BIN_FILES) $(OBJ_FILES) *~ gras_prop.o _gras_prop_simulator.o _gras_prop_client.o _gras_prop_server.o
-       rm -rf $(DISTDIR)
-
-.SUFFIXES:
-.PHONY : clean
-
index 85e31a3..fb30f00 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "surfxml.dtd">
 <platform version="2">
-  <process host="Jacquelin" function="server">
+  <process host="C1-01" function="server">
     <prop id="someprop" value="somevalue"/>
   </process>
-  <process host="Boivin" function="client">
+  <process host="C1-00" function="client">
     <prop id="otherprop" value="othervalue"/>
   </process>
 </platform>
diff --git a/examples/gras/properties/gras_prop_platform.xml b/examples/gras/properties/gras_prop_platform.xml
deleted file mode 100644 (file)
index 9c75822..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "surfxml.dtd">
-<platform version="2">
-  <host id="Jacquelin" power="137333000">
-    <prop id="Hdd" value="120"/>
-  </host>
-  <host id="Boivin" power="98095000">
-    <prop id="Memory" value="4"/>
-  </host>
-  <link id="1" bandwidth="3430125" latency="0.000536941"/>
-  <route src="Jacquelin" dst="Boivin"><link:ctn id="1"/></route>
-  <route src="Boivin" dst="Jacquelin"><link:ctn id="1"/></route>
-</platform>