forked from scouter-project/scouter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scouter-project#981 from scouter-project/feature/r…
…eactor34 Feature/reactor34
- Loading branch information
Showing
7 changed files
with
117 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
import scouter.agent.Logger; | ||
import scouter.agent.util.Tuple; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* @author Gun Lee ([email protected]) on 2020/08/08 | ||
*/ | ||
|
@@ -31,7 +33,8 @@ public class ScouterOptimizableOperatorProxy { | |
public static boolean accessible = false; | ||
public static boolean first = true; | ||
|
||
public static Tuple.StringLongPair nameOnCheckpoint(Object candidate, int maxScanDepth) { | ||
public static Tuple.StringLongPair nameOnCheckpoint(Object candidate, int maxScanDepth, boolean isReactor34, | ||
Method isCheckpoint) { | ||
try { | ||
if (!accessible && first) { | ||
try { | ||
|
@@ -54,12 +57,14 @@ public static Tuple.StringLongPair nameOnCheckpoint(Object candidate, int maxSca | |
} | ||
if (closeAssembly instanceof MonoOnAssembly) { | ||
FluxOnAssembly.AssemblySnapshot snapshot = ((MonoOnAssembly) closeAssembly).stacktrace; | ||
if (snapshot != null && snapshot.isCheckpoint()) { | ||
boolean cp = isReactor34 ? (Boolean) isCheckpoint.invoke(snapshot) : snapshot.checkpointed; | ||
if (snapshot != null && cp) { | ||
return new Tuple.StringLongPair(snapshot.cached, snapshot.hashCode()); | ||
} | ||
} else if (closeAssembly instanceof FluxOnAssembly) { | ||
FluxOnAssembly.AssemblySnapshot snapshot = ((FluxOnAssembly) closeAssembly).snapshotStack; | ||
if (snapshot != null && snapshot.isCheckpoint()) { | ||
boolean cp = isReactor34 ? (Boolean) isCheckpoint.invoke(snapshot) : snapshot.checkpointed; | ||
if (snapshot != null && cp) { | ||
return new Tuple.StringLongPair(snapshot.cached, snapshot.hashCode()); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
scouter.agent.java/src/main/java/scouter/xtra/reactive/ReactiveSupportUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package scouter.xtra.reactive; | ||
|
||
import reactor.core.publisher.Mono; | ||
import scouter.agent.Logger; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* @author Gun Lee ([email protected]) on 2/21/24 | ||
*/ | ||
public class ReactiveSupportUtils { | ||
|
||
public static boolean isSupportReactor34() { | ||
try { | ||
Class<?> assemblySnapshotClass = Class.forName("reactor.core.publisher.FluxOnAssembly$AssemblySnapshot"); | ||
assemblySnapshotClass.getDeclaredMethod("isCheckpoint"); | ||
|
||
Class<Mono> monoClass = Mono.class; | ||
Class<?>[] parameterTypes = new Class<?>[]{Function.class}; | ||
monoClass.getMethod("contextWrite", parameterTypes); | ||
|
||
return true; | ||
|
||
} catch (ClassNotFoundException | NoSuchMethodException e) { | ||
e.printStackTrace(); | ||
Logger.println("R301", e.getMessage()); | ||
return false; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
Logger.println("R302", e.getMessage(), e); | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters