@Override public OLocalRecordCache getLocalCache() { checkOpenness(); return internal.getLocalCache(); }
/** * Updates the record cache after unsuccessful micro-transaction commit. */ public void updateRecordCacheAfterRollback() { final OLocalRecordCache databaseLocalCache = database.getLocalCache(); for (ORecordOperation recordOperation : recordOperations.values()) databaseLocalCache.deleteRecord(recordOperation.getRecord().getIdentity()); }
public void internalRollback() { status = TXSTATUS.ROLLBACKING; // CLEAR THE CACHE database.getLocalCache().clear(); // REMOVE ALL THE DIRTY ENTRIES AND UNDO ANY DIRTY DOCUMENT IF POSSIBLE. for (ORecordOperation v : allEntries.values()) { final ORecord rec = v.getRecord(); rec.unload(); } close(); status = TXSTATUS.ROLLED_BACK; }
private void deleteCluster(final ODatabaseDocumentInternal db, final int clusterId) { db.getStorage().dropCluster(clusterId, false); db.getLocalCache().freeCluster(clusterId); }
public void bindToCache(ODatabaseDocumentInternal db) { if (isRecord()) { ORecord rec = element.getRecord(); ORecord cached = db.getLocalCache().findRecord(rec.getIdentity()); if (cached != null) { if (!cached.isDirty()) { cached.fromStream(rec.toStream()); } element = cached; } else { db.getLocalCache().updateRecord(rec); } } } }
protected boolean pushResult(final Object rec) { if (rec instanceof ORecord) { final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) db.getLocalCache().updateRecord((ORecord) rec); } return request.getResultListener().result(rec); }
@ConsoleCommand(splitInWords = false, description = "Delete records from the database", onlineHelp = "SQL-Delete") public void delete(@ConsoleParameter(name = "command-text", description = "The command text to execute") String iCommandText) { sqlCommand("delete", iCommandText, "\nDelete record(s) '%s' in %f sec(s).\n", true); updateDatabaseInfo(); currentDatabase.getLocalCache().invalidate(); }
@ConsoleCommand(splitInWords = false, description = "Update records in the database", onlineHelp = "SQL-Update") public void update(@ConsoleParameter(name = "command-text", description = "The command text to execute") String iCommandText) { sqlCommand("update", iCommandText, "\nUpdated record(s) '%s' in %f sec(s).\n", true); updateDatabaseInfo(); currentDatabase.getLocalCache().invalidate(); }
private void doRollback() { storage.rollback(this); database.getLocalCache().clear(); for (ORecordOperation recordOperation : recordOperations.values()) { final ORecord record = recordOperation.record.getRecord(); if (record.isDirty()) if (record instanceof ODocument) { final ODocument document = (ODocument) record; if (document.isTrackingChanges()) document.undo(); } else record.unload(); } reset(); }
ODatabaseRecordThreadLocal.instance().get().getLocalCache().invalidate(); ODatabaseRecordThreadLocal.instance().get().getLocalCache().invalidate();
database.getLocalCache().freeCluster(cls.getDefaultClusterId());
/** * Execute the command. */ public Object execute(final Map<Object, Object> iArgs) { if (records.isEmpty()) throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); int deleted = 0; final ODatabaseDocumentInternal database = getDatabase(); for (String rec : records) { try { final ORecordId rid = new ORecordId(rec); final OStorageOperationResult<Boolean> result = database.getStorage().deleteRecord(rid, -1, 0, null); database.getLocalCache().deleteRecord(rid); if (result.getResult()) deleted++; } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException("Error on executing command"), e); } } return deleted; }
getDatabase().getLocalCache().clear(); if (retry >= maxRetry) throw e; getDatabase().getLocalCache().clear(); if (retry >= maxRetry) throw e; getDatabase().getLocalCache().clear(); if (retry >= maxRetry) throw e; getDatabase().getLocalCache().clear(); if (retry >= maxRetry) throw e;
public static void updateCacheFromEntries(final ODatabaseDocumentInternal database, final Iterable<? extends ORecordOperation> entries, final boolean updateStrategy) { final OLocalRecordCache dbCache = database.getLocalCache(); for (ORecordOperation txEntry : entries) { if (!updateStrategy) // ALWAYS REMOVE THE RECORD FROM CACHE dbCache.deleteRecord(txEntry.getRecord().getIdentity()); else if (txEntry.type == ORecordOperation.DELETED) // DELETION dbCache.deleteRecord(txEntry.getRecord().getIdentity()); else if (txEntry.type == ORecordOperation.UPDATED || txEntry.type == ORecordOperation.CREATED) // UDPATE OR CREATE dbCache.updateRecord(txEntry.getRecord()); } }
@Override public OResultSet executeSimple(OCommandContext ctx) { List<ORid> recs = new ArrayList<>(); if (record != null) { recs.add(record); } else { recs.addAll(records); } OInternalResultSet rs = new OInternalResultSet(); final ODatabaseDocumentInternal database = (ODatabaseDocumentInternal) ctx.getDatabase(); for (ORid rec : recs) { try { final ORecordId rid = rec.toRecordId((OResult) null, ctx); final OStorageOperationResult<Boolean> result = database.getStorage().deleteRecord(rid, -1, 0, null); database.getLocalCache().deleteRecord(rid); if (result.getResult()) { OResultInternal recordRes = new OResultInternal(); recordRes.setProperty("operation", "truncate record"); recordRes.setProperty("record", rec.toString()); rs.add(recordRes); } } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException("Error on executing command"), e); } } return rs; }
/** * Deletes the record. */ public void deleteRecord(final ORecord iRecord, final OPERATION_MODE iMode) { if (!iRecord.getIdentity().isPersistent()) return; try { database.executeDeleteRecord(iRecord, iRecord.getVersion(), true, iMode, false); } catch (Exception e) { // REMOVE IT FROM THE CACHE TO AVOID DIRTY RECORDS final ORecordId rid = (ORecordId) iRecord.getIdentity(); if (rid.isValid()) database.getLocalCache().freeRecord(rid); if (e instanceof RuntimeException) throw (RuntimeException) e; throw OException.wrapException( new ODatabaseException("Error during deletion of record" + (iRecord != null ? " with rid " + iRecord.getIdentity() : "")), e); } }
database.getLocalCache().freeRecord(rid);