Replicas of objects have the same object id as the objects they are replicas of. On every node, exactly one of the following statements is true for object of given object id:
The object is local.
The object is remote and its replica exists on the node.
Neither the object itself nor its replica exists on the node. The object is either remote or does not exist at all.
As described in Chapter 5, Pointers, objects pointed to by a strong pointer are always local. However, weak pointer may reference a remote object. If the object is remote, and its replica exists on local node, weak pointer can be used as if the object was local, and it will access the replica instead of the object.
The following example shows how to determine whether an object is local, replica of the object is local, or the object is remote. Moreover, if a replica of the object exists, it determines whether it is consistent or not (the replica consistency is described in Section 7.7, “Consistency of Replication Groups”):
WeakPointer< Object > foo = ...; if( foo.is_local() ) { if( foo->is_replica() ) { if( foo->is_consistent() ) { /* Consistent replica of foo is local. */ } else { /* Inconsistent replica of foo is local. */ } } else { /* foo is a local object. */ } } else { /* foo is a remote object, or does not exist at all. */ } |
The Core restricts operations on replicas; especially it's illegal to modify properties of replicas. For complete list of allowed and illegal operations, refer to Section 7.10, “Allowed and Illegal Operations”