Search in sources :

Example 1 with OTransactionAbstract

use of com.orientechnologies.orient.core.tx.OTransactionAbstract in project orientdb by orientechnologies.

the class ODistributedTransactionManager method checkForClusterIds.

protected void checkForClusterIds(final OTransaction iTx, final String localNodeName, final ODistributedConfiguration dbCfg) {
    for (ORecordOperation op : iTx.getAllRecordEntries()) {
        final ORecordId rid = (ORecordId) op.getRecord().getIdentity();
        switch(op.type) {
            case ORecordOperation.CREATED:
                final ORecordId newRid = rid.copy();
                if (rid.getClusterId() < 1) {
                    final String clusterName = ((OTransactionAbstract) iTx).getClusterName(op.getRecord());
                    if (clusterName != null) {
                        newRid.setClusterId(ODatabaseRecordThreadLocal.INSTANCE.get().getClusterIdByName(clusterName));
                        iTx.updateIdentityAfterCommit(rid, newRid);
                    }
                }
                if (storage.checkForCluster(op.getRecord(), localNodeName, dbCfg) != null)
                    iTx.updateIdentityAfterCommit(rid, newRid);
                break;
        }
    }
}
Also used : OTransactionAbstract(com.orientechnologies.orient.core.tx.OTransactionAbstract) ORecordOperation(com.orientechnologies.orient.core.db.record.ORecordOperation) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Aggregations

ORecordOperation (com.orientechnologies.orient.core.db.record.ORecordOperation)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1 OTransactionAbstract (com.orientechnologies.orient.core.tx.OTransactionAbstract)1