Yeah it is the same code,

locks are held across the cluster.

An explicit locking API will make it in one of the future versions of Neo4j, it 
has not been decided when that will happen.

Cheers

Michael

Am 07.08.2011 um 19:20 schrieb etc1:

> I see, that makes sense, ty
> Does this code work the same for embedded single node and cluster high
> availability graph db's?
> 
> 
> 
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Michael Hunger
> Sent: Sunday, August 07, 2011 1:04 PM
> To: Neo4j user discussions
> Subject: Re: [Neo4j] Unique Constaint on Index
> 
> Just from my head.
> 
> tx = graphdb.beginTransaction();
> try {
>  Node lockNode = graphdb.getReferenceNode(); // or another node that is
> used for locking this unique index
>  lockNode.removeProperty("__non_existent_property__");
> 
>  index=graphdb.index().forNodes("unique-name");
> 
>  Node user = index.get("name",name).getSingle();
>  if (user==null) {
>     user=graphdb.createNode();
>     user.setProperty("name",name);
>     index.add(user,"name",name);
>  }
>  tx.success();
> } finally {
>  tx.finish();
> }
> 
> Am 07.08.2011 um 17:40 schrieb etc1:
> 
>> Not sure I understand this:
>> A consistent, but hackish, attempt to acquire a cluster-wide lock is 
>> to remove a non-existent node; what does this mean, exactly; code sample?
>> 
>> 
>> -----Original Message-----
>> From: [email protected] 
>> [mailto:[email protected]] On Behalf Of etc3
>> Sent: Thursday, July 07, 2011 11:49 AM
>> To: 'Neo4j user discussions'
>> Subject: Re: [Neo4j] Unique Constaint on Index
>> 
>> I'm new to this framework, is there an example that demonstrates 
>> removing a non-existent property and how it would be used in this context?
>> 
>> Thanks
>> 
>> -----Original Message-----
>> From: [email protected] 
>> [mailto:[email protected]] On Behalf Of Chris Gioran
>> Sent: Thursday, July 07, 2011 11:04 AM
>> To: Neo4j user discussions
>> Subject: Re: [Neo4j] Unique Constaint on Index
>> 
>> Hi,
>> 
>> the ability to acquire locks cluster-wide exists, albeit in an ad hoc 
>> fashion. Grabbing a write lock on the node you want to ensure is 
>> uniquely indexed will ensure that the operations are serialized across 
>> all cluster members.
>> The most simple way to get that lock currently is the (somewhat 
>> hackish but entirely correct) removal of a non-existing property.
>> 
>> cheers,
>> CG
>> 
>> On Thu, Jul 7, 2011 at 5:53 PM, etc3 <[email protected]> wrote:
>>> How do I ensure another request is not performing the same operation 
>>> on another node in the cluster?
>>> 
>>> 
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Marko Rodriguez
>>> Sent: Thursday, July 07, 2011 10:35 AM
>>> To: Neo4j user discussions
>>> Subject: Re: [Neo4j] Unique Constaint on Index
>>> 
>>> Hi,
>>> 
>>>> We are testing Neo4J and need to support unique emails across all 
>>>> users. Is this possible with the current API?
>>> 
>>> You can add such a constraint when updating the indices:
>>> 
>>> if(index.get('email', address).hasNext()) {  throw new 
>>> RuntimeException("There are two nodes that share the same email 
>>> address."); } else {  index.put('email', address, node); }
>>> 
>>> Marko.
>>> 
>>> http://markorodriguez.com
>>> _______________________________________________
>>> Neo4j mailing list
>>> [email protected]
>>> https://lists.neo4j.org/mailman/listinfo/user
>>> 
>>> _______________________________________________
>>> Neo4j mailing list
>>> [email protected]
>>> https://lists.neo4j.org/mailman/listinfo/user
>>> 
>> _______________________________________________
>> Neo4j mailing list
>> [email protected]
>> https://lists.neo4j.org/mailman/listinfo/user
>> 
>> _______________________________________________
>> Neo4j mailing list
>> [email protected]
>> https://lists.neo4j.org/mailman/listinfo/user
>> 
>> _______________________________________________
>> Neo4j mailing list
>> [email protected]
>> https://lists.neo4j.org/mailman/listinfo/user
> 
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
> 
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user

_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to