These are chat archives for atomix/atomix

27th
Feb 2016
Richard Pijnenburg
@electrical
Feb 27 2016 11:36
@kuujo you got a moment when you are online?
Richard Pijnenburg
@electrical
Feb 27 2016 12:23
found it. was looking how to include all the dependencies in its own directory
Richard Pijnenburg
@electrical
Feb 27 2016 14:53
advice on a good yaml parser? want to use yaml for the config file of my project :-)
Richard Pijnenburg
@electrical
Feb 27 2016 16:23
uhg.. java
want to start atomix in its own thread because its blocking loading anything else.
Richard Pijnenburg
@electrical
Feb 27 2016 16:43
and i'll need the atomix part to run separate of anything else.
or at least the main process.
eventually atomix will control what other treads will run out there.
the logstash plugins for example
Richard Pijnenburg
@electrical
Feb 27 2016 17:37
oh man. this is getting so hard :-(
i got atomix running in its own thread.. but most likely in a way that i can't use the constructor in any way anywhere else to do anything else with it.
`public class Client extends Thread
that's how i'm running it now
must be a better way to do it
Richard Pijnenburg
@electrical
Feb 27 2016 17:50
could i reuse catalysts implementation of concurent easy for this kind of stuff?
Jordan Halterman
@kuujo
Feb 27 2016 19:28
:-P sorry I've been a little sick. Atomix will run in a few of its own threads that it creates internally. Atomix clients have two threads, and servers have several threads. It uses the Catalyst ThreadContext to control the threads. Generally, everything uses Catalyst's SingleThreadContext which is essentially an event loop. Additionally, Netty creates its own event loop threads that Atomix uses for messaging. So, nothing should really be blocking anything else. It's possible some APIs are being used incorrectly. Example:
atomix.open() will open an Atomix instance in an internal Atomix thread, and the returned CompletableFuture will be completed in an Atomix thread once it's done. So, you can do e.g. atomix.open().thenRun(() -> ...) and continue on doing other stuff while Atomix starts up. Alternatively, join() will block the calling thread until Atomix starts.
Copycat and Atomix use ThreadContext to control threads by calling execute(...) on the ThreadContext for the thread on which the callback should run
Jordan Halterman
@kuujo
Feb 27 2016 19:34
But the ThreadContext has some additional overhead that’s integrated with the Serializer. Namely, Serializer is not thread safe for performance reasons. Instead of thread safety, Serializer instances are cloned for each thread and stored in the ThreadContext. So, you can do ThreadContext.currentContext().serializer().writeObject(“foo”) to serialize ”foo” using the current thread’s serializer
Richard Pijnenburg
@electrical
Feb 27 2016 19:34
I did copy the standalone example including the thread sleep. Shouldn't I have used that last bit then ?
Jordan Halterman
@kuujo
Feb 27 2016 19:36
oh yeah that’s not necessary… in the example that is just blocking the main thread to prevent it from exiting while the server is running in the Atomix threads, but if you’re doing other things in the main thread just remove that
Basically, Java has the main thread. When you call atomix.open(), Atomix will run on a bunch of Atomix threads that will stay running as long as the main thread is running, so I block the main thread to keep the Atomix threads running. But you can keep on doing other things and Atomix will be fine
Richard Pijnenburg
@electrical
Feb 27 2016 19:37
Ahh okay. Will try that. Any other advice / tips ?
Jordan Halterman
@kuujo
Feb 27 2016 19:38
that was actually something that got me the first time I used Java too :-)
nope
Richard Pijnenburg
@electrical
Feb 27 2016 19:38
I can put the code on github what I have now and you can take a look at some point lol. Bet there is a lot of horrible code.
Jordan Halterman
@kuujo
Feb 27 2016 19:39
yeah that would be awesome
No judgement. I can only imagine what my code would look like trying to write Ruby or something
Richard Pijnenburg
@electrical
Feb 27 2016 19:43
Haha true. Can use all the help I can get lol