Closed EasonLiao closed 10 years ago
sounds good. what's the signature of the takesnapshot method? it needs to notify the caller when snapshot completes, either though a callback or by returning a future and letting the caller add listeners.
I feel we don't need future and callbacks. Since we'll take snapshot via callbacks, so user will know when snapshot gets complete.
ok that's a fair point. how do you communicate errors back to the caller? how about snapshot file names? maybe the caller wants to know where the snapshot has been saved.
My understanding is that user shouldn't care about where the file is stored, Jzab will manage the files for user. Or we can make the takeSnapshot blocking until the snapshot is completed, like goraft. What do you think?
i think you know what i'm going to say, but no, we shouldn't make it blocking.
the caller might want to know what the snapshot filename is, maybe to make a backup or something. anyways, the key point i want to make is that the snapshot call should be non-blocking, and there should be a way to communicate the result back to the caller.
how about adding another callback like snapshotSaved
and pass the file name and exception back to application?
how do we handle Zab.remove()? does the caller get notified when it gets removed from the cluster?
Yes, before it gets shut down it will get notified.
@m1ch1
is this patch ready to be checked in?
one request: i prefer having a single commit per pull request unless commits are trivial. otherwise i end up reviewing all the commits multiple times until they get merged even when some of them are not updated.
you can check in this patch, I guess the associating the context object with the request I'll address all of them in another commit.
Sorry for the multiple commits per PR problem, I'll do it in the way you suggested.
Like goraft, let user decides when to take snapshot, user just call
Zab.takeSnapshot
and Zab is responsible callingsave
callback. User just decides the timing of taking snapshot, Zab still manages the snapshot file for them.The benefit is there's more flexibility for application, some application might have specific preference of when to take snapshot.