onyx

FYI: alternative Onyx :onyx: chat is at <https://gitter.im/onyx-platform/onyx> ; log can be found at <https://clojurians-log.clojureverse.org/onyx/index.html>
raymcdermott 2018-01-14T17:25:23.000006Z

hey guys … basic question here about REPL usage

raymcdermott 2018-01-14T17:26:03.000077Z

I’m working with one of the examples (session windows to be specific)

raymcdermott 2018-01-14T17:26:26.000057Z

and when I load the REPL I get a ZooKeeper error

raymcdermott 2018-01-14T17:27:11.000039Z

where is says the address is in use

raymcdermott 2018-01-14T17:27:30.000035Z

@raymcdermott uploaded a file: https://clojurians.slack.com/files/U04V5V0V4/F8TG0HDPY/image.png

raymcdermott 2018-01-14T17:28:05.000013Z

any ideas / tips on how I can run the examples in the REPL?

lucasbradstreet 2018-01-14T20:54:20.000099Z

@raymcdermott it seems like everything has already been eval’d by the time you start evaluating things? It’s not that great for repl play since you need to eval things in turn.

raymcdermott 2018-01-14T21:27:49.000041Z

@lucasbradstreet er, yeah I just took the example and loaded it into the REPL … my point is only that it seems like ZK is started twice and I don’t get that

lucasbradstreet 2018-01-14T21:28:02.000075Z

Ah, this is before you even eval anything?

lucasbradstreet 2018-01-14T21:28:12.000079Z

(manually I mean)

raymcdermott 2018-01-14T21:29:45.000109Z

ah … it might be that cursive evals it when starting the REPL and than I load it … so it’s done twice

lucasbradstreet 2018-01-14T21:30:06.000119Z

Right, that’s what I was thinking.

lucasbradstreet 2018-01-14T21:30:28.000023Z

They’d be better off in tests I think.

lucasbradstreet 2018-01-14T21:30:39.000029Z

But this way you can go through line by line and see what happens.

raymcdermott 2018-01-14T21:31:24.000096Z

yes, that’s what it was

raymcdermott 2018-01-14T21:31:48.000067Z

agreed yes although I guess your examples are made for lein run rather than the REPL

raymcdermott 2018-01-14T21:31:56.000026Z

I now get this message

raymcdermott 2018-01-14T21:32:10.000027Z

@raymcdermott uploaded a file: https://clojurians.slack.com/files/U04V5V0V4/F8S54A4HF/-.clj

raymcdermott 2018-01-14T21:32:43.000030Z

but I don’t get that from lein run

lucasbradstreet 2018-01-14T21:33:06.000112Z

it might just be a timing thing, because it can’t tell whether the media driver was dead or had just been shut down recently.

raymcdermott 2018-01-14T21:35:01.000058Z

when I submit the job (plucked from the main fn) it all works

lucasbradstreet 2018-01-14T21:35:25.000089Z

And not if not?

lucasbradstreet 2018-01-14T21:35:40.000053Z

this is the session window example, right?

raymcdermott 2018-01-14T21:35:44.000077Z

yes

lucasbradstreet 2018-01-14T21:35:55.000057Z

k, lemme try

raymcdermott 2018-01-14T21:36:08.000119Z

I mean it all still works regardless of the aeron error / warning

lucasbradstreet 2018-01-14T21:36:22.000100Z

Ah

lucasbradstreet 2018-01-14T21:36:40.000053Z

it’s probably just not shutting things down afterwards, since the shutdowns are in the main entry point

lucasbradstreet 2018-01-14T21:37:00.000054Z

but there are none in the repl eval sections

raymcdermott 2018-01-14T21:37:07.000045Z

i executed them manually … I can try again from the top

raymcdermott 2018-01-14T21:38:47.000016Z

yeah when I reload after doing the shutdown manually, no warnings

lucasbradstreet 2018-01-14T21:39:30.000003Z

Cool, it’s just stale state then. If you can think of a better way to keep the repl bits while also cleaning up the state, I’m all ears

lucasbradstreet 2018-01-14T21:39:34.000083Z

This is certainly non-ideal

lucasbradstreet 2018-01-14T21:40:12.000068Z

Maybe I could add a (comment) wrapping things and some helpers to start up, and do the final shutdown. It’s really easy to get into a state where you have to reload the repl

lucasbradstreet 2018-01-14T21:40:21.000016Z

That’s why I prefer tests for general dev

raymcdermott 2018-01-14T21:41:06.000049Z

sure I’m just trying to get my hands dirty for the first time with Onyx in anger tbh

lucasbradstreet 2018-01-14T21:41:34.000126Z

🙂

raymcdermott 2018-01-14T21:43:40.000027Z

thanks @lucasbradstreet also for Onyx 🙂

lucasbradstreet 2018-01-14T21:44:39.000079Z

Of course 🙂

raymcdermott 2018-01-14T21:45:59.000039Z

one other question while I’m here

lucasbradstreet 2018-01-14T21:46:11.000121Z

sure

raymcdermott 2018-01-14T21:46:25.000053Z

one of our goals is to dump data to mongodb at the end of each session window

raymcdermott 2018-01-14T21:46:37.000018Z

I guess that is done via the trigger fn?

lucasbradstreet 2018-01-14T21:47:20.000057Z

you can do it with trigger/sync, or you can use trigger/emit to emit the window contents to a downstream task (which you could write a simple mongo output plugin for)

lucasbradstreet 2018-01-14T21:47:36.000056Z

output plugins are pretty easy to write

raymcdermott 2018-01-14T21:47:55.000044Z

ah, that sounds cool …. are there some examples?

lucasbradstreet 2018-01-14T21:48:19.000026Z

I’ve been meaning to fix up the onyx-plugin template.

raymcdermott 2018-01-14T21:48:40.000013Z

please let me give you work 😉

lucasbradstreet 2018-01-14T21:48:54.000094Z

Ha, too much to do 😛

raymcdermott 2018-01-14T21:49:15.000077Z

I guess it’s a protocol?

lucasbradstreet 2018-01-14T21:50:11.000142Z

It is. Everything below this line is an SQL output plugin https://github.com/onyx-platform/onyx-sql/blob/0.12.x/src/onyx/plugin/sql.clj#L187

raymcdermott 2018-01-14T21:52:01.000106Z

sweet, I think I can do one of those for mongodb using monger …

lucasbradstreet 2018-01-14T21:52:08.000097Z

yea, shouldn’t be too hard.

raymcdermott 2018-01-14T21:52:17.000113Z

I might need to come back for the wiring

lucasbradstreet 2018-01-14T21:52:23.000010Z

sure, any questions let me know.

raymcdermott 2018-01-14T21:52:27.000147Z

thanks man

raymcdermott 2018-01-14T21:58:08.000025Z

sorry to come back so soon 🙂

raymcdermott 2018-01-14T21:58:27.000079Z

looking in more detail at the sql plugin, it’s all about outputting segments

raymcdermott 2018-01-14T21:59:46.000024Z

but I want to transform the data into a pre-defined JSON doc format

raymcdermott 2018-01-14T22:00:03.000118Z

so it’s not a 1:1 case

raymcdermott 2018-01-14T22:00:36.000095Z

if I have 10 segments I only want to output 1 doc, summarising the data

lucasbradstreet 2018-01-14T22:04:13.000061Z

Well, you can:

lucasbradstreet 2018-01-14T22:04:15.000004Z

1. transform the state in your trigger/emit function before you send it downstream

lucasbradstreet 2018-01-14T22:04:48.000002Z

2. alternatively or additionally batch your outputs via the output plugin (this is mostly for perf optimisation, as you have no guarantees about which segments will batch together)

lucasbradstreet 2018-01-14T22:04:52.000079Z

I’m guessing you want 1

raymcdermott 2018-01-14T22:05:16.000078Z

seem like 1 is the most appropriate in this case

raymcdermott 2018-01-14T22:05:37.000051Z

of course mongo is easier than sql

raymcdermott 2018-01-14T22:05:43.000071Z

as there is no schema

lucasbradstreet 2018-01-14T22:05:47.000055Z

you just need to use the right aggregation for your window

lucasbradstreet 2018-01-14T22:06:04.000042Z

You could either collect via something like conj and transform in trigger/emit, or you can build your document incrementally with your own aggregation

lucasbradstreet 2018-01-14T22:06:17.000105Z

just beware that with sessions you will need to merge sessions together too

raymcdermott 2018-01-14T22:07:36.000013Z

I think conj + transform is simpler

raymcdermott 2018-01-14T22:07:51.000139Z

how do I merge the sessions?

lucasbradstreet 2018-01-14T22:19:43.000066Z

The conj aggregation will do it for you. It’s just a function that the aggregation has to define

raymcdermott 2018-01-14T22:21:39.000053Z

oh sorry, I thought you meant I had extra work to do

raymcdermott 2018-01-14T22:22:05.000023Z

[ I could not see anything in the merge tests ]

lucasbradstreet 2018-01-14T22:22:07.000068Z

Not unless you want to merge it as you go

lucasbradstreet 2018-01-14T22:22:18.000080Z

With some different logic

raymcdermott 2018-01-14T22:22:55.000016Z

ah ok, I see … in that case you need to merge with the existing session state?

lucasbradstreet 2018-01-14T22:23:18.000069Z

Yeah, when two sessions combine, it’ll merge the two states

raymcdermott 2018-01-14T22:24:01.000018Z

ok, so you can either conj or have some merge function that is executed when one or more segments are added

raymcdermott 2018-01-14T22:25:03.000077Z

in my case I think just using conj and then doing the transform at the session boundary is more straightforward

lucasbradstreet 2018-01-14T22:25:18.000011Z

Agree, since it’s less work

raymcdermott 2018-01-14T22:25:55.000051Z

ok, I think I’ve got it … so I’ll leave you to enjoy Sunday 🙂

raymcdermott 2018-01-14T22:26:04.000094Z

also I have to sleep !

raymcdermott 2018-01-14T22:26:21.000047Z

and I can sleep soundly now