Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to apply to a Java Application without changing any code #7

Open
arnzel opened this issue Mar 1, 2019 · 7 comments
Open

How to apply to a Java Application without changing any code #7

arnzel opened this issue Mar 1, 2019 · 7 comments

Comments

@arnzel
Copy link

arnzel commented Mar 1, 2019

Hi, first i want to thank you for creating this agent. I tried it out to one of our webservices and it works perfectly.

The only problem is that we have to add an additional endpoint to our webservice to run "System.setProperty(..)". It would be nicer if we could apply this change without any Code changes at all. Because we also have about 15 other services and it will take a lot of time to apply this by code changes. Other problem is that our poject managers are not happy to change services for testing purpose.

Can you say how you use this agent in your application ? do you apply System.setProperties by adding some Endpoint, JMX Bean, SocketConnection,.. ? Would be interesting to know that.

@arvindsv
Copy link
Owner

arvindsv commented Mar 1, 2019

@arnzel Have you tried running your program with -Dfaketime.offset.seconds?

Something like:

java -agentpath:/path/to/the/library/you/got/above \
  -XX:+UnlockDiagnosticVMOptions \
  -XX:DisableIntrinsic=_currentTimeMillis \
  -XX:CompileCommand=exclude,java/lang/System.currentTimeMillis \
  -Dfaketime.offset.seconds=86400 \
  org.test.Main

@arnzel
Copy link
Author

arnzel commented Mar 1, 2019

Hi @arvindsv : yes that would be a possibility. For manual tetsing something this would be enough. But we have also automated tests where start services as docker container and want to change the timestamp depending on the use case we test at runtime.REstarting the container with other parameter valuewould be a little bit heavy.

@arvindsv
Copy link
Owner

arvindsv commented Mar 1, 2019

I see. Yes, I can understand. Unfortunately, there is no other way. Of course, it's technically possible to change the code to make it read from a socket or even a file, but writing jvmti code is quite tricky and making the current code read from something else takes some effort (to get it correct and to not crash or leak memory), which I'm not able to find time for. :(

@arnzel
Copy link
Author

arnzel commented Mar 1, 2019

Okay thanks for answer. I was just interested how you use this agent or others do. I can fully understand that you dont want to change it. Maybe i can try to add an additonal agent which does this in future. But i fear this will also takes time.

@Qvazar
Copy link

Qvazar commented May 1, 2019

Pull request #9 introduces support for reading an offset from a file that could've been mounted in as a volume. The file contents can be changed at runtime by an external process.

@arnzel
Copy link
Author

arnzel commented May 2, 2019

@Qvazar thanks for the notification. I looks exactly like the thing i need. I hope i can try it soon

@arvindsv
Copy link
Owner

arvindsv commented May 2, 2019

I haven't had a chance to take a look yet. @arnzel Feel free to try it out (build the PR) and see if it works. It'll help with the verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants