Pergunta

Instances of Apache Curator's CuratorFramework class allow mutation operations to be run inTransaction(). I'm currently using these calls, but can't figure out how to commit them.

Looking at the CuratorTransaction JavaDoc, it clearly states:

Important:
     the operations are not submitted until CuratorTransactionFinal.commit() is called.

However, CuratorTransactionFinal is an interface with no implementing classes (that I can find).

Am I expected to implement it and define the functionality of commit()?
Or am I missing some larger concept?

Foi útil?

Solução

Found it in the source code:

Assuming your instance of CuratorFramework is called "client".

if you perform an operation like...

client.create().forPath("/foo");

...it is not transactional. If you perform...

client.inTransaction().create.forPath("/foo");

...it is, but the operation will not actually be completed until you commit the transaction. This much I already knew. To commit the transaction, you do:

client.inTransaction().create().forPath("/foo")
    .and().create().forPath("/bar")
    .and().commit();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top