2.2.5. Object Models

TxCore supports two models for objects, which as we shall show affect how an objects state and concurrency control are implemented:
  • SINGLE: only a single copy of the object exists within the application; this will reside within a single JVM, and all clients must address their invocations to this server. This model provides better performance, but represents a single point of failure, and in a multi-threaded environment may not protect the object from corruption if a single thread fails.
    Figure 3: Single Object Model
  • MULTIPLE: logically a single instance of the object exists, but copies of it are distributed across different JVMs; the performance of this model is worse than the SINGLE model, but it provides better failure isolation.
    Figure 4: Multiple Object Model
The default model is SINGLE. The programmer can override this on a per object basis by providing an appropriate instance of the com.arjuna.ats.arjuna.gandiva.ObjectName class at object construction.

Note

The model can be changed between each successive instantiation of the object, i.e., it need not be the same during the object's lifetime.
To provide a suitable ObjectName class, it is necessary to perform the following steps:
  • create a new instance of ObjectName.
  • set the object model attribute using the com.arjuna.ats.arjuna.ArjunaNames.StateManager_objectModel() name.
For example:
{
    ObjectName attr = new ObjectName(“SNS:myObjectName”);
    
    attr.setLongAttribute(ArjunaNames.StateManager_objectModel(),
    ObjectModel.SINGLE);
    
    AtomicObject obj = new AtomicObject(ObjectType.ANDPERSISTENT, attr);
                }