I am testing Apache Ignite version 2.16.0 using YCSB to send 100K inputs of integers. I want to use JFR to track when cache operations happen. I added the following JFR events in ignite/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@Name("org.apache.ignite.CacheGet")
@Label("Cache Get Operation")
class CacheGetEvent extends Event {
@Label("Key")
String key;
@Label("Operation Success")
boolean success;
}
@Name("org.apache.ignite.CachePut")
@Label("Cache Put Operation")
class CachePutEvent extends Event {
@Label("Key")
String key;
@Label("Operation Success")
boolean success;
}
@Name("org.apache.ignite.CacheRemove")
@Label("Cache Remove Operation")
class CacheRemoveEvent extends Event {
@Label("Key")
String key;
@Label("Operation Success")
boolean success;
}
I also use them in the get(), put() and remove() functions in the same file:
@Override public V get(K key) {
CacheGetEvent event = new CacheGetEvent();
event.key = key.toString(); // Assuming key.toString() provides a meaningful representation
event.begin();
IgniteInternalCache<K, V> delegate = getDelegateSafe();
try {
V result;
if (isAsync()) {
setFuture(delegate.getAsync(key));
result = null;
}
else {
result = delegate.get(key);
}
event.success = true; // Operation succeeded
return result;
}
catch (IgniteCheckedException | IgniteException e) {
event.success = false; // Operation failed
throw cacheException(e);
}
finally {
event.commit(); // Commit the JFR event regardless of the outcome
}
}
@Override public void put(K key, V val) {
CachePutEvent event = new CachePutEvent();
event.key = key.toString(); // Capture the key involved in the operation
event.begin();
IgniteInternalCache<K, V> delegate = getDelegateSafe();
try {
if (isAsync())
setFuture(putAsync0(key, val));
else
delegate.put(key, val);
event.success = true; // Mark the operation as successful
}
catch (IgniteCheckedException | IgniteException e) {
event.success = false; // Mark the operation as failed
throw cacheException(e);
}
finally {
event.commit(); // Commit the JFR event regardless of the outcome
}
}
@Override public boolean remove(K key) {
CacheRemoveEvent event = new CacheRemoveEvent();
event.key = key.toString(); // Capture the key involved in the operation
event.begin();
IgniteInternalCache<K, V> delegate = getDelegateSafe();
boolean result;
try {
if (isAsync()) {
setFuture(delegate.removeAsync(key));
result = false; // Async operation, actual result unknown here
}
else {
result = delegate.remove(key); // Synchronous operation, result known
}
event.success = true; // Assuming success if no exception
}
catch (IgniteCheckedException | IgniteException e) {
event.success = false; // Mark the operation as failed
throw cacheException(e);
}
finally {
event.commit(); // Commit the JFR event regardless of the outcome
}
return result;
}
I build Ignite using mvn then I run it using the following script:
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk use java 17.0.10-librca
IGNITE=/home/sameer/thesis/ignite
#/home/sameer/thesis/ignite
# Define the directory for storing JFR recordings
JFR_DIR=data/jfr
mkdir -p "$JFR_DIR" # Ensure the JFR directory exists
# Define the filename for the JFR recording
JFR_FILE="$JFR_DIR/ignite_recording.jfr"
# Ensure directories for Ignite data exist
mkdir -p /data/dbignite
mkdir -p /data/walignite
mkdir -p /data/walarchignite
# Include JFR options in the JVM options
export JVM_OPTS="$JVM_OPTS -XX:+FlightRecorder -XX:StartFlightRecording=filename=$JFR_FILE,dumponexit=true"
# Start Ignite with the specified XML configuration
"$IGNITE"/bin/ignite.sh ignite01.xml
However, whenever I convert the .jfr recording that gets produced to a json using jfr print --json --events "*" data/jfr/ignite_recording.jfr > data/jfr/ignite_recording.json, none of the custom cache events are present. Do I need to add the custom JFR events to a different file in the Ignite source code?
It's just a theory, I haven't tried it, but I have a suspicion that the events in question are not even being fired. In that case the cache events should be explicitly enabled in the
IgniteConfigurationbean. The doc says how to achieve that.