diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java index ec144baf106..c6fa334ffba 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java @@ -1761,11 +1761,15 @@ private void initNameIdMapping() throws IOException, InterruptedException { final Path nameIdMapHolderV1 = storagePath.resolve(NAME_ID_MAP_V1); final Path nameIdMapHolderV2 = storagePath.resolve(NAME_ID_MAP_V2); + final Path nameIdMapHolderV3 = storagePath.resolve(NAME_ID_MAP_V3); if (Files.exists(nameIdMapHolderV1)) { if (Files.exists(nameIdMapHolderV2)) { Files.delete(nameIdMapHolderV2); } + if (Files.exists(nameIdMapHolderV3)) { + Files.delete(nameIdMapHolderV3); + } try (final FileChannel nameIdMapHolder = FileChannel.open(nameIdMapHolderV1, StandardOpenOption.WRITE, StandardOpenOption.READ)) { @@ -1774,7 +1778,9 @@ private void initNameIdMapping() throws IOException, InterruptedException { Files.delete(nameIdMapHolderV1); } else if (Files.exists(nameIdMapHolderV2)) { - nameIdMapHolderPath = storagePath.resolve(NAME_ID_MAP_V2); + if (Files.exists(nameIdMapHolderV3)) { + Files.delete(nameIdMapHolderV3); + } try (final FileChannel nameIdMapHolder = FileChannel.open(nameIdMapHolderV2, StandardOpenOption.WRITE, StandardOpenOption.READ)) { @@ -1784,7 +1790,7 @@ private void initNameIdMapping() throws IOException, InterruptedException { Files.delete(nameIdMapHolderV2); } - nameIdMapHolderPath = storagePath.resolve(NAME_ID_MAP_V3); + nameIdMapHolderPath = nameIdMapHolderV3; if (Files.exists(nameIdMapHolderPath)) { try (final FileChannel nameIdMapHolder = FileChannel.open( @@ -1903,10 +1909,16 @@ private void readNameIdMapV3(FileChannel nameIdMapHolder) localFileCounter = absFileId; } - nameIdMap.put(nameFileIdEntry.name, nameFileIdEntry.fileId); - idNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.name); + if (absFileId != 0) { + nameIdMap.put(nameFileIdEntry.name, nameFileIdEntry.fileId); + idNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.name); - idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName); + idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName); + } else { + nameIdMap.remove(nameFileIdEntry.name); + idNameMap.remove(nameFileIdEntry.fileId); + idFileNameMap.remove(nameFileIdEntry.fileId); + } } for (final Map.Entry nameIdEntry : nameIdMap.entrySet()) { @@ -1966,12 +1978,14 @@ private void readNameIdMapV2(FileChannel nameIdMapHolder) if (absFileId != 0) { nameIdMap.put(nameFileIdEntry.name, nameFileIdEntry.fileId); idNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.name); + + idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName); } else { nameIdMap.remove(nameFileIdEntry.name); + idNameMap.remove(nameFileIdEntry.fileId); + idFileNameMap.remove(nameFileIdEntry.fileId); } - - idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName); } for (final Map.Entry nameIdEntry : nameIdMap.entrySet()) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/cas/CASDiskWriteAheadLog.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/cas/CASDiskWriteAheadLog.java index d1c5a39deb8..ff544325cb9 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/cas/CASDiskWriteAheadLog.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/cas/CASDiskWriteAheadLog.java @@ -948,7 +948,7 @@ private boolean checkPageIsBrokenAndDecrypt( } final int pageSize = buffer.getShort(CASWALPage.PAGE_SIZE_OFFSET); - if (pageSize == 0 || pageSize > walPageSize) { + if (pageSize <= 0 || pageSize > walPageSize) { return true; } diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageEncryptionTestIT.java b/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageEncryptionTestIT.java index bdeb5fb3757..b117cd83c52 100644 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageEncryptionTestIT.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageEncryptionTestIT.java @@ -6,7 +6,6 @@ import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; import com.orientechnologies.orient.core.db.ODatabaseSession; -import com.orientechnologies.orient.core.db.ODatabaseType; import com.orientechnologies.orient.core.db.OrientDB; import com.orientechnologies.orient.core.db.OrientDBConfig; import com.orientechnologies.orient.core.id.ORID; @@ -170,7 +169,8 @@ public void testEncryptionSingleDatabase() { .addConfig(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY, "T1JJRU5UREJfSVNfQ09PTA==") .build(); - orientDB.create("encryption", ODatabaseType.PLOCAL, orientDBConfig); + orientDB.execute( + "create database encryption plocal users ( admin identified by 'admin' role admin)"); } try (final OrientDB orientDB = new OrientDB( diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageTestIT.java b/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageTestIT.java index 51b91b7f265..0119491ae4b 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageTestIT.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/OStorageTestIT.java @@ -5,7 +5,6 @@ import com.orientechnologies.orient.core.db.ODatabase; import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; import com.orientechnologies.orient.core.db.ODatabaseSession; -import com.orientechnologies.orient.core.db.ODatabaseType; import com.orientechnologies.orient.core.db.OSharedContext; import com.orientechnologies.orient.core.db.OrientDB; import com.orientechnologies.orient.core.db.OrientDBConfig; @@ -53,7 +52,10 @@ public void testCheckSumFailureReadOnly() throws Exception { .build(); orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config); - orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config); + orientDB.execute( + "create database " + + OStorageTestIT.class.getSimpleName() + + " plocal users ( admin identified by 'admin' role admin)"); ODatabaseSession session = orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config); @@ -114,7 +116,10 @@ public void testCheckMagicNumberReadOnly() throws Exception { .build(); orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config); - orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config); + orientDB.execute( + "create database " + + OStorageTestIT.class.getSimpleName() + + " plocal users ( admin identified by 'admin' role admin)"); ODatabaseSession session = orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config); @@ -171,7 +176,10 @@ public void testCheckMagicNumberVerify() throws Exception { .build(); orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config); - orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config); + orientDB.execute( + "create database " + + OStorageTestIT.class.getSimpleName() + + " plocal users ( admin identified by 'admin' role admin)"); ODatabaseSession session = orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config); @@ -230,7 +238,10 @@ public void testCheckSumFailureVerifyAndLog() throws Exception { .build(); orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config); - orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config); + orientDB.execute( + "create database " + + OStorageTestIT.class.getSimpleName() + + " plocal users ( admin identified by 'admin' role admin)"); ODatabaseSession session = orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config); @@ -287,8 +298,10 @@ public void testCreatedVersionIsStored() { orientDB = new OrientDB( "embedded:" + buildPath.toFile().getAbsolutePath(), OrientDBConfig.defaultConfig()); - orientDB.create( - OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, OrientDBConfig.defaultConfig()); + orientDB.execute( + "create database " + + OStorageTestIT.class.getSimpleName() + + " plocal users ( admin identified by 'admin' role admin)"); final ODatabaseSession session = orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin"); diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/index/hashindex/local/v2/LocalHashTableV2TestIT.java b/core/src/test/java/com/orientechnologies/orient/core/storage/index/hashindex/local/v2/LocalHashTableV2TestIT.java index 47e0c7066ed..6878edc233d 100644 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/index/hashindex/local/v2/LocalHashTableV2TestIT.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/index/hashindex/local/v2/LocalHashTableV2TestIT.java @@ -5,7 +5,6 @@ import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.db.ODatabaseInternal; import com.orientechnologies.orient.core.db.ODatabaseSession; -import com.orientechnologies.orient.core.db.ODatabaseType; import com.orientechnologies.orient.core.db.OrientDB; import com.orientechnologies.orient.core.db.OrientDBConfig; import com.orientechnologies.orient.core.metadata.schema.OType; @@ -37,7 +36,8 @@ public void before() throws Exception { .build(); orientDB = new OrientDB("plocal:" + buildDirectory, config); - orientDB.create(DB_NAME, ODatabaseType.PLOCAL, config); + orientDB.execute( + "create database " + DB_NAME + " plocal users ( admin identified by 'admin' role admin)"); final ODatabaseSession databaseDocumentTx = orientDB.open(DB_NAME, "admin", "admin", config); storage = (OAbstractPaginatedStorage) ((ODatabaseInternal) databaseDocumentTx).getStorage(); OMurmurHash3HashFunction murmurHash3HashFunction = diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v1/SBTreeV1TestIT.java b/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v1/SBTreeV1TestIT.java index 025d936b857..e219f5e19df 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v1/SBTreeV1TestIT.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v1/SBTreeV1TestIT.java @@ -8,7 +8,6 @@ import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.db.ODatabaseInternal; import com.orientechnologies.orient.core.db.ODatabaseSession; -import com.orientechnologies.orient.core.db.ODatabaseType; import com.orientechnologies.orient.core.db.OrientDB; import com.orientechnologies.orient.core.db.OrientDBConfig; import com.orientechnologies.orient.core.db.record.OIdentifiable; @@ -78,7 +77,8 @@ public void before() throws Exception { .addConfig(OGlobalConfiguration.STORAGE_TRACK_PAGE_OPERATIONS_IN_TX, true) .build(); orientDB = new OrientDB("plocal:" + buildDirectory, orientDBConfig); - orientDB.create(dbName, ODatabaseType.PLOCAL, orientDBConfig); + orientDB.execute( + "create database " + dbName + " plocal users ( admin identified by 'admin' role admin)"); databaseDocumentTx = orientDB.open(dbName, "admin", "admin"); diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v2/SBTreeV2TestIT.java b/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v2/SBTreeV2TestIT.java index 8d03a04411f..8cb929987ca 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v2/SBTreeV2TestIT.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/local/v2/SBTreeV2TestIT.java @@ -8,7 +8,6 @@ import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.db.ODatabaseInternal; import com.orientechnologies.orient.core.db.ODatabaseSession; -import com.orientechnologies.orient.core.db.ODatabaseType; import com.orientechnologies.orient.core.db.OrientDB; import com.orientechnologies.orient.core.db.OrientDBConfig; import com.orientechnologies.orient.core.db.record.OIdentifiable; @@ -79,7 +78,8 @@ public void before() throws Exception { .addConfig(OGlobalConfiguration.STORAGE_TRACK_PAGE_OPERATIONS_IN_TX, true) .build(); orientDB = new OrientDB("plocal:" + buildDirectory, orientDBConfig); - orientDB.create(dbName, ODatabaseType.PLOCAL, orientDBConfig); + orientDB.execute( + "create database " + dbName + " plocal users ( admin identified by 'admin' role admin)"); databaseDocumentTx = orientDB.open(dbName, "admin", "admin"); diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtreebonsai/global/btree/BTreeTestIT.java b/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtreebonsai/global/btree/BTreeTestIT.java index c472abd4fa9..0a96c6ada08 100644 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtreebonsai/global/btree/BTreeTestIT.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtreebonsai/global/btree/BTreeTestIT.java @@ -4,7 +4,6 @@ import com.orientechnologies.common.util.ORawPair; import com.orientechnologies.orient.core.db.ODatabaseInternal; import com.orientechnologies.orient.core.db.ODatabaseSession; -import com.orientechnologies.orient.core.db.ODatabaseType; import com.orientechnologies.orient.core.db.OrientDB; import com.orientechnologies.orient.core.db.OrientDBConfig; import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage; @@ -69,7 +68,8 @@ public static void beforeClass() { orientDB.drop(DB_NAME); } - orientDB.create(DB_NAME, ODatabaseType.PLOCAL); + orientDB.execute( + "create database " + DB_NAME + " plocal users ( admin identified by 'admin' role admin)"); ODatabaseSession databaseSession = orientDB.open(DB_NAME, "admin", "admin"); storage = (OAbstractPaginatedStorage) ((ODatabaseInternal) databaseSession).getStorage();