how to determine if tailers or appenders chronicle was closed?

61 views
Skip to first unread message

Vachagan Balayan

unread,
Dec 28, 2015, 3:36:49 AM12/28/15
to Chronicle
I have some objects who keep reference to tailer or appender of a chronicle and use them for streaming/appending data trough observables,
and if for some reason someone closed the chronicle and these observables are still looping over the queue and stream it i want them to quit early, 
so i need to determine using tailer or appender if their chronicle was close() -ed. But cant find api for that. Any help?

Vachagan Balayan

unread,
Dec 28, 2015, 3:40:31 AM12/28/15
to Chronicle
or catching IllegalStateException is expected?

Peter Lawrey

unread,
Dec 28, 2015, 3:58:18 AM12/28/15
to java-ch...@googlegroups.com

It is not expected that you will still be reading a chronicle when it is forceably closed by another thread. A thread should really close it's own chronicle or not close it all except perhaps for unit tests. Why are you closing the chronicle unless it's for testing?

On 28 Dec 2015 8:40 am, "Vachagan Balayan" <vachagan...@gmail.com> wrote:
or catching IllegalStateException is expected?

--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luca Burgazzoli

unread,
Dec 28, 2015, 4:23:40 AM12/28/15
to java-ch...@googlegroups.com
In addition to what Peter said, you can know if a chronicle is closed from an excerpt via:

    excerpt.chronicle().isClosed()

But that won't help to detect if chronicle is closed in the middle of a red/write operation and in such case the application may crash so the best would be to have multiple chronicles or implement your own shutdown orchestration.




Vachagan Balayan

unread,
Dec 28, 2015, 6:07:19 AM12/28/15
to Chronicle
Luca in package net.openhft.chronicle.Chronicle interface there is no method isClosed() (intellij wont show anything), maybe you refer to alpha version?

Peter here is my use case, as i can have multiple readers and single writer for indexed chronicle, i expose this functionality wrapped in a closable object,
so i may have one chronicle instantiated and N wrapped readers in different threads, and when the source chronicle is closed, i want to be able to determine that in readers which keep reading and publishing data trough Observable... so the source chronicle may be closed without the readers being aware of it, and when its close()-ed its not onError() but onComplete() (expected termination for me)...

so the question goes down to how do i find out if chronicle closed before i do reader.nextIndex() ?
currently i wrap the expression and check for error message like this :

if (cause.getMessage().equals(chronicle.name() + " is closed")){
  // everything is fine we just finished sooner than expected 
}

when i used this i tought thats fine, cos this is indeed exceptional case...
but i hoped for an api.

I guess the next version has it. 

Luca Burgazzoli

unread,
Dec 28, 2015, 6:16:55 AM12/28/15
to java-ch...@googlegroups.com
Looks like isClosed is not yet in Chronicle v3 release, you should find it in 3.6.0-SNAPSHOT

--

Vachagan Balayan

unread,
Dec 28, 2015, 6:49:29 AM12/28/15
to Chronicle
Do i misuse something? Is it fine to have the same chronicle instantiated for each thread? my current impression about it is that i must hold one instance of chronicle per application... and create instances of readers and writers etc...

Also could you please give approximation of how expensive are those to create? for example creating chronicle vs instantiating reader/writer etc...

jaisins

unread,
Jan 5, 2016, 2:39:04 PM1/5/16
to Chronicle
Hi,

I have a similar use case- instantiating a single chronicle in an application, with one writer thread, and another reader thread.
I am trying to use it as a "Queue", ie writer writes sequentially, and reader processes in the same order, both with varying speeds.
I was able to access the same Chronicle if I build as vanilla queue, but having trouble doing a sanity check, if indeed the appenders and tailers in different writer and reader threads are reading sequentially.
If I use IndexedQueue, the writer(appender) is incrementing the index sequentially, but the tailer in reader thread never even gets to a valid nextIndex().
Which of the two queue types is better to use in this case?

Luca Burgazzoli

unread,
Jan 5, 2016, 3:14:17 PM1/5/16
to java-ch...@googlegroups.com
Both may be ok, could you please open a github issue with a test case showing the issue?
--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
lb
Reply all
Reply to author
Forward
0 new messages