src/jmsg_task.h
)
+set(JTRACE_C_SRC
+ src/jtrace.c
+ src/jtrace.h
+)
+
set(JMSG_JAVA_SRC
org/simgrid/msg/Host.java
org/simgrid/msg/HostFailureException.java
org/simgrid/msg/Comm.java
org/simgrid/msg/RngStream.java
)
+set(JTRACE_JAVA_SRC
+ org/simgrid/trace/Trace.java
+)
set(JAVA_EXAMPLES
examples/async/AsyncTest.java
examples/startKillTime/Master.java
examples/startKillTime/Slave.java
examples/startKillTime/StartKillTime.java
+ examples/tracing/PingPongTask.java
examples/suspend/DreamMaster.java
examples/suspend/LazyGuy.java
examples/suspend/Suspend.java
+ examples/tracing/Sender.java
+ examples/tracing/Receiver.java
+ examples/tracing/TracingTest.java
)
set(CMAKE_SRC
set(XML_FILES
examples/platform.xml
examples/async/asyncDeployment.xml
+ examples/tracing/tracingPingPongDeployment.xml
examples/bittorrent/bittorrent.xml
examples/commTime/commTimeDeployment.xml
examples/masterslave/masterslaveDeployment.xml
set(source_to_pack
${CMAKE_SRC}
${JMSG_C_SRC}
+${JTRACE_C_SRC}
${JMSG_JAVA_SRC}
+${JTRACE_JAVA_SRC}
${JAVA_EXAMPLES}
${XML_FILES}
)
-string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/org/" JAVA_FILES "${JMSG_JAVA_SRC}")
+string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/org/" JAVA_FILES_MSG "${JMSG_JAVA_SRC}")
+string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/org/" JAVA_FILES_TRACE "${JTRACE_JAVA_SRC}")
string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/classes/org/" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC}")
+string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/classes/org/" JTRACE_JAVA_SRC_CLASS "${JTRACE_JAVA_SRC}")
string(REPLACE ".java" ".class" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC_CLASS}")
+string(REPLACE ".java" ".class" JTRACE_JAVA_SRC_CLASS "${JTRACE_JAVA_SRC_CLASS}")
string(REPLACE "examples/" "${CMAKE_HOME_DIRECTORY}/examples/" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES}")
string(REPLACE ".java" ".class" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES_CLASS}")
set_target_properties(SG_java PROPERTIES LINK_FLAGS "-L${SIMGRID_LIB_PATH}")
endif(WIN32)
+# SG_java_tracing
+add_library(SG_java_tracing SHARED ${JTRACE_C_SRC})
+if(WIN32)
+ set_target_properties(SG_java_tracing PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB}" PREFIX "")
+ find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
+ message(STATUS "pexports: ${PEXPORTS_PATH}")
+ if(PEXPORTS_PATH)
+ add_custom_command(TARGET SG_java_tracing POST_BUILD
+ COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java_tracing.dll > ${CMAKE_BINARY_DIR}/SG_java_tracing.def)
+ endif(PEXPORTS_PATH)
+else(WIN32)
+ target_link_libraries(SG_java_tracing pcre pthread simgrid)
+ set_target_properties(SG_java_tracing PROPERTIES LINK_FLAGS "-L${SIMGRID_LIB_PATH}")
+endif(WIN32)
+
+
# java_classes
add_custom_command(
- OUTPUT ${JMSG_JAVA_SRC_CLASS}
+ OUTPUT ${JMSG_JAVA_SRC_CLASS}
DEPENDS ${JMSG_JAVA_SRC}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
- -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_FILES}
- COMMENT "Compiling java sources of core library..."
+ -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_FILES_MSG}
+ COMMENT "Compiling java sources of core libraries..."
)
+
+add_custom_command(
+ OUTPUT ${JTRACE_JAVA_SRC_CLASS}
+ DEPENDS ${JTRACE_JAVA_SRC}
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
+ COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
+ -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_FILES_TRACE}
+ COMMENT "Compiling java sources of core libraries..."
+)
+
add_custom_target(java_classes ALL
- DEPENDS ${JMSG_JAVA_SRC_CLASS}
+ DEPENDS ${JMSG_JAVA_SRC_CLASS} ${JTRACE_JAVA_SRC_CLASS}
)
# simgrid_jar
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/priority/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/*.java
+ COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/tracing/*.java
+ COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/suspend/*.java
)
# Declare dependencies #
########################
add_dependencies(simgrid_jar java_classes)
-add_dependencies(simgrid_java_examples simgrid_jar SG_java)
+add_dependencies(simgrid_java_examples simgrid_jar SG_java SG_java_tracing)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
${CMAKE_HOME_DIRECTORY}/simgrid.jar
ADD_TEST(priority ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh)
ADD_TEST(startKillTime ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh)
ADD_TEST(suspend ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh)
+ADD_TEST(tracing ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/tracing/tracingPingPong.tesh)
+#Don't forget to put new test in this list!!!
#Don't forget to put new test in this list!!!
-set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime)
+set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime tracing)
##########################################
# Set the DYLD_LIBRARY_PATH for mac #
###########
# Install #
###########
-install(TARGETS SG_java
+install(TARGETS SG_java SG_java_tracing
DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
install(FILES ${CMAKE_HOME_DIRECTORY}/simgrid.jar
DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
+SimGrid-java (3.8) unstable; urgency=low
+
+ * Introduce org.simgrid.trace.Trace (partial implementation of JAVA bindings
+ for the TRACE API).
+ Although all TRACE methods appear in the Trace class, please not that only
+ few of thems are really implemented at the JNI level (see ./src/jtrace.c
+ for further information).
+
SimGrid-java (3.7.1) stable; urgency=low
The "Java aint got to be bloated and slow" release
-
+
Major cleanups:
* Various internal cleanups and performance improvement
Simulations are expected to run up to twice faster or so
--- /dev/null
+/*
+ * Copyright 2006,2007,2010. The SimGrid Team. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package.
+ */
+
+package tracing;
+import org.simgrid.msg.NativeException;
+import org.simgrid.msg.Task;
+
+public class PingPongTask extends Task {
+
+ private double timeVal;
+
+ public PingPongTask() throws NativeException {
+ this.timeVal = 0;
+ }
+
+ public PingPongTask(String name, double computeDuration, double messageSize) throws NativeException {
+ super(name,computeDuration,messageSize);
+ }
+
+ public void setTime(double timeVal){
+ this.timeVal = timeVal;
+ }
+
+ public double getTime() {
+ return this.timeVal;
+ }
+}
+
--- /dev/null
+This is a stupid ping/pong example. The processes exchange a simple
+task and time them.
\ No newline at end of file
--- /dev/null
+/*
+ * $Id$
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier
+ * Copyright 2012 The SimGrid Team. All rights reserved.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package.
+ */
+package tracing;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+import org.simgrid.trace.Trace;
+
+public class Receiver extends Process {
+
+ private final double commSizeLat = 1;
+ private final double commSizeBw = 100000000;
+
+ public Receiver(Host host, String name, String[]args) {
+ super(host,name,args);
+ }
+
+ public void main(String[] args) throws MsgException {
+
+ Msg.info("hello!");
+ Trace.hostPushState (host.getName(), "PM_STATE", "waitingPing");
+ double communicationTime=0;
+
+ double time = Msg.getClock();
+
+ /* Wait for the ping */
+ Msg.info("try to get a task");
+
+ PingPongTask ping = (PingPongTask)Task.receive(getHost().getName());
+ double timeGot = Msg.getClock();
+ double timeSent = ping.getTime();
+
+ Msg.info("Got at time "+ timeGot);
+ Msg.info("Was sent at time "+timeSent);
+ time=timeSent;
+
+ communicationTime=timeGot - time;
+ Msg.info("Communication time : " + communicationTime);
+
+ Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
+
+ /* Send the pong */
+ Trace.hostPushState (host.getName(), "PM_STATE", "sendingPong");
+ double computeDuration = 0;
+ PingPongTask pong = new PingPongTask("no name",computeDuration,commSizeLat);
+ pong.setTime(time);
+ pong.send(ping.getSource().getName());
+
+ /* Pop the two states */
+ Trace.hostPopState (host.getName(), "PM_STATE");
+ Trace.hostPopState (host.getName(), "PM_STATE");
+
+ Msg.info("goodbye!");
+ }
+}
--- /dev/null
+/*
+ * Sender of basic ping/pong example
+ *
+ * Copyright 2006,2007,2010, 2012 The SimGrid Team. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package.
+ */
+package tracing;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+import org.simgrid.trace.Trace;
+
+public class Sender extends Process {
+
+ private final double commSizeLat = 1;
+ private final double commSizeBw = 100000000;
+
+ public Sender(Host host, String name, String[] args) {
+ super(host,name,args);
+ }
+
+ public void main(String[] args) throws MsgException {
+ Msg.info("hello !");
+ Trace.hostPushState (host.getName(), "PM_STATE", "sendingPing");
+
+ int hostCount = args.length;
+ Msg.info("host count: " + hostCount);
+ String mailboxes[] = new String[hostCount];
+ double time;
+ double computeDuration = 0;
+ PingPongTask ping, pong;
+
+ for(int pos = 0; pos < args.length ; pos++) {
+ try {
+ mailboxes[pos] = Host.getByName(args[pos]).getName();
+ } catch (HostNotFoundException e) {
+ Msg.info("Invalid deployment file: " + e.toString());
+ System.exit(1);
+ }
+ }
+
+ for (int pos = 0; pos < hostCount; pos++) {
+ time = Msg.getClock();
+ Msg.info("sender time: " + time);
+ ping = new PingPongTask("no name",computeDuration,commSizeLat);
+ ping.setTime(time);
+ ping.send(mailboxes[pos]);
+
+ Trace.hostPushState (host.getName(), "PM_STATE", "waitingPong");
+ pong = (PingPongTask)Task.receive(getHost().getName());
+ double timeGot = Msg.getClock();
+ double timeSent = ping.getTime();
+ double communicationTime=0;
+
+ Msg.info("Got at time "+ timeGot);
+ Msg.info("Was sent at time "+timeSent);
+ time=timeSent;
+
+ communicationTime=timeGot - time;
+ Msg.info("Communication time : " + communicationTime);
+
+ Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
+
+ /* Pop the last state (going back to sending ping) */
+ Trace.hostPopState (host.getName(), "PM_STATE");
+
+ }
+ /* Pop the sendingPong state */
+ Trace.hostPopState (host.getName(), "PM_STATE");
+ Msg.info("goodbye!");
+ }
+}
--- /dev/null
+/*
+ * $Id$
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier
+ * Copyright 2012 The SimGrid team
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package.
+ */
+package tracing;
+import org.simgrid.msg.Msg;
+import org.simgrid.trace.Trace;
+import org.simgrid.msg.NativeException;
+
+public class TracingTest {
+
+ /* This only contains the launcher. If you do nothing more than than you can run
+ * java simgrid.msg.Msg
+ * which also contains such a launcher
+ */
+
+ public static void main(String[] args) throws NativeException {
+ /* initialize the MSG simulation. Must be done before anything else (even logging). */
+ Msg.init(args);
+ if(args.length < 2) {
+ Msg.info("Usage : PingPong platform_file deployment_file");
+ Msg.info("example : PingPong ping_pong_platform.xml ping_pong_deployment.xml");
+ System.exit(1);
+ }
+
+ /* construct the platform and deploy the application */
+ Msg.createEnvironment(args[0]);
+ Msg.deployApplication(args[1]);
+
+ /* Initialize some state for the hosts */
+ Trace.hostStateDeclare ("PM_STATE");
+ Trace.hostStateDeclareValue ("PM_STATE", "waitingPing", "0 0 1");
+ Trace.hostStateDeclareValue ("PM_STATE", "sendingPong", "0 1 0");
+ Trace.hostStateDeclareValue ("PM_STATE", "sendingPing", "0 1 1");
+ Trace.hostStateDeclareValue ("PM_STATE", "waitingPong", "1 0 0");
+
+ /* execute the simulation. */
+ Msg.run();
+ Msg.clean();
+ }
+}
--- /dev/null
+#! ./tesh
+
+! output sort
+
+$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar tracing/TracingTest ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/tracing/tracingPingPongDeployment.xml --cfg=tracing:1 --cfg=tracing/filename:simulation.trace --cfg=tracing/platform:1
+> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to '1'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'simulation.trace'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/platform' to '1'
+> [4.474433] [jmsg/INFO] Done running MSG_MAIN
+> [4.474433] [jmsg/INFO] MSG_main finished
+> [4.474433] [jmsg/INFO] Clean java world
+> [4.474433] [jmsg/INFO] Clean native world
+> [Boivin:tracing.Receiver:(2) 0.000000] [jmsg/INFO] hello!
+> [Boivin:tracing.Receiver:(2) 0.000000] [jmsg/INFO] try to get a task
+> [Boivin:tracing.Receiver:(2) 1.048890] [jmsg/INFO] Got at time 1.0488895059341703
+> [Boivin:tracing.Receiver:(2) 1.048890] [jmsg/INFO] Was sent at time 0.0
+> [Boivin:tracing.Receiver:(2) 1.048890] [jmsg/INFO] Communication time : 1.0488895059341703
+> [Boivin:tracing.Receiver:(2) 1.048890] [jmsg/INFO] --- bw 9.533892696441577E7 ----
+> [Boivin:tracing.Receiver:(2) 2.097779] [jmsg/INFO] goodbye!
+> [Jacquelin:tracing.Sender:(1) 0.000000] [jmsg/INFO] hello !
+> [Jacquelin:tracing.Sender:(1) 0.000000] [jmsg/INFO] host count: 2
+> [Jacquelin:tracing.Sender:(1) 0.000000] [jmsg/INFO] sender time: 0.0
+> [Jacquelin:tracing.Sender:(1) 2.097779] [jmsg/INFO] Got at time 2.09777901186834
+> [Jacquelin:tracing.Sender:(1) 2.097779] [jmsg/INFO] Was sent at time 0.0
+> [Jacquelin:tracing.Sender:(1) 2.097779] [jmsg/INFO] Communication time : 2.09777901186834
+> [Jacquelin:tracing.Sender:(1) 2.097779] [jmsg/INFO] --- bw 4.7669463482207894E7 ----
+> [Jacquelin:tracing.Sender:(1) 2.097779] [jmsg/INFO] sender time: 2.09777901186834
+> [Jacquelin:tracing.Sender:(1) 4.474433] [jmsg/INFO] Got at time 4.47443270471118
+> [Jacquelin:tracing.Sender:(1) 4.474433] [jmsg/INFO] Was sent at time 2.09777901186834
+> [Jacquelin:tracing.Sender:(1) 4.474433] [jmsg/INFO] Communication time : 2.37665369284284
+> [Jacquelin:tracing.Sender:(1) 4.474433] [jmsg/INFO] --- bw 4.207596601101137E7 ----
+> [Jacquelin:tracing.Sender:(1) 4.474433] [jmsg/INFO] goodbye!
+> [Marcel:tracing.Receiver:(3) 0.000000] [jmsg/INFO] hello!
+> [Marcel:tracing.Receiver:(3) 0.000000] [jmsg/INFO] try to get a task
+> [Marcel:tracing.Receiver:(3) 3.057947] [jmsg/INFO] Got at time 3.05794733778171
+> [Marcel:tracing.Receiver:(3) 3.057947] [jmsg/INFO] Was sent at time 2.09777901186834
+> [Marcel:tracing.Receiver:(3) 3.057947] [jmsg/INFO] Communication time : 0.96016832591337
+> [Marcel:tracing.Receiver:(3) 3.057947] [jmsg/INFO] --- bw 1.0414840533806817E8 ----
+> [Marcel:tracing.Receiver:(3) 4.474433] [jmsg/INFO] goodbye!
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+ <process host="Jacquelin" function="tracing.Sender">
+ <argument value="Boivin"/>
+ <argument value="Marcel"/>
+ </process>
+<process host="Boivin" function="tracing.Receiver"/>
+<process host="Marcel" function="tracing.Receiver"/>
+</platform>
--- /dev/null
+package org.simgrid.trace;
+
+/*
+ * JNI interface to C code for the TRACES part of SimGrid.
+ *
+ * Copyright 2006,2007,2010,2011, 2012 The SimGrid Team.
+ * All right reserved.
+ *
+ * This program is free software; you can redistribute
+ * it and/or modify it under the terms of the license
+ * (GNU LGPL) which comes with this package.
+ */
+
+public final class Trace {
+ /* Statically load the library which contains all native functions used in here */
+ static {
+ try {
+ System.loadLibrary("SG_java_tracing");
+ } catch(UnsatisfiedLinkError e) {
+ System.err.println("Cannot load the bindings to the simgrid library: ");
+ e.printStackTrace();
+ System.err.println(
+ "Please check your LD_LIBRARY_PATH, or copy the simgrid and SG_java_tracing libraries to the current directory");
+ System.exit(1);
+ }
+ }
+
+ // TODO complete the binding of the tracing API
+
+ /**
+ * Declare a new user variable associated to hosts.
+ *
+ * @param variable
+ */
+ public final static native void hostVariableDeclare (String variable);
+
+ /**
+ * Declare a new user variable associated to hosts with a color.
+ *
+ * @param variable
+ * @param color
+ */
+ public final static native void hostVariableDeclareWithColor (String variable, String color);
+
+ /**
+ * Set the value of a variable of a host.
+ *
+ * @param host
+ * @param variable
+ * @param value
+ */
+ public final static native void hostVariableSet (String host, String variable, double value);
+
+ /**
+ * Add a value to a variable of a host.
+ *
+ * @param host
+ * @param variable
+ * @param value
+ */
+ public final static native void hostVariableAdd (String host, String variable, double value);
+
+ /**
+ * Subtract a value from a variable of a host.
+ *
+ * @param host
+ * @param variable
+ * @param value
+ */
+ public final static native void hostVariableSub (String host, String variable, double value);
+
+ /**
+ * Set the value of a variable of a host at a given timestamp.
+ *
+ * @param time
+ * @param host
+ * @param variable
+ * @param value
+ */
+ public final static native void hostVariableSetWithTime (double time, String host, String variable, double value);
+
+ /**
+ * Add a value to a variable of a host at a given timestamp.
+ *
+ * @param time
+ * @param host
+ * @param variable
+ * @param value
+ */
+ public final static native void hostVariableAddWithTime (double time, String host, String variable, double value);
+
+ /**
+ * Subtract a value from a variable of a host at a given timestamp.
+ *
+ * @param time
+ * @param host
+ * @param variable
+ * @param value
+ */
+ public final static native void hostVariableSubWithTime (double time, String host, String variable, double value);
+
+ /**
+ * Get declared user host variables.
+ *
+ */
+ public final static native String[] getHostVariablesName ();
+
+ /**
+ * Declare a new user variable associated to links.
+ *
+ * @param variable
+ */
+ public final static native void linkVariableDeclare (String variable);
+
+ /**
+ * Declare a new user variable associated to links with a color.
+ * @param variable
+ * @param color
+ */
+ public final static native void linkVariableDeclareWithColor (String variable, String color);
+
+ /**
+ * Set the value of a variable of a link.
+ *
+ * @param link
+ * @param variable
+ * @param value
+ */
+ public final static native void linkVariableSet (String link, String variable, double value);
+
+ /**
+ * Add a value to a variable of a link.
+ *
+ * @param link
+ * @param variable
+ * @param value
+ */
+ public final static native void linkVariableAdd (String link, String variable, double value);
+
+ /**
+ * Subtract a value from a variable of a link.
+ *
+ * @param link
+ * @param variable
+ * @param value
+ */
+ public final static native void linkVariableSub (String link, String variable, double value);
+
+ /**
+ * Set the value of a variable of a link at a given timestamp.
+ *
+ * @param time
+ * @param link
+ * @param variable
+ * @param value
+ */
+ public final static native void linkVariableSetWithTime (double time, String link, String variable, double value);
+
+ /**
+ * Add a value to a variable of a link at a given timestamp.
+ *
+ * @param time
+ * @param link
+ * @param variable
+ * @param value
+ */
+ public final static native void linkVariableAddWithTime (double time, String link, String variable, double value);
+
+
+ /**
+ * Subtract a value from a variable of a link at a given timestamp.
+ *
+ * @param time
+ * @param link
+ * @param variable
+ * @param value
+ */
+ public final static native void linkVariableSubWithTime (double time, String link, String variable, double value);
+
+ /**
+ * Set the value of the variable present in the links connecting source and destination.
+ *
+ * @param src
+ * @param dst
+ * @param variable
+ * @param value
+ */
+ public final static native void linkSrcDstVariableSet (String src, String dst, String variable, double value);
+
+ /**
+ * Add a value to the variable present in the links connecting source and destination.
+ *
+ * @param src
+ * @param dst
+ * @param variable
+ * @param value
+ */
+ public final static native void linkSrcDstVariableAdd (String src, String dst, String variable, double value);
+
+ /**
+ * Subtract a value from the variable present in the links connecting source and destination.
+ *
+ * @param src
+ * @param dst
+ * @param variable
+ * @param value
+ */
+ public final static native void linkSrcDstVariableSub (String src, String dst, String variable, double value);
+
+ /**
+ * Set the value of the variable present in the links connecting source and destination at a given timestamp.
+ *
+ * @param time
+ * @param src
+ * @param dst
+ * @param variable
+ * @param value
+ */
+ public final static native void linkSrcDstVariableSetWithTime (double time, String src, String dst, String variable, double value);
+
+ /**
+ * Add a value to the variable present in the links connecting source and destination at a given timestamp.
+ *
+ * @param time
+ * @param src
+ * @param dst
+ * @param variable
+ * @param value
+ */
+ public final static native void linkSrcdstVariableAddWithTime (double time, String src, String dst, String variable, double value);
+
+ /**
+ * Subtract a value from the variable present in the links connecting source and destination at a given timestamp.
+ *
+ * @param time
+ * @param src
+ * @param dst
+ * @param variable
+ * @param value
+ */
+ public final static native void linkSrcDstVariableSubWithTime (double time, String src, String dst, String variable, double value);
+
+ /**
+ * Get declared user link variables.
+ */
+ public final static native String[] getLinkVariablesName ();
+
+
+ /* **** ******** WARNINGS ************** ***** */
+ /* Only the following routines have been */
+ /* JNI implemented - Adrien May, 22nd */
+ /* **** ******************************** ***** */
+
+ /**
+ * Declare a user state that will be associated to hosts.
+ * A user host state can be used to trace application states.
+ *
+ * @param name The name of the new state to be declared.
+ */
+ public final static native void hostStateDeclare(String name);
+
+ /**
+ * Declare a new value for a user state associated to hosts.
+ * The color needs to be a string with three numbers separated by spaces in the range [0,1].
+ * A light-gray color can be specified using "0.7 0.7 0.7" as color.
+ *
+ * @param state The name of the new state to be declared.
+ * @param value The name of the value
+ * @param color The color of the value
+ */
+ public final static native void hostStateDeclareValue (String state, String value, String color);
+
+ /**
+ * Set the user state to the given value.
+ * (the queue is totally flushed and reinitialized with the given state).
+ *
+ * @param host The name of the host to be considered.
+ * @param state The name of the state previously declared.
+ * @param value The new value of the state.
+ */
+ public final static native void hostSetState (String host, String state, String value);
+
+ /**
+ * Push a new value for a state of a given host.
+ *
+ * @param host The name of the host to be considered.
+ * @param state The name of the state previously declared.
+ * @param value The value to be pushed.
+ */
+ public final static native void hostPushState (String host, String state, String value);
+
+ /**
+ * Pop the last value of a state of a given host.
+ *
+ * @param host The name of the host to be considered.
+ * @param state The name of the state to be popped.
+ */
+ public final static native void hostPopState (String host, String state);
+
+
+}
--- /dev/null
+/* Java Wrappers to the TRACE API. */
+
+/* Copyright (c) 2012 The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+
+// Please note, this file strongly relies on the jmsg.c,
+// It will be great that a JNI expert gives a look to validate it - Adrien ;)
+
+#include "jtrace.h"
+#include <instr/instr.h>
+
+/* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
+#ifndef JNIEXPORT
+#define JNIEXPORT
+#endif
+#ifndef JNICALL
+#define JNICALL
+#endif
+/* end of eclipse-mandated pimple */
+
+// Define a new category
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY (jtrace, bindings, "TRACE for Java(TM)");
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_trace_Trace_hostStateDeclare(JNIEnv * env, jclass cls, jstring js)
+{
+ const char *s = (*env)->GetStringUTFChars(env, js, 0);
+ TRACE_host_state_declare(s);
+ (*env)->ReleaseStringUTFChars(env, js, s);
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_trace_Trace_hostStateDeclareValue
+ (JNIEnv *env, jclass cls, jstring js_state, jstring js_value, jstring js_color)
+{
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+ const char *value = (*env)->GetStringUTFChars(env, js_value, 0);
+ const char *color = (*env)->GetStringUTFChars(env, js_color, 0);
+
+ TRACE_host_state_declare_value(state, value, color);
+
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+ (*env)->ReleaseStringUTFChars(env, js_value, value);
+ (*env)->ReleaseStringUTFChars(env, js_color, color);
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_trace_Trace_hostSetState
+ (JNIEnv *env, jclass cls, jstring js_host, jstring js_state, jstring js_value)
+{
+ const char *host = (*env)->GetStringUTFChars(env, js_host, 0);
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+ const char *value = (*env)->GetStringUTFChars(env, js_value, 0);
+
+ TRACE_host_set_state(host, state, value);
+
+ (*env)->ReleaseStringUTFChars(env, js_host, host);
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+ (*env)->ReleaseStringUTFChars(env, js_value, value);
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_trace_Trace_hostPushState
+ (JNIEnv *env, jclass cls, jstring js_host, jstring js_state, jstring js_value)
+{
+ const char *host = (*env)->GetStringUTFChars(env, js_host, 0);
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+ const char *value = (*env)->GetStringUTFChars(env, js_value, 0);
+
+ TRACE_host_push_state(host, state, value);
+
+ (*env)->ReleaseStringUTFChars(env, js_host, host);
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+ (*env)->ReleaseStringUTFChars(env, js_value, value);
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_trace_Trace_hostPopState
+ (JNIEnv *env, jclass cls, jstring js_host, jstring js_state)
+{
+ const char *host = (*env)->GetStringUTFChars(env, js_host, 0);
+ const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+ TRACE_host_pop_state(host, state);
+
+ (*env)->ReleaseStringUTFChars(env, js_host, host);
+ (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_simgrid_trace_Trace */
+
+#ifndef _Included_org_simgrid_trace_Trace
+#define _Included_org_simgrid_trace_Trace
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableDeclare
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableDeclare
+ (JNIEnv *, jclass, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableDeclareWithColor
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableDeclareWithColor
+ (JNIEnv *, jclass, jstring, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableSet
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSet
+ (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableAdd
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableAdd
+ (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableSub
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSub
+ (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableSetWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSetWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableAddWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableAddWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostVariableSubWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSubWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: getHostVariablesName
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_org_simgrid_trace_Trace_getHostVariablesName
+ (JNIEnv *, jclass);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableDeclare
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableDeclare
+ (JNIEnv *, jclass, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableDeclareWithColor
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableDeclareWithColor
+ (JNIEnv *, jclass, jstring, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableSet
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableSet
+ (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableAdd
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableAdd
+ (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableSub
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableSub
+ (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableSetWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableSetWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableAddWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableAddWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkVariableSubWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkVariableSubWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkSrcDstVariableSet
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkSrcDstVariableSet
+ (JNIEnv *, jclass, jstring, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkSrcDstVariableAdd
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkSrcDstVariableAdd
+ (JNIEnv *, jclass, jstring, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkSrcDstVariableSub
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkSrcDstVariableSub
+ (JNIEnv *, jclass, jstring, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkSrcDstVariableSetWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkSrcDstVariableSetWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkSrcdstVariableAddWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkSrcdstVariableAddWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: linkSrcDstVariableSubWithTime
+ * Signature: (DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_linkSrcDstVariableSubWithTime
+ (JNIEnv *, jclass, jdouble, jstring, jstring, jstring, jdouble);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: getLinkVariablesName
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_org_simgrid_trace_Trace_getLinkVariablesName
+ (JNIEnv *, jclass);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostStateDeclare
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostStateDeclare
+ (JNIEnv *, jclass, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostStateDeclareValue
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostStateDeclareValue
+ (JNIEnv *, jclass, jstring, jstring, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostSetState
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostSetState
+ (JNIEnv *, jclass, jstring, jstring, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostPushState
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostPushState
+ (JNIEnv *, jclass, jstring, jstring, jstring);
+
+/*
+ * Class: org_simgrid_trace_Trace
+ * Method: hostPopState
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostPopState
+ (JNIEnv *, jclass, jstring, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+#endif