diff --git a/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeBonsaiRemote.java b/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeBonsaiRemote.java old mode 100644 new mode 100755 index 6eabb9b180b..8b42e073247 --- a/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeBonsaiRemote.java +++ b/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeBonsaiRemote.java @@ -72,7 +72,7 @@ public OBonsaiCollectionPointer getCollectionPointer() { @Override public V get(K key) { - final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying(); + final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying(); final byte[] keyStream = new byte[keySerializer.getObjectSize(key)]; keySerializer.serialize(key, keyStream, 0); @@ -168,7 +168,7 @@ private boolean pushEntriesToListener(RangeResultListener listener, List> fetchEntriesMajor(final K key,final boolean inclusive) { final byte[] keyStream = new byte[keySerializer.getObjectSize(key)]; keySerializer.serialize(key, keyStream, 0); - final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying(); + final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying(); return storage.networkOperation(new OStorageRemoteOperation>>() { @Override public List> execute(final OChannelBinaryAsynchClient client, OStorageRemoteSession session) throws IOException { @@ -215,7 +215,7 @@ public Collection getValuesBetween(K keyFrom, boolean fromInclusive, K keyTo, @Override public K firstKey() { - final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying(); + final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying(); return storage.networkOperation(new OStorageRemoteOperation() { @Override public K execute(final OChannelBinaryAsynchClient client, OStorageRemoteSession session) throws IOException { @@ -251,7 +251,7 @@ public void loadEntriesBetween(K keyFrom, boolean fromInclusive, K keyTo, boolea @Override public int getRealBagSize(final Map changes) { - final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying(); + final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying(); return storage.networkOperation(new OStorageRemoteOperation() { @Override public Integer execute(OChannelBinaryAsynchClient client, OStorageRemoteSession session) throws IOException { diff --git a/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemote.java b/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemote.java index b58f5ad6d39..145787b00bb 100755 --- a/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemote.java +++ b/client/src/main/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemote.java @@ -76,7 +76,7 @@ public void onStartup() { @Override protected OSBTreeBonsaiRemote createTree(final int clusterId) { if (remoteCreationAllowed) { - final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying(); + final OStorageRemote storage = (OStorageRemote) ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying(); return storage.networkOperation(new OStorageRemoteOperation>() { @Override public OSBTreeBonsaiRemote execute(final OChannelBinaryAsynchClient client, diff --git a/client/src/main/java/com/orientechnologies/orient/client/remote/OServerAdmin.java b/client/src/main/java/com/orientechnologies/orient/client/remote/OServerAdmin.java index 9af102cb591..2d6a4d19306 100755 --- a/client/src/main/java/com/orientechnologies/orient/client/remote/OServerAdmin.java +++ b/client/src/main/java/com/orientechnologies/orient/client/remote/OServerAdmin.java @@ -378,7 +378,7 @@ public Boolean execute(final OChannelBinaryAsynchClient network, OStorageRemoteS s.close(true, true); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); return this; } diff --git a/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java b/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java index b537d5625d8..0816120cf33 100755 --- a/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java +++ b/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java @@ -541,7 +541,7 @@ public Set getClusterNames() { public OStorageOperationResult createRecord(final ORecordId iRid, final byte[] iContent, final int iRecordVersion, final byte iRecordType, final int iMode, final ORecordCallback iCallback) { - final OSBTreeCollectionManager collectionManager = ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager(); + final OSBTreeCollectionManager collectionManager = ODatabaseRecordThreadLocal.instance().get().getSbTreeCollectionManager(); ORecordCallback realCallback = null; if (iCallback != null) { realCallback = new ORecordCallback() { @@ -663,7 +663,7 @@ public OStorageOperationResult execute(OChannelBinaryAsynchClient ne byte[] bytes = network.readBytes(); ORawBuffer buffer = new ORawBuffer(bytes, recVersion, type); - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().getIfDefined(); ORecord record; while (network.readByte() == 2) { @@ -722,7 +722,7 @@ public OStorageOperationResult execute(OChannelBinaryAsynchClient ne buffer = new ORawBuffer(bytes, recVersion, type); } - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().getIfDefined(); ORecord record; while (network.readByte() == 2) { record = (ORecord) OChannelBinaryProtocol.readIdentifiable(network); @@ -772,7 +772,7 @@ public void restoreFromIncrementalBackup(final String filePath) { public OStorageOperationResult updateRecord(final ORecordId iRid, final boolean updateContent, final byte[] iContent, final int iVersion, final byte iRecordType, final int iMode, final ORecordCallback iCallback) { - final OSBTreeCollectionManager collectionManager = ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager(); + final OSBTreeCollectionManager collectionManager = ODatabaseRecordThreadLocal.instance().get().getSbTreeCollectionManager(); Integer resVersion = asyncNetworkOperation(new OStorageRemoteOperationWrite() { @Override @@ -1175,7 +1175,7 @@ public Object command(final OCommandRequestText iCommand) { if (!(iCommand instanceof OSerializableStream)) throw new OCommandExecutionException("Cannot serialize the command to be executed to the server side."); final boolean live = iCommand instanceof OLiveQuery; - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().get(); return networkOperation(new OStorageRemoteOperation() { @Override @@ -1245,7 +1245,7 @@ public Object execute(final OChannelBinaryAsynchClient network, OStorageRemoteSe OStorageRemote.this.asynchEventListener.unregisterLiveListener(token); } else { final OLiveResultListener listener = (OLiveResultListener) iCommand.getResultListener(); - ODatabaseDocumentInternal current = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal current = ODatabaseRecordThreadLocal.instance().get(); final ODatabaseDocument dbCopy = current.copy(); ORemoteConnectionPool pool = OStorageRemote.this.connectionManager.getPool(network.getServerURL()); OStorageRemote.this.asynchEventListener.registerLiveListener(pool, token, new OLiveResultListener() { @@ -1432,7 +1432,7 @@ public Void execute(OChannelBinaryAsynchClient network, OStorageRemoteSession se updatedRecordsMap.clear(); if (collectionChanges != null) - updateCollection(collectionChanges, ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager()); + updateCollection(collectionChanges, ODatabaseRecordThreadLocal.instance().get().getSbTreeCollectionManager()); } finally { endResponse(network); @@ -2557,7 +2557,7 @@ public Object call() throws Exception { } protected OStorageRemoteSession getCurrentSession() { - final ODatabaseDocumentTx db = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentTx db = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db == null) return null; OStorageRemoteSession session = (OStorageRemoteSession) ODatabaseDocumentTxInternal.getSessionMetadata(db); @@ -2581,7 +2581,7 @@ public boolean isClosed() { @Override public OStorageRemote copy(final ODatabaseDocumentTx source, final ODatabaseDocumentTx dest) { - ODatabaseDocumentInternal origin = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal origin = ODatabaseRecordThreadLocal.instance().getIfDefined(); final OStorageRemoteSession session = (OStorageRemoteSession) ODatabaseDocumentTxInternal.getSessionMetadata(source); if (session != null) { @@ -2597,7 +2597,7 @@ public OStorageRemote copy(final ODatabaseDocumentTx source, final ODatabaseDocu } catch (IOException e) { OLogManager.instance().error(this, "Can not open remote database", e); } finally { - ODatabaseRecordThreadLocal.INSTANCE.set(origin); + ODatabaseRecordThreadLocal.instance().set(origin); } return this; } diff --git a/client/src/test/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemoteTest.java b/client/src/test/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemoteTest.java old mode 100644 new mode 100755 index 99aff696000..ded0f975334 --- a/client/src/test/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemoteTest.java +++ b/client/src/test/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemoteTest.java @@ -46,7 +46,7 @@ public void setUp() throws Exception { @Test(enabled = false) public void testCreateTree() throws Exception { OSBTreeCollectionManagerRemote remoteManager = new OSBTreeCollectionManagerRemote(storageMock, networkSerializerMock); - ODatabaseRecordThreadLocal.INSTANCE.set(dbMock); + ODatabaseRecordThreadLocal.instance().set(dbMock); when(dbMock.getStorage()).thenReturn(storageMock); when(storageMock.getUnderlying()).thenReturn(storageMock); diff --git a/core/pom.xml b/core/pom.xml index 14380016d4c..a1c7320e44d 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -39,6 +39,8 @@ com.sun.jna;resolution:=optional, org.xerial.snappy;resolution:=optional, sun.nio.ch;resolution:=optional, + com.orientechnologies.orient.server.distributed.impl;resolution:=optional, + com.orientechnologies.orient.server.distributed.impl.task;resolution:=optional, * com.orientechnologies.orient.core.*, diff --git a/core/src/main/java/com/orientechnologies/common/log/OLogManager.java b/core/src/main/java/com/orientechnologies/common/log/OLogManager.java index 93033c5f529..86004d3fd8b 100755 --- a/core/src/main/java/com/orientechnologies/common/log/OLogManager.java +++ b/core/src/main/java/com/orientechnologies/common/log/OLogManager.java @@ -97,7 +97,7 @@ public void log(final Object iRequester, final Level iLevel, String iMessage, fi if (iMessage != null) { try { final ODatabaseDocumentInternal db = - ODatabaseRecordThreadLocal.INSTANCE != null ? ODatabaseRecordThreadLocal.INSTANCE.getIfDefined() : null; + ODatabaseRecordThreadLocal.instance() != null ? ODatabaseRecordThreadLocal.instance().getIfDefined() : null; if (db != null && db.getStorage() != null && db.getStorage() instanceof OAbstractPaginatedStorage) { final String dbName = db.getStorage().getName(); if (dbName != null) diff --git a/core/src/main/java/com/orientechnologies/orient/core/cache/OLocalRecordCache.java b/core/src/main/java/com/orientechnologies/orient/core/cache/OLocalRecordCache.java index fc579b39526..165b15c454d 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/cache/OLocalRecordCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/cache/OLocalRecordCache.java @@ -43,7 +43,7 @@ public OLocalRecordCache() { @Override public void startup() { - ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); profilerPrefix = "db." + db.getName() + ".cache.level1."; profilerMetadataPrefix = "db.*.cache.level1."; diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandExecutorAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandExecutorAbstract.java old mode 100644 new mode 100755 index 92f1b9dd172..ae23c1b26a5 --- a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandExecutorAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandExecutorAbstract.java @@ -47,7 +47,7 @@ public abstract class OCommandExecutorAbstract extends OBaseParser implements OC protected OCommandContext context; public static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } public OCommandExecutorAbstract init(final OCommandRequestText iRequest) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java index 86a68a60762..87d9e51fb3a 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java @@ -66,7 +66,7 @@ public RET execute(final Object... iArgs) { OExecutionThreadLocal.INSTANCE.get().onAsyncReplicationOk = onAsyncReplicationOk; OExecutionThreadLocal.INSTANCE.get().onAsyncReplicationError = onAsyncReplicationError; - return (RET) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().command(this); + return (RET) ODatabaseRecordThreadLocal.instance().get().getStorage().command(this); } public String getText() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/ODocumentEqualityWrapper.java b/core/src/main/java/com/orientechnologies/orient/core/command/ODocumentEqualityWrapper.java old mode 100644 new mode 100755 index d8484614bdb..d35dd54949a --- a/core/src/main/java/com/orientechnologies/orient/core/command/ODocumentEqualityWrapper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/ODocumentEqualityWrapper.java @@ -18,7 +18,7 @@ public class ODocumentEqualityWrapper { public boolean equals(Object obj) { if(obj instanceof ODocumentEqualityWrapper) { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); return ODocumentHelper.hasSameContentOf(internal, db, ((ODocumentEqualityWrapper)obj).internal, db, null); } return false; diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/script/OCommandExecutorFunction.java b/core/src/main/java/com/orientechnologies/orient/core/command/script/OCommandExecutorFunction.java index bb74bb6549c..8f17e27d100 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/command/script/OCommandExecutorFunction.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/script/OCommandExecutorFunction.java @@ -64,7 +64,7 @@ public Object executeInContext(final OCommandContext iContext, final Map iArgs) { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final OScriptManager scriptManager = Orient.instance().getScriptManager(); CompiledScript compiledScript = request.getCompiledScript(); @@ -223,7 +223,7 @@ protected Object executeJsr223Script(final String language, final OCommandContex // TODO: CREATE A REGULAR JSR223 SCRIPT IMPL protected Object executeSQL() { - ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { return executeSQLScript(parserText, db); diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/script/ODatabaseScriptManager.java b/core/src/main/java/com/orientechnologies/orient/core/command/script/ODatabaseScriptManager.java old mode 100644 new mode 100755 index 8b24e3c7b01..def18718e4b --- a/core/src/main/java/com/orientechnologies/orient/core/command/script/ODatabaseScriptManager.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/script/ODatabaseScriptManager.java @@ -49,7 +49,7 @@ public OPartitionedObjectPool.ObjectFactory create(final String la @Override public ScriptEngine create() { final ScriptEngine scriptEngine = scriptManager.getEngine(language); - final String library = scriptManager.getLibrary(ODatabaseRecordThreadLocal.INSTANCE.get(), language); + final String library = scriptManager.getLibrary(ODatabaseRecordThreadLocal.instance().get(), language); if (library != null) try { diff --git a/core/src/main/java/com/orientechnologies/orient/core/conflict/OContentRecordConflictStrategy.java b/core/src/main/java/com/orientechnologies/orient/core/conflict/OContentRecordConflictStrategy.java index b7ce7f0c4d2..2ad907ff093 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/conflict/OContentRecordConflictStrategy.java +++ b/core/src/main/java/com/orientechnologies/orient/core/conflict/OContentRecordConflictStrategy.java @@ -53,7 +53,7 @@ public byte[] onUpdate(OStorage storage, final byte iRecordType, final ORecordId final ODocument storedRecord = new ODocument(rid).fromStream(res.getResult().getBuffer()); final ODocument newRecord = new ODocument().fromStream(iRecordContent); - final ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.instance().get(); hasSameContent = ODocumentHelper.hasSameContentOf(storedRecord, currentDb, newRecord, currentDb, null, false); } else { // CHECK BYTE PER BYTE diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseRecordThreadLocal.java b/core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseRecordThreadLocal.java index d63d3a45cac..dba1781d9f9 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseRecordThreadLocal.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/ODatabaseRecordThreadLocal.java @@ -22,25 +22,38 @@ import com.orientechnologies.orient.core.OOrientListenerAbstract; import com.orientechnologies.orient.core.Orient; import com.orientechnologies.orient.core.exception.ODatabaseException; +import com.orientechnologies.orient.core.metadata.schema.OClass; + +import java.util.concurrent.atomic.AtomicReference; public class ODatabaseRecordThreadLocal extends ThreadLocal { - public static volatile ODatabaseRecordThreadLocal INSTANCE = new ODatabaseRecordThreadLocal(); + private static final AtomicReference INSTANCE = new AtomicReference(); - static { - final Orient inst = Orient.instance(); - inst.registerListener(new OOrientListenerAbstract() { - @Override - public void onStartup() { - if (INSTANCE == null) - INSTANCE = new ODatabaseRecordThreadLocal(); - } + public static ODatabaseRecordThreadLocal instance() { + final ODatabaseRecordThreadLocal dbInst = INSTANCE.get(); - @Override - public void onShutdown() { - INSTANCE = null; - } - }); + if (dbInst != null) + return dbInst; + + //we can do that to avoid thread local memory leaks in containers + if (INSTANCE.get() == null) { + final Orient inst = Orient.instance(); + inst.registerListener(new OOrientListenerAbstract() { + @Override + public void onStartup() { + } + + @Override + public void onShutdown() { + INSTANCE.set(null); + } + }); + + INSTANCE.compareAndSet(null, new ODatabaseRecordThreadLocal()); + + } + return INSTANCE.get(); } @Override @@ -49,12 +62,12 @@ public ODatabaseDocumentInternal get() { if (db == null) { if (Orient.instance().getDatabaseThreadFactory() == null) { throw new ODatabaseException( - "The database instance is not set in the current thread. Be sure to set it with: ODatabaseRecordThreadLocal.INSTANCE.set(db);"); + "The database instance is not set in the current thread. Be sure to set it with: ODatabaseRecordThreadLocal.instance().set(db);"); } else { db = Orient.instance().getDatabaseThreadFactory().getThreadDatabase(); if (db == null) { throw new ODatabaseException( - "The database instance is not set in the current thread. Be sure to set it with: ODatabaseRecordThreadLocal.INSTANCE.set(db);"); + "The database instance is not set in the current thread. Be sure to set it with: ODatabaseRecordThreadLocal.instance().set(db);"); } else { set(db); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/OPartitionedDatabasePool.java b/core/src/main/java/com/orientechnologies/orient/core/db/OPartitionedDatabasePool.java index 1345f2dbe48..c226561bec0 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/OPartitionedDatabasePool.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/OPartitionedDatabasePool.java @@ -343,7 +343,7 @@ public void close() { db.activateOnCurrentThread(); OStorage storage = db.getStorage(); storage.close(); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.java b/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.java index 870defabb30..5cdd4146751 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.java @@ -188,7 +188,7 @@ public ODatabaseDocumentTx(final String iURL, boolean keepStorageOpen) { } catch (Exception t) { if (storage != null) Orient.instance().unregisterStorage(storage); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); throw OException.wrapException(new ODatabaseException("Error on opening database '" + iURL + "'"), t); } @@ -543,7 +543,7 @@ private void internalDrop() { storage = null; status = STATUS.CLOSED; - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); clearOwner(); } catch (OException e) { @@ -559,7 +559,7 @@ private void internalDrop() { * instance. The database copy is not set in thread local. */ public ODatabaseDocumentTx copy() { - ODatabaseDocumentInternal dbInThreadLocal = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal dbInThreadLocal = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (this.isClosed()) throw new ODatabaseException("Cannot copy a closed db"); @@ -594,8 +594,8 @@ public ODatabaseDocumentTx copy() { if (dbInThreadLocal != null) { dbInThreadLocal.activateOnCurrentThread(); } else { - if (ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + if (ODatabaseRecordThreadLocal.instance().isDefined()) { + ODatabaseRecordThreadLocal.instance().remove(); } } @@ -1276,7 +1276,7 @@ public void close() { } finally { // ALWAYS RESET TL - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); clearOwner(); } } @@ -3165,7 +3165,7 @@ public void setCurrentDatabaseInThreadLocal() { */ @Override public ODatabaseDocumentTx activateOnCurrentThread() { - final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.INSTANCE; + final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.instance(); if (tl != null) tl.set(this); return this; @@ -3173,7 +3173,7 @@ public ODatabaseDocumentTx activateOnCurrentThread() { @Override public boolean isActiveOnCurrentThread() { - final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.INSTANCE; + final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.instance(); final ODatabaseDocumentInternal db = tl != null ? tl.getIfDefined() : null; return db == this; } @@ -3418,7 +3418,7 @@ public ORawBuffer readRecord(OStorage storage, ORecordId rid, String fetchPlan, } public void checkIfActive() { - final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.INSTANCE; + final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.instance(); final ODatabaseDocumentInternal currentDatabase = tl != null ? tl.getIfDefined() : null; if (currentDatabase != this) throw new IllegalStateException( diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTxPooled.java b/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTxPooled.java index 372d64f1c14..facbc605106 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTxPooled.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTxPooled.java @@ -53,7 +53,7 @@ public void reuse(final Object iOwner, final Object[] iAdditionalArgs) { ownerPool = (ODatabaseDocumentPool) iOwner; getLocalCache().invalidate(); // getMetadata().reload(); - ODatabaseRecordThreadLocal.INSTANCE.set(this); + ODatabaseRecordThreadLocal.instance().set(this); try { callOnOpenListeners(); @@ -138,7 +138,7 @@ public void close() { localCopy.release(this); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } public void forceClose() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/record/OLazyRecordIterator.java b/core/src/main/java/com/orientechnologies/orient/core/db/record/OLazyRecordIterator.java old mode 100644 new mode 100755 index 5849a72028b..7b1ad09dfab --- a/core/src/main/java/com/orientechnologies/orient/core/db/record/OLazyRecordIterator.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/record/OLazyRecordIterator.java @@ -71,7 +71,7 @@ public OIdentifiable next() { if (value == null) return null; - if (value instanceof ORecordId && autoConvert2Record && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { + if (value instanceof ORecordId && autoConvert2Record && ODatabaseRecordThreadLocal.instance().isDefined()) { try { final ORecord rec = ((ORecordId) value).getRecord(); if (sourceRecord != null && rec != null) diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/record/OPlaceholder.java b/core/src/main/java/com/orientechnologies/orient/core/db/record/OPlaceholder.java index 27802159f94..7d415415281 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/record/OPlaceholder.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/record/OPlaceholder.java @@ -115,22 +115,22 @@ public void fromStream(final DataInput in) throws IOException { @Override public void lock(final boolean iExclusive) { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().lockRecord(this, + ODatabaseRecordThreadLocal.instance().get().getTransaction().lockRecord(this, iExclusive ? OStorage.LOCKING_STRATEGY.EXCLUSIVE_LOCK : OStorage.LOCKING_STRATEGY.SHARED_LOCK); } @Override public boolean isLocked() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().isLockedRecord(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().isLockedRecord(this); } @Override public OStorage.LOCKING_STRATEGY lockingStrategy() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().lockingStrategy(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().lockingStrategy(this); } @Override public void unlock() { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().unlockRecord(this); + ODatabaseRecordThreadLocal.instance().get().getTransaction().unlockRecord(this); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/ORidBag.java b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/ORidBag.java index 6c1630bbd11..6228a7b5321 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/ORidBag.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/ORidBag.java @@ -199,7 +199,7 @@ public int toStream(BytesContainer bytesContainer) throws OSerializationExceptio final ORecordSerializationContext context = ORecordSerializationContext.getContext(); if (context != null) { - if (isEmbedded() && ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager() != null + if (isEmbedded() && ODatabaseRecordThreadLocal.instance().get().getSbTreeCollectionManager() != null && delegate.size() >= topThreshold) { ORidBagDelegate oldDelegate = delegate; delegate = new OSBTreeRidBag(); @@ -242,7 +242,7 @@ public int toStream(BytesContainer bytesContainer) throws OSerializationExceptio } final UUID oldUuid = uuid; - final OSBTreeCollectionManager sbTreeCollectionManager = ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager(); + final OSBTreeCollectionManager sbTreeCollectionManager = ODatabaseRecordThreadLocal.instance().get().getSbTreeCollectionManager(); if (sbTreeCollectionManager != null) uuid = sbTreeCollectionManager.listenForChanges(this); else diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/embedded/OEmbeddedRidBag.java b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/embedded/OEmbeddedRidBag.java index e98fd31aab9..1bb8f78b6d1 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/embedded/OEmbeddedRidBag.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/embedded/OEmbeddedRidBag.java @@ -104,7 +104,7 @@ public OIdentifiable next() { nextIndex = nextIndex(); final OIdentifiable identifiable = (OIdentifiable) nextValue; - if (convertToRecord && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) + if (convertToRecord && ODatabaseRecordThreadLocal.instance().isDefined()) return identifiable.getRecord(); return identifiable; @@ -405,7 +405,7 @@ public int getSerializedSize(byte[] stream, int offset) { public int serialize(byte[] stream, int offset, UUID ownerUuid) { OIntegerSerializer.INSTANCE.serializeLiteral(size, stream, offset); offset += OIntegerSerializer.INT_SIZE; - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); final int totEntries = entries.length; for (int i = 0; i < totEntries; ++i) { final Object entry = entries[i]; diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OIndexRIDContainer.java b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OIndexRIDContainer.java index 40e7698bfb2..9027015999f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OIndexRIDContainer.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OIndexRIDContainer.java @@ -71,7 +71,7 @@ public void setBottomThreshold(int bottomThreshold) { } private long resolveFileIdByName(String fileName) { - final OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() + final OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) ODatabaseRecordThreadLocal.instance().get().getStorage() .getUnderlying(); final OAtomicOperation atomicOperation; try { @@ -243,7 +243,7 @@ public void checkNotEmbedded() { } private void convertToSbTree() { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final OIndexRIDContainerSBTree tree = new OIndexRIDContainerSBTree(fileId, (OAbstractPaginatedStorage) db.getStorage().getUnderlying()); diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OSBTreeRidBag.java b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OSBTreeRidBag.java index d732c6c4a42..68a0ec779f3 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OSBTreeRidBag.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OSBTreeRidBag.java @@ -57,7 +57,7 @@ * @author Artem Orobets (enisher-at-gmail.com) */ public class OSBTreeRidBag implements ORidBagDelegate { - private final OSBTreeCollectionManager collectionManager = ODatabaseRecordThreadLocal.INSTANCE.get() + private final OSBTreeCollectionManager collectionManager = ODatabaseRecordThreadLocal.instance().get() .getSbTreeCollectionManager(); private final NavigableMap changes = new ConcurrentSkipListMap(); /** @@ -806,7 +806,7 @@ public Object returnOriginalState(List -1; - collectionPointer = ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager() + collectionPointer = ODatabaseRecordThreadLocal.instance().get().getSbTreeCollectionManager() .createSBTree(clusterId, ownerUuid); } } @@ -874,7 +874,7 @@ public int serialize(byte[] stream, int offset, UUID ownerUuid) { ChangeSerializationHelper.INSTANCE.serializeChanges(changes, OLinkSerializer.INSTANCE, stream, offset); } else { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); for (Entry change : this.changes.entrySet()) { OIdentifiable key = change.getKey(); if (db != null && db.getTransaction().isActive()) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/dictionary/ODictionary.java b/core/src/main/java/com/orientechnologies/orient/core/dictionary/ODictionary.java old mode 100644 new mode 100755 index 4e6525ff940..dcd5bf0d56d --- a/core/src/main/java/com/orientechnologies/orient/core/dictionary/ODictionary.java +++ b/core/src/main/java/com/orientechnologies/orient/core/dictionary/ODictionary.java @@ -47,7 +47,7 @@ public RET get(final String iKey, final String iFetchPlan) { return null; if (value instanceof ORID) - return (RET) ODatabaseRecordThreadLocal.INSTANCE.get().load(((ORID) value), iFetchPlan); + return (RET) ODatabaseRecordThreadLocal.instance().get().load(((ORID) value), iFetchPlan); return (RET) ((ODocument) value).load(iFetchPlan); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/exception/OCoreException.java b/core/src/main/java/com/orientechnologies/orient/core/exception/OCoreException.java index 79d1592f894..8a9e40e4b22 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/exception/OCoreException.java +++ b/core/src/main/java/com/orientechnologies/orient/core/exception/OCoreException.java @@ -41,7 +41,7 @@ public OCoreException(final String message, final String componentName, final OE this.componentName = null; } - final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (database != null) { dbName = database.getName(); } else { diff --git a/core/src/main/java/com/orientechnologies/orient/core/hook/ODocumentHookAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/hook/ODocumentHookAbstract.java index 091470a19fb..b5403943683 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/hook/ODocumentHookAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/hook/ODocumentHookAbstract.java @@ -41,7 +41,7 @@ public abstract class ODocumentHookAbstract implements ORecordHook { @Deprecated public ODocumentHookAbstract() { - this.database = ODatabaseRecordThreadLocal.INSTANCE.get(); + this.database = ODatabaseRecordThreadLocal.instance().get(); } public ODocumentHookAbstract(ODatabaseDocument database) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/id/ORecordId.java b/core/src/main/java/com/orientechnologies/orient/core/id/ORecordId.java index 2c5c39cb7f3..ab5d7d86866 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/id/ORecordId.java +++ b/core/src/main/java/com/orientechnologies/orient/core/id/ORecordId.java @@ -284,23 +284,23 @@ public void copyFrom(final ORID iSource) { @Override public void lock(final boolean iExclusive) { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction() + ODatabaseRecordThreadLocal.instance().get().getTransaction() .lockRecord(this, iExclusive ? OStorage.LOCKING_STRATEGY.EXCLUSIVE_LOCK : OStorage.LOCKING_STRATEGY.SHARED_LOCK); } @Override public boolean isLocked() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().isLockedRecord(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().isLockedRecord(this); } @Override public OStorage.LOCKING_STRATEGY lockingStrategy() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().lockingStrategy(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().lockingStrategy(this); } @Override public void unlock() { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().unlockRecord(this); + ODatabaseRecordThreadLocal.instance().get().getTransaction().unlockRecord(this); } public String next() { @@ -321,10 +321,10 @@ public T getRecord() { if (!isValid()) return null; - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); if (db == null) throw new ODatabaseException( - "No database found in current thread local space. If you manually control databases over threads assure to set the current database before to use it by calling: ODatabaseRecordThreadLocal.INSTANCE.set(db);"); + "No database found in current thread local space. If you manually control databases over threads assure to set the current database before to use it by calling: ODatabaseRecordThreadLocal.instance().set(db);"); return (T) db.load(this); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java index bb686142d50..1bbc722c96e 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java @@ -96,7 +96,7 @@ public OIndexAbstract(String name, final String type, final String algorithm, fi final ODocument metadata, final int version, final OStorage storage) { acquireExclusiveLock(); try { - databaseName = ODatabaseRecordThreadLocal.INSTANCE.get().getName(); + databaseName = ODatabaseRecordThreadLocal.instance().get().getName(); this.version = version; this.name = name; @@ -1016,7 +1016,7 @@ public boolean acquireAtomicExclusiveLock(Object key) { } protected ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } protected long[] indexCluster(final String clusterName, final OProgressListener iProgressListener, long documentNum, diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstractDelegate.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstractDelegate.java old mode 100644 new mode 100755 index e3adfa84165..1ee0a1ca212 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstractDelegate.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstractDelegate.java @@ -92,7 +92,7 @@ protected void checkForKeyType(final Object iKey) { if (type == null) return; - OIndexManagerProxy indexManager = ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata().getIndexManager(); + OIndexManagerProxy indexManager = ODatabaseRecordThreadLocal.instance().get().getMetadata().getIndexManager(); getInternal().setType(type); indexManager.save(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java index 28be50129cb..479cfe1977f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java @@ -199,7 +199,7 @@ private static OPropertyMapIndexDefinition.INDEX_BY extractMapIndexSpecifier(fin } private static Locale getServerLocale() { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); OStorage storage = db.getStorage(); OStorageConfiguration configuration = storage.getConfiguration(); return configuration.getLocaleInstance(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerAbstract.java index 61b8053c93e..121d35b82a2 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerAbstract.java @@ -422,11 +422,11 @@ protected void clearMetadata() { } protected static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } protected ODatabaseDocumentInternal getDatabaseIfDefined() { - return ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + return ODatabaseRecordThreadLocal.instance().getIfDefined(); } protected void addIndexInternal(final OIndex index) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerRemote.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerRemote.java index aa9ed71a5de..51bf4cb826b 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerRemote.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerRemote.java @@ -63,7 +63,7 @@ public OIndex createIndex(final String iName, final String iType, final OInde getDatabase().command(new OCommandSQL(createIndexDDL)).execute(); ORecordInternal.setIdentity(document, - new ORecordId(ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().indexMgrRecordId)); + new ORecordId(ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().indexMgrRecordId)); if (progressListener != null) progressListener.onCompletition(this, true); diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java index f5e490c04bf..caba712cf66 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java @@ -352,7 +352,7 @@ public boolean autoRecreateIndexesAfterCrash() { if (rebuildCompleted) return false; - final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get(); final OStorage storage = database.getStorage().getUnderlying(); if (storage instanceof OAbstractPaginatedStorage) { OAbstractPaginatedStorage paginatedStorage = (OAbstractPaginatedStorage) storage; diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexRemote.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexRemote.java old mode 100644 new mode 100755 index 7e5a8dfcd1c..074615adc29 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexRemote.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexRemote.java @@ -82,7 +82,7 @@ public OIndexRemote(final String iName, final String iWrappedType, final String this.indexDefinition = iIndexDefinition; this.configuration = iConfiguration; this.clustersToIndex = new HashSet(clustersToIndex); - this.databaseName = ODatabaseRecordThreadLocal.INSTANCE.get().getName(); + this.databaseName = ODatabaseRecordThreadLocal.instance().get().getName(); } public OIndexRemote create(final String name, final OIndexDefinition indexDefinition, final String clusterIndexName, @@ -479,6 +479,6 @@ protected OCommandRequest formatCommand(final String iTemplate, final Object... } protected ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/engine/OHashTableIndexEngine.java b/core/src/main/java/com/orientechnologies/orient/core/index/engine/OHashTableIndexEngine.java index e00b41e41b5..dd98d00347b 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/engine/OHashTableIndexEngine.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/engine/OHashTableIndexEngine.java @@ -430,6 +430,6 @@ public boolean acquireAtomicExclusiveLock(Object key) { } private ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/function/ODatabaseFunctionFactory.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/function/ODatabaseFunctionFactory.java old mode 100644 new mode 100755 index 588e621efaa..23f15b80eca --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/function/ODatabaseFunctionFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/function/ODatabaseFunctionFactory.java @@ -36,19 +36,19 @@ public class ODatabaseFunctionFactory implements OSQLFunctionFactory { @Override public boolean hasFunction(final String iName) { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); return db.getMetadata().getFunctionLibrary().getFunction(iName) != null; } @Override public Set getFunctionNames() { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); return db.getMetadata().getFunctionLibrary().getFunctionNames(); } @Override public OSQLFunction createFunction(final String name) throws OCommandExecutionException { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); final OFunction f = db.getMetadata().getFunctionLibrary().getFunction(name); return new ODatabaseFunction(f); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunction.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunction.java index 072c7e33220..d3671955b37 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunction.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunction.java @@ -208,7 +208,7 @@ public Object execute(final Map iArgs) { } if (Orient.instance().getProfiler().isRecording()) - Orient.instance().getProfiler().stopChrono("db." + ODatabaseRecordThreadLocal.INSTANCE.get().getName() + ".function.execute", + Orient.instance().getProfiler().stopChrono("db." + ODatabaseRecordThreadLocal.instance().get().getName() + ".function.execute", "Time to execute a function", start, "db.*.function.execute"); return result; diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunctionLibraryImpl.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunctionLibraryImpl.java index 3a8fc92cb55..7f553ebb498 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunctionLibraryImpl.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/function/OFunctionLibraryImpl.java @@ -68,7 +68,7 @@ public void load() { functions.clear(); // LOAD ALL THE FUNCTIONS IN MEMORY - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); if (((OMetadataInternal) db.getMetadata()).getImmutableSchemaSnapshot().existsClass("OFunction")) { List result = db.query(new OSQLSynchQuery("select from OFunction order by name")); for (ODocument d : result) { @@ -117,7 +117,7 @@ public void close() { } protected void init() { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); if (db.getMetadata().getSchema().existsClass("OFunction")) { final OClass f = db.getMetadata().getSchema().getClass("OFunction"); OProperty prop = f.getProperty("name"); diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OClassImpl.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OClassImpl.java index 7d5748b18aa..8716212cb5b 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OClassImpl.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OClassImpl.java @@ -1992,7 +1992,7 @@ public void getClassIndexes(final Collection> indexes) { @Override public OIndex getAutoShardingIndex() { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); return db != null ? db.getMetadata().getIndexManager().getClassAutoShardingIndex(name) : null; } @@ -2741,7 +2741,7 @@ private void tryDropCluster(final int defaultClusterId) { } private ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } /** diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableClass.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableClass.java old mode 100644 new mode 100755 index 609852d4fad..f00d1e34929 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableClass.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableClass.java @@ -152,7 +152,7 @@ public void init() { this.ouser = isSubClassOf(OUser.CLASS_NAME); this.orole = isSubClassOf(ORole.CLASS_NAME); - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); this.autoShardingIndex = db != null && db.getMetadata() != null && db.getMetadata().getIndexManager() != null ? db.getMetadata().getIndexManager().getClassAutoShardingIndex(name) : null; } @@ -760,7 +760,7 @@ public int compareTo(final OClass other) { } private ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } private Map getCustomInternal() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableSchema.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableSchema.java index d35af838a9b..c23fd8626cf 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableSchema.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OImmutableSchema.java @@ -276,7 +276,7 @@ public void onPostIndexManagement() { } private ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } public Set getBlobClusters() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OPropertyImpl.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OPropertyImpl.java index 2c9ee2f5330..7f8be4c6491 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OPropertyImpl.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OPropertyImpl.java @@ -1217,7 +1217,7 @@ public void checkEmbedded() { } protected ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } private void setNameInternal(final String name) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java index 1f6b78f5a42..8c1efe5d919 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java @@ -1382,7 +1382,7 @@ private void dropClassIndexes(final OClass cls) { } private ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } private void ensurePropertiesSize(int size) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OType.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OType.java index 9d9070abc17..b2ec2f20524 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OType.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OType.java @@ -431,10 +431,10 @@ else if (((String) iValue).equalsIgnoreCase("false")) if (OIOUtils.isLong(iValue.toString())) return new Date(Long.parseLong(iValue.toString())); try { - return ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateTimeFormatInstance() + return ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance() .parse((String) iValue); } catch (ParseException ignore) { - return ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateFormatInstance() + return ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateFormatInstance() .parse((String) iValue); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/clusterselection/OBalancedClusterSelectionStrategy.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/clusterselection/OBalancedClusterSelectionStrategy.java old mode 100644 new mode 100755 index 5332c0eea13..b3ff3316760 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/clusterselection/OBalancedClusterSelectionStrategy.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/clusterselection/OBalancedClusterSelectionStrategy.java @@ -37,7 +37,7 @@ public int getCluster(final OClass iClass, final ODocument doc) { // ONLY ONE: RETURN THE FIRST ONE return clusters[0]; - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db == null) return clusters[0]; diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/security/OSecurityShared.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/security/OSecurityShared.java index 0c6d68f9207..a96b22b8205 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/security/OSecurityShared.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/security/OSecurityShared.java @@ -197,7 +197,7 @@ public boolean isAllowed(final Set iAllowAll, final Set result = db.query(new OSQLSynchQuery("SELECT FROM " + OSequence.CLASS_NAME)); for (ODocument document : result) { @@ -116,7 +116,7 @@ public void dropSequence(final String iName) { final OSequence seq = getSequence(iName); if (seq != null) { - ODatabaseRecordThreadLocal.INSTANCE.get().delete(seq.getDocument().getIdentity()); + ODatabaseRecordThreadLocal.instance().get().delete(seq.getDocument().getIdentity()); sequences.remove(iName.toUpperCase(Locale.ENGLISH)); } } @@ -171,7 +171,7 @@ public void onSequenceDropped(final ODocument iDocument) { } private void init() { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); if (db.getMetadata().getSchema().existsClass(OSequence.CLASS_NAME)) { return; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/sequence/OSequenceTrigger.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/sequence/OSequenceTrigger.java old mode 100644 new mode 100755 index d40cc6aed2d..a90740c0f80 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/sequence/OSequenceTrigger.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/sequence/OSequenceTrigger.java @@ -57,7 +57,7 @@ public void onRecordAfterCreate(final ODocument iDocument) { } private static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } @Override @@ -71,7 +71,7 @@ public void onRecordAfterDelete(final ODocument iDocument) { } private OSequenceLibrary getSequenceLibrary() { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); return db.getMetadata().getSequenceLibrary(); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/ORecordAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/record/ORecordAbstract.java index 5dfaa84d671..54f3ce6b5da 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/record/ORecordAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/ORecordAbstract.java @@ -234,11 +234,11 @@ public ORecord load() { } public ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } public ODatabaseDocument getDatabaseIfDefined() { - return ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + return ODatabaseRecordThreadLocal.instance().getIfDefined(); } public ORecord reload() { @@ -300,23 +300,23 @@ public int getSize() { @Override public void lock(final boolean iExclusive) { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction() + ODatabaseRecordThreadLocal.instance().get().getTransaction() .lockRecord(this, iExclusive ? OStorage.LOCKING_STRATEGY.EXCLUSIVE_LOCK : OStorage.LOCKING_STRATEGY.SHARED_LOCK); } @Override public boolean isLocked() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().isLockedRecord(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().isLockedRecord(this); } @Override public OStorage.LOCKING_STRATEGY lockingStrategy() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().lockingStrategy(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().lockingStrategy(this); } @Override public void unlock() { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().unlockRecord(this); + ODatabaseRecordThreadLocal.instance().get().getTransaction().unlockRecord(this); } @Override @@ -429,11 +429,11 @@ protected void onAfterIdentityChanged(final ORecord iRecord) { } protected ODatabaseDocumentInternal getDatabaseInternal() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } protected ODatabaseDocumentInternal getDatabaseIfDefinedInternal() { - return ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + return ODatabaseRecordThreadLocal.instance().getIfDefined(); } /** @@ -491,7 +491,7 @@ protected void invokeListenerEvent(final ORecordListener.EVENT iEvent) { } protected void checkForLoading() { - if (_status == ORecordElement.STATUS.NOT_LOADED && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) + if (_status == ORecordElement.STATUS.NOT_LOADED && ODatabaseRecordThreadLocal.instance().isDefined()) reload(null, true); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/ORecordFactoryManager.java b/core/src/main/java/com/orientechnologies/orient/core/record/ORecordFactoryManager.java index 211f13866ef..88bec194c61 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/record/ORecordFactoryManager.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/ORecordFactoryManager.java @@ -83,7 +83,7 @@ public Class getRecordTypeClass(final byte iRecordType) { } public ORecord newInstance() { - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().get(); try { return (ORecord) getFactory(database.getRecordType()).newRecord(); } catch (Exception e) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocument.java b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocument.java index b0a51288d2d..86271fdd1c5 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocument.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocument.java @@ -653,7 +653,7 @@ public ODocument reload(final String fetchPlan, final boolean ignoreCache) { } public boolean hasSameContentOf(final ODocument iOther) { - final ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); return ODocumentHelper.hasSameContentOf(this, currentDb, iOther, currentDb, null); } @@ -731,8 +731,8 @@ public void fromString(final String iValue) { public String[] fieldNames() { checkForLoading(); - if (_status == ORecordElement.STATUS.LOADED && _source != null && ODatabaseRecordThreadLocal.INSTANCE.isDefined() - && !ODatabaseRecordThreadLocal.INSTANCE.get().isClosed()) { + if (_status == ORecordElement.STATUS.LOADED && _source != null && ODatabaseRecordThreadLocal.instance().isDefined() + && !ODatabaseRecordThreadLocal.instance().get().isClosed()) { // DESERIALIZE FIELD NAMES ONLY (SUPPORTED ONLY BY BINARY SERIALIZER) final String[] fieldNames = _recordFormat.getFieldNames(this, _source); if (fieldNames != null) @@ -823,7 +823,7 @@ public RET field(final String iFieldName) { RET value = this.rawField(iFieldName); if (!iFieldName.startsWith("@") && _lazyLoad && value instanceof ORID && (((ORID) value).isPersistent() || ((ORID) value) - .isNew()) && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { + .isNew()) && ODatabaseRecordThreadLocal.instance().isDefined()) { // CREATE THE DOCUMENT OBJECT IN LAZY WAY RET newValue = (RET) getDatabase().load((ORID) value); if (newValue != null) { @@ -1563,7 +1563,7 @@ public ODocument clear() { */ @Override public ODocument reset() { - ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && db.getTransaction().isActive()) throw new IllegalStateException("Cannot reset documents during a transaction. Create a new one each time"); @@ -2028,7 +2028,7 @@ public void validate() throws OValidationException { autoConvertValues(); - if (ODatabaseRecordThreadLocal.INSTANCE.isDefined() && !getDatabase().isValidationEnabled()) + if (ODatabaseRecordThreadLocal.instance().isDefined() && !getDatabase().isValidationEnabled()) return; final OImmutableClass immutableSchemaClass = getImmutableSchemaClass(); @@ -2632,7 +2632,7 @@ protected boolean checkForFields(final String... iFields) { protected void setup() { super.setup(); - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) _recordFormat = db.getSerializer(); @@ -2671,7 +2671,7 @@ protected Set> getRawEntries() { private void fetchSchemaIfCan() { if (_schema == null) { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && !db.isClosed()) { OMetadataInternal metadata = (OMetadataInternal) db.getMetadata(); _schema = metadata.getImmutableSchemaSnapshot(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentComparator.java b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentComparator.java index ac81daf4565..56e729dff0c 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentComparator.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentComparator.java @@ -50,7 +50,7 @@ public class ODocumentComparator implements Comparator { public ODocumentComparator(final List> iOrderCriteria, OCommandContext iContext) { this.orderCriteria = iOrderCriteria; this.context = iContext; - ODatabaseDocumentInternal internal = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal internal = ODatabaseRecordThreadLocal.instance().get(); collator = Collator.getInstance(new Locale(internal.get(ATTRIBUTES.LOCALECOUNTRY) + "_" + internal.get(ATTRIBUTES.LOCALELANGUAGE))); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentHelper.java b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentHelper.java index 1b943c6d275..5ebdb5a4357 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentHelper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocumentHelper.java @@ -190,8 +190,8 @@ public static RET convertField(final ODocument iDocument, final String iFi throw new IllegalArgumentException( "Property '" + iFieldName + "' of type '" + iFieldType + "' cannot accept value of type: " + iValue.getClass()); } else if (Date.class.isAssignableFrom(iFieldType)) { - if (iValue instanceof String && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) { - final OStorageConfiguration config = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration(); + if (iValue instanceof String && ODatabaseRecordThreadLocal.instance().isDefined()) { + final OStorageConfiguration config = ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration(); DateFormat formatter = config.getDateFormatInstance(); @@ -868,7 +868,7 @@ else if (currentValue instanceof Number) result = new Date(((Number) currentValue).longValue()); else try { - result = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateFormatInstance() + result = ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateFormatInstance() .parse(currentValue.toString()); } catch (ParseException e) { OLogManager.instance().warn(ODocumentHelper.class, "Error during function evaluation", e); @@ -880,7 +880,7 @@ else if (currentValue instanceof Number) result = new Date(((Number) currentValue).longValue()); else try { - result = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateTimeFormatInstance() + result = ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance() .parse(currentValue.toString()); } catch (ParseException e) { OLogManager.instance().warn(ODocumentHelper.class, "Error during function evaluation", e); @@ -1404,7 +1404,7 @@ public static boolean compareBags(ODatabaseDocumentInternal iMyDb, ORidBag myFie final ORidBag myBag = myFieldValue; final ORidBag otherBag = otherFieldValue; - final ODatabaseDocumentInternal originalDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal originalDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final int mySize = makeDbCall(iMyDb, new ODbRelatedCall() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordBytes.java b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordBytes.java index f42f5481e52..8e5fb31ec85 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordBytes.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordBytes.java @@ -51,12 +51,12 @@ public ORecordBytes() { public ORecordBytes(final ODatabaseDocumentInternal iDatabase) { setup(); - ODatabaseRecordThreadLocal.INSTANCE.set(iDatabase); + ODatabaseRecordThreadLocal.instance().set(iDatabase); } public ORecordBytes(final ODatabaseDocumentInternal iDatabase, final byte[] iSource) { this(iSource); - ODatabaseRecordThreadLocal.INSTANCE.set(iDatabase); + ODatabaseRecordThreadLocal.instance().set(iDatabase); } public ORecordBytes(final byte[] iSource) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordFlat.java b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordFlat.java old mode 100644 new mode 100755 index c5db8b322f7..72683597a71 --- a/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordFlat.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/impl/ORecordFlat.java @@ -43,7 +43,7 @@ public class ORecordFlat extends ORecordAbstract implements ORecordStringable { public ORecordFlat(ODatabaseDocumentInternal iDatabase) { this(); - ODatabaseRecordThreadLocal.INSTANCE.set(iDatabase); + ODatabaseRecordThreadLocal.instance().set(iDatabase); } public ORecordFlat() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/schedule/OScheduledEvent.java b/core/src/main/java/com/orientechnologies/orient/core/schedule/OScheduledEvent.java index c3379a8ad3e..87f63b39608 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/schedule/OScheduledEvent.java +++ b/core/src/main/java/com/orientechnologies/orient/core/schedule/OScheduledEvent.java @@ -299,7 +299,7 @@ private boolean isEventAlreadyExecuted() { } private void bindDb() { - final ODatabaseDocumentInternal tlDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal tlDb = ODatabaseRecordThreadLocal.instance().get(); if (tlDb != null && !tlDb.isClosed()) this.db = ((ODatabaseDocumentTx) tlDb).copy(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/schedule/OSchedulerImpl.java b/core/src/main/java/com/orientechnologies/orient/core/schedule/OSchedulerImpl.java index 7c0a065ca01..437f1548005 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/schedule/OSchedulerImpl.java +++ b/core/src/main/java/com/orientechnologies/orient/core/schedule/OSchedulerImpl.java @@ -107,7 +107,7 @@ public OScheduledEvent getEvent(final String name) { @Override public void load() { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); if (db.getMetadata().getSchema().existsClass(OScheduledEvent.CLASS_NAME)) { final Iterable result = db.browseClass(OScheduledEvent.CLASS_NAME); @@ -130,7 +130,7 @@ public void close() { @Override public void create() { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); if (db.getMetadata().getSchema().existsClass(OScheduledEvent.CLASS_NAME)) return; final OClass f = db.getMetadata().getSchema().createClass(OScheduledEvent.CLASS_NAME); diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/OStringSerializerHelper.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/OStringSerializerHelper.java index e3f293f8ab2..1fa2b15f60c 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/OStringSerializerHelper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/OStringSerializerHelper.java @@ -850,7 +850,7 @@ public static OClass getRecordClassName(final String iValue, OClass iLinkedClass .indexOfOutsideStrings(iValue, OStringSerializerHelper.CLASS_SEPARATOR.charAt(0), 0, -1); if (classSeparatorPos > -1) { final String className = iValue.substring(0, classSeparatorPos); - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().get(); if (className != null && database != null) iLinkedClass = ((OMetadataInternal) database.getMetadata()).getImmutableSchemaSnapshot().getClass(className); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/binary/OBinarySerializerFactory.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/binary/OBinarySerializerFactory.java index f241c3ce6af..c64c7ae0a0f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/binary/OBinarySerializerFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/binary/OBinarySerializerFactory.java @@ -86,7 +86,7 @@ public static OBinarySerializerFactory create(int binaryFormatVersion) { } public static OBinarySerializerFactory getInstance() { - final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (database != null) return database.getSerializerFactory(); else diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/OBinaryComparatorV0.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/OBinaryComparatorV0.java index 6a486346c58..da5f97a4e65 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/OBinaryComparatorV0.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/OBinaryComparatorV0.java @@ -477,7 +477,7 @@ public boolean isEqual(final OBinaryField iField1, final OBinaryField iField2) { return value1 == value2; } - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final SimpleDateFormat dateFormat = db != null ? db.getStorage().getConfiguration().getDateFormatInstance() : new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATETIME_FORMAT); @@ -545,7 +545,7 @@ public boolean isEqual(final OBinaryField iField1, final OBinaryField iField2) { return value1 == value2; } - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final SimpleDateFormat dateFormat = db != null ? db.getStorage().getConfiguration().getDateTimeFormatInstance() : new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATETIME_FORMAT); @@ -1054,7 +1054,7 @@ public int compare(final OBinaryField iField1, final OBinaryField iField2) { return (value1 < value2) ? -1 : ((value1 == value2) ? 0 : 1); } - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final SimpleDateFormat dateFormat = db != null ? db.getStorage().getConfiguration().getDateTimeFormatInstance() : new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATETIME_FORMAT); @@ -1120,7 +1120,7 @@ public int compare(final OBinaryField iField1, final OBinaryField iField2) { return (value1 < value2) ? -1 : ((value1 == value2) ? 0 : 1); } - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final SimpleDateFormat dateFormat = db != null ? db.getStorage().getConfiguration().getDateFormatInstance() : new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATE_FORMAT); diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/ORecordSerializerBinaryV0.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/ORecordSerializerBinaryV0.java index e103108f50a..ef46f741a09 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/ORecordSerializerBinaryV0.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/ORecordSerializerBinaryV0.java @@ -164,7 +164,7 @@ public OBinaryField deserializeField(final BytesContainer bytes, final OClass iC final byte[] field = iFieldName.getBytes(); - final OMetadataInternal metadata = (OMetadataInternal) ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata(); + final OMetadataInternal metadata = (OMetadataInternal) ODatabaseRecordThreadLocal.instance().get().getMetadata(); final OImmutableSchema _schema = metadata.getImmutableSchemaSnapshot(); while (true) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java index b416adba7b1..aa7de97625a 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java @@ -90,7 +90,7 @@ private static OIdentifiable linkToStream(final StringBuilder buffer, final ODoc // JUST THE REFERENCE rid = (ORID) iLinked; - assert rid.getIdentity().isValid() || (ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() instanceof OStorageProxy) : + assert rid.getIdentity().isValid() || (ODatabaseRecordThreadLocal.instance().get().getStorage() instanceof OStorageProxy) : "Impossible to serialize invalid link " + rid.getIdentity(); resultRid = rid; } else { @@ -112,10 +112,10 @@ else if (!(iLinked instanceof ORecord)) { ORecord iLinkedRecord = ((OIdentifiable) iLinked).getRecord(); rid = iLinkedRecord.getIdentity(); - assert rid.getIdentity().isValid() || (ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() instanceof OStorageProxy) : + assert rid.getIdentity().isValid() || (ODatabaseRecordThreadLocal.instance().get().getStorage() instanceof OStorageProxy) : "Impossible to serialize invalid link " + rid.getIdentity(); - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().get(); if (iParentRecord != null) { if (!database.isRetainRecords()) // REPLACE CURRENT RECORD WITH ITS ID: THIS SAVES A LOT OF MEMORY @@ -193,7 +193,7 @@ public Object fieldFromStream(final ORecord iSourceRecord, final OType iType, OC if (iValue.length() > 1) { int pos = iValue.indexOf(OStringSerializerHelper.CLASS_SEPARATOR); if (pos > -1) - ((OMetadataInternal) ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata()).getImmutableSchemaSnapshot() + ((OMetadataInternal) ODatabaseRecordThreadLocal.instance().get().getMetadata()).getImmutableSchemaSnapshot() .getClass(iValue.substring(1, pos)); else pos = 0; @@ -567,8 +567,8 @@ else if (o.getValue() instanceof ODocumentSerializable) { record = ((ODocumentSerializable) o.getValue()).toDocument(); record.field(ODocumentSerializable.CLASS_NAME, o.getValue().getClass().getName()); } else { - if (iDatabase == null && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) - iDatabase = ODatabaseRecordThreadLocal.INSTANCE.get(); + if (iDatabase == null && ODatabaseRecordThreadLocal.instance().isDefined()) + iDatabase = ODatabaseRecordThreadLocal.instance().get(); record = OObjectSerializerHelperManager.getInstance() .toStream(o.getValue(), new ODocument(o.getValue().getClass().getSimpleName()), @@ -767,7 +767,7 @@ public StringBuilder embeddedCollectionToStream(ODatabase iDatabase, final OU if (doc.hasOwners()) linkedType = OType.EMBEDDED; - assert linkedType == OType.EMBEDDED || id.getIdentity().isValid() || (ODatabaseRecordThreadLocal.INSTANCE.get() + assert linkedType == OType.EMBEDDED || id.getIdentity().isValid() || (ODatabaseRecordThreadLocal.instance().get() .getStorage() instanceof OStorageProxy) : "Impossible to serialize invalid link " + id.getIdentity(); linkedClass = ODocumentInternal.getImmutableSchemaClass(doc); @@ -783,8 +783,8 @@ public StringBuilder embeddedCollectionToStream(ODatabase iDatabase, final OU else if (linkedType != OType.LINK && (linkedClass != null || doc != null)) { if (id == null) { // EMBEDDED OBJECTS - if (iDatabase == null && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) - iDatabase = ODatabaseRecordThreadLocal.INSTANCE.get(); + if (iDatabase == null && ODatabaseRecordThreadLocal.instance().isDefined()) + iDatabase = ODatabaseRecordThreadLocal.instance().get(); id = OObjectSerializerHelperManager.getInstance().toStream(o, new ODocument(o.getClass().getSimpleName()), iDatabase instanceof ODatabaseObject ? diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java index e6f1834cc4e..edd02e8f851 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java @@ -213,7 +213,7 @@ public ORecord fromString(String iSource, ORecord iRecord, final String[] iField } } else if (needReload && fieldName.equals(ODocumentHelper.ATTRIBUTE_RID) && iRecord instanceof ODocument) { if (fieldValue != null && fieldValue.length() > 0) { - ORecord localRecord = ODatabaseRecordThreadLocal.INSTANCE.get().load(new ORecordId(fieldValueAsString)); + ORecord localRecord = ODatabaseRecordThreadLocal.instance().get().load(new ORecordId(fieldValueAsString)); if (localRecord != null) iRecord = localRecord; } @@ -633,7 +633,7 @@ private Object getValueAsRecord(ODocument iRecord, String iFieldValue, OType iTy if (shouldBeDeserializedAsEmbedded(recordInternal, iType)) ODocumentInternal.addOwner(recordInternal, iRecord); else { - ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (rid.isPersistent() && database != null) { ODocument documentToMerge = database.load(rid); diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerSchemaAware2CSV.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerSchemaAware2CSV.java index b488970ee8e..c72ef293d6f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerSchemaAware2CSV.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerSchemaAware2CSV.java @@ -100,7 +100,7 @@ public ORecord fromString(String iContent, final ORecord iRecord, final String[] final ODocument record = (ODocument) iRecord; int pos; - final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().getIfDefined(); final int posFirstValue = iContent.indexOf(OStringSerializerHelper.ENTRY_SEPARATOR); pos = iContent.indexOf(OStringSerializerHelper.CLASS_SEPARATOR); if (pos > -1 && (pos < posFirstValue || posFirstValue == -1)) { @@ -351,7 +351,7 @@ protected StringBuilder toString(ORecord iRecord, final StringBuilder iOutput, f if (type == null) { if (fieldValue.getClass() == byte[].class) type = OType.BINARY; - else if (ODatabaseRecordThreadLocal.INSTANCE.isDefined() && fieldValue instanceof ORecord) { + else if (ODatabaseRecordThreadLocal.instance().isDefined() && fieldValue instanceof ORecord) { if (type == null) // DETERMINE THE FIELD TYPE if (fieldValue instanceof ODocument && ((ODocument) fieldValue).hasOwners()) @@ -359,18 +359,18 @@ else if (ODatabaseRecordThreadLocal.INSTANCE.isDefined() && fieldValue instanceo else type = OType.LINK; - linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.INSTANCE.get(), fieldClassName); + linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.instance().get(), fieldClassName); } else if (fieldValue instanceof ORID) // DETERMINE THE FIELD TYPE type = OType.LINK; - else if (ODatabaseRecordThreadLocal.INSTANCE.isDefined() && ODatabaseRecordThreadLocal.INSTANCE.get() + else if (ODatabaseRecordThreadLocal.instance().isDefined() && ODatabaseRecordThreadLocal.instance().get() .getDatabaseOwner() instanceof ODatabaseObject && - ((ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()).getEntityManager() + ((ODatabaseObject) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner()).getEntityManager() .getEntityClass(fieldClassName) != null) { // DETERMINE THE FIELD TYPE type = OType.LINK; - linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.INSTANCE.get(), fieldClassName); + linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.instance().get(), fieldClassName); } else if (fieldValue instanceof Date) type = OType.DATETIME; else if (fieldValue instanceof String) @@ -418,12 +418,12 @@ else if (fieldValue instanceof ORidBag) type = OType.LINKSET; else type = OType.LINKLIST; - } else if (ODatabaseRecordThreadLocal.INSTANCE.isDefined() && (firstValue instanceof ODocument + } else if (ODatabaseRecordThreadLocal.instance().isDefined() && (firstValue instanceof ODocument && !((ODocument) firstValue).isEmbedded()) && (firstValue instanceof ORecord || ( - ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner() instanceof ODatabaseObject - && ((ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()).getEntityManager() + ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner() instanceof ODatabaseObject + && ((ODatabaseObject) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner()).getEntityManager() .getEntityClass(getClassName(firstValue)) != null))) { - linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.INSTANCE.get(), getClassName(firstValue)); + linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.instance().get(), getClassName(firstValue)); if (type == null) { // LINK: GET THE CLASS linkedType = OType.LINK; @@ -481,12 +481,12 @@ else if (fieldValue instanceof Set) final Object firstValue = OMultiValue.getFirstValue(fieldValue); if (firstValue != null) { - if (ODatabaseRecordThreadLocal.INSTANCE.isDefined() && (firstValue instanceof ODocument && !((ODocument) firstValue) + if (ODatabaseRecordThreadLocal.instance().isDefined() && (firstValue instanceof ODocument && !((ODocument) firstValue) .isEmbedded()) && (firstValue instanceof ORecord || ( - ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner() instanceof ODatabaseObject && - ((ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()).getEntityManager() + ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner() instanceof ODatabaseObject && + ((ODatabaseObject) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner()).getEntityManager() .getEntityClass(getClassName(firstValue)) != null))) { - linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.INSTANCE.get(), getClassName(firstValue)); + linkedClass = getLinkInfo(ODatabaseRecordThreadLocal.instance().get(), getClassName(firstValue)); // LINK: GET THE CLASS linkedType = OType.LINK; type = OType.LINKMAP; diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerStringAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerStringAbstract.java index 13baedbd168..461583914ca 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerStringAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerStringAbstract.java @@ -198,7 +198,7 @@ public static void fieldTypeToString(final StringBuilder iBuffer, OType iType, f case EMBEDDEDSET: ORecordSerializerSchemaAware2CSV.INSTANCE - .embeddedCollectionToStream(ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(), null, iBuffer, null, null, iValue, true, + .embeddedCollectionToStream(ODatabaseRecordThreadLocal.instance().getIfDefined(), null, iBuffer, null, null, iValue, true, true); PROFILER.stopChrono(PROFILER.getProcessMetric("serializer.record.string.embedSet2string"), "Serialize embeddedset to string", timer); @@ -206,14 +206,14 @@ public static void fieldTypeToString(final StringBuilder iBuffer, OType iType, f case EMBEDDEDLIST: ORecordSerializerSchemaAware2CSV.INSTANCE - .embeddedCollectionToStream(ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(), null, iBuffer, null, null, iValue, true, + .embeddedCollectionToStream(ODatabaseRecordThreadLocal.instance().getIfDefined(), null, iBuffer, null, null, iValue, true, false); PROFILER.stopChrono(PROFILER.getProcessMetric("serializer.record.string.embedList2string"), "Serialize embeddedlist to string", timer); break; case EMBEDDEDMAP: - ORecordSerializerSchemaAware2CSV.INSTANCE.embeddedMapToStream(ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(), null, + ORecordSerializerSchemaAware2CSV.INSTANCE.embeddedMapToStream(ODatabaseRecordThreadLocal.instance().getIfDefined(), null, iBuffer, null, null, iValue, true); PROFILER.stopChrono(PROFILER.getProcessMetric("serializer.record.string.embedMap2string"), "Serialize embeddedmap to string", timer); @@ -673,7 +673,7 @@ public StringBuilder toString(final ORecord iRecord, final StringBuilder iOutput } public ORecord fromString(final String iSource) { - return fromString(iSource, (ORecord) ODatabaseRecordThreadLocal.INSTANCE.get().newInstance(), null); + return fromString(iSource, (ORecord) ODatabaseRecordThreadLocal.instance().get().newInstance(), null); } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/stream/OStreamSerializerSBTreeIndexRIDContainer.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/stream/OStreamSerializerSBTreeIndexRIDContainer.java old mode 100644 new mode 100755 index 449a20e390a..eb33cc62db9 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/stream/OStreamSerializerSBTreeIndexRIDContainer.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/stream/OStreamSerializerSBTreeIndexRIDContainer.java @@ -164,7 +164,7 @@ public OIndexRIDContainer deserializeNativeObject(byte[] stream, int offset) { final long pageIndex = LONG_SERIALIZER.deserializeNative(stream, offset + SBTREE_ROOTINDEX_OFFSET); final int pageOffset = INT_SERIALIZER.deserializeNative(stream, offset + SBTREE_ROOTOFFSET_OFFSET); final OBonsaiBucketPointer rootPointer = new OBonsaiBucketPointer(pageIndex, pageOffset); - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final OIndexRIDContainerSBTree underlying = new OIndexRIDContainerSBTree(fileId, rootPointer, durable, (OAbstractPaginatedStorage) db.getStorage().getUnderlying()); return new OIndexRIDContainer(fileId, underlying, durable); @@ -236,7 +236,7 @@ public OIndexRIDContainer deserializeFromByteBufferObject(ByteBuffer buffer) { final int pageOffset = buffer.getInt(); final OBonsaiBucketPointer rootPointer = new OBonsaiBucketPointer(pageIndex, pageOffset); - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final OIndexRIDContainerSBTree underlying = new OIndexRIDContainerSBTree(fileId, rootPointer, durable, (OAbstractPaginatedStorage) db.getStorage().getUnderlying()); return new OIndexRIDContainer(fileId, underlying, durable); @@ -280,7 +280,7 @@ public OIndexRIDContainer deserializeFromByteBufferObject(ByteBuffer buffer, OWA final long pageIndex = walChanges.getLongValue(buffer, offset + SBTREE_ROOTINDEX_OFFSET); final int pageOffset = walChanges.getIntValue(buffer, offset + SBTREE_ROOTOFFSET_OFFSET); final OBonsaiBucketPointer rootPointer = new OBonsaiBucketPointer(pageIndex, pageOffset); - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final OIndexRIDContainerSBTree underlying = new OIndexRIDContainerSBTree(fileId, rootPointer, durable, (OAbstractPaginatedStorage) db.getStorage().getUnderlying()); return new OIndexRIDContainer(fileId, underlying, durable); diff --git a/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingClusterSelectionStrategy.java b/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingClusterSelectionStrategy.java index 474f8348742..2837ab761f7 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingClusterSelectionStrategy.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingClusterSelectionStrategy.java @@ -53,7 +53,7 @@ public OAutoShardingClusterSelectionStrategy(final OClass clazz, final OIndex au throw new OConfigurationException("Cannot use auto-sharding cluster strategy because class '" + clazz + "' has an auto-sharding index defined with multiple fields"); - final OStorage stg = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying(); + final OStorage stg = ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying(); if (!(stg instanceof OAbstractPaginatedStorage)) throw new OConfigurationException("Cannot use auto-sharding cluster strategy because storage is not embedded"); diff --git a/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingIndexEngine.java b/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingIndexEngine.java index 394b0d0d27e..9f1865555f2 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingIndexEngine.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sharding/auto/OAutoShardingIndexEngine.java @@ -341,7 +341,7 @@ public String getIndexNameByKey(final Object key) { } private ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } private OHashTable getPartition(final Object iKey) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLLiveSelect.java b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLLiveSelect.java index 285f6effb39..787ea4624b7 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLLiveSelect.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLLiveSelect.java @@ -104,7 +104,7 @@ private void subscribeToLiveQuery(Integer token, ODatabaseInternal db) { public void onLiveResult(final ORecordOperation iOp) { - ODatabaseDocumentInternal oldThreadLocal = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal oldThreadLocal = ODatabaseRecordThreadLocal.instance().getIfDefined(); execDb.activateOnCurrentThread(); try { @@ -121,9 +121,9 @@ public void onLiveResult(final ORecordOperation iOp) { } } finally { if (oldThreadLocal == null) { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } else { - ODatabaseRecordThreadLocal.INSTANCE.set(oldThreadLocal); + ODatabaseRecordThreadLocal.instance().set(oldThreadLocal); } } final OCommandResultListener listener = request.getResultListener(); @@ -139,14 +139,14 @@ public void onLiveResult(final ORecordOperation iOp) { } protected void execInSeparateDatabase(final OCallable iCallback) { - final ODatabaseDocumentInternal prevDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal prevDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { iCallback.call(null); } finally { if (prevDb != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(prevDb); + ODatabaseRecordThreadLocal.instance().set(prevDb); } else { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } } @@ -217,13 +217,13 @@ public void onLiveResultEnd() { } if (execDb != null) { - ODatabaseDocumentInternal oldThreadDB = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal oldThreadDB = ODatabaseRecordThreadLocal.instance().getIfDefined(); execDb.activateOnCurrentThread(); execDb.close(); if (oldThreadDB == null) { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } else { - ODatabaseRecordThreadLocal.INSTANCE.set(oldThreadDB); + ODatabaseRecordThreadLocal.instance().set(oldThreadDB); } } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLResultsetAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLResultsetAbstract.java index 5b15045120e..1fa55d8974f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLResultsetAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLResultsetAbstract.java @@ -279,7 +279,7 @@ protected Object getResult() { protected boolean pushResult(final Object rec) { if (rec instanceof ORecord) { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) db.getLocalCache().updateRecord((ORecord) rec); } @@ -440,7 +440,7 @@ protected void assignLetClauses(final ORecord iRecord) { subQuery.getContext().setParent(context); subQuery.getContext().setVariable("parentQuery", this); subQuery.getContext().setVariable("current", iRecord); - varValue = ODatabaseRecordThreadLocal.INSTANCE.get().query(subQuery); + varValue = ODatabaseRecordThreadLocal.instance().get().query(subQuery); if (varValue instanceof OResultSet) { varValue = ((OResultSet) varValue).copy(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorToOStatementWrapper.java b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorToOStatementWrapper.java old mode 100644 new mode 100755 index 2e2ebd16830..db36885d7d7 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorToOStatementWrapper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorToOStatementWrapper.java @@ -70,7 +70,7 @@ public OCommandExecutorToOStatementWrapper parse(OCommandRequest iCommand) { } public static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/OFindReferenceHelper.java b/core/src/main/java/com/orientechnologies/orient/core/sql/OFindReferenceHelper.java old mode 100644 new mode 100755 index d42c2a1c546..63135d61259 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/OFindReferenceHelper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/OFindReferenceHelper.java @@ -56,7 +56,7 @@ public class OFindReferenceHelper { public static List findReferences(final Set iRecordIds, final String classList) { - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); final Map> map = new HashMap>(); for (ORID rid : iRecordIds) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java b/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java index 51e995de12b..f48ddedf618 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java @@ -334,7 +334,7 @@ public static ODocument bindParameters(final ODocument iDocument, final List(); if (metadataTarget.equals(OCommandExecutorSQLAbstract.METADATA_SCHEMA)) { - ((ArrayList) targetRecords).add(new ORecordId(ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() + ((ArrayList) targetRecords).add(new ORecordId(ODatabaseRecordThreadLocal.instance().get().getStorage() .getConfiguration().schemaRecordId)); } else if (metadataTarget.equals(OCommandExecutorSQLAbstract.METADATA_INDEXMGR)) { - ((ArrayList) targetRecords).add(new ORecordId(ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() + ((ArrayList) targetRecords).add(new ORecordId(ODatabaseRecordThreadLocal.instance().get().getStorage() .getConfiguration().indexMgrRecordId)); } else throw new OQueryParsingException("Metadata element not supported: " + metadataTarget); @@ -245,7 +245,7 @@ private boolean extractTargets() { final String key = originalSubjectName.substring(OCommandExecutorSQLAbstract.DICTIONARY_PREFIX.length()); targetRecords = new ArrayList(); - final OIdentifiable value = ODatabaseRecordThreadLocal.INSTANCE.get().getDictionary().get(key); + final OIdentifiable value = ODatabaseRecordThreadLocal.instance().get().getDictionary().get(key); if (value != null) ((List) targetRecords).add(value); @@ -267,10 +267,10 @@ private boolean extractTargets() { if (targetClasses == null) targetClasses = new HashMap(); - final OClass cls = ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata().getSchema().getClass(subjectName); + final OClass cls = ODatabaseRecordThreadLocal.instance().get().getMetadata().getSchema().getClass(subjectName); if (cls == null) throw new OCommandExecutionException("Class '" + subjectName + "' was not found in database '" - + ODatabaseRecordThreadLocal.INSTANCE.get().getName() + "'"); + + ODatabaseRecordThreadLocal.instance().get().getName() + "'"); targetClasses.put(cls.getName(), alias); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/OSQLFunctionAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/OSQLFunctionAbstract.java old mode 100644 new mode 100755 index 8e35938b562..433df63ac77 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/OSQLFunctionAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/OSQLFunctionAbstract.java @@ -102,6 +102,6 @@ protected boolean returnDistributedResult() { } protected String getDistributedStorageId() { - return ((OAutoshardedStorage) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage()).getStorageId(); + return ((OAutoshardedStorage) ODatabaseRecordThreadLocal.instance().get().getStorage()).getStorageId(); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDate.java b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDate.java index 5fc2c4a9531..f43cca1148b 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDate.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDate.java @@ -53,7 +53,7 @@ public Object execute(Object iThis, OIdentifiable iCurrentRecord, OCommandContex return new Date(((Number) iThis).longValue()); } else { try { - return ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateFormatInstance() + return ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateFormatInstance() .parse(iThis.toString()); } catch (ParseException e) { OLogManager.instance().error(this, "Error during execution a method '%s'", e, NAME); diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDateTime.java b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDateTime.java index 84c65a97d9a..c57a9aca9ed 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDateTime.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/conversion/OSQLMethodAsDateTime.java @@ -53,7 +53,7 @@ public Object execute(Object iThis, OIdentifiable iCurrentRecord, OCommandContex return new Date(((Number) iThis).longValue()); } else { try { - return ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateTimeFormatInstance() + return ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance() .parse(iThis.toString()); } catch (ParseException e) { OLogManager.instance().error(this, "Error during execution a method '%s'", e, NAME); diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/misc/OSQLFunctionDate.java b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/misc/OSQLFunctionDate.java index 3027415aaa7..be7eb8bd73e 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/misc/OSQLFunctionDate.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/misc/OSQLFunctionDate.java @@ -69,7 +69,7 @@ public Object execute(Object iThis, final OIdentifiable iCurrentRecord, final Ob format = new SimpleDateFormat((String) iParams[1]); format.setTimeZone(ODateHelper.getDatabaseTimeZone()); } else - format = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateTimeFormatInstance(); + format = ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance(); if (iParams.length == 3) format.setTimeZone(TimeZone.getTimeZone(iParams[2].toString())); diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/sequence/OSQLFunctionSequence.java b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/sequence/OSQLFunctionSequence.java old mode 100644 new mode 100755 index 54dca621d16..eaf722e4873 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/functions/sequence/OSQLFunctionSequence.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/functions/sequence/OSQLFunctionSequence.java @@ -29,7 +29,7 @@ public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurren else seqName = configuredParameters[0].toString(); - OSequence result = ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata().getSequenceLibrary().getSequence(seqName); + OSequence result = ODatabaseRecordThreadLocal.instance().get().getMetadata().getSequenceLibrary().getSequence(seqName); if (result == null) { throw new OCommandExecutionException("Sequence not found: " + seqName); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java index 7870c07fc79..80f53319381 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java @@ -52,7 +52,7 @@ public class OQueryOperatorEquals extends OQueryOperatorEqualityNotNulls { public OQueryOperatorEquals() { super("=", 5, false); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorInstanceof.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorInstanceof.java old mode 100644 new mode 100755 index 9d600ea8ecb..ed07ddf9dd4 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorInstanceof.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorInstanceof.java @@ -48,7 +48,7 @@ public OQueryOperatorInstanceof() { protected boolean evaluateExpression(final OIdentifiable iRecord, final OSQLFilterCondition iCondition, final Object iLeft, final Object iRight, OCommandContext iContext) { - final OSchema schema = ((OMetadataInternal)ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata()).getImmutableSchemaSnapshot(); + final OSchema schema = ((OMetadataInternal)ODatabaseRecordThreadLocal.instance().get().getMetadata()).getImmutableSchemaSnapshot(); final String baseClassName = iRight.toString(); final OClass baseClass = schema.getClass(baseClassName); diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajor.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajor.java index 72eb768474e..07406d02ee6 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajor.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajor.java @@ -53,7 +53,7 @@ public class OQueryOperatorMajor extends OQueryOperatorEqualityNotNulls { public OQueryOperatorMajor() { super(">", 5, false); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajorEquals.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajorEquals.java index e757a0482ad..ce9a492eb84 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajorEquals.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMajorEquals.java @@ -52,7 +52,7 @@ public class OQueryOperatorMajorEquals extends OQueryOperatorEqualityNotNulls { public OQueryOperatorMajorEquals() { super(">=", 5, false); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinor.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinor.java index e06efa53db6..13054932bce 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinor.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinor.java @@ -52,7 +52,7 @@ public class OQueryOperatorMinor extends OQueryOperatorEqualityNotNulls { public OQueryOperatorMinor() { super("<", 5, false); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinorEquals.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinorEquals.java index b10a6db21ec..432a608f4eb 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinorEquals.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorMinorEquals.java @@ -51,7 +51,7 @@ public class OQueryOperatorMinorEquals extends OQueryOperatorEqualityNotNulls { public OQueryOperatorMinorEquals() { super("<=", 5, false); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals.java old mode 100644 new mode 100755 index cad6f9e982a..89467c0101b --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals.java @@ -39,7 +39,7 @@ public class OQueryOperatorNotEquals extends OQueryOperatorEqualityNotNulls { public OQueryOperatorNotEquals() { super("<>", 5, false); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals2.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals2.java old mode 100644 new mode 100755 index cf71481f989..1e3340954a9 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals2.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorNotEquals2.java @@ -39,7 +39,7 @@ public class OQueryOperatorNotEquals2 extends OQueryOperatorEqualityNotNulls { public OQueryOperatorNotEquals2() { super("!=", 5, false); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFunctionCall.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFunctionCall.java old mode 100644 new mode 100755 index c0777c94327..c06c40b9c0e --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFunctionCall.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFunctionCall.java @@ -90,7 +90,7 @@ record = (OIdentifiable) targetObjects; } public static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } public boolean isIndexedFunctionCall() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMatchPathItemIterator.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMatchPathItemIterator.java old mode 100644 new mode 100755 index f7c12e39967..b607d2d3e88 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMatchPathItemIterator.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMatchPathItemIterator.java @@ -81,7 +81,7 @@ protected void loadNextInternal() { final OWhereClause filter = this.item.filter == null ? null : this.item.filter.getFilter(); final String className = this.item.filter == null ? null : this.item.filter.getClassName(ctx); final OClass clazz = - className == null ? null : ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata().getSchema().getClass(className); + className == null ? null : ODatabaseRecordThreadLocal.instance().get().getMetadata().getSchema().getClass(className); final OWhereClause whileCondition = this.item.filter == null ? null : this.item.filter.getWhileCondition(); final Integer maxDepth = maxDepth(this.item.filter); final OClass oClass = diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMethodCall.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMethodCall.java old mode 100644 new mode 100755 index 7972cfe17f9..3ad51f83748 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMethodCall.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OMethodCall.java @@ -126,7 +126,7 @@ public Object executeReverse(Object targetObjects, OCommandContext ctx) { } public static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OStatementCache.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OStatementCache.java index 7bda9c27217..a77aab9cbcd 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OStatementCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OStatementCache.java @@ -104,7 +104,7 @@ public OStatement get(String statement) { */ protected static OStatement parse(String statement) throws OCommandSQLParsingException { try { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); InputStream is; if (db == null) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/SimpleNode.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/SimpleNode.java old mode 100644 new mode 100755 index 72d357d1755..e011727390b --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/SimpleNode.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/SimpleNode.java @@ -135,7 +135,7 @@ public void dump(String prefix) { } public static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } public void toString(Map params, StringBuilder builder) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLNonBlockingQuery.java b/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLNonBlockingQuery.java index 84a14fb87b7..dd89698d45a 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLNonBlockingQuery.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLNonBlockingQuery.java @@ -258,17 +258,17 @@ public T executeFirst() { @Override public RET execute(final Object... iArgs) { - final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get(); final ONonBlockingQueryFuture future = new ONonBlockingQueryFuture(); if (database instanceof ODatabaseDocumentTx) { - ODatabaseDocumentInternal currentThreadLocal = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal currentThreadLocal = ODatabaseRecordThreadLocal.instance().getIfDefined(); final ODatabaseDocumentInternal db = ((ODatabaseDocumentTx) database).copy(); if (currentThreadLocal != null) { currentThreadLocal.activateOnCurrentThread(); } else { - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } Thread t = new Thread(new Runnable() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLQuery.java b/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLQuery.java index 171bd751c47..a747c7831be 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLQuery.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/query/OSQLQuery.java @@ -68,7 +68,7 @@ public OSQLQuery(final String iText) { */ @SuppressWarnings("unchecked") public List run(final Object... iArgs) { - final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get(); if (database == null) throw new OQueryParsingException("No database configured"); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java index db8a245d0d7..23d00b2b1bd 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java @@ -190,7 +190,7 @@ public STATUS getStatus() { public void checkForClusterPermissions(final String iClusterName) { // CHECK FOR ORESTRICTED - OMetadata metaData = ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata(); + OMetadata metaData = ODatabaseRecordThreadLocal.instance().get().getMetadata(); if (metaData != null) { final Set classes = ((OMetadataInternal) metaData).getImmutableSchemaSnapshot().getClassesRelyOnCluster(iClusterName); for (OClass c : classes) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java index fbf56ae71da..5dc89044b18 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java @@ -3314,7 +3314,7 @@ public Object executeCommand(final OCommandRequestText iCommand, final OCommandE try { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); // CALL BEFORE COMMAND Iterable listeners = db.getListeners(); @@ -3372,12 +3372,12 @@ public Object executeCommand(final OCommandRequestText iCommand, final OCommandE } finally { if (Orient.instance().getProfiler().isRecording()) { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) { final OSecurityUser user = db.getUser(); final String userString = user != null ? user.toString() : null; Orient.instance().getProfiler() - .stopChrono("db." + ODatabaseRecordThreadLocal.INSTANCE.get().getName() + ".command." + iCommand.toString(), + .stopChrono("db." + ODatabaseRecordThreadLocal.instance().get().getName() + ".command." + iCommand.toString(), "Command executed against the database", beginTime, "db.*.command.*", null, userString); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java index 58414736190..54102450fa6 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java @@ -357,7 +357,7 @@ public Object set(final OCluster.ATTRIBUTES attribute, final Object value) throw throw new IllegalArgumentException( "Cannot change compression setting on cluster '" + getName() + "' because it is not empty"); setCompressionInternal(stringValue, - ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getContextConfiguration() + ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getContextConfiguration() .getValueAsString(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY)); break; case CONFLICTSTRATEGY: @@ -374,7 +374,7 @@ public Object set(final OCluster.ATTRIBUTES attribute, final Object value) throw throw new IllegalArgumentException( "Cannot change encryption setting on cluster '" + getName() + "' because it is not empty"); setEncryptionInternal(stringValue, - ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getContextConfiguration() + ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getContextConfiguration() .getValueAsString(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY)); break; default: diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagDeleteSerializationOperation.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagDeleteSerializationOperation.java index 65a96af0b0b..0cf518f1a7c 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagDeleteSerializationOperation.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagDeleteSerializationOperation.java @@ -37,7 +37,7 @@ public class ORidBagDeleteSerializationOperation implements ORecordSerialization public ORidBagDeleteSerializationOperation(OBonsaiCollectionPointer collectionPointer, OSBTreeRidBag ridBag) { this.collectionPointer = collectionPointer; this.ridBag = ridBag; - collectionManager = ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager(); + collectionManager = ODatabaseRecordThreadLocal.instance().get().getSbTreeCollectionManager(); } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagUpdateSerializationOperation.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagUpdateSerializationOperation.java index 4a0be752fb5..5ca3ee076b0 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagUpdateSerializationOperation.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORidBagUpdateSerializationOperation.java @@ -46,7 +46,7 @@ public ORidBagUpdateSerializationOperation(final NavigableMap getLockedRecords() { } public String getClusterName(final ORecord record) { - if (ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().isRemote()) + if (ODatabaseRecordThreadLocal.instance().get().getStorage().isRemote()) // DON'T ASSIGN CLUSTER WITH REMOTE: SERVER KNOWS THE RIGHT CLUSTER BASED ON LOCALITY return null; diff --git a/core/src/main/java/com/orientechnologies/orient/core/util/ODateHelper.java b/core/src/main/java/com/orientechnologies/orient/core/util/ODateHelper.java old mode 100644 new mode 100755 index d2d3ee4f9e1..88d8d429114 --- a/core/src/main/java/com/orientechnologies/orient/core/util/ODateHelper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/util/ODateHelper.java @@ -38,14 +38,14 @@ public static Calendar getDatabaseCalendar() { } public static TimeZone getDatabaseTimeZone() { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && !db.isClosed()) return db.getStorage().getConfiguration().getTimeZone(); return TimeZone.getDefault(); } public static DateFormat getDateFormatInstance() { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && !db.isClosed()) return db.getStorage().getConfiguration().getDateFormatInstance(); else @@ -53,7 +53,7 @@ public static DateFormat getDateFormatInstance() { } public static String getDateFormat() { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && !db.isClosed()) return db.getStorage().getConfiguration().getDateFormat(); else @@ -61,7 +61,7 @@ public static String getDateFormat() { } public static DateFormat getDateTimeFormatInstance() { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && !db.isClosed()) return db.getStorage().getConfiguration().getDateTimeFormatInstance(); else @@ -69,7 +69,7 @@ public static DateFormat getDateTimeFormatInstance() { } public static String getDateTimeFormat() { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && !db.isClosed()) return db.getStorage().getConfiguration().getDateTimeFormat(); else diff --git a/core/src/test/java/com/orientechnologies/orient/core/TestExceptionNotOpen.java b/core/src/test/java/com/orientechnologies/orient/core/TestExceptionNotOpen.java old mode 100644 new mode 100755 index 5e27790a728..5da0901f7bd --- a/core/src/test/java/com/orientechnologies/orient/core/TestExceptionNotOpen.java +++ b/core/src/test/java/com/orientechnologies/orient/core/TestExceptionNotOpen.java @@ -65,7 +65,7 @@ public void testExceptionNotOpenRemote() { ODatabaseDocument db = new ODatabaseDocumentTx("remote:127.0.0.1:00"); Assert.fail(); } catch (ODatabaseException e) { - Assert.assertNull(ODatabaseRecordThreadLocal.INSTANCE.getIfDefined()); + Assert.assertNull(ODatabaseRecordThreadLocal.instance().getIfDefined()); } } diff --git a/core/src/test/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentPoolOpenCloseTest.java b/core/src/test/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentPoolOpenCloseTest.java old mode 100644 new mode 100755 index dabe435f092..e796bdf2130 --- a/core/src/test/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentPoolOpenCloseTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentPoolOpenCloseTest.java @@ -21,7 +21,7 @@ public void openCloseClearThreadLocal() { try { ODatabaseDocument db = pool.acquire(); db.close(); - assertNull(ODatabaseRecordThreadLocal.INSTANCE.getIfDefined()); + assertNull(ODatabaseRecordThreadLocal.instance().getIfDefined()); } finally { pool.close(); diff --git a/core/src/test/java/com/orientechnologies/orient/core/db/tool/TestImportRewriteLinks.java b/core/src/test/java/com/orientechnologies/orient/core/db/tool/TestImportRewriteLinks.java index 3a18c349ff7..891240211e5 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/db/tool/TestImportRewriteLinks.java +++ b/core/src/test/java/com/orientechnologies/orient/core/db/tool/TestImportRewriteLinks.java @@ -19,7 +19,7 @@ public class TestImportRewriteLinks { @Test public void testNestedLinkRewrite() { // Fx for remove dirty database in the thread local - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); OIndex mapper = Mockito.mock(OIndex.class); Mockito.when(mapper.get(new ORecordId(10, 4))).thenReturn(new ORecordId(10, 3)); diff --git a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentFieldConversionTest.java b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentFieldConversionTest.java old mode 100644 new mode 100755 index e531a8f6ae2..44dced267b6 --- a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentFieldConversionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentFieldConversionTest.java @@ -74,7 +74,7 @@ public void before() { @Test public void testDateToSchemaConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Calendar calendare = Calendar.getInstance(); calendare.set(Calendar.MILLISECOND, 0); Date date = calendare.getTime(); @@ -101,12 +101,12 @@ public void testDateToSchemaConversion() { assertTrue(doc.field("date") instanceof Date); assertEquals(20304L, ((Date) doc.field("date")).getTime()); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralToSchemaConvertionInteger() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("integer", 2L); assertTrue(doc.field("integer") instanceof Integer); @@ -131,13 +131,13 @@ public void testLiteralToSchemaConvertionInteger() { // doc.field("integer", true); // assertTrue(doc.field("integer") instanceof Integer); // assertEquals(1, doc.field("integer")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralToSchemaConvertionString() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("string", 1); @@ -163,12 +163,12 @@ public void testLiteralToSchemaConvertionString() { doc.field("string", true); assertTrue(doc.field("string") instanceof String); assertEquals("true", doc.field("string")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralToSchemaConvertionFloat() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("float", 1); @@ -194,12 +194,12 @@ public void testLiteralToSchemaConvertionFloat() { // doc.field("float", true); // assertTrue(doc.field("float") instanceof Float); // assertEquals(1f, doc.field("float")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralToSchemaConvertionDouble() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("double", 1); @@ -225,12 +225,12 @@ public void testLiteralToSchemaConvertionDouble() { // doc.field("double", true); // assertTrue(doc.field("double") instanceof Double); // assertEquals(1d, doc.field("double")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralToSchemaConvertionLong() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("long", 1); @@ -256,12 +256,12 @@ public void testLiteralToSchemaConvertionLong() { // doc.field("long", true); // assertTrue(doc.field("long") instanceof Long); // assertEquals(1, doc.field("long")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralToSchemaConvertionBoolean() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("boolean", 0); @@ -287,12 +287,12 @@ public void testLiteralToSchemaConvertionBoolean() { doc.field("boolean", new BigDecimal("6")); assertTrue(doc.field("boolean") instanceof Boolean); assertEquals(true, doc.field("boolean")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralToSchemaConvertionDecimal() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("decimal", 0); @@ -318,12 +318,12 @@ public void testLiteralToSchemaConvertionDecimal() { doc.field("boolean", new BigDecimal("6")); assertTrue(doc.field("boolean") instanceof Boolean); assertEquals(true, doc.field("boolean")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testConversionAlsoWithWrongType() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(clazz); doc.field("float", 2, OType.INTEGER); @@ -341,12 +341,12 @@ public void testConversionAlsoWithWrongType() { doc.field("long", 1d, OType.DOUBLE); assertTrue(doc.field("long") instanceof Long); assertEquals(1L, doc.field("long")); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testLiteralConversionAfterSchemaSet() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(); doc.field("float", 1); @@ -380,13 +380,13 @@ public void testLiteralConversionAfterSchemaSet() { assertTrue(doc.field("date") instanceof Date); assertEquals(20304L, ((Date) doc.field("date")).getTime()); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @SuppressWarnings({ "rawtypes" }) @Test public void testListByteCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("byteList", values); @@ -409,13 +409,13 @@ public void testListByteCoversion() { for (int i = 1; i < 7; i++) { assertTrue(set.contains((byte) i)); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test @SuppressWarnings({ "rawtypes" }) public void testCollectionIntegerCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("integerList", values); @@ -439,13 +439,13 @@ public void testCollectionIntegerCoversion() { assertTrue(set.contains(i)); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test @SuppressWarnings({ "rawtypes" }) public void testCollectionLongCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("longList", values); @@ -469,13 +469,13 @@ public void testCollectionLongCoversion() { assertTrue(set.contains((long) i)); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void testCollectionBooleanCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("booleanList", values); @@ -512,13 +512,13 @@ public void testCollectionBooleanCoversion() { assertEquals(1, set.size()); assertTrue(set.iterator().next() instanceof Boolean); assertTrue((Boolean) set.iterator().next()); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void testCollectionStringCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("stringList", values); @@ -553,7 +553,7 @@ public void testCollectionStringCoversion() { } assertTrue(contain); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -571,7 +571,7 @@ private void fillSet(Set set) { @Test @SuppressWarnings({ "rawtypes" }) public void testCollectionFloatCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("floatList", values); @@ -596,7 +596,7 @@ public void testCollectionFloatCoversion() { assertTrue(set.contains(new Float(i))); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -615,7 +615,7 @@ private void fillList(List values) { @Test @SuppressWarnings({ "rawtypes" }) public void testCollectionDoubleCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("doubleList", values); @@ -640,13 +640,13 @@ public void testCollectionDoubleCoversion() { assertTrue(set.contains(new Double(i))); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test @SuppressWarnings({ "rawtypes" }) public void testCollectionDecimalCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("decimalList", values); @@ -676,13 +676,13 @@ public void testCollectionDecimalCoversion() { assertTrue(contain); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void testCollectionDateCoversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List values = new ArrayList(); ODocument doc = new ODocument(clazz); doc.field("dateList", values); @@ -716,12 +716,12 @@ public void testCollectionDateCoversion() { assertTrue(set.contains(new Date(i))); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapIntegerConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("integerMap", values); @@ -732,12 +732,12 @@ public void testMapIntegerConversion() { assertTrue(val instanceof Integer); assertEquals((Integer) 1, val); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapLongConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("longMap", values); @@ -748,12 +748,12 @@ public void testMapLongConversion() { assertTrue(val instanceof Long); assertEquals((Long) 1L, val); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapByteConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("byteMap", values); @@ -764,12 +764,12 @@ public void testMapByteConversion() { assertTrue(val instanceof Byte); assertEquals((byte) 1, val); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapFloatConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("floatMap", values); @@ -780,12 +780,12 @@ public void testMapFloatConversion() { assertTrue(val instanceof Float); assertEquals((Float) 1f, val); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapDoubleConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("doubleMap", values); @@ -796,12 +796,12 @@ public void testMapDoubleConversion() { assertTrue(val instanceof Double); assertEquals((Double) 1d, val); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapDecimalConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("decimalMap", values); @@ -812,12 +812,12 @@ public void testMapDecimalConversion() { assertTrue(val instanceof BigDecimal); assertTrue(val.toString().contains("1")); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapStringConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("stringMap", values); @@ -828,12 +828,12 @@ public void testMapStringConversion() { assertTrue(val instanceof String); assertTrue(val.toString().contains("1")); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @Test public void testMapDateConversion() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); Map values = new HashMap(); ODocument doc = new ODocument(clazz); doc.field("dateMap", values); @@ -850,7 +850,7 @@ public void testMapDateConversion() { assertTrue(val instanceof Date); assertEquals(1, ((Date) val).getTime()); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } private void fillMap(Map values) { diff --git a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemafullSerializationTest.java b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemafullSerializationTest.java old mode 100644 new mode 100755 index 92542d2de22..d4f8db1bbbb --- a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemafullSerializationTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemafullSerializationTest.java @@ -132,7 +132,7 @@ public void after() { @Test public void testSimpleSerialization() { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocument); + ODatabaseRecordThreadLocal.instance().set(databaseDocument); ODocument document = new ODocument(simple); document.field(STRING_FIELD, NAME); @@ -165,7 +165,7 @@ public void testSimpleSerialization() { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testSimpleLiteralList() { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocument); + ODatabaseRecordThreadLocal.instance().set(databaseDocument); ODocument document = new ODocument(embSimp); List strings = new ArrayList(); strings.add("a"); @@ -255,7 +255,7 @@ public void testSimpleLiteralList() { @Test public void testSimpleMapStringLiteral() { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocument); + ODatabaseRecordThreadLocal.instance().set(databaseDocument); ODocument document = new ODocument(embMapSimple); Map mapString = new HashMap(); @@ -311,7 +311,7 @@ public void testSimpleMapStringLiteral() { @Test public void testSimpleEmbeddedDoc() { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocument); + ODatabaseRecordThreadLocal.instance().set(databaseDocument); ODocument document = new ODocument(simple); ODocument embedded = new ODocument(address); embedded.field(NAME, "test"); @@ -331,7 +331,7 @@ public void testSimpleEmbeddedDoc() { @Test public void testUpdateBooleanWithPropertyTypeAny() { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocument); + ODatabaseRecordThreadLocal.instance().set(databaseDocument); ODocument document = new ODocument(simple); document.field(ANY_FIELD, false); @@ -351,7 +351,7 @@ public void testUpdateBooleanWithPropertyTypeAny() { @Test public void simpleTypeKeepingTest() { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocument); + ODatabaseRecordThreadLocal.instance().set(databaseDocument); ODocument document = new ODocument(); document.field("name", "test"); diff --git a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessBinarySerializationTest.java b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessBinarySerializationTest.java old mode 100644 new mode 100755 index 4653673028a..cd3061f843f --- a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessBinarySerializationTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessBinarySerializationTest.java @@ -85,7 +85,7 @@ public ODocumentSchemalessBinarySerializationTest() { @Test public void testSimpleSerialization() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); document.field("name", "name"); @@ -154,7 +154,7 @@ public void testSimpleSerialization() { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testSimpleLiteralArray() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); String[] strings = new String[3]; strings[0] = "a"; @@ -249,7 +249,7 @@ public void testSimpleLiteralArray() { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testSimpleLiteralList() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); List strings = new ArrayList(); strings.add("a"); @@ -340,7 +340,7 @@ public void testSimpleLiteralList() { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testSimpleLiteralSet() throws InterruptedException { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); Set strings = new HashSet(); strings.add("a"); @@ -464,7 +464,7 @@ public void testLinkCollections() { @Test public void testSimpleEmbeddedDoc() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); ODocument embedded = new ODocument(); embedded.field("name", "test"); @@ -482,7 +482,7 @@ public void testSimpleEmbeddedDoc() { @Test public void testSimpleMapStringLiteral() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); Map mapString = new HashMap(); @@ -543,7 +543,7 @@ public void testSimpleMapStringLiteral() { @Test public void testlistOfList() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); List> list = new ArrayList>(); List ls = new ArrayList(); @@ -561,7 +561,7 @@ public void testlistOfList() { @Test public void testArrayOfArray() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); String[][] array = new String[1][]; String[] ls = new String[2]; @@ -583,7 +583,7 @@ public void testArrayOfArray() { @Test public void testEmbeddedListOfEmbeddedMap() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); List> coll = new ArrayList>(); @@ -604,7 +604,7 @@ public void testEmbeddedListOfEmbeddedMap() { @Test public void testMapOfEmbeddedDocument() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -663,7 +663,7 @@ public void testDocumentWithClassName() { @Test public void testDocumentWithCostum() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); document.field("test", "test"); document.field("custom", new Custom()); @@ -677,7 +677,7 @@ public void testDocumentWithCostum() { @Test public void testDocumentWithCostumDocument() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); document.field("test", "test"); document.field("custom", new CustomDocument()); @@ -695,7 +695,7 @@ private class WrongData { @Test(expectedExceptions = OSerializationException.class) private void testSetOfWrongData() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -708,7 +708,7 @@ private void testSetOfWrongData() { @Test(expectedExceptions = OSerializationException.class) private void testListOfWrongData() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -721,7 +721,7 @@ private void testListOfWrongData() { @Test(expectedExceptions = OSerializationException.class) private void testMapOfWrongData() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -734,7 +734,7 @@ private void testMapOfWrongData() { @Test(expectedExceptions = ClassCastException.class) private void testLinkSetOfWrongData() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -747,7 +747,7 @@ private void testLinkSetOfWrongData() { @Test(expectedExceptions = ClassCastException.class) private void testLinkListOfWrongData() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -760,7 +760,7 @@ private void testLinkListOfWrongData() { @Test(expectedExceptions = ClassCastException.class) private void testLinkMapOfWrongData() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -773,7 +773,7 @@ private void testLinkMapOfWrongData() { @Test(expectedExceptions = OSerializationException.class) private void testFieldWrongData() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); @@ -785,7 +785,7 @@ private void testFieldWrongData() { @Test private void testCollectionOfEmbeddedDocument() { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); ODocument document = new ODocument(); diff --git a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessSerializationTest.java b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessSerializationTest.java old mode 100644 new mode 100755 index 2ea77679885..fe0c49f90e2 --- a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessSerializationTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSchemalessSerializationTest.java @@ -41,7 +41,7 @@ public ODocumentSchemalessSerializationTest() { public void before() { defaultSerializer = ODatabaseDocumentTx.getDefaultSerializer(); ODatabaseDocumentTx.setDefaultSerializer(serializer); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } @AfterMethod diff --git a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSerializationPersistentTest.java b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSerializationPersistentTest.java index e270eb243ec..3cfdb36444b 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSerializationPersistentTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/record/impl/ODocumentSerializationPersistentTest.java @@ -78,7 +78,7 @@ public void testSerialization() throws Exception { @Test public void testRidBagInEmbeddedDocument() { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); ODocument doc = new ODocument(); ORidBag rids = new ORidBag(); rids.add(new ORecordId(2, 3)); diff --git a/core/src/test/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLUpdateTest.java b/core/src/test/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLUpdateTest.java old mode 100644 new mode 100755 index 306ebe3ccac..9992163a1ff --- a/core/src/test/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLUpdateTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLUpdateTest.java @@ -218,7 +218,7 @@ public void testUpdateParamDate() throws Exception { public void testBooleanListNamedParameter() { ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:testBooleanListNamedParameter"); try { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); db.create(); db.getMetadata().getSchema().createClass("test"); diff --git a/core/src/test/java/com/orientechnologies/orient/core/sql/functions/sql/OFunctionSqlTest.java b/core/src/test/java/com/orientechnologies/orient/core/sql/functions/sql/OFunctionSqlTest.java old mode 100644 new mode 100755 index 4a33c2eb81c..dfd6cea3f89 --- a/core/src/test/java/com/orientechnologies/orient/core/sql/functions/sql/OFunctionSqlTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/sql/functions/sql/OFunctionSqlTest.java @@ -23,7 +23,7 @@ public void functionSqlWithParameters() { ODatabaseDocument db = new ODatabaseDocumentTx("memory:functionSqlWithParameters"); db.create(); - // ODatabaseRecordThreadLocal.INSTANCE.set(db); + // ODatabaseRecordThreadLocal.instance().set(db); ODocument doc1 = new ODocument("Test"); doc1.field("name", "Enrico"); db.save(doc1); @@ -55,7 +55,7 @@ public void functionSqlWithInnerFunctionJs() { ODatabaseDocument db = new ODatabaseDocumentTx("memory:functionSqlWithInnerFunctionJs"); db.create(); - // ODatabaseRecordThreadLocal.INSTANCE.set(db); + // ODatabaseRecordThreadLocal.instance().set(db); ODocument doc1 = new ODocument("Test"); doc1.field("name", "Enrico"); db.save(doc1); diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWAL.java b/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWAL.java index 5a92c85abc8..e5f3a9a2409 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWAL.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWAL.java @@ -196,7 +196,7 @@ else if (storageFile.getName().equals("baseLocalPaginatedStorageRestoreFromWAL.2 } private void createSchema(ODatabaseDocumentTx databaseDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocumentTx); + ODatabaseRecordThreadLocal.instance().set(databaseDocumentTx); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass testOneClass = schema.createClass("TestOne"); diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWALAndAddAdditionalRecords.java b/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWALAndAddAdditionalRecords.java index 742b1a34060..c400b4b5db7 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWALAndAddAdditionalRecords.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreFromWALAndAddAdditionalRecords.java @@ -192,7 +192,7 @@ else if (fileToCopy.endsWith("baseLocalPaginatedStorageRestoreFromWALAndAddAddit } private void createSchema(ODatabaseDocumentTx databaseDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocumentTx); + ODatabaseRecordThreadLocal.instance().set(databaseDocumentTx); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass testOneClass = schema.createClass("TestOne"); @@ -229,7 +229,7 @@ public Void call() throws Exception { Random random = new Random(seed); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); try { List testTwoList = new ArrayList(); @@ -305,19 +305,19 @@ public Void call() throws Exception { } private void saveDoc(ODocument document) { - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); ODocument testDoc = new ODocument(); document.copyTo(testDoc); document.save(); if (testDB != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); testDoc.save(); Assert.assertEquals(testDoc.getIdentity(), document.getIdentity()); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); } } @@ -325,11 +325,11 @@ private void deleteDoc(ORID rid) { baseDB.delete(rid); if (testDB != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); Assert.assertNotNull(testDB.load(rid)); testDB.delete(rid); Assert.assertNull(testDB.load(rid)); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); } } } diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreTx.java b/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreTx.java index 6e39c2d7dd9..34b35e9987c 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreTx.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageRestoreTx.java @@ -191,7 +191,7 @@ private static void copyFile(String from, String to) throws IOException { } private void createSchema(ODatabaseDocumentTx databaseDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(databaseDocumentTx); + ODatabaseRecordThreadLocal.instance().set(databaseDocumentTx); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass testOneClass = schema.createClass("TestOne"); diff --git a/distributed/pom.xml b/distributed/pom.xml index 47cb5136f00..da5a67e9edc 100755 --- a/distributed/pom.xml +++ b/distributed/pom.xml @@ -42,7 +42,7 @@ 1.6 com.orientechnologies.orient.server.OServerMain com.hazelcast.*;resolution:=optional,com.tinkerpop.*;resolution:=optional,* - com.orientechnologies.orient.server.hazelcast.* + com.orientechnologies.orient.server.hazelcast.*,com.orientechnologies.orient.server.distributed.impl.* UTF-8 -ea -Xmx2048m -XX:MaxDirectMemorySize=512g -Dstorage.diskCache.bufferSize=4096 -Dindex.flushAfterCreate=false -Dstorage.makeFullCheckpointAfterCreate=false diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedAbstractPlugin.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedAbstractPlugin.java index 5931fe17950..2100c3bd254 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedAbstractPlugin.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedAbstractPlugin.java @@ -295,7 +295,7 @@ public void onOpen(final ODatabaseInternal iDatabase) { if (status != NODE_STATUS.ONLINE && status != NODE_STATUS.STARTING) return; - final ODatabaseDocumentInternal currDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal currDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final String dbName = iDatabase.getName(); @@ -333,7 +333,7 @@ public void onOpen(final ODatabaseInternal iDatabase) { } finally { // RESTORE ORIGINAL DATABASE INSTANCE IN TL - ODatabaseRecordThreadLocal.INSTANCE.set(currDb); + ODatabaseRecordThreadLocal.instance().set(currDb); } } @@ -560,7 +560,7 @@ public ODistributedResponse sendRequest(final String iDatabaseName, final Collec final ODistributedRequest req = new ODistributedRequest(this, nodeId, reqId, iDatabaseName, iTask); - final ODatabaseDocument currentDatabase = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocument currentDatabase = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (currentDatabase != null && currentDatabase.getUser() != null) // SET CURRENT DATABASE NAME req.setUserRID((ORecordId) currentDatabase.getUser().getIdentity().getIdentity()); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedDatabaseImpl.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedDatabaseImpl.java index 3fface68670..e5a846132b7 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedDatabaseImpl.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedDatabaseImpl.java @@ -621,7 +621,7 @@ public boolean lockRecord(final ORID rid, final ODistributedRequestId requestId, // USE THE EXISTENT lock.record = currentRecord; else if (rid.isPersistent()) { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) lock.record = db.getStorage().getUnderlying().readRecord((ORecordId) rid, null, false, false, null).getResult(); } @@ -704,7 +704,7 @@ public boolean forceLockRecord(final ORID rid, final ODistributedRequestId reque if (lockedCtx != null) { // CANCEL THE ENTIRE TX/CONTEXT/REQ-ID - lockedCtx.cancel(manager, ODatabaseRecordThreadLocal.INSTANCE.get()); + lockedCtx.cancel(manager, ODatabaseRecordThreadLocal.instance().get()); } else { // ABORT SINGLE REQUEST @@ -723,7 +723,7 @@ public boolean forceLockRecord(final ORID rid, final ODistributedRequestId reque lock.record = currentRecord; else if (rid.isPersistent()) { // RELOAD IT - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) lock.record = db.getStorage().getUnderlying().readRecord((ORecordId) rid, null, false, false, null).getResult(); } diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedOutput.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedOutput.java index 2c8ff3ec5dc..c1cf9893f72 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedOutput.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedOutput.java @@ -523,7 +523,7 @@ public void onMessage(final String text, final Object... args) { } }); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && db.isClosed()) db = null; diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java index dcfb56844fa..0c141979ef6 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java @@ -336,7 +336,7 @@ public Object call(OModifiableDistributedConfiguration iArgument) { if (exec.involveSchema()) // UPDATE THE SCHEMA - dManager.propagateSchemaChanges(ODatabaseRecordThreadLocal.INSTANCE.get()); + dManager.propagateSchemaChanges(ODatabaseRecordThreadLocal.instance().get()); break; } @@ -1407,7 +1407,7 @@ public Object call() throws Exception { try { final List result = txManager - .commit((ODatabaseDocumentTx) ODatabaseRecordThreadLocal.INSTANCE.get(), iTx, callback, eventListener); + .commit((ODatabaseDocumentTx) ODatabaseRecordThreadLocal.instance().get(), iTx, callback, eventListener); if (result != null) { for (ORecordOperation r : result) { @@ -1946,7 +1946,7 @@ protected OAsyncReplicationError getAsyncReplicationError() { if (OExecutionThreadLocal.INSTANCE.get().onAsyncReplicationError != null) { final OAsyncReplicationError subCallback = OExecutionThreadLocal.INSTANCE.get().onAsyncReplicationError; - final ODatabaseDocumentTx currentDatabase = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentTx currentDatabase = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.instance().get(); final ODatabaseDocumentTx copyDatabase = currentDatabase.copy(); currentDatabase.activateOnCurrentThread(); @@ -2004,7 +2004,7 @@ void executeUndoOnLocalServer(final ODistributedRequestId reqId, final OAbstract OScenarioThreadLocal.executeAsDistributed(new Callable() { @Override public Object call() throws Exception { - ODatabaseDocumentTx database = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentTx database = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.instance().getIfDefined(); final boolean databaseAlreadyDefined; if (database == null) { @@ -2078,7 +2078,7 @@ protected String checkForCluster(final ORecord record, final String localNodeNam return null; final OCluster cl = getClusterByName(clusterName); - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final OClass cls = db.getMetadata().getSchema().getClassByClusterId(cl.getId()); String newClusterName = null; if (cls != null) { diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedTransactionManager.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedTransactionManager.java index 17e626af632..0d6b600f065 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedTransactionManager.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedTransactionManager.java @@ -289,7 +289,7 @@ protected void checkForClusterIds(final OTransaction iTx, final String localNode if (rid.getClusterId() < 1) { final String clusterName = ((OTransactionAbstract) iTx).getClusterName(op.getRecord()); if (clusterName != null) { - newRid.setClusterId(ODatabaseRecordThreadLocal.INSTANCE.get().getClusterIdByName(clusterName)); + newRid.setClusterId(ODatabaseRecordThreadLocal.instance().get().getClusterIdByName(clusterName)); iTx.updateIdentityAfterCommit(rid, newRid); } } @@ -625,7 +625,7 @@ protected List createUndoTasksFromTx(final OTransaction iTx OScenarioThreadLocal.executeAsDefault(new Callable() { @Override public Object call() throws Exception { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final ORecordOperation txEntry = db.getTransaction().getRecordEntry(rid); final ORecord record; diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/OLocalClusterWrapperStrategy.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/OLocalClusterWrapperStrategy.java index 0509c604869..fc933fde8a2 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/OLocalClusterWrapperStrategy.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/OLocalClusterWrapperStrategy.java @@ -83,7 +83,7 @@ public int getCluster(final OClass iClass, final ODocument doc) { if (!iClass.equals(cls)) throw new IllegalArgumentException("Class '" + iClass + "' is different than the configured one: " + cls); - final OStorage storage = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage(); + final OStorage storage = ODatabaseRecordThreadLocal.instance().get().getStorage(); if (!(storage instanceof ODistributedStorage)) throw new IllegalStateException("Storage is not distributed"); @@ -127,7 +127,7 @@ protected ODistributedConfiguration readConfiguration() { if (cls.isAbstract()) throw new IllegalArgumentException("Cannot create a new instance of abstract class"); - final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); int[] clusterIds = cls.getClusterIds(); final List clusterNames = new ArrayList(clusterIds.length); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OClusterRepairInfoTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OClusterRepairInfoTask.java index 609c9ff8091..12eeb9e04a8 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OClusterRepairInfoTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OClusterRepairInfoTask.java @@ -58,7 +58,7 @@ public Object execute(ODistributedRequestId requestId, final OServer iServer, OD ODistributedServerLog.debug(this, iManager.getLocalNodeName(), getNodeSource(), ODistributedServerLog.DIRECTION.IN, "Repair cluster acquiring information about cluster '%s' db=%s (reqId=%s)...", clusterName, database.getName(), requestId); - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); final ODistributedDatabase ddb = iManager.getMessageService().getDatabase(database.getName()); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCompleted2pcTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCompleted2pcTask.java old mode 100644 new mode 100755 index fcc8c7bccd4..39870bb3aa1 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCompleted2pcTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCompleted2pcTask.java @@ -80,7 +80,7 @@ public Object execute(final ODistributedRequestId msgId, final OServer iServer, .debug(this, iManager.getLocalNodeName(), getNodeSource(), DIRECTION.IN, "%s transaction db=%s originalReqId=%s...", (success ? "Committing" : fixTasks.isEmpty() ? "Rolling back" : "Fixing"), database.getName(), requestId, requestId); - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); // UNLOCK ALL LOCKS ACQUIRED IN TX final ODistributedDatabase ddb = iManager.getMessageService().getDatabase(database.getName()); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCreateRecordTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCreateRecordTask.java old mode 100644 new mode 100755 index 79852132846..4b596d51b63 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCreateRecordTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OCreateRecordTask.java @@ -71,7 +71,7 @@ public OCreateRecordTask init(final ORecord record) { init((ORecordId) record.getIdentity(), record.toStream(), record.getVersion() - 1, ORecordInternal.getRecordType(record)); if (rid.getClusterId() == ORID.CLUSTER_ID_INVALID) { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); clusterId = db.assignAndCheckCluster(record, null); // RESETTING FOR AVOID DESERIALIZATION ISSUE. ((ORecordId) record.getIdentity()).setClusterId(ORID.CLUSTER_ID_INVALID); @@ -110,7 +110,7 @@ public Object executeRecordTask(final ODistributedRequestId requestId, final OSe if (!rid.isPersistent()) throw new ODistributedException("Record " + rid + " has not been saved on owner node first (temporary rid)"); - final OPaginatedCluster cluster = (OPaginatedCluster) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() + final OPaginatedCluster cluster = (OPaginatedCluster) ODatabaseRecordThreadLocal.instance().get().getStorage() .getClusterById(rid.getClusterId()); final OPaginatedCluster.RECORD_STATUS recordStatus = cluster.getRecordStatus(rid.getClusterPosition()); @@ -123,7 +123,7 @@ public Object executeRecordTask(final ODistributedRequestId requestId, final OSe case REMOVED: { // RECYCLE THE RID AND OVERWRITE IT WITH THE NEW CONTENT getRecord(); - ODatabaseRecordThreadLocal.INSTANCE.get().recycle(record); + ODatabaseRecordThreadLocal.instance().get().recycle(record); } case ALLOCATED: @@ -222,7 +222,7 @@ public ORemoteTask getFixTask(final ODistributedRequest iRequest, ORemoteTask iO // SAME SERVER: LOAD THE RECORD FROM ANOTHER NODE final ODistributedConfiguration dCfg = dManager.getDatabaseConfiguration(iRequest.getDatabaseName()); final List nodes = dCfg - .getServers(ODatabaseRecordThreadLocal.INSTANCE.get().getClusterNameById(clusterId), dManager.getLocalNodeName()); + .getServers(ODatabaseRecordThreadLocal.instance().get().getClusterNameById(clusterId), dManager.getLocalNodeName()); final OReadRecordTask task = (OReadRecordTask) dManager.getTaskFactoryManager().getFactoryByServerNames(nodes) .createTask(OReadRecordTask.FACTORYID); @@ -247,7 +247,7 @@ public ORemoteTask getFixTask(final ODistributedRequest iRequest, ORemoteTask iO try { new OFixUpdateRecordTask().init(toUpdateRid, toUpdateRecord.toStream(), toUpdateRecord.getVersion(), ORecordInternal.getRecordType(toUpdateRecord)) - .execute(iRequest.getId(), dManager.getServerInstance(), dManager, ODatabaseRecordThreadLocal.INSTANCE.get()); + .execute(iRequest.getId(), dManager.getServerInstance(), dManager, ODatabaseRecordThreadLocal.instance().get()); } catch (Exception e) { throw OException.wrapException( new ODistributedOperationException("Cannot create record " + rid + " because assigned RID is different"), e); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ODeleteRecordTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ODeleteRecordTask.java index 3e2332cc41e..3fda0667afa 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ODeleteRecordTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ODeleteRecordTask.java @@ -175,7 +175,7 @@ public boolean isIdempotent() { public ORecord prepareUndoOperation() { if (previousRecord == null) { // READ DIRECTLY FROM THE UNDERLYING STORAGE - final OStorageOperationResult loaded = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying() + final OStorageOperationResult loaded = ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying() .readRecord(rid, null, true, false, null); if (loaded == null || loaded.getResult() == null) diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ORepairClusterTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ORepairClusterTask.java index 723e44b6551..b6b38dd9cbc 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ORepairClusterTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/ORepairClusterTask.java @@ -60,7 +60,7 @@ public Object execute(final ODistributedRequestId requestId, final OServer iServ ODistributedServerLog.debug(this, iManager.getLocalNodeName(), getNodeSource(), ODistributedServerLog.DIRECTION.IN, "Repair cluster: repairing cluster '%s' db=%s (reqId=%s)...", clusterName, database.getName(), requestId); - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); final ODistributedDatabase ddb = iManager.getMessageService().getDatabase(database.getName()); // CREATE A CONTEXT OF TX diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OSQLCommandTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OSQLCommandTask.java old mode 100644 new mode 100755 index d8f11ec2693..02452583d18 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OSQLCommandTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OSQLCommandTask.java @@ -180,7 +180,7 @@ public String toString() { @Override public ORemoteTask getUndoTask(ODistributedServerManager dManager, final ODistributedRequestId reqId, List servers) { - final OCommandRequest cmd = ODatabaseRecordThreadLocal.INSTANCE.get().command(new OCommandSQL(text)); + final OCommandRequest cmd = ODatabaseRecordThreadLocal.instance().get().command(new OCommandSQL(text)); OCommandExecutor executor = OCommandManager.instance().getExecutor((OCommandRequestInternal) cmd); executor.parse(cmd); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OTxTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OTxTask.java old mode 100644 new mode 100755 index eb370397ce0..2caf6287658 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OTxTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OTxTask.java @@ -60,7 +60,7 @@ public Object execute(final ODistributedRequestId requestId, final OServer iServ .debug(this, iManager.getLocalNodeName(), getNodeSource(), DIRECTION.IN, "Executing transaction db=%s (reqId=%s)...", database.getName(), requestId); - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); final ODistributedDatabase ddb = iManager.getMessageService().getDatabase(database.getName()); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OUpdateRecordTask.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OUpdateRecordTask.java index 53282222712..687787e15f6 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OUpdateRecordTask.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/task/OUpdateRecordTask.java @@ -235,7 +235,7 @@ public int getFactoryId() { public ORecord prepareUndoOperation() { if (previousRecord == null) { // READ DIRECTLY FROM THE UNDERLYING STORAGE - final OStorageOperationResult loaded = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying() + final OStorageOperationResult loaded = ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying() .readRecord(rid, null, true, false, null); if (loaded == null || loaded.getResult() == null) diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/sql/OCommandExecutorSQLHASyncCluster.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/sql/OCommandExecutorSQLHASyncCluster.java index 08ede318ccf..da00e905710 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/sql/OCommandExecutorSQLHASyncCluster.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/sql/OCommandExecutorSQLHASyncCluster.java @@ -203,7 +203,7 @@ else if (result instanceof Exception) { OZIPCompressionUtil.uncompressDirectory(new FileInputStream(tempFile), tempDirectory.getAbsolutePath(), null); - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); final boolean openDatabaseHere = db == null; if (db == null) db = serverInstance.openDatabase("plocal:" + dbPath, "", "", null, true); diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/hazelcast/OHazelcastPlugin.java b/distributed/src/main/java/com/orientechnologies/orient/server/hazelcast/OHazelcastPlugin.java index 525aadb108a..fed4071815c 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/hazelcast/OHazelcastPlugin.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/hazelcast/OHazelcastPlugin.java @@ -1164,7 +1164,7 @@ public void onCreate(final ODatabaseInternal iDatabase) { if (status != NODE_STATUS.ONLINE) return; - final ODatabaseDocumentInternal currDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal currDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final String dbName = iDatabase.getName(); @@ -1230,7 +1230,7 @@ public void onCreate(final ODatabaseInternal iDatabase) { } finally { // RESTORE ORIGINAL DATABASE INSTANCE IN TL - ODatabaseRecordThreadLocal.INSTANCE.set(currDb); + ODatabaseRecordThreadLocal.instance().set(currDb); } } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractDistributedConcurrentTxTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractDistributedConcurrentTxTest.java old mode 100644 new mode 100755 index 226ef1596d4..b74eebadc43 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractDistributedConcurrentTxTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractDistributedConcurrentTxTest.java @@ -173,7 +173,7 @@ protected OrientVertex createVertex(OrientBaseGraph graph, int serverId, int thr final Object result = graph.command(new OCommandSQL("create vertex Provider content {'id': '" + UUID.randomUUID().toString() + "', 'name': 'Billy" + uniqueId + "', 'surname': 'Mayes" + uniqueId + "', 'birthday': '" - + ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getDateFormatInstance().format(new Date()) + + ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateFormatInstance().format(new Date()) + "', 'children': '" + uniqueId + "', 'saved': 0}")).execute(); return (OrientVertex) result; } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterSQLGraphTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterSQLGraphTest.java old mode 100644 new mode 100755 index fc1434412fb..a84d6670037 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterSQLGraphTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterSQLGraphTest.java @@ -153,7 +153,7 @@ protected OrientVertex createVertex(OrientGraph graph, int serverId, int threadI final Object result = graph.command(new OCommandSQL( "create vertex Person content {'id': '" + UUID.randomUUID().toString() + "', 'name': 'Billy" + uniqueId - + "', 'surname': 'Mayes" + uniqueId + "', 'birthday': '" + ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() + + "', 'surname': 'Mayes" + uniqueId + "', 'birthday': '" + ODatabaseRecordThreadLocal.instance().get().getStorage() .getConfiguration().getDateFormatInstance().format(new Date()) + "', 'children': '" + uniqueId + "'}")).execute(); return (OrientVertex) result; } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterTest.java index e0705fab312..bd5646ff5bf 100755 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/AbstractServerClusterTest.java @@ -348,9 +348,9 @@ protected void executeWhen(int serverId, OCallable executeWhen(db, condition, action); } finally { if (!db.isClosed()) { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); db.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } } @@ -458,9 +458,9 @@ protected void waitFor(final int serverId, final OCallable clusterNames = new ArrayList(1); - clusterNames.add(ODatabaseRecordThreadLocal.INSTANCE.get().getClusterNameById(rid.getClusterId())); + clusterNames.add(ODatabaseRecordThreadLocal.instance().get().getClusterNameById(rid.getClusterId())); ODistributedResponse response = dManager .sendRequest(getDatabaseName(), clusterNames, Arrays.asList(servers), new OReadRecordTask().init(rid), @@ -514,7 +514,7 @@ protected ODistributedResponse createRemoteRecord(final int serverId, final ORec final ODistributedServerManager dManager = serverInstance.get(serverId).getServerInstance().getDistributedManager(); final Collection clusterNames = new ArrayList(1); - clusterNames.add(ODatabaseRecordThreadLocal.INSTANCE.get().getClusterNameById(record.getIdentity().getClusterId())); + clusterNames.add(ODatabaseRecordThreadLocal.instance().get().getClusterNameById(record.getIdentity().getClusterId())); return dManager.sendRequest(getDatabaseName(), clusterNames, Arrays.asList(servers), new OCreateRecordTask() .init((ORecordId) record.getIdentity(), record.toStream(), record.getVersion(), ORecordInternal.getRecordType(record)), @@ -525,7 +525,7 @@ protected ODistributedResponse updateRemoteRecord(final int serverId, final ORec final ODistributedServerManager dManager = serverInstance.get(serverId).getServerInstance().getDistributedManager(); final Collection clusterNames = new ArrayList(1); - clusterNames.add(ODatabaseRecordThreadLocal.INSTANCE.get().getClusterNameById(record.getIdentity().getClusterId())); + clusterNames.add(ODatabaseRecordThreadLocal.instance().get().getClusterNameById(record.getIdentity().getClusterId())); return dManager.sendRequest(getDatabaseName(), clusterNames, Arrays.asList(servers), new OFixUpdateRecordTask() .init((ORecordId) record.getIdentity(), record.toStream(), record.getVersion(), ORecordInternal.getRecordType(record)), @@ -536,7 +536,7 @@ protected ODistributedResponse deleteRemoteRecord(final int serverId, final ORec final ODistributedServerManager dManager = serverInstance.get(serverId).getServerInstance().getDistributedManager(); final Collection clusterNames = new ArrayList(1); - clusterNames.add(ODatabaseRecordThreadLocal.INSTANCE.get().getClusterNameById(rid.getClusterId())); + clusterNames.add(ODatabaseRecordThreadLocal.instance().get().getClusterNameById(rid.getClusterId())); return dManager.sendRequest(getDatabaseName(), clusterNames, Arrays.asList(servers), new OFixCreateRecordTask().init(rid, -1), dManager.getNextMessageIdCounter(), ODistributedRequest.EXECUTION_MODE.RESPONSE, null, null, null); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/AbstractScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/AbstractScenarioTest.java old mode 100644 new mode 100755 index ed668bd3561..5be533fc2c8 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/AbstractScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/AbstractScenarioTest.java @@ -51,14 +51,14 @@ public abstract class AbstractScenarioTest extends AbstractServerClusterInsertTe protected ODocument loadRecord(ODatabaseDocumentTx database, int serverId, int threadId, int i) { final String uniqueId = serverId + "-" + threadId + "-" + i; - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); List result = database .query(new OSQLSynchQuery("select from Person where name = 'Billy" + uniqueId + "'")); if (result.size() == 0) assertTrue("No record found with name = 'Billy" + uniqueId + "'!", false); else if (result.size() > 1) assertTrue(result.size() + " records found with name = 'Billy" + uniqueId + "'!", false); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); return result.get(0); } @@ -277,9 +277,9 @@ protected void checkWritesAboveCluster(List checkConsistencyOnServers } finally { for (ODatabaseDocumentTx db : dbs) { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); db.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } @@ -371,7 +371,7 @@ protected ODocument retrieveRecord(String dbUrl, String uniqueId, boolean return try { // dbServer.getLocalCache().invalidate(); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer); + ODatabaseRecordThreadLocal.instance().set(dbServer); dbServer.getMetadata().getSchema().reload(); @@ -398,7 +398,7 @@ protected ODocument retrieveRecord(String dbUrl, String uniqueId, boolean return return doc; } finally { dbServer.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } @@ -407,14 +407,14 @@ private long selectCountInClass(String dbUrl, String className) { ODatabaseDocumentTx dbServer = poolFactory.get(dbUrl, "admin", "admin").acquire(); try { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer); + ODatabaseRecordThreadLocal.instance().set(dbServer); List result = dbServer.query(new OSQLSynchQuery("select count(*) from " + className)); numberOfRecords = ((Number) result.get(0).field("count")).longValue(); } catch (Exception e) { e.printStackTrace(); } finally { dbServer.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } return numberOfRecords; @@ -525,9 +525,9 @@ protected void waitFor(final int serverId, OCallable checkConsisten } finally { for (OrientBaseGraph db : dbs) { - ODatabaseRecordThreadLocal.INSTANCE.set(db.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(db.getRawGraph()); db.getRawGraph().close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/BasicShardingNoReplicaScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/BasicShardingNoReplicaScenarioTest.java old mode 100644 new mode 100755 index 0fd4e6e3bd3..b39ca72c34e --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/BasicShardingNoReplicaScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/BasicShardingNoReplicaScenarioTest.java @@ -114,7 +114,7 @@ public void executeTest() throws Exception { try { System.out.print("Checking that records on server3 are not available in the cluster..."); graphNoTx = localFactory.getNoTx(); - ODatabaseRecordThreadLocal.INSTANCE.set(graphNoTx.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(graphNoTx.getRawGraph()); final String uniqueId = "client_asia-s2-t10-v0"; Iterable it = graphNoTx.command(new OCommandSQL("select from Client where name = '" + uniqueId + "'")).execute(); List result = new LinkedList(); @@ -124,7 +124,7 @@ public void executeTest() throws Exception { assertEquals(0, result.size()); System.out.println("Done"); graphNoTx.getRawGraph().close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } catch (Exception e) { e.printStackTrace(); fail(); @@ -143,7 +143,7 @@ public void executeTest() throws Exception { System.out.print("Checking server3 status by querying a record inserted on it..."); localFactory = new OrientGraphFactory("plocal:target/server2/databases/" + getDatabaseName()); graphNoTx = localFactory.getNoTx(); - ODatabaseRecordThreadLocal.INSTANCE.set(graphNoTx.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(graphNoTx.getRawGraph()); final String uniqueId = "client_asia-s2-t10-v0"; Iterable it = graphNoTx.command(new OCommandSQL("select from Client where name = '" + uniqueId + "'")).execute(); List result = new LinkedList(); @@ -152,7 +152,7 @@ public void executeTest() throws Exception { } assertEquals(1, result.size()); graphNoTx.getRawGraph().close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } catch (Exception e) { e.printStackTrace(); fail(e.toString()); @@ -167,9 +167,9 @@ public void executeTest() throws Exception { fail(e.toString()); } finally { if (!graphNoTx.getRawGraph().isClosed()) { - ODatabaseRecordThreadLocal.INSTANCE.set(graphNoTx.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(graphNoTx.getRawGraph()); graphNoTx.getRawGraph().close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DBCreationAndUpdateOneNodeScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DBCreationAndUpdateOneNodeScenarioTest.java old mode 100644 new mode 100755 index a4e95ddf4f6..1545040c685 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DBCreationAndUpdateOneNodeScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DBCreationAndUpdateOneNodeScenarioTest.java @@ -61,7 +61,7 @@ public void executeTest() throws Exception { Thread.sleep(1000); // checking the db was created both on server2 and server3 - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); ODatabaseDocumentTx dbServer2 = poolFactory.get(url2, "admin", "admin").acquire(); try { assertNotNull(dbServer2); @@ -74,7 +74,7 @@ public void executeTest() throws Exception { dbServer2.close(); } - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); ODatabaseDocumentTx dbServer3 = poolFactory.get(url3, "admin", "admin").acquire(); try { assertNotNull(dbServer3); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DeleteAndLazarusScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DeleteAndLazarusScenarioTest.java old mode 100644 new mode 100755 index 04f6d7fc270..e432f2cfee0 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DeleteAndLazarusScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/DeleteAndLazarusScenarioTest.java @@ -83,7 +83,7 @@ public void executeTest() throws Exception { // inserting record r1 and checking consistency on all the servers try { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); System.out.print("Inserting record r1..."); new ODocument("Person").fields("id", "R001", "firstName", "Luke", "lastName", "Skywalker").save(); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/FaultDuringWritingWithOperationRedirectScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/FaultDuringWritingWithOperationRedirectScenarioTest.java old mode 100644 new mode 100755 index d7880d46bb5..2d3f07b1fd7 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/FaultDuringWritingWithOperationRedirectScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/FaultDuringWritingWithOperationRedirectScenarioTest.java @@ -89,7 +89,7 @@ public void executeTest() throws Exception { // TO-CHANGE // writes on server3 (remote access) while a task is monitoring the inserted records amount and shutdown server // after 1/3 of total number of records to insert, and restarting it when 2/3 of records were inserted. - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); Callable shutdownAndRestartTask = new ShutdownAndRestartServer(serverInstance.get(2), dbServerUrl1, "net-fault"); final ExecutorService executor = Executors.newSingleThreadExecutor(); Future f = executor.submit(shutdownAndRestartTask); @@ -101,7 +101,7 @@ public void executeTest() throws Exception { // TO-CHANGE waitForMultipleInsertsInClassPropagation(500L, "Person", 5000L); // preliminar check - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3); + ODatabaseRecordThreadLocal.instance().set(dbServer3); result = dbServer3.query(new OSQLSynchQuery("select from Person")); assertEquals(500, result.size()); @@ -115,9 +115,9 @@ public void executeTest() throws Exception { // TO-CHANGE } finally { if(!dbServer3.isClosed()) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3); + ODatabaseRecordThreadLocal.instance().set(dbServer3); dbServer3.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } } @@ -159,7 +159,7 @@ public Void call() throws Exception { while (true) { // check inserted record amount - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); long insertedRecords = dbServer1.countClass("Person"); if(insertedRecords > 2*totalNumberOfRecordsToInsert/3) { diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IncrementalRestartScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IncrementalRestartScenarioTest.java old mode 100644 new mode 100755 index b80a9cb6070..614b0857b59 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IncrementalRestartScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IncrementalRestartScenarioTest.java @@ -153,7 +153,7 @@ public Void call() throws Exception { assertFalse(serverInstance.get(2).isActive()); // writes on server1 - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); try { new ODocument("Person").fields("name", "Jay", "surname", "Miner").save(); new ODocument("Person").fields("name", "Luke", "surname", "Skywalker").save(); @@ -212,9 +212,9 @@ public Void call() throws Exception { fail(e.getMessage()); } finally { if (dbServer1 != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); dbServer1.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } @@ -273,7 +273,7 @@ public Void call() throws Exception { assertFalse(serverInstance.get(2).isActive()); // writes on server1 - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); try { System.out.println("Inserting 3 record on server1..."); new ODocument("Person").fields("name", "Darth", "surname", "Vader").save(); @@ -330,9 +330,9 @@ public Void call() throws Exception { fail(e.getMessage()); } finally { if (dbServer1 != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); dbServer1.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IsolatedNodeRejoinScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IsolatedNodeRejoinScenarioTest.java old mode 100644 new mode 100755 index e6dad8de0c2..a0c89a742f2 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IsolatedNodeRejoinScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/IsolatedNodeRejoinScenarioTest.java @@ -138,13 +138,13 @@ public Boolean call(ODatabaseDocumentTx db) { @Override protected ODocument retrieveRecord(String dbUrl, String uniqueId) { ODatabaseDocumentTx dbServer = poolFactory.get(dbUrl, "admin", "admin").acquire(); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer); + ODatabaseRecordThreadLocal.instance().set(dbServer); List result = dbServer.query(new OSQLSynchQuery("select from Hero where id = '" + uniqueId + "'")); if (result.size() == 0) fail("No record found with id = '" + uniqueId + "'!"); else if (result.size() > 1) fail(result.size() + " records found with id = '" + uniqueId + "'!"); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); return result.get(0); } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/MultipleDBAlignmentOnNodesJoining.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/MultipleDBAlignmentOnNodesJoining.java old mode 100644 new mode 100755 index d56c62c33a8..bc16e3d5895 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/MultipleDBAlignmentOnNodesJoining.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/MultipleDBAlignmentOnNodesJoining.java @@ -157,7 +157,7 @@ protected void onAfterDatabaseCreation(final OrientBaseGraph db, String database String databaseName = db.getRawGraph().getName(); System.out.println("Creating database schema for " + databaseName + "..."); - ODatabaseRecordThreadLocal.INSTANCE.set(db.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(db.getRawGraph()); // building basic schema OClass personClass = db.getRawGraph().getMetadata().getSchema().createClass("Person"); @@ -170,7 +170,7 @@ protected void onAfterDatabaseCreation(final OrientBaseGraph db, String database OClass person = schema.getClass("Person"); idx = person.createIndex("Person.name", OClass.INDEX_TYPE.UNIQUE, "name"); - // ODatabaseRecordThreadLocal.INSTANCE.set(null); + // ODatabaseRecordThreadLocal.instance().set(null); // populating db try { @@ -275,9 +275,9 @@ protected void compareDBOnServer(List checkConsistencyOnServers, Stri } finally { for (ODatabaseDocumentTx db : dbs) { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); db.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } @@ -285,14 +285,14 @@ protected void compareDBOnServer(List checkConsistencyOnServers, Stri protected ODocument loadRecord(ODatabaseDocumentTx database, int i) { final String uniqueId = database.getName() + "-" + i; - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); List result = database .query(new OSQLSynchQuery("select from Person where name = 'Billy" + uniqueId + "'")); if (result.size() == 0) assertTrue("No record found with name = 'Billy" + uniqueId + "'!", false); else if (result.size() > 1) assertTrue(result.size() + " records found with name = 'Billy" + uniqueId + "'!", false); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); return result.get(0); } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/NodeInDeadlockScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/NodeInDeadlockScenarioTest.java old mode 100644 new mode 100755 index ac83dc813c6..44536d422ff --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/NodeInDeadlockScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/NodeInDeadlockScenarioTest.java @@ -82,7 +82,7 @@ public void executeTest() throws Exception { banner("Test with quorum = 2"); // writes on server1 and server2 - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); executeMultipleWrites(this.executeTestsOnServers, "remote", this.executeTestsOnServers); // check consistency on server1 and server2 @@ -102,9 +102,9 @@ public void executeTest() throws Exception { } finally { if (!dbServer3.isClosed()) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3); + ODatabaseRecordThreadLocal.instance().set(dbServer3); dbServer3.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/Quorum1ScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/Quorum1ScenarioTest.java old mode 100644 new mode 100755 index f9dd552d79b..fcc112c03a5 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/Quorum1ScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/Quorum1ScenarioTest.java @@ -124,13 +124,13 @@ public Boolean call(ODatabaseDocumentTx db) { @Override protected ODocument retrieveRecord(String dbUrl, String uniqueId) { ODatabaseDocumentTx dbServer = poolFactory.get(dbUrl, "admin", "admin").acquire(); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer); + ODatabaseRecordThreadLocal.instance().set(dbServer); List result = dbServer.query(new OSQLSynchQuery("select from Hero where id = '" + uniqueId + "'")); if (result.size() == 0) fail("No record found with id = '" + uniqueId + "'!"); else if (result.size() > 1) fail(result.size() + " records found with id = '" + uniqueId + "'!"); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); return result.get(0); } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ShutdownAndRestartNodeScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ShutdownAndRestartNodeScenarioTest.java old mode 100644 new mode 100755 index d208fbeefbe..b023101ec48 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ShutdownAndRestartNodeScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ShutdownAndRestartNodeScenarioTest.java @@ -133,7 +133,7 @@ public Void call() throws Exception { // trying write on server3, writes must be served from the first available node try { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3); + ODatabaseRecordThreadLocal.instance().set(dbServer3); ODocument doc = new ODocument("Person").fields("name", "Joe", "surname", "Black").save(); this.initialCount++; result = dbServer3.query(new OSQLSynchQuery("select count(*) from Person")); @@ -145,7 +145,7 @@ public Void call() throws Exception { } // writes on server1 and server2 - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); this.executeWritesOnServers.remove(2); executeMultipleWrites(this.executeWritesOnServers, "plocal", executeWritesOnServers); @@ -155,7 +155,7 @@ public Void call() throws Exception { assertTrue(serverInstance.get(2).isActive()); // check consistency - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3); + ODatabaseRecordThreadLocal.instance().set(dbServer3); dbServer3.getMetadata().getSchema().reload(); result = dbServer3.query(new OSQLSynchQuery("select count(*) from Person")); assertEquals(1, result.size()); @@ -167,9 +167,9 @@ public Void call() throws Exception { fail(e.getMessage()); } finally { if (dbServer3 != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3); + ODatabaseRecordThreadLocal.instance().set(dbServer3); dbServer3.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } @@ -239,7 +239,7 @@ public Void call() throws Exception { // single write System.out.print("Insert operation in the database..."); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); try { new ODocument("Person").fields("id", "L-001", "name", "John", "surname", "Black").save(); fail("Error: record inserted with 2 server running and writeWuorum=3."); @@ -253,12 +253,12 @@ public Void call() throws Exception { assertEquals(0, result.size()); final ODatabaseDocumentTx dbServer2 = new ODatabaseDocumentTx(databaseUrl2).open("admin", "admin"); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer2); + ODatabaseRecordThreadLocal.instance().set(dbServer2); result = dbServer2.query(new OSQLSynchQuery("select from Person where id='L-001'")); assertEquals(0, result.size()); System.out.println("Done.\n"); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); // restarting server3 serverInstance.get(2).startServer(getDistributedServerConfiguration(serverInstance.get(SERVERS - 1))); @@ -281,21 +281,21 @@ public Void call() throws Exception { System.out.println("Checking consistency..."); // check consistency - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); dbServer1.getMetadata().getSchema().reload(); result = dbServer1.query(new OSQLSynchQuery("select from Person")); assertEquals(1500, result.size()); checkWritesAboveCluster(serverInstance, executeWritesOnServers); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } finally { if (dbServer1 != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); dbServer1.close(); - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordDeleteWithTransactionsOnMultipleServersScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordDeleteWithTransactionsOnMultipleServersScenarioTest.java old mode 100644 new mode 100755 index 1cc2a087b96..192bc61490b --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordDeleteWithTransactionsOnMultipleServersScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordDeleteWithTransactionsOnMultipleServersScenarioTest.java @@ -72,7 +72,7 @@ public void executeTest() throws Exception { ODatabaseDocumentTx dbServer3 = poolFactory.get(getDatabaseURL(serverInstance.get(2)), "admin", "admin").acquire(); // inserts record1 - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); ODocument record1Server1 = new ODocument("Person").fromMap(hanFields); record1Server1.save(); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordUpdateWithTransactionsOnMultipleServersScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordUpdateWithTransactionsOnMultipleServersScenarioTest.java old mode 100644 new mode 100755 index 8c470076379..8487f8758f8 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordUpdateWithTransactionsOnMultipleServersScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/ThreeClientsRecordUpdateWithTransactionsOnMultipleServersScenarioTest.java @@ -92,7 +92,7 @@ public void executeTest() throws Exception { ODatabaseDocumentTx dbServer3 = poolFactory.get(getDatabaseURL(serverInstance.get(2)), "admin", "admin").acquire(); // inserts record1 - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); ODocument record1Server1 = new ODocument("Person").fromMap(hanFields); record1Server1.save(); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateDuringRetryWithTransactionsOnMultipleServersScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateDuringRetryWithTransactionsOnMultipleServersScenarioTest.java old mode 100644 new mode 100755 index c32dac83bba..3658b0f71dd --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateDuringRetryWithTransactionsOnMultipleServersScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateDuringRetryWithTransactionsOnMultipleServersScenarioTest.java @@ -82,7 +82,7 @@ public void executeTest() throws Exception { ODatabaseDocumentTx dbServer2 = poolFactory.get(getDatabaseURL(serverInstance.get(1)), "admin", "admin").acquire(); // inserts record1 - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer2); + ODatabaseRecordThreadLocal.instance().set(dbServer2); ODocument record1Server1 = new ODocument("Person").fields("id", RECORD_ID, "firstName", "Han", "lastName", "Solo"); record1Server1.save(); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnThreeServersScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnThreeServersScenarioTest.java index d2ef0e0e358..0290423d2d9 100755 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnThreeServersScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnThreeServersScenarioTest.java @@ -87,7 +87,7 @@ public void executeTest() throws Exception { ODatabaseDocumentTx dbServer1 = poolFactory.get(getDatabaseURL(serverInstance.get(1)), "admin", "admin").acquire(); // inserts record - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer0); + ODatabaseRecordThreadLocal.instance().set(dbServer0); ODocument recordServer0 = new ODocument("Person").fromMap(hanFields); recordServer0.save(); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnTwoServersWithQuorum2ScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnTwoServersWithQuorum2ScenarioTest.java old mode 100644 new mode 100755 index 8cfe6067087..12422d92bdd --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnTwoServersWithQuorum2ScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/TwoClientsRecordUpdateTxOnTwoServersWithQuorum2ScenarioTest.java @@ -74,7 +74,7 @@ public void executeTest() throws Exception { ODatabaseDocumentTx dbServer0 = poolFactory.get(getDatabaseURL(serverInstance.get(0)), "admin", "admin").acquire(); // inserts record - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer0); + ODatabaseRecordThreadLocal.instance().set(dbServer0); ODocument recordServer0 = new ODocument("Person").fields("id", RECORD_ID, "firstName", "Han", "lastName", "Solo"); recordServer0.save(); diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/WWConflictAndNodeInDeadlockScenarioTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/WWConflictAndNodeInDeadlockScenarioTest.java old mode 100644 new mode 100755 index f497cc667d3..3177fa164e9 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/WWConflictAndNodeInDeadlockScenarioTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/scenariotest/WWConflictAndNodeInDeadlockScenarioTest.java @@ -117,7 +117,7 @@ public void executeTest() throws Exception { // inserting record r1 and checking consistency on server1 and server2 System.out.print("Inserting record r1 and on server1 and checking consistency on both server1 and server2..."); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); ODocument r1onServer1 = new ODocument("Person").fields("id", "R001", "firstName", "Han", "lastName", "Solo"); r1onServer1.save(); Thread.sleep(200); @@ -171,11 +171,11 @@ public void executeTest() throws Exception { r1onServer2 = retrieveRecord(getDatabaseURL(serverInstance.get(1)), "R001"); ODocument r1onServer3 = retrieveRecord(getDatabaseURL(serverInstance.get(2)), "R001"); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer1); + ODatabaseRecordThreadLocal.instance().set(dbServer1); r1onServer1.reload(); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer2); + ODatabaseRecordThreadLocal.instance().set(dbServer2); r1onServer2.reload(); - ODatabaseRecordThreadLocal.INSTANCE.set(dbServer3); + ODatabaseRecordThreadLocal.instance().set(dbServer3); r1onServer3.reload(); /** diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/sequence/AbstractServerClusterSequenceTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/sequence/AbstractServerClusterSequenceTest.java old mode 100644 new mode 100755 index f90672c7fae..e902334db91 --- a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/sequence/AbstractServerClusterSequenceTest.java +++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/sequence/AbstractServerClusterSequenceTest.java @@ -67,10 +67,10 @@ private void executeCachedSequenceTest(final ODatabaseDocumentTx[] dbs, final St Assert.assertEquals(seq1.getSequenceType(), seq2.getSequenceType()); Assert.assertEquals(seq1.getSequenceType(), SEQUENCE_TYPE.CACHED); - ODatabaseRecordThreadLocal.INSTANCE.set(dbs[0]); + ODatabaseRecordThreadLocal.instance().set(dbs[0]); long v1 = seq1.next(); - ODatabaseRecordThreadLocal.INSTANCE.set(dbs[1]); + ODatabaseRecordThreadLocal.instance().set(dbs[1]); long v2 = seq2.next(); Assert.assertEquals((long) CACHE_SIZE, v2 - v1); @@ -85,21 +85,21 @@ private void executeOrderedSequenceTest(final ODatabaseDocumentTx[] dbs, final S Assert.assertNotNull("The sequence has not be propagated to the 2nd server", seq2.getSequence(sequenceName)); - ODatabaseRecordThreadLocal.INSTANCE.set(dbs[0]); + ODatabaseRecordThreadLocal.instance().set(dbs[0]); Assert.assertEquals(0L, seq1.getSequence(sequenceName).current()); - ODatabaseRecordThreadLocal.INSTANCE.set(dbs[1]); + ODatabaseRecordThreadLocal.instance().set(dbs[1]); Assert.assertEquals(0L, seq2.getSequence(sequenceName).current()); Assert.assertEquals(1L, seq2.getSequence(sequenceName).next()); - ODatabaseRecordThreadLocal.INSTANCE.set(dbs[0]); + ODatabaseRecordThreadLocal.instance().set(dbs[0]); Assert.assertEquals(2L, seq1.getSequence(sequenceName).next()); Assert.assertEquals(3L, seq1.getSequence(sequenceName).next()); - ODatabaseRecordThreadLocal.INSTANCE.set(dbs[1]); + ODatabaseRecordThreadLocal.instance().set(dbs[1]); Assert.assertEquals(0L, seq2.getSequence(sequenceName).reset()); - ODatabaseRecordThreadLocal.INSTANCE.set(dbs[0]); + ODatabaseRecordThreadLocal.instance().set(dbs[0]); Assert.assertEquals(0L, seq1.getSequence(sequenceName).current()); if (RUN_PARALLEL_SYNC_TEST) { @@ -119,7 +119,7 @@ private void executeParallelSyncTest(final ODatabaseDocumentTx[] dbs, final Stri @Override public List call() throws Exception { final ODatabaseDocumentTx db = dbs[id]; - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List res = new ArrayList(SEQ_RUN_COUNT); diff --git a/graphdb/src/main/java/com/orientechnologies/orient/graph/graphml/OGraphSONReader.java b/graphdb/src/main/java/com/orientechnologies/orient/graph/graphml/OGraphSONReader.java old mode 100644 new mode 100755 index dc463a9d610..64955ecd2da --- a/graphdb/src/main/java/com/orientechnologies/orient/graph/graphml/OGraphSONReader.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/graph/graphml/OGraphSONReader.java @@ -140,7 +140,7 @@ public void inputGraph(final InputStream jsonInputStream, int bufferSize, final printStatus(jp, importedVertices, importedEdges); if (importedVertices % 1000 == 0) - ODatabaseRecordThreadLocal.INSTANCE.get().getLocalCache().invalidate(); + ODatabaseRecordThreadLocal.instance().get().getLocalCache().invalidate(); } } else if (fieldname.equals(GraphSONTokens.EDGES)) { jp.nextToken(); @@ -153,7 +153,7 @@ public void inputGraph(final InputStream jsonInputStream, int bufferSize, final printStatus(jp, importedVertices, importedEdges); if (importedEdges % 1000 == 0) - ODatabaseRecordThreadLocal.INSTANCE.get().getLocalCache().invalidate(); + ODatabaseRecordThreadLocal.instance().get().getLocalCache().invalidate(); } } } diff --git a/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OCommandGremlinExecutor.java b/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OCommandGremlinExecutor.java old mode 100644 new mode 100755 index 98c42f64afd..f7c41cf6755 --- a/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OCommandGremlinExecutor.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OCommandGremlinExecutor.java @@ -46,7 +46,7 @@ public class OCommandGremlinExecutor extends OCommandExecutorAbstract { @Override public RET parse(OCommandRequest iRequest) { parserText = ((OCommandRequestText) iRequest).getText(); - db = OGremlinHelper.getGraphDatabase(ODatabaseRecordThreadLocal.INSTANCE.get()); + db = OGremlinHelper.getGraphDatabase(ODatabaseRecordThreadLocal.instance().get()); return (RET) this; } diff --git a/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OGremlinHelper.java b/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OGremlinHelper.java index 7485c25e382..0b7463775f7 100755 --- a/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OGremlinHelper.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/graph/gremlin/OGremlinHelper.java @@ -306,7 +306,7 @@ public static OGremlinHelper global() { } public static ODatabaseDocumentTx getGraphDatabase(final ODatabaseDocumentInternal iCurrentDatabase) { - ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.instance().get(); if (currentDb == null && iCurrentDatabase != null) // GET FROM THE RECORD currentDb = iCurrentDatabase; diff --git a/graphdb/src/main/java/com/orientechnologies/orient/graph/script/OScriptGraphOrientWrapper.java b/graphdb/src/main/java/com/orientechnologies/orient/graph/script/OScriptGraphOrientWrapper.java old mode 100644 new mode 100755 index 2a8587d4137..2675da032b0 --- a/graphdb/src/main/java/com/orientechnologies/orient/graph/script/OScriptGraphOrientWrapper.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/graph/script/OScriptGraphOrientWrapper.java @@ -32,16 +32,16 @@ public class OScriptGraphOrientWrapper extends OScriptOrientWrapper { public OScriptGraphOrientWrapper() { - super(ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()); + super(ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner()); } public OScriptGraphWrapper getGraphNoTx() { - final ODatabaseDocumentTx threadDatabase = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); + final ODatabaseDocumentTx threadDatabase = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner(); return new OScriptGraphWrapper(OrientGraphFactory.getNoTxGraphImplFactory().getGraph(threadDatabase)); } public OScriptGraphWrapper getGraph() { - final ODatabaseDocumentTx threadDatabase = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); + final ODatabaseDocumentTx threadDatabase = (ODatabaseDocumentTx) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner(); return new OScriptGraphWrapper(OrientGraphFactory.getTxGraphImplFactory().getGraph(threadDatabase)); } } diff --git a/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OCommandExecutorSQLDeleteEdge.java b/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OCommandExecutorSQLDeleteEdge.java index a172864d48e..d3bedcdcbcb 100755 --- a/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OCommandExecutorSQLDeleteEdge.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OCommandExecutorSQLDeleteEdge.java @@ -93,7 +93,7 @@ public OCommandExecutorSQLDeleteEdge parse(final OCommandRequest iRequest) { originalTemp = parserText.substring(parserGetPreviousPosition(), parserGetCurrentPosition()).trim(); final OModifiableBoolean shutdownFlag = new OModifiableBoolean(); - ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.instance().get(); final OrientGraph graph = OGraphCommandExecutorSQLFactory.getGraph(false, shutdownFlag); try { while (temp != null) { @@ -185,7 +185,7 @@ public OCommandExecutorSQLDeleteEdge parse(final OCommandRequest iRequest) { } finally { if (shutdownFlag.getValue()) graph.shutdown(false, false); - ODatabaseRecordThreadLocal.INSTANCE.set(curDb); + ODatabaseRecordThreadLocal.instance().set(curDb); } } finally { textRequest.setText(originalQuery); diff --git a/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OGraphCommandExecutorSQLFactory.java b/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OGraphCommandExecutorSQLFactory.java index 38aa38a87e4..19f369adf78 100755 --- a/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OGraphCommandExecutorSQLFactory.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OGraphCommandExecutorSQLFactory.java @@ -74,7 +74,7 @@ public interface GraphCallBack { * @return Transactional OrientGraph implementation from the current database in thread local. */ public static OrientGraph getGraph(final boolean autoStartTx, OModifiableBoolean shouldBeShutDown) { - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().get(); final OrientBaseGraph result = OrientBaseGraph.getActiveGraph(); @@ -85,7 +85,7 @@ public static OrientGraph getGraph(final boolean autoStartTx, OModifiableBoolean if (canReuseActiveGraph(graphDb, database)) { if (!graphDb.isClosed()) { - ODatabaseRecordThreadLocal.INSTANCE.set(graphDb); + ODatabaseRecordThreadLocal.instance().set(graphDb); if (autoStartTx && autoTxStartRequired(graphDb)) ((OrientGraph) result).begin(); @@ -95,7 +95,7 @@ public static OrientGraph getGraph(final boolean autoStartTx, OModifiableBoolean } } // Set it again on ThreadLocal because the getRawGraph() may have set a closed db in the thread-local - ODatabaseRecordThreadLocal.INSTANCE.set((ODatabaseDocumentInternal) database); + ODatabaseRecordThreadLocal.instance().set((ODatabaseDocumentInternal) database); shouldBeShutDown.setValue(true); final OrientGraph g = (OrientGraph) OrientGraphFactory.getTxGraphImplFactory().getGraph((ODatabaseDocumentTx) database, false); @@ -108,7 +108,7 @@ public static OrientGraph getGraph(final boolean autoStartTx, OModifiableBoolean * @return a Non Transactional OrientGraph implementation from the current database in thread local. */ public static OrientGraphNoTx getGraphNoTx(final OModifiableBoolean shouldBeShutDown) { - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().get(); final OrientBaseGraph result = OrientBaseGraph.getActiveGraph(); @@ -119,7 +119,7 @@ public static OrientGraphNoTx getGraphNoTx(final OModifiableBoolean shouldBeShut if (canReuseActiveGraph(graphDb, database)) { if (!graphDb.isClosed()) { - ODatabaseRecordThreadLocal.INSTANCE.set(graphDb); + ODatabaseRecordThreadLocal.instance().set(graphDb); shouldBeShutDown.setValue(false); return (OrientGraphNoTx) result; } @@ -128,7 +128,7 @@ public static OrientGraphNoTx getGraphNoTx(final OModifiableBoolean shouldBeShut // Set it again on ThreadLocal because the getRawGraph() may have set a closed db in the thread-local shouldBeShutDown.setValue(true); - ODatabaseRecordThreadLocal.INSTANCE.set((ODatabaseDocumentInternal) database); + ODatabaseRecordThreadLocal.instance().set((ODatabaseDocumentInternal) database); return (OrientGraphNoTx) OrientGraphFactory.getNoTxGraphImplFactory().getGraph((ODatabaseDocumentTx) database); } @@ -137,7 +137,7 @@ public static OrientGraphNoTx getGraphNoTx(final OModifiableBoolean shouldBeShut * local. */ public static OrientBaseGraph getAnyGraph(final OModifiableBoolean shouldBeShutDown) { - final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().get(); final OrientBaseGraph result = OrientBaseGraph.getActiveGraph(); @@ -156,7 +156,7 @@ public static OrientBaseGraph getAnyGraph(final OModifiableBoolean shouldBeShutD // Set it again on ThreadLocal because the getRawGraph() may have set a closed db in the thread-local shouldBeShutDown.setValue(true); - ODatabaseRecordThreadLocal.INSTANCE.set((ODatabaseDocumentInternal) database); + ODatabaseRecordThreadLocal.instance().set((ODatabaseDocumentInternal) database); return (OrientGraphNoTx) OrientGraphFactory.getNoTxGraphImplFactory().getGraph((ODatabaseDocumentTx) database); } @@ -185,7 +185,7 @@ public static T runInTx(final OrientGraph graph, final GraphCallBack call public static T runInTx(final GraphCallBack callBack) { final OModifiableBoolean shutdownFlag = new OModifiableBoolean(); - final ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.instance().get(); final boolean txAlreadyBegun = curDb.getTransaction().isActive(); final OrientGraph graph = OGraphCommandExecutorSQLFactory.getGraph(true, shutdownFlag); try { @@ -198,13 +198,13 @@ public static T runInTx(final GraphCallBack callBack) { graph.shutdown(false, false); } - ODatabaseRecordThreadLocal.INSTANCE.set(curDb); + ODatabaseRecordThreadLocal.instance().set(curDb); } } public static T runWithAnyGraph(final GraphCallBack callBack) { final OModifiableBoolean shutdownFlag = new OModifiableBoolean(); - final ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.instance().get(); final OrientBaseGraph graph = OGraphCommandExecutorSQLFactory.getAnyGraph(shutdownFlag); try { return callBack.call(graph); @@ -212,12 +212,12 @@ public static T runWithAnyGraph(final GraphCallBack callBack) { if (shutdownFlag.getValue()) graph.shutdown(false, false); - ODatabaseRecordThreadLocal.INSTANCE.set(curDb); + ODatabaseRecordThreadLocal.instance().set(curDb); } } public static ODatabaseDocument getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } /** @@ -247,7 +247,7 @@ public OCommandExecutorSQLAbstract createCommand(final String name) throws OComm public static T runInConfiguredTxMode(final GraphCallBack callBack) { final OModifiableBoolean shutdownFlag = new OModifiableBoolean(); - final ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.instance().get(); final boolean txAlreadyBegun = curDb.getTransaction().isActive(); OrientBaseGraph graph = null; @@ -269,12 +269,12 @@ public static T runInConfiguredTxMode(final GraphCallBack callBack) { } } - ODatabaseRecordThreadLocal.INSTANCE.set(curDb); + ODatabaseRecordThreadLocal.instance().set(curDb); } } public static boolean isTxRequiredForSQLGraphOperations() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().isTxRequiredForSQLGraphOperations(); + return ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().isTxRequiredForSQLGraphOperations(); } public static GRAPH_CONSISTENCY_MODE getConsistencyMode(final OrientBaseGraph graph) { diff --git a/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/functions/OSQLFunctionGremlin.java b/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/functions/OSQLFunctionGremlin.java old mode 100644 new mode 100755 index 675cb48d864..6a29e66988a --- a/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/functions/OSQLFunctionGremlin.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/graph/sql/functions/OSQLFunctionGremlin.java @@ -57,7 +57,7 @@ public OSQLFunctionGremlin() { public Object execute(Object iThis, final OIdentifiable iCurrentRecord, Object iCurrentResult, final Object[] iParams, final OCommandContext iContext) { - final ODatabaseDocumentTx db = OGremlinHelper.getGraphDatabase(ODatabaseRecordThreadLocal.INSTANCE.get()); + final ODatabaseDocumentTx db = OGremlinHelper.getGraphDatabase(ODatabaseRecordThreadLocal.instance().get()); result = new ArrayList(); diff --git a/graphdb/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java b/graphdb/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java index 7c2de3285d9..e49bf5bbdf7 100755 --- a/graphdb/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java +++ b/graphdb/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java @@ -68,7 +68,7 @@ public void writeRecords(final Object iRecords, final String iFetchPlan, String throw new IllegalArgumentException("Graph mode cannot accept '" + accept + "'"); final OrientGraphNoTx graph = (OrientGraphNoTx) OrientGraphFactory.getNoTxGraphImplFactory() - .getGraph((ODatabaseDocumentTx) ODatabaseRecordThreadLocal.INSTANCE.get()); + .getGraph((ODatabaseDocumentTx) ODatabaseRecordThreadLocal.instance().get()); try { //all the edges in the result-set diff --git a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java index 37ea93c867e..ceef7b2699e 100755 --- a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java +++ b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java @@ -313,9 +313,9 @@ public void makeActive() { activeGraph.set(this); - final ODatabaseDocument tlDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocument tlDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (tlDb != database) - ODatabaseRecordThreadLocal.INSTANCE.set(getDatabase()); + ODatabaseRecordThreadLocal.instance().set(getDatabase()); } /** @@ -1050,7 +1050,7 @@ public void removeEdge(final Edge edge) { * @param iDatabase Underlying database object */ public OrientBaseGraph reuse(final ODatabaseDocumentTx iDatabase) { - ODatabaseRecordThreadLocal.INSTANCE.set(iDatabase); + ODatabaseRecordThreadLocal.instance().set(iDatabase); this.url = iDatabase.getURL(); database = iDatabase; @@ -1847,11 +1847,11 @@ protected void setCurrentGraphInThreadLocal() { if (getThreadMode() == THREAD_MODE.MANUAL) return; - final ODatabaseDocument tlDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocument tlDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (getThreadMode() == THREAD_MODE.ALWAYS_AUTOSET || tlDb == null) { if (getDatabase() != null && tlDb != getDatabase()) // SET IT - ODatabaseRecordThreadLocal.INSTANCE.set(getDatabase()); + ODatabaseRecordThreadLocal.instance().set(getDatabase()); } } @@ -1872,7 +1872,7 @@ private void pollGraphFromStack(boolean updateDb) { } else { activeGraph.set(null); if (updateDb) - ODatabaseRecordThreadLocal.INSTANCE.set(null); + ODatabaseRecordThreadLocal.instance().set(null); } } diff --git a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientConfigurableGraph.java b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientConfigurableGraph.java index 901348816b3..18e18d9a8d5 100755 --- a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientConfigurableGraph.java +++ b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientConfigurableGraph.java @@ -483,7 +483,7 @@ public void setWarnOnForceClosingTx(final boolean warnOnSchemaChangeInTx) { * Returns the current thread mode: *
    *
  • MANUAL the user has to manually invoke the current database in Thread Local: - * ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
  • + * ODatabaseRecordThreadLocal.instance().set(graph.getRawGraph()); *
  • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one * was set before
  • *
  • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local
  • @@ -505,7 +505,7 @@ public THREAD_MODE getThreadMode() { * Changes the thread mode: *
      *
    • MANUAL the user has to manually invoke the current database in Thread Local: - * ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
    • + * ODatabaseRecordThreadLocal.instance().set(graph.getRawGraph()); *
    • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one * was set before
    • *
    • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local
    • @@ -791,7 +791,7 @@ public OrientConfigurableGraph setWarnOnForceClosingTx(final boolean warnOnSchem * Returns the current thread mode: *
        *
      • MANUAL the user has to manually invoke the current database in Thread Local: - * ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
      • + * ODatabaseRecordThreadLocal.instance().set(graph.getRawGraph()); *
      • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one was * set before
      • *
      • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local
      • @@ -810,7 +810,7 @@ public THREAD_MODE getThreadMode() { * Changes the thread mode: *
          *
        • MANUAL the user has to manually invoke the current database in Thread Local: - * ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
        • + * ODatabaseRecordThreadLocal.instance().set(graph.getRawGraph()); *
        • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one was * set before
        • *
        • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local
        • diff --git a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientEdgeIterator.java b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientEdgeIterator.java index 3870d2893d2..0eb95a82fdf 100755 --- a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientEdgeIterator.java +++ b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientEdgeIterator.java @@ -112,7 +112,7 @@ public OrientEdge createGraphElement(final Object iObject) { boolean newGraph = false; if (graph == null) { newGraph = true; - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) { graph = new OrientGraphNoTx((ODatabaseDocumentTx) db); } diff --git a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientElement.java b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientElement.java index fc0125851ba..b84a77c4298 100755 --- a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientElement.java +++ b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientElement.java @@ -382,7 +382,7 @@ public void readExternal(final ObjectInput in) throws IOException, ClassNotFound */ @Override public void lock(final boolean iExclusive) { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().lockRecord(this, + ODatabaseRecordThreadLocal.instance().get().getTransaction().lockRecord(this, iExclusive ? OStorage.LOCKING_STRATEGY.EXCLUSIVE_LOCK : OStorage.LOCKING_STRATEGY.SHARED_LOCK); } @@ -391,12 +391,12 @@ public void lock(final boolean iExclusive) { */ @Override public boolean isLocked() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().isLockedRecord(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().isLockedRecord(this); } @Override public OStorage.LOCKING_STRATEGY lockingStrategy() { - return ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().lockingStrategy(this); + return ODatabaseRecordThreadLocal.instance().get().getTransaction().lockingStrategy(this); } /** @@ -406,7 +406,7 @@ public OStorage.LOCKING_STRATEGY lockingStrategy() { */ @Override public void unlock() { - ODatabaseRecordThreadLocal.INSTANCE.get().getTransaction().unlockRecord(this); + ODatabaseRecordThreadLocal.instance().get().getTransaction().unlockRecord(this); } /** diff --git a/graphdb/src/test/java/com/orientechnologies/orient/test/server/network/http/BaseHttpDatabaseTest.java b/graphdb/src/test/java/com/orientechnologies/orient/test/server/network/http/BaseHttpDatabaseTest.java index 0e5c7d051d7..78d726d6104 100755 --- a/graphdb/src/test/java/com/orientechnologies/orient/test/server/network/http/BaseHttpDatabaseTest.java +++ b/graphdb/src/test/java/com/orientechnologies/orient/test/server/network/http/BaseHttpDatabaseTest.java @@ -14,7 +14,7 @@ public abstract class BaseHttpDatabaseTest extends BaseHttpTest { @Before public void createDatabase() throws Exception { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); super.startServer(); Assert.assertEquals( diff --git a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphFactoryTest.java b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphFactoryTest.java old mode 100644 new mode 100755 index 7d5a892772b..c5d3115fdfd --- a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphFactoryTest.java +++ b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphFactoryTest.java @@ -113,7 +113,7 @@ public void releaseThreadLocal() { g.addVertex(null); g.commit(); g.shutdown(); - assertNull(ODatabaseRecordThreadLocal.INSTANCE.getIfDefined()); + assertNull(ODatabaseRecordThreadLocal.instance().getIfDefined()); factory.close(); } diff --git a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxRemoteTest.java b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxRemoteTest.java index 0763ef7f663..b3f32a96822 100755 --- a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxRemoteTest.java +++ b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxRemoteTest.java @@ -146,7 +146,7 @@ public Graph generateGraph(final String graphDirectoryName) { if (graph.isClosed()) currentGraphs.remove(url); else { - ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(graph.getRawGraph()); return graph; } } diff --git a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxTest.java b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxTest.java index 789cf130eef..f1d26f1bca0 100755 --- a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxTest.java +++ b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphNoTxTest.java @@ -86,7 +86,7 @@ public Graph generateGraph(final String graphDirectoryName) { if (graph.isClosed()) currentGraphs.remove(url); else { - ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(graph.getRawGraph()); return graph; } } diff --git a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphTest.java b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphTest.java old mode 100644 new mode 100755 index 08617d15782..69fdb23dfac --- a/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphTest.java +++ b/graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientGraphTest.java @@ -149,7 +149,7 @@ public Graph generateGraph(final String graphDirectoryName) { if (graph.isClosed()) currentGraphs.remove(url); else { - ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph()); + ODatabaseRecordThreadLocal.instance().set(graph.getRawGraph()); return graph; } } diff --git a/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneIndexEngineAbstract.java b/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneIndexEngineAbstract.java index 330b372f41d..4d8445bd558 100755 --- a/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneIndexEngineAbstract.java +++ b/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneIndexEngineAbstract.java @@ -263,7 +263,7 @@ protected void reOpen() throws IOException { } protected ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } private synchronized void open() throws IOException { diff --git a/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneStorage.java b/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneStorage.java index aae435d6ea8..8d17c58c165 100755 --- a/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneStorage.java +++ b/lucene/src/main/java/com/orientechnologies/lucene/engine/OLuceneStorage.java @@ -122,7 +122,7 @@ private void reOpen() throws IOException { return; } - ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get(); final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying(); Directory dir = null; diff --git a/lucene/src/main/java/com/orientechnologies/lucene/operator/OLuceneTextOperator.java b/lucene/src/main/java/com/orientechnologies/lucene/operator/OLuceneTextOperator.java old mode 100644 new mode 100755 index 256c926b4c0..337f8a63dfe --- a/lucene/src/main/java/com/orientechnologies/lucene/operator/OLuceneTextOperator.java +++ b/lucene/src/main/java/com/orientechnologies/lucene/operator/OLuceneTextOperator.java @@ -239,7 +239,7 @@ protected OLuceneFullTextIndex involvedIndex(OIdentifiable iRecord, ODocument iC } protected static ODatabaseDocumentInternal getDatabase() { - return ODatabaseRecordThreadLocal.INSTANCE.get(); + return ODatabaseRecordThreadLocal.instance().get(); } private boolean isChained(Object left) { diff --git a/lucene/src/test/java/com/orientechnologies/lucene/integration/OLuceneIndexCrashRestoreIT.java b/lucene/src/test/java/com/orientechnologies/lucene/integration/OLuceneIndexCrashRestoreIT.java index b839a11a646..46e4187079e 100755 --- a/lucene/src/test/java/com/orientechnologies/lucene/integration/OLuceneIndexCrashRestoreIT.java +++ b/lucene/src/test/java/com/orientechnologies/lucene/integration/OLuceneIndexCrashRestoreIT.java @@ -310,7 +310,7 @@ public Void call() throws Exception { } int nameIdx = (int) (id % names.size()); - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); for (int i = 0; i < 10; i++) { String insert = "insert into person (name) values ('" + names.get(nameIdx) + "')"; testDB.command(new OCommandSQL(insert)).execute(); diff --git a/lucene/src/test/java/com/orientechnologies/lucene/test/LuceneTransactionQueryTest.java b/lucene/src/test/java/com/orientechnologies/lucene/test/LuceneTransactionQueryTest.java old mode 100644 new mode 100755 index 3ad2f21fb78..b3e413acff1 --- a/lucene/src/test/java/com/orientechnologies/lucene/test/LuceneTransactionQueryTest.java +++ b/lucene/src/test/java/com/orientechnologies/lucene/test/LuceneTransactionQueryTest.java @@ -58,13 +58,13 @@ public void testRollback() { db.save(doc); String query = "select from C1 where p1 lucene \"abc\" "; - List vertices = ODatabaseRecordThreadLocal.INSTANCE.get().command(new OSQLSynchQuery(query)).execute(); + List vertices = ODatabaseRecordThreadLocal.instance().get().command(new OSQLSynchQuery(query)).execute(); Assert.assertEquals(vertices.size(), 1); db.rollback(); query = "select from C1 where p1 lucene \"abc\" "; - vertices = ODatabaseRecordThreadLocal.INSTANCE.get().command(new OSQLSynchQuery(query)).execute(); + vertices = ODatabaseRecordThreadLocal.instance().get().command(new OSQLSynchQuery(query)).execute(); Assert.assertEquals(vertices.size(), 0); } @@ -81,7 +81,7 @@ public void txRemoveTest() { db.save(doc); String query = "select from C1 where p1 lucene \"abc\" "; - List vertices = ODatabaseRecordThreadLocal.INSTANCE.get().command(new OSQLSynchQuery(query)).execute(); + List vertices = ODatabaseRecordThreadLocal.instance().get().command(new OSQLSynchQuery(query)).execute(); Assert.assertEquals(vertices.size(), 1); @@ -150,7 +150,7 @@ public void txUpdateTest() { db.save(doc); String query = "select from C1 where p1 lucene \"update\" "; - List vertices = ODatabaseRecordThreadLocal.INSTANCE.get().command(new OSQLSynchQuery(query)).execute(); + List vertices = ODatabaseRecordThreadLocal.instance().get().command(new OSQLSynchQuery(query)).execute(); Assert.assertEquals(vertices.size(), 1); diff --git a/object/src/main/java/com/orientechnologies/orient/object/db/OLazyCollectionUtil.java b/object/src/main/java/com/orientechnologies/orient/object/db/OLazyCollectionUtil.java old mode 100644 new mode 100755 index 512dd7c34b3..f0b14333701 --- a/object/src/main/java/com/orientechnologies/orient/object/db/OLazyCollectionUtil.java +++ b/object/src/main/java/com/orientechnologies/orient/object/db/OLazyCollectionUtil.java @@ -13,7 +13,7 @@ public class OLazyCollectionUtil { * Gets the current thread database as a ODatabasePojoAbstract, wrapping it where necessary. */ protected static ODatabasePojoAbstract getDatabase() { - ODatabaseInternal databaseOwner = ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); + ODatabaseInternal databaseOwner = ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner(); if (databaseOwner instanceof ODatabasePojoAbstract) { return (ODatabasePojoAbstract) databaseOwner; } else if (databaseOwner instanceof ODatabaseDocumentTx) { diff --git a/object/src/main/java/com/orientechnologies/orient/object/db/OObjectDatabaseTxPooled.java b/object/src/main/java/com/orientechnologies/orient/object/db/OObjectDatabaseTxPooled.java index 6244d9516e6..9adecd73836 100755 --- a/object/src/main/java/com/orientechnologies/orient/object/db/OObjectDatabaseTxPooled.java +++ b/object/src/main/java/com/orientechnologies/orient/object/db/OObjectDatabaseTxPooled.java @@ -52,7 +52,7 @@ public void reuse(final Object iOwner, final Object[] iAdditionalArgs) { ownerPool = (OObjectDatabasePool) iOwner; if (isClosed()) open((String) iAdditionalArgs[0], (String) iAdditionalArgs[1]); - ODatabaseRecordThreadLocal.INSTANCE.set(getUnderlying()); + ODatabaseRecordThreadLocal.instance().set(getUnderlying()); init(); try { diff --git a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java index ee2b1638f39..b5e97a2b343 100755 --- a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java +++ b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java @@ -138,7 +138,7 @@ public T getProxiedInstance(final Class iClass, Object iEnclosingInstance } if (constructor != null) { newEntity = (T) constructor.newInstance(iArgs); - initDocument(iClass, newEntity, doc, (ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()); + initDocument(iClass, newEntity, doc, (ODatabaseObject) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner()); } else { if (iEnclosingInstance != null) newEntity = createInstanceNoParameters(c, iEnclosingInstance); diff --git a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntitySerializer.java b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntitySerializer.java index 10a72d31af8..0441abb4a66 100755 --- a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntitySerializer.java +++ b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntitySerializer.java @@ -111,7 +111,7 @@ public static class OObjectEntitySerializedSchema { } protected static OObjectEntitySerializedSchema getCurrentSerializedSchema() { - OStorage storage = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage(); + OStorage storage = ODatabaseRecordThreadLocal.instance().get().getStorage(); OObjectEntitySerializedSchema serializedShchema = storage .getResource(SIMPLE_NAME, new Callable() { @Override @@ -405,7 +405,7 @@ public static synchronized void registerClass(final Class iClass) { */ @SuppressWarnings("unchecked") public static synchronized void registerClass(final Class iClass, boolean forceReload) { - if (!ODatabaseRecordThreadLocal.INSTANCE.isDefined() || ODatabaseRecordThreadLocal.INSTANCE.get().isClosed()) + if (!ODatabaseRecordThreadLocal.instance().isDefined() || ODatabaseRecordThreadLocal.instance().get().isClosed()) return; final OObjectEntitySerializedSchema serializedSchema = getCurrentSerializedSchema(); if (serializedSchema == null) @@ -419,7 +419,7 @@ public static synchronized void registerClass(final Class iClass, boolean for boolean reloadSchema = false; boolean automaticSchemaGeneration = false; - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); final OSchema oSchema = db.getMetadata().getSchema(); if (forceReload) { oSchema.reload(); diff --git a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java index 871da3d143a..ba2410d5958 100755 --- a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java +++ b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java @@ -81,7 +81,7 @@ public class OObjectProxyMethodHandler implements MethodHandler { public OObjectProxyMethodHandler(ODocument iDocument) { doc = iDocument; - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); if (db.getDatabaseOwner() instanceof ODatabaseObject && !((ODatabaseObject) db.getDatabaseOwner()).isLazyLoading()) doc.detach(); loadedFields = new HashMap(); @@ -609,7 +609,7 @@ protected Object manageCollectionSave(final Object self, final Field f, Collecti OObjectEntitySerializer.isCascadeDeleteField(self.getClass(), f.getName())); } } - if (!((ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()).isLazyLoading()) + if (!((ODatabaseObject) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner()).isLazyLoading()) ((OObjectLazyMultivalueElement) value).detach(false); return value; } @@ -885,7 +885,7 @@ protected Method getSetMethod(final Class iClass, final String fieldName, Obj } private ODatabaseObject getDatabase() { - return (ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner(); + return (ODatabaseObject) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner(); } private Object getDefaultValueForField(Field field) { diff --git a/object/src/main/java/com/orientechnologies/orient/object/metadata/schema/OSchemaProxyObject.java b/object/src/main/java/com/orientechnologies/orient/object/metadata/schema/OSchemaProxyObject.java index 84598f7b084..63315454ed6 100755 --- a/object/src/main/java/com/orientechnologies/orient/object/metadata/schema/OSchemaProxyObject.java +++ b/object/src/main/java/com/orientechnologies/orient/object/metadata/schema/OSchemaProxyObject.java @@ -249,7 +249,7 @@ public synchronized void generateSchema(final String iPackageName, final ClassLo * :- the Class to generate */ public synchronized void generateSchema(final Class iClass) { - generateSchema(iClass, ODatabaseRecordThreadLocal.INSTANCE.get()); + generateSchema(iClass, ODatabaseRecordThreadLocal.instance().get()); } /** @@ -349,7 +349,7 @@ public synchronized void generateSchema(final Class iClass, ODatabaseDocument * Checks if all registered entities has schema generated, if not it generates it */ public synchronized void synchronizeSchema() { - OObjectDatabaseTx database = ((OObjectDatabaseTx) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()); + OObjectDatabaseTx database = ((OObjectDatabaseTx) ODatabaseRecordThreadLocal.instance().get().getDatabaseOwner()); Collection> registeredEntities = database.getEntityManager().getRegisteredEntities(); boolean automaticSchemaGeneration = database.isAutomaticSchemaGeneration(); boolean reloadSchema = false; @@ -412,7 +412,7 @@ protected static void generateOClass(Class iClass, ODatabaseDocument database // ODOCUMENT FIELDS currentClass = Object.class; - if (ODatabaseRecordThreadLocal.INSTANCE.get() != null && !ODatabaseRecordThreadLocal.INSTANCE.get().isClosed() + if (ODatabaseRecordThreadLocal.instance().get() != null && !ODatabaseRecordThreadLocal.instance().get().isClosed() && !currentClass.equals(Object.class)) { OClass oSuperClass; OClass currentOClass = database.getMetadata().getSchema().getClass(iClassName); diff --git a/server/src/main/java/com/orientechnologies/orient/server/OSystemDatabase.java b/server/src/main/java/com/orientechnologies/orient/server/OSystemDatabase.java index 99f1099de22..e34802d6aef 100755 --- a/server/src/main/java/com/orientechnologies/orient/server/OSystemDatabase.java +++ b/server/src/main/java/com/orientechnologies/orient/server/OSystemDatabase.java @@ -56,7 +56,7 @@ public String getSystemDatabasePath() { * Adds the specified cluster to the class, if it doesn't already exist. */ public void createCluster(final String className, final String clusterName) { - final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final ODatabaseDocumentInternal sysdb = openSystemDatabase(); try { @@ -78,9 +78,9 @@ public void createCluster(final String className, final String clusterName) { } finally { if (currentDB != null) - ODatabaseRecordThreadLocal.INSTANCE.set(currentDB); + ODatabaseRecordThreadLocal.instance().set(currentDB); else - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } @@ -93,7 +93,7 @@ public ODatabaseDocumentInternal openSystemDatabase() { } public Object execute(final OCallable callback, final String sql, final Object... args) { - final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { // BYPASS SECURITY final ODatabase db = openSystemDatabase(); @@ -111,9 +111,9 @@ public Object execute(final OCallable callback, final String sql } finally { if (currentDB != null) - ODatabaseRecordThreadLocal.INSTANCE.set(currentDB); + ODatabaseRecordThreadLocal.instance().set(currentDB); else - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } @@ -122,7 +122,7 @@ public ODocument save(final ODocument document) { } public ODocument save(final ODocument document, final String clusterName) { - final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { // BYPASS SECURITY final ODatabaseDocumentInternal db = openSystemDatabase(); @@ -137,14 +137,14 @@ public ODocument save(final ODocument document, final String clusterName) { } finally { if (currentDB != null) - ODatabaseRecordThreadLocal.INSTANCE.set(currentDB); + ODatabaseRecordThreadLocal.instance().set(currentDB); else - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } private void init() { - final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.INSTANCE; + final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.instance(); final ODatabaseDocumentInternal oldDbInThread = tl != null ? tl.getIfDefined() : null; try { @@ -163,16 +163,16 @@ private void init() { } finally { if (oldDbInThread != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(oldDbInThread); + ODatabaseRecordThreadLocal.instance().set(oldDbInThread); } else { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } } public void executeInDBScope(OCallable callback) { - final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal currentDB = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { final ODatabase db = openSystemDatabase(); @@ -183,15 +183,15 @@ public void executeInDBScope(OCallable callback) { } } finally { if (currentDB != null) - ODatabaseRecordThreadLocal.INSTANCE.set(currentDB); + ODatabaseRecordThreadLocal.instance().set(currentDB); else - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } public boolean exists() { - final ODatabaseDocumentInternal oldDbInThread = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal oldDbInThread = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { ODatabaseDocumentTx sysDB = new ODatabaseDocumentTx("plocal:" + getSystemDatabasePath()); @@ -200,9 +200,9 @@ public boolean exists() { } finally { if (oldDbInThread != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(oldDbInThread); + ODatabaseRecordThreadLocal.instance().set(oldDbInThread); } else { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } } diff --git a/server/src/main/java/com/orientechnologies/orient/server/distributed/task/OAbstractRecordReplicatedTask.java b/server/src/main/java/com/orientechnologies/orient/server/distributed/task/OAbstractRecordReplicatedTask.java old mode 100644 new mode 100755 index 686480fdf11..d40cd219b5c --- a/server/src/main/java/com/orientechnologies/orient/server/distributed/task/OAbstractRecordReplicatedTask.java +++ b/server/src/main/java/com/orientechnologies/orient/server/distributed/task/OAbstractRecordReplicatedTask.java @@ -62,7 +62,7 @@ public OAbstractRecordReplicatedTask init(final ORecordId iRid, final int iVersi this.rid = iRid; this.version = iVersion; - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) { final OClass clazz = db.getMetadata().getSchema().getClassByClusterId(rid.getClusterId()); if (clazz != null) { @@ -130,14 +130,14 @@ public int getVersion() { } public boolean checkForClusterAvailability(final String localNode, final ODistributedConfiguration cfg) { - final String clusterName = ODatabaseRecordThreadLocal.INSTANCE.get().getClusterNameById(rid.getClusterId()); + final String clusterName = ODatabaseRecordThreadLocal.instance().get().getClusterNameById(rid.getClusterId()); return cfg.isServerContainingCluster(localNode, clusterName); } public ORecord prepareUndoOperation() { if (previousRecord == null) { // READ DIRECTLY FROM THE UNDERLYING STORAGE - final OStorageOperationResult loaded = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying() + final OStorageOperationResult loaded = ODatabaseRecordThreadLocal.instance().get().getStorage().getUnderlying() .readRecord(rid, null, true, false, null); if (loaded == null || loaded.getResult() == null) diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/OLiveCommandResultListener.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/OLiveCommandResultListener.java old mode 100644 new mode 100755 index 9235a44feca..acbdfe8f932 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/OLiveCommandResultListener.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/OLiveCommandResultListener.java @@ -113,7 +113,7 @@ public void onLiveResult(int iToken, ORecordOperation iOp) throws OException { List connections = session.getConnections(); if (connections.size() == 0) { try { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); OLogManager.instance().warn(this, "Unsubscribing live query for connection " + connection); OLiveQueryHook.unsubscribe(iToken, db); } catch (Exception e) { @@ -153,7 +153,7 @@ public void onLiveResult(int iToken, ORecordOperation iOp) throws OException { session.removeConnection(curConnection); connections = session.getConnections(); if (connections.isEmpty()) { - ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get(); OLiveQueryHook.unsubscribe(iToken, db); break; } diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java index 969035876ce..7beeb1a01f6 100755 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java @@ -454,12 +454,12 @@ private OClientConnection onBeforeHandshakeRequest(OClientConnection connection, } catch (RuntimeException e) { if (connection != null) server.getClientConnectionManager().disconnect(connection); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); throw e; } catch (IOException e) { if (connection != null) server.getClientConnectionManager().disconnect(connection); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); throw e; } @@ -508,12 +508,12 @@ private OClientConnection onBeforeOperationalRequest(OClientConnection connectio } catch (RuntimeException e) { if (connection != null) server.getClientConnectionManager().disconnect(connection); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); throw e; } catch (IOException e) { if (connection != null) server.getClientConnectionManager().disconnect(connection); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); throw e; } return connection; @@ -2884,7 +2884,7 @@ public byte[] getRecordBytes(OClientConnection connection, final ORecord iRecord final byte[] stream; String dbSerializerName = null; - if (ODatabaseRecordThreadLocal.INSTANCE.getIfDefined() != null) + if (ODatabaseRecordThreadLocal.instance().getIfDefined() != null) dbSerializerName = ((ODatabaseDocumentInternal) iRecord.getDatabase()).getSerializer().toString(); String name = getRecordSerializerName(connection); if (ORecordInternal.getRecordType(iRecord) == ODocument.RECORD_TYPE && (dbSerializerName == null || !dbSerializerName @@ -2921,7 +2921,7 @@ private void writeRecord(OClientConnection connection, final ORecord iRecord) th protected int trimCsvSerializedContent(OClientConnection connection, final byte[] stream) { int realLength = stream.length; - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && db instanceof ODatabaseDocument) { if (ORecordSerializerSchemaAware2CSV.NAME.equals(getRecordSerializerName(connection))) { // TRIM TAILING SPACES (DUE TO OVERSIZE) diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/ONetworkProtocolHttpDb.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/ONetworkProtocolHttpDb.java index 1a69220cd46..99e8c6fd841 100755 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/ONetworkProtocolHttpDb.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/ONetworkProtocolHttpDb.java @@ -58,6 +58,6 @@ public String getType() { @Override protected void afterExecution() throws InterruptedException { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } } diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/OServerCommandAuthenticatedDbAbstract.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/OServerCommandAuthenticatedDbAbstract.java index 79d526b3617..0f72cb3c7a8 100755 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/OServerCommandAuthenticatedDbAbstract.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/OServerCommandAuthenticatedDbAbstract.java @@ -152,7 +152,7 @@ public boolean beforeExecute(final OHttpRequest iRequest, OHttpResponse iRespons @Override public boolean afterExecute(final OHttpRequest iRequest, OHttpResponse iResponse) throws IOException { - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); return true; } @@ -217,7 +217,7 @@ protected ODatabaseDocumentInternal getProfiledDatabaseInstance(final OHttpReque protected ODatabaseDocumentInternal getProfiledDatabaseInstanceToken(final OHttpRequest iRequest) throws InterruptedException { // after authentication, if current login user is different compare with current DB user, reset DB user to login user - ODatabaseDocumentInternal localDatabase = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal localDatabase = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (localDatabase == null) { localDatabase = (ODatabaseDocumentTx) server.openDatabase(iRequest.databaseName, iRequest.bearerToken); } else { @@ -242,7 +242,7 @@ protected ODatabaseDocumentInternal getProfiledDatabaseInstanceBasic(final OHttp throw new OSecurityAccessException(iRequest.databaseName, "No session active"); // after authentication, if current login user is different compare with current DB user, reset DB user to login user - ODatabaseDocumentInternal localDatabase = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + ODatabaseDocumentInternal localDatabase = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (localDatabase == null) { localDatabase = (ODatabaseDocumentTx) server diff --git a/server/src/main/java/com/orientechnologies/orient/server/security/ODefaultServerSecurity.java b/server/src/main/java/com/orientechnologies/orient/server/security/ODefaultServerSecurity.java index 72486fff35e..294d7a3354f 100755 --- a/server/src/main/java/com/orientechnologies/orient/server/security/ODefaultServerSecurity.java +++ b/server/src/main/java/com/orientechnologies/orient/server/security/ODefaultServerSecurity.java @@ -569,7 +569,7 @@ public void run() { } catch (Exception ex) { OLogManager.instance().error(this, "securityRecordChange() Exception: ", ex); } - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } }); diff --git a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreMultiValueIT.java b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreMultiValueIT.java index 0e905104c69..773ec056356 100755 --- a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreMultiValueIT.java +++ b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreMultiValueIT.java @@ -279,7 +279,7 @@ public Void call() throws Exception { long id = idGen.getAndIncrement(); long ts = System.currentTimeMillis(); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); ODocument doc = new ODocument(); doc.field("ts", ts); doc.save(); @@ -290,7 +290,7 @@ public Void call() throws Exception { baseDB.command(new OCommandSQL("insert into index:mi (key, rid) values (" + id + ", " + doc.getIdentity() + ")")) .execute(); - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); for (int i = 0; i < 10; i++) { testDB.command(new OCommandSQL("insert into index:mi (key, rid) values (" + id + ", #0:" + i + ")")).execute(); } diff --git a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreSingleValueIT.java b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreSingleValueIT.java index 526848cd029..7d840fbaf68 100755 --- a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreSingleValueIT.java +++ b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/IndexCrashRestoreSingleValueIT.java @@ -151,7 +151,7 @@ public void testEntriesAddition() throws Exception { } private void compareIndexes() { - ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx); + ODatabaseRecordThreadLocal.instance().set(baseDocumentTx); OIndexCursor cursor = baseDocumentTx.getMetadata().getIndexManager().getIndex("mi").cursor(); long lastTs = 0; @@ -161,7 +161,7 @@ private void compareIndexes() { Map.Entry entry = cursor.nextEntry(); while (entry != null) { - ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx); + ODatabaseRecordThreadLocal.instance().set(baseDocumentTx); Integer key = (Integer) entry.getKey(); OIdentifiable identifiable = entry.getValue(); @@ -173,7 +173,7 @@ private void compareIndexes() { entry = cursor.nextEntry(); - ODatabaseRecordThreadLocal.INSTANCE.set(testDocumentTx); + ODatabaseRecordThreadLocal.instance().set(testDocumentTx); OIndex testIndex = testDocumentTx.getMetadata().getIndexManager().getIndex("mi"); Set result = (Set) testIndex.get(key); @@ -184,7 +184,7 @@ private void compareIndexes() { restoredRecords++; } - ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx); + ODatabaseRecordThreadLocal.instance().set(baseDocumentTx); System.out.println( "Restored entries : " + restoredRecords + " out of : " + baseDocumentTx.getMetadata().getIndexManager().getIndex("mi") .getSize()); @@ -196,7 +196,7 @@ private void compareIndexes() { } private void createSchema(ODatabaseDocumentTx dbDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbDocumentTx); + ODatabaseRecordThreadLocal.instance().set(dbDocumentTx); dbDocumentTx.command(new OCommandSQL("create index mi notunique integer")).execute(); dbDocumentTx.getMetadata().getIndexManager().reload(); } @@ -237,7 +237,7 @@ public Void call() throws Exception { long id = idGen.getAndIncrement(); long ts = System.currentTimeMillis(); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); ODocument doc = new ODocument(); doc.field("ts", ts); @@ -246,7 +246,7 @@ public Void call() throws Exception { baseDB.command(new OCommandSQL("insert into index:mi (key, rid) values (" + id + ", " + doc.getIdentity() + ")")) .execute(); - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); doc = new ODocument(); doc.field("ts", ts); doc.save(); diff --git a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageCreateCrashRestoreIT.java b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageCreateCrashRestoreIT.java index 5ea32d82728..7c92a296477 100755 --- a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageCreateCrashRestoreIT.java +++ b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageCreateCrashRestoreIT.java @@ -151,7 +151,7 @@ public void testDocumentCreation() throws Exception { } private void createSchema(ODatabaseDocumentTx dbDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbDocumentTx); + ODatabaseRecordThreadLocal.instance().set(dbDocumentTx); OSchema schema = dbDocumentTx.getMetadata().getSchema(); if (!schema.existsClass("TestClass")) { @@ -274,7 +274,7 @@ private void saveDoc(ODocument document) { document.save(); baseDB.commit(); - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); testDB.activateOnCurrentThread(); testDB.begin(); testDoc.save(); diff --git a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageLinkBagCrashRestoreIT.java b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageLinkBagCrashRestoreIT.java index 2e4e718d412..04edd3c9785 100755 --- a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageLinkBagCrashRestoreIT.java +++ b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageLinkBagCrashRestoreIT.java @@ -181,14 +181,14 @@ private void compareDocuments(long lastTs) { for (OPhysicalPosition physicalPosition : physicalPositions) { rid.setClusterPosition(physicalPosition.clusterPosition); - ODatabaseRecordThreadLocal.INSTANCE.set(base_db); + ODatabaseRecordThreadLocal.instance().set(base_db); ODocument baseDocument = base_db.load(rid); baseDocument.setLazyLoad(false); - ODatabaseRecordThreadLocal.INSTANCE.set(test_db); + ODatabaseRecordThreadLocal.instance().set(test_db); ODocument testDocument = test_db.load(rid); if (testDocument == null) { - ODatabaseRecordThreadLocal.INSTANCE.set(base_db); + ODatabaseRecordThreadLocal.instance().set(base_db); if (((Long) baseDocument.field("ts")) < minTs) minTs = baseDocument.field("ts"); } else { @@ -196,24 +196,24 @@ private void compareDocuments(long lastTs) { long baseTs; long testTs; - ODatabaseRecordThreadLocal.INSTANCE.set(base_db); + ODatabaseRecordThreadLocal.instance().set(base_db); baseTs = baseDocument.field("ts"); - ODatabaseRecordThreadLocal.INSTANCE.set(test_db); + ODatabaseRecordThreadLocal.instance().set(test_db); testTs = testDocument.field("ts"); boolean equals = baseTs == testTs; if (equals) { Set baseRids = new HashSet(); - ODatabaseRecordThreadLocal.INSTANCE.set(base_db); + ODatabaseRecordThreadLocal.instance().set(base_db); ORidBag baseRidBag = baseDocument.field("ridBag"); for (OIdentifiable baseIdentifiable : baseRidBag) baseRids.add(baseIdentifiable.getIdentity()); Set testRids = new HashSet(); - ODatabaseRecordThreadLocal.INSTANCE.set(test_db); + ODatabaseRecordThreadLocal.instance().set(test_db); ORidBag testRidBag = testDocument.field("ridBag"); for (OIdentifiable testIdentifiable : testRidBag) diff --git a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageMixCrashRestoreIT.java b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageMixCrashRestoreIT.java index 9494ad5bce0..c61dd212447 100755 --- a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageMixCrashRestoreIT.java +++ b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageMixCrashRestoreIT.java @@ -177,7 +177,7 @@ public void testDocumentChanges() throws Exception { } private void createSchema(ODatabaseDocumentTx dbDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbDocumentTx); + ODatabaseRecordThreadLocal.instance().set(dbDocumentTx); OSchema schema = dbDocumentTx.getMetadata().getSchema(); if (!schema.existsClass("TestClass")) { @@ -239,12 +239,12 @@ private void compareDocuments(long lastTs) { for (OPhysicalPosition physicalPosition : physicalPositions) { rid.setClusterPosition(physicalPosition.clusterPosition); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx); + ODatabaseRecordThreadLocal.instance().set(baseDocumentTx); ODocument baseDocument = baseDocumentTx.load(rid); int id = baseDocument.field("id"); if (addedIds.contains(id)) { - ODatabaseRecordThreadLocal.INSTANCE.set(testDocumentTx); + ODatabaseRecordThreadLocal.instance().set(testDocumentTx); List testDocuments = testDocumentTx .query(new OSQLSynchQuery("select from TestClass where id = " + baseDocument.field("id"))); if (testDocuments.size() == 0) { @@ -260,7 +260,7 @@ private void compareDocuments(long lastTs) { recordsTested++; } else if (updatedIds.contains(id)) { - ODatabaseRecordThreadLocal.INSTANCE.set(testDocumentTx); + ODatabaseRecordThreadLocal.instance().set(testDocumentTx); List testDocuments = testDocumentTx .query(new OSQLSynchQuery("select from TestClass where id = " + baseDocument.field("id"))); if (testDocuments.size() == 0) { @@ -287,7 +287,7 @@ private void compareDocuments(long lastTs) { physicalPositions = baseStorage.higherPhysicalPositions(clusterId, physicalPositions[physicalPositions.length - 1]); } - ODatabaseRecordThreadLocal.INSTANCE.set(testDocumentTx); + ODatabaseRecordThreadLocal.instance().set(testDocumentTx); System.out.println("Check deleted records"); for (Map.Entry deletedEntry : deletedIds.entrySet()) { int deletedId = deletedEntry.getKey(); @@ -434,15 +434,15 @@ private long deleteRecord() { addedIds.remove(idToDelete); updatedIds.remove(idToDelete); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); int deleted = baseDB.command(new OCommandSQL("delete from TestClass where id = " + idToDelete)).execute(); Assert.assertEquals(deleted, 1); - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); deleted = testDB.command(new OCommandSQL("delete from TestClass where id = " + idToDelete)).execute(); Assert.assertEquals(deleted, 1); - ODatabaseRecordThreadLocal.INSTANCE.set(baseDB); + ODatabaseRecordThreadLocal.instance().set(baseDB); long ts = System.currentTimeMillis(); diff --git a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageSmallCacheBigRecordsCrashRestoreIT.java b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageSmallCacheBigRecordsCrashRestoreIT.java index 5aa85e83743..f3a36cb7819 100755 --- a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageSmallCacheBigRecordsCrashRestoreIT.java +++ b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageSmallCacheBigRecordsCrashRestoreIT.java @@ -154,7 +154,7 @@ public void testDocumentCreation() throws Exception { } private void createSchema(ODatabaseDocumentTx dbDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbDocumentTx); + ODatabaseRecordThreadLocal.instance().set(dbDocumentTx); OSchema schema = dbDocumentTx.getMetadata().getSchema(); if (!schema.existsClass("TestClass")) { diff --git a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageUpdateCrashRestoreIT.java b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageUpdateCrashRestoreIT.java index 5aa38eafcda..5c57956c504 100755 --- a/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageUpdateCrashRestoreIT.java +++ b/server/src/test/java/com/orientechnologies/orient/core/storage/impl/local/paginated/LocalPaginatedStorageUpdateCrashRestoreIT.java @@ -171,7 +171,7 @@ public void testDocumentUpdate() throws Exception { } private void createSchema(ODatabaseDocumentTx dbDocumentTx) { - ODatabaseRecordThreadLocal.INSTANCE.set(dbDocumentTx); + ODatabaseRecordThreadLocal.instance().set(dbDocumentTx); OSchema schema = dbDocumentTx.getMetadata().getSchema(); if (!schema.existsClass("TestClass")) { @@ -209,7 +209,7 @@ private void saveDoc(ODocument document, ODatabaseDocumentTx baseDB, ODatabaseDo document.copyTo(testDoc); document.save(); - ODatabaseRecordThreadLocal.INSTANCE.set(testDB); + ODatabaseRecordThreadLocal.instance().set(testDB); testDB.activateOnCurrentThread(); testDoc.save(); diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/CRUDDocumentPhysicalTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/CRUDDocumentPhysicalTest.java index 4906843d592..8d17fa5b573 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/CRUDDocumentPhysicalTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/CRUDDocumentPhysicalTest.java @@ -777,7 +777,7 @@ public void testUpdateInChain() { public void testSerialization() { ORecordSerializer current = ODatabaseDocumentTx.getDefaultSerializer(); ODatabaseDocumentTx.setDefaultSerializer(ORecordSerializerSchemaAware2CSV.INSTANCE); - ODatabaseDocumentInternal oldDb = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocumentInternal oldDb = ODatabaseRecordThreadLocal.instance().get(); ORecordSerializer dbser = oldDb.getSerializer(); ((ODatabaseDocumentTx) oldDb).setSerializer(ORecordSerializerSchemaAware2CSV.INSTANCE); final byte[] streamOrigin = "Account@html:{\"path\":\"html/layout\"},config:{\"title\":\"Github Admin\",\"modules\":(githubDisplay:\"github_display\")},complex:(simple1:\"string1\",one_level1:(simple2:\"string2\"),two_levels:(simple3:\"string3\",one_level2:(simple4:\"string4\")))" diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DatabaseThreadFactoryTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DatabaseThreadFactoryTest.java index 594b9ac0b8d..d1fb0d41b12 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DatabaseThreadFactoryTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DatabaseThreadFactoryTest.java @@ -48,16 +48,16 @@ public void beforeMethod() throws Exception { @BeforeClass public void init() { try { - ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); db.close(); - ODatabaseRecordThreadLocal.INSTANCE.remove(); + ODatabaseRecordThreadLocal.instance().remove(); } catch (ODatabaseException ode) { } } @Test(expectedExceptions = { ODatabaseException.class }) public void testNoFactory() { - ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseRecordThreadLocal.instance().get(); Assert.fail("Database Should not be set in Current Thread"); } @@ -70,7 +70,7 @@ public ODatabaseDocumentInternal getThreadDatabase() { return poolFactory.get(url, "admin", "admin").acquire(); } }); - ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); + ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); Assert.assertNotNull(db); db.close(); } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SchemaTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SchemaTest.java index c0f590dc7c3..4be6a692c21 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SchemaTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SchemaTest.java @@ -189,7 +189,7 @@ public void testMultiThreadSchemaCreation() throws InterruptedException { @Override public void run() { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); ODocument doc = new ODocument("NewClass"); database.save(doc); diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionOptimisticTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionOptimisticTest.java index a8877934389..e7765e29961 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionOptimisticTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionOptimisticTest.java @@ -97,14 +97,14 @@ public void testTransactionOptimisticConcurrentException() throws IOException { // RE-READ THE RECORD record1.load(); - ODatabaseRecordThreadLocal.INSTANCE.set(db2); + ODatabaseRecordThreadLocal.instance().set(db2); OBlob record2 = db2.load(record1.getIdentity()); record2.setDirty(); record2.fromStream("This is the second version".getBytes()); record2.save(); - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); record1.setDirty(); record1.fromStream("This is the third version".getBytes()); record1.save(); @@ -165,7 +165,7 @@ public void testTransactionOptimisticCacheMgmt2Db() throws IOException { record1.save(); try { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); database.begin(); // RE-READ THE RECORD diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java index 96a5cf09b85..afc4eaed8f6 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java @@ -313,7 +313,7 @@ public void traverseAndCheckReturn() { String q = "traverse in('married') from " + nicoleKidman.getIdentity() + ""; ODatabaseDocumentTx db = database.copy(); - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List result1 = db.command(new OSQLSynchQuery(q)).execute(); Assert.assertEquals(result1.size(), 2); boolean found = false; @@ -322,7 +322,7 @@ public void traverseAndCheckReturn() { Assert.assertTrue(doc instanceof ODocument); } } finally { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); } } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/speed/GiantFileTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/speed/GiantFileTest.java index 5d2718416d1..62e684572bf 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/speed/GiantFileTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/speed/GiantFileTest.java @@ -150,7 +150,7 @@ private static void storeFileData(final ODocument fileDoc, final File file) thro // TODO: is this assumption ok? // Get the currently open database for this thread and set intent. - final ODatabase database = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabase database = ODatabaseRecordThreadLocal.instance().get(); database.declareIntent(new OIntentMassiveInsert()); // Insert File data. diff --git a/tests/src/test/java/com/orientechnologies/orient/test/internal/FreezeMultiThreadingTestNonTX.java b/tests/src/test/java/com/orientechnologies/orient/test/internal/FreezeMultiThreadingTestNonTX.java index 4450df2ac5c..bf3d94ebd04 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/internal/FreezeMultiThreadingTestNonTX.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/internal/FreezeMultiThreadingTestNonTX.java @@ -80,7 +80,7 @@ public Void call() throws Exception { ODatabaseDocumentTx database = new ODatabaseDocumentTx(URL); database.open("admin", "admin"); try { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); countDownLatch.await(); long value = createCounter.getAndIncrement(); @@ -115,7 +115,7 @@ public Void call() throws Exception { ODatabaseDocumentTx database = new ODatabaseDocumentTx(URL); database.open("admin", "admin"); try { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); countDownLatch.await(); long value = transactionalCreateCounter.getAndIncrement(); @@ -156,7 +156,7 @@ public Void call() throws Exception { ODatabaseDocumentTx database = new ODatabaseDocumentTx(URL); database.open("admin", "admin"); try { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); countDownLatch.await(); @@ -234,7 +234,7 @@ public Void call() throws Exception { ODatabaseDocumentTx database = new ODatabaseDocumentTx(URL); database.open("admin", "admin"); try { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); countDownLatch.await(); @@ -315,7 +315,7 @@ public Void call() throws Exception { ODatabaseDocumentTx database = new ODatabaseDocumentTx(URL); database.open("admin", "admin"); try { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); countDownLatch.await(); @@ -372,7 +372,7 @@ public Void call() throws Exception { ODatabaseDocumentTx database = new ODatabaseDocumentTx(URL); database.open("admin", "admin"); try { - ODatabaseRecordThreadLocal.INSTANCE.set(database); + ODatabaseRecordThreadLocal.instance().set(database); countDownLatch.await(); @@ -575,7 +575,7 @@ private void assertDocumentAreEquals(List firstDocs, List outer: for (final ODocument firstDoc : firstDocs) { for (final ODocument secondDoc : secondDocs) { if (firstDoc.equals(secondDoc)) { - final ODatabaseDocumentInternal databaseRecord = ODatabaseRecordThreadLocal.INSTANCE.get(); + final ODatabaseDocumentInternal databaseRecord = ODatabaseRecordThreadLocal.instance().get(); Assert.assertTrue(ODocumentHelper.hasSameContentOf(firstDoc, databaseRecord, secondDoc, databaseRecord, null)); continue outer; } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/internal/LockMultithreadingTest.java b/tests/src/test/java/com/orientechnologies/orient/test/internal/LockMultithreadingTest.java old mode 100644 new mode 100755 index 4f503cbb337..1a07d61bbee --- a/tests/src/test/java/com/orientechnologies/orient/test/internal/LockMultithreadingTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/internal/LockMultithreadingTest.java @@ -47,7 +47,7 @@ private class NonTransactionalAdder implements Callable { public Void call() throws Exception { Thread.currentThread().setName("Adder - " + Thread.currentThread().getId()); countDownLatch.await(); - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); long value = createCounter.getAndIncrement(); while (value < DOCUMENT_COUNT) { // because i like 7:) @@ -77,7 +77,7 @@ public Void call() throws Exception { continue; } - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List execute; System.out.println(Thread.currentThread() + " : before search cycle(update)" + updateCounter); do { @@ -118,7 +118,7 @@ public Void call() throws Exception { //wait while necessary document will be created while (number > createCounter.get()); try { - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); List execute; System.out.println(Thread.currentThread() + " : before search cycle (delete) " + number); diff --git a/tests/src/test/java/com/orientechnologies/orient/test/internal/index/IndexConcurrencyTest.java b/tests/src/test/java/com/orientechnologies/orient/test/internal/index/IndexConcurrencyTest.java index 16ec3049ecf..162546e9cbf 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/internal/index/IndexConcurrencyTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/internal/index/IndexConcurrencyTest.java @@ -248,7 +248,7 @@ public static void main(String[] args) { ODatabaseHelper.dropDatabase(db, url, "plocal"); } ODatabaseHelper.createDatabase(db, url); - ODatabaseRecordThreadLocal.INSTANCE.set(db); + ODatabaseRecordThreadLocal.instance().set(db); db.close(); } catch (IOException ex) { System.out.println("Exception: " + ex); diff --git a/tools/src/main/java/com/orientechnologies/orient/console/OTableFormatter.java b/tools/src/main/java/com/orientechnologies/orient/console/OTableFormatter.java index 0858fcf3d2d..c23cd61643e 100755 --- a/tools/src/main/java/com/orientechnologies/orient/console/OTableFormatter.java +++ b/tools/src/main/java/com/orientechnologies/orient/console/OTableFormatter.java @@ -323,7 +323,7 @@ else if (value instanceof ORecord) { value = ((ORecord) value).getIdentity().toString(); } } else if (value instanceof Date) { - final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined(); + final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) value = db.getStorage().getConfiguration().getDateTimeFormatInstance().format((Date) value); else {