From dd6211975f911869b7003a4c873b54294d461aaa Mon Sep 17 00:00:00 2001 From: Mikhaylo Demianenko Date: Mon, 29 Aug 2016 19:37:23 +0200 Subject: [PATCH] Remove introduced Fixed reference capability. Introduce format family and use it as one of the criteria for format migration. Based on format family not it's possible to see what kind of format do we see - Standard, High limit or other based on its family that is the same across all versions. --- .../kernel/impl/store/format/Capability.java | 5 -- .../impl/store/format/FormatFamily.java | 70 +++++++++++++++ .../impl/store/format/RecordFormats.java | 2 + .../impl/store/format/StoreVersion.java | 54 ++---------- .../format/standard/StandardFormatFamily.java | 48 +++++++++++ .../store/format/standard/StandardV2_0.java | 7 ++ .../store/format/standard/StandardV2_1.java | 7 ++ .../store/format/standard/StandardV2_2.java | 7 ++ .../store/format/standard/StandardV2_3.java | 7 ++ .../store/format/standard/StandardV3_0.java | 7 ++ .../storemigration/UpgradableDatabase.java | 18 ++-- .../participant/StoreMigrator.java | 13 ++- .../ForcedSecondaryUnitRecordFormats.java | 7 ++ .../RecordFormatPropertyConfiguratorTest.java | 7 ++ .../impl/store/format/StoreVersionTest.java | 85 ------------------- .../state/PrepareTrackingRecordFormats.java | 8 ++ .../store/format/highlimit/HighLimit.java | 11 ++- .../highlimit/HighLimitFormatFamily.java | 50 +++++++++++ .../format/highlimit/v30/HighLimitV3_0.java | 11 ++- .../UpgradableDatabaseTest.java | 21 +++-- integrationtests/logs/http.log | 2 + 21 files changed, 287 insertions(+), 160 deletions(-) create mode 100644 community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/FormatFamily.java create mode 100644 community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardFormatFamily.java delete mode 100644 community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/StoreVersionTest.java create mode 100644 enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFormatFamily.java rename {community => enterprise}/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabaseTest.java (93%) create mode 100644 integrationtests/logs/http.log diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/Capability.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/Capability.java index 379e982f664af..4af806f61b918 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/Capability.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/Capability.java @@ -37,11 +37,6 @@ public enum Capability */ DENSE_NODES( CapabilityType.FORMAT, CapabilityType.STORE ), - /** - * Store has fixed reference encoding support - */ - FIXED_REFERENCE( CapabilityType.FORMAT ), - /** * Store has version trailers in the end of cleanly shut down store */ diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/FormatFamily.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/FormatFamily.java new file mode 100644 index 0000000000000..00c332fa5e3f1 --- /dev/null +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/FormatFamily.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2002-2016 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.kernel.impl.store.format; + +/** + * Family of the format. Family of format is specific to a format across all version that format support. + * Two formats in different versions should have same format family. + * Family is one of the criteria that will determine if migration between formats is possible. + */ +public abstract class FormatFamily implements Comparable +{ + /** + * Get format family name + * @return family name + */ + public abstract String getName(); + + /** + * get format family rank + * @return rank + */ + public abstract int rank(); + + @Override + public int compareTo( FormatFamily formatFamily ) + { + return Integer.compare( this.rank(), formatFamily.rank() ); + } + + /** + * Check if migration between provided font families is possible. + * Family is upgradable if rank of the new family is higher then rank of old family + * @param oldFamily old family + * @param newFamily new family + * @return true if upgrade between families is possible, false otherwise + */ + public static boolean isUpgradable( FormatFamily oldFamily, FormatFamily newFamily ) + { + return oldFamily.compareTo( newFamily ) < 0; + } + + /** + * Check if provided font families is not upgradable. + * Family is not upgradable if rank of the new family is lower or equal to rank of old family + * @param oldFamily old family + * @param newFamily new family + * @return true if families not upgradable, false otherwise + */ + public static boolean isNotUpgradable( FormatFamily oldFamily, FormatFamily newFamily ) + { + return oldFamily.compareTo( newFamily ) > 0; + } +} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormats.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormats.java index f3cb75f795c97..6ee9c1cd74560 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormats.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormats.java @@ -92,6 +92,8 @@ public Factory( String key, String... altKeys ) */ boolean hasCapability( Capability capability ); + FormatFamily getFormatFamily(); + /** * Whether or not this format has the same capabilities of the specific {@code type} as the {@code other} format. * diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/StoreVersion.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/StoreVersion.java index bb60c2066fbd4..1b484a52dd59c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/StoreVersion.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/StoreVersion.java @@ -19,67 +19,29 @@ */ package org.neo4j.kernel.impl.store.format; -import javax.annotation.Nonnull; - /** * All known store formats are collected here. */ public enum StoreVersion { - STANDARD_V2_0( "v0.A.1", true ), - STANDARD_V2_1( "v0.A.3", true ), - STANDARD_V2_2( "v0.A.5", true ), - STANDARD_V2_3( "v0.A.6", true ), - STANDARD_V3_0( "v0.A.7", true ), - - HIGH_LIMIT_V3_0( "vE.H.0", false ), - HIGH_LIMIT_V3_1( "vE.H.1", false ); + STANDARD_V2_0( "v0.A.1" ), + STANDARD_V2_1( "v0.A.3" ), + STANDARD_V2_2( "v0.A.5" ), + STANDARD_V2_3( "v0.A.6" ), + STANDARD_V3_0( "v0.A.7" ), - private static final StoreVersion[] ALL_STORE_VERSIONS = values(); + HIGH_LIMIT_V3_0( "vE.H.0" ), + HIGH_LIMIT_V3_1( "vE.H.1" ); private final String versionString; - private final boolean isCommunity; - StoreVersion( String versionString, boolean isCommunity ) + StoreVersion( String versionString ) { this.versionString = versionString; - this.isCommunity = isCommunity; } public String versionString() { return versionString; } - - /** - * @param version string - * @return true if the store version is a known community format, false otherwise - */ - public static boolean isCommunityStoreVersion( @Nonnull String version ) - { - for ( StoreVersion storeVersion : ALL_STORE_VERSIONS ) - { - if ( storeVersion.versionString.equals( version ) && storeVersion.isCommunity ) - { - return true; - } - } - return false; - } - - /** - * @param version string - * @return true if the store version is a known enterprise format, false otherwise - */ - public static boolean isEnterpriseStoreVersion( @Nonnull String version ) - { - for ( StoreVersion storeVersion : ALL_STORE_VERSIONS ) - { - if ( storeVersion.versionString.equals( version ) && !storeVersion.isCommunity ) - { - return true; - } - } - return false; - } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardFormatFamily.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardFormatFamily.java new file mode 100644 index 0000000000000..de84a7adbe602 --- /dev/null +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardFormatFamily.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002-2016 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.kernel.impl.store.format.standard; + +import org.neo4j.kernel.impl.store.format.FormatFamily; + +/** + * Standard format family. + * @see FormatFamily + */ +public class StandardFormatFamily extends FormatFamily +{ + public static final FormatFamily INSTANCE = new StandardFormatFamily(); + + private StandardFormatFamily() + { + } + + @Override + public String getName() + { + return "Standard format family"; + } + + @Override + public int rank() + { + return 0; + } + +} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_0.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_0.java index 6fb82c870dd8b..177372095e3ef 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_0.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_0.java @@ -21,6 +21,7 @@ import org.neo4j.kernel.impl.store.format.BaseRecordFormats; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; @@ -90,4 +91,10 @@ public RecordFormat dynamic() { return new DynamicRecordFormat(); } + + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_1.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_1.java index d534d83df5a0c..cfa9849b6476d 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_1.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_1.java @@ -21,6 +21,7 @@ import org.neo4j.kernel.impl.store.format.BaseRecordFormats; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; @@ -91,4 +92,10 @@ public RecordFormat dynamic() { return new DynamicRecordFormat(); } + + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_2.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_2.java index 2364a0d1ba9b0..3ed82249c37c3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_2.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_2.java @@ -21,6 +21,7 @@ import org.neo4j.kernel.impl.store.format.BaseRecordFormats; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; @@ -91,4 +92,10 @@ public RecordFormat dynamic() { return new DynamicRecordFormat(); } + + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_3.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_3.java index 07d832b2c5cbc..5f694eea95b32 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_3.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV2_3.java @@ -21,6 +21,7 @@ import org.neo4j.kernel.impl.store.format.BaseRecordFormats; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; @@ -90,4 +91,10 @@ public RecordFormat dynamic() { return new DynamicRecordFormat(); } + + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV3_0.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV3_0.java index 48121c114d692..de8148dfd939e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV3_0.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/StandardV3_0.java @@ -21,6 +21,7 @@ import org.neo4j.kernel.impl.store.format.BaseRecordFormats; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; @@ -91,4 +92,10 @@ public RecordFormat dynamic() { return new DynamicRecordFormat(); } + + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabase.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabase.java index 97420f5c2f370..c78e43abd27cb 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabase.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabase.java @@ -25,9 +25,9 @@ import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.impl.store.MetaDataStore; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormatSelector; import org.neo4j.kernel.impl.store.format.RecordFormats; -import org.neo4j.kernel.impl.store.format.StoreVersion; import org.neo4j.kernel.impl.storemigration.StoreUpgrader.DatabaseNotCleanlyShutDownException; import org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnexpectedUpgradingStoreFormatException; import org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnexpectedUpgradingStoreVersionException; @@ -88,18 +88,18 @@ public RecordFormats checkUpgradeable( File storeDirectory ) return format; } - // If we are trying to open an enterprise store when configured to use community format, then inform the user - // of the config setting to change since downgrades aren't possible but the store can still be opened. - if ( StoreVersion.isEnterpriseStoreVersion( result.actualVersion ) && - StoreVersion.isCommunityStoreVersion( format.storeVersion() ) ) - { - throw new StoreUpgrader.UnexpectedUpgradingStoreFormatException(); - } - RecordFormats fromFormat; try { fromFormat = RecordFormatSelector.selectForVersion( result.actualVersion ); + + // If we are trying to open an enterprise store when configured to use community format, then inform the user + // of the config setting to change since downgrades aren't possible but the store can still be opened. + if ( FormatFamily.isNotUpgradable( fromFormat.getFormatFamily(), format.getFormatFamily() ) ) + { + throw new StoreUpgrader.UnexpectedUpgradingStoreFormatException(); + } + if ( fromFormat.generation() > format.generation() ) { // Tried to downgrade, that isn't supported diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/participant/StoreMigrator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/participant/StoreMigrator.java index 6318c3b3b5ab5..89720c04a5877 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/participant/StoreMigrator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/participant/StoreMigrator.java @@ -56,6 +56,7 @@ import org.neo4j.kernel.impl.store.TransactionId; import org.neo4j.kernel.impl.store.counts.CountsTracker; import org.neo4j.kernel.impl.store.format.CapabilityType; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.standard.MetaDataRecordFormat; import org.neo4j.kernel.impl.store.format.standard.NodeRecordFormat; @@ -170,7 +171,7 @@ public void migrate( File storeDir, File migrationDir, MigrationProgressMonitor. RecordFormats oldFormat = selectForVersion( versionToMigrateFrom ); RecordFormats newFormat = selectForVersion( versionToMigrateTo ); - if ( !oldFormat.hasSameCapabilities( newFormat, CapabilityType.FORMAT ) ) + if ( upgradeFormatType( oldFormat, newFormat ) || isDifferentCapabilities( oldFormat, newFormat ) ) { // TODO if this store has relationship indexes then warn user about that they will be incorrect // after migration, because now we're rewriting the relationship ids. @@ -192,6 +193,16 @@ public void migrate( File storeDir, File migrationDir, MigrationProgressMonitor. // must be a proper translation happening while doing so. } + private boolean isDifferentCapabilities( RecordFormats oldFormat, RecordFormats newFormat ) + { + return !oldFormat.hasSameCapabilities( newFormat, CapabilityType.FORMAT ); + } + + private boolean upgradeFormatType( RecordFormats oldFormat, RecordFormats newFormat ) + { + return FormatFamily.isUpgradable( oldFormat.getFormatFamily(), newFormat.getFormatFamily() ); + } + void writeLastTxInformation( File migrationDir, TransactionId txInfo ) throws IOException { writeTxLogCounters( fileSystem, lastTxInformationFile( migrationDir ), diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/ForcedSecondaryUnitRecordFormats.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/ForcedSecondaryUnitRecordFormats.java index 1dab36fd27ba3..6559983fdaa14 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/ForcedSecondaryUnitRecordFormats.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/ForcedSecondaryUnitRecordFormats.java @@ -19,6 +19,7 @@ */ package org.neo4j.kernel.impl.store.format; +import org.neo4j.kernel.impl.store.format.standard.StandardFormatFamily; import org.neo4j.kernel.impl.store.id.IdSequence; import org.neo4j.kernel.impl.store.record.AbstractBaseRecord; import org.neo4j.kernel.impl.store.record.DynamicRecord; @@ -129,6 +130,12 @@ public boolean hasCapability( Capability capability ) return actual.hasCapability( capability ); } + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } + @Override public boolean hasSameCapabilities( RecordFormats other, CapabilityType type ) { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatPropertyConfiguratorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatPropertyConfiguratorTest.java index 7f218d6cac94f..c01105a066e84 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatPropertyConfiguratorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatPropertyConfiguratorTest.java @@ -26,6 +26,7 @@ import org.neo4j.helpers.collection.MapUtil; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.store.format.standard.NoRecordFormat; +import org.neo4j.kernel.impl.store.format.standard.StandardFormatFamily; import org.neo4j.kernel.impl.store.format.standard.StandardV3_0; import org.neo4j.kernel.impl.store.record.DynamicRecord; import org.neo4j.kernel.impl.store.record.LabelTokenRecord; @@ -174,6 +175,12 @@ public boolean hasCapability( Capability capability ) return false; } + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } + @Override public boolean hasSameCapabilities( RecordFormats other, CapabilityType type ) { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/StoreVersionTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/StoreVersionTest.java deleted file mode 100644 index 3a785f4f2d1c3..0000000000000 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/StoreVersionTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2002-2016 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.store.format; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Arrays; -import java.util.Collection; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -@RunWith( Parameterized.class ) -public class StoreVersionTest -{ - @Parameterized.Parameter( 0 ) - public String version; - - @Parameterized.Parameters( name = "{0}" ) - public static Collection versions() - { - return Arrays.asList( - StoreVersion.STANDARD_V2_0.versionString(), - StoreVersion.STANDARD_V2_1.versionString(), - StoreVersion.STANDARD_V2_2.versionString(), - StoreVersion.STANDARD_V2_3.versionString(), - StoreVersion.STANDARD_V3_0.versionString() ); - } - - @Test - public void shouldBeCommunityFormat() - { - assertTrue( "Expected community format", StoreVersion.isCommunityStoreVersion( version ) ); - } - - @Test - public void shouldNotBeLabeledEnterpriseFormat() - { - assertFalse( "Expected non-enterprise format", StoreVersion.isEnterpriseStoreVersion( version ) ); - } - - @RunWith( Parameterized.class ) - public static class EnterpriseVersions - { - @Parameterized.Parameter( 0 ) - public String version; - - @Parameterized.Parameters( name = "{0}" ) - public static Collection versions() - { - return Arrays.asList( StoreVersion.HIGH_LIMIT_V3_0.versionString() ); - } - - @Test - public void shouldBeCommunityFormat() - { - assertFalse( "Expected non-community format", StoreVersion.isCommunityStoreVersion( version ) ); - } - - @Test - public void shouldNotBeLabeledEnterpriseFormat() - { - assertTrue( "Expected enterprise format", StoreVersion.isEnterpriseStoreVersion( version ) ); - } - } -} diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/PrepareTrackingRecordFormats.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/PrepareTrackingRecordFormats.java index f6944126b3e35..63af0636c545b 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/PrepareTrackingRecordFormats.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/PrepareTrackingRecordFormats.java @@ -27,8 +27,10 @@ import org.neo4j.kernel.impl.store.StoreHeader; import org.neo4j.kernel.impl.store.format.Capability; import org.neo4j.kernel.impl.store.format.CapabilityType; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; +import org.neo4j.kernel.impl.store.format.standard.StandardFormatFamily; import org.neo4j.kernel.impl.store.id.IdSequence; import org.neo4j.kernel.impl.store.record.AbstractBaseRecord; import org.neo4j.kernel.impl.store.record.DynamicRecord; @@ -138,6 +140,12 @@ public boolean hasCapability( Capability capability ) return actual.hasCapability( capability ); } + @Override + public FormatFamily getFormatFamily() + { + return StandardFormatFamily.INSTANCE; + } + @Override public boolean hasSameCapabilities( RecordFormats other, CapabilityType type ) { diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimit.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimit.java index ea56046074472..c3ed6d7e8a557 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimit.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimit.java @@ -21,10 +21,10 @@ import org.neo4j.kernel.impl.store.format.BaseRecordFormats; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; -import org.neo4j.kernel.impl.store.format.highlimit.v30.HighLimitV3_0; import org.neo4j.kernel.impl.store.format.standard.LabelTokenRecordFormat; import org.neo4j.kernel.impl.store.format.standard.PropertyKeyTokenRecordFormat; import org.neo4j.kernel.impl.store.format.standard.RelationshipTypeTokenRecordFormat; @@ -55,8 +55,7 @@ public class HighLimit extends BaseRecordFormats public HighLimit() { - super( STORE_VERSION, 8, Capability.DENSE_NODES, Capability.SCHEMA, Capability.LUCENE_5, - Capability.FIXED_REFERENCE ); + super( STORE_VERSION, 8, Capability.DENSE_NODES, Capability.SCHEMA, Capability.LUCENE_5 ); } @Override @@ -106,4 +105,10 @@ public RecordFormat dynamic() { return new DynamicRecordFormat(); } + + @Override + public FormatFamily getFormatFamily() + { + return HighLimitFormatFamily.INSTANCE; + } } diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFormatFamily.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFormatFamily.java new file mode 100644 index 0000000000000..bff83c29d2b31 --- /dev/null +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFormatFamily.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002-2016 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.neo4j.kernel.impl.store.format.highlimit; + +import org.neo4j.kernel.impl.store.format.FormatFamily; + +/** + * High limit format family. + * @see FormatFamily + */ +public class HighLimitFormatFamily extends FormatFamily +{ + public static final FormatFamily INSTANCE = new HighLimitFormatFamily(); + + private static final String HIGH_LIMIT_FORMAT_FAMILY_NAME = "High limit format family"; + + private HighLimitFormatFamily() + { + } + + @Override + public String getName() + { + return HIGH_LIMIT_FORMAT_FAMILY_NAME; + } + + @Override + public int rank() + { + return 1; + } + +} diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/v30/HighLimitV3_0.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/v30/HighLimitV3_0.java index c24139a74dcff..56bee9193c73f 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/v30/HighLimitV3_0.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/v30/HighLimitV3_0.java @@ -21,10 +21,12 @@ import org.neo4j.kernel.impl.store.format.BaseRecordFormats; import org.neo4j.kernel.impl.store.format.Capability; +import org.neo4j.kernel.impl.store.format.FormatFamily; import org.neo4j.kernel.impl.store.format.RecordFormat; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; import org.neo4j.kernel.impl.store.format.highlimit.DynamicRecordFormat; +import org.neo4j.kernel.impl.store.format.highlimit.HighLimitFormatFamily; import org.neo4j.kernel.impl.store.format.standard.LabelTokenRecordFormat; import org.neo4j.kernel.impl.store.format.standard.PropertyKeyTokenRecordFormat; import org.neo4j.kernel.impl.store.format.standard.RelationshipTypeTokenRecordFormat; @@ -55,8 +57,7 @@ public class HighLimitV3_0 extends BaseRecordFormats public HighLimitV3_0() { - super( STORE_VERSION, 7, Capability.DENSE_NODES, Capability.SCHEMA, Capability.LUCENE_5, - Capability.FIXED_REFERENCE ); + super( STORE_VERSION, 7, Capability.DENSE_NODES, Capability.SCHEMA, Capability.LUCENE_5 ); } @Override @@ -106,4 +107,10 @@ public RecordFormat dynamic() { return new DynamicRecordFormat(); } + + @Override + public FormatFamily getFormatFamily() + { + return HighLimitFormatFamily.INSTANCE; + } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabaseTest.java b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabaseTest.java similarity index 93% rename from community/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabaseTest.java rename to enterprise/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabaseTest.java index adc5e63fa6f23..2305a5f8f99f0 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabaseTest.java +++ b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/UpgradableDatabaseTest.java @@ -5,17 +5,17 @@ * This file is part of Neo4j. * * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Affero General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . */ package org.neo4j.kernel.impl.storemigration; @@ -36,8 +36,10 @@ import org.neo4j.io.fs.DefaultFileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.impl.store.MetaDataStore; +import org.neo4j.kernel.impl.store.format.RecordFormatSelector; import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.StoreVersion; +import org.neo4j.kernel.impl.store.format.standard.StandardFormatFamily; import org.neo4j.kernel.impl.store.format.standard.StandardV2_0; import org.neo4j.kernel.impl.store.format.standard.StandardV2_1; import org.neo4j.kernel.impl.store.format.standard.StandardV2_2; @@ -50,6 +52,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.neo4j.kernel.impl.store.MetaDataStore.Position.STORE_VERSION; @@ -211,7 +214,7 @@ public static class UnsupportedVersions @Parameterized.Parameters( name = "{0}" ) public static Collection versions() { - return Arrays.asList( "v0.9.5", "v0.A.4", StoreVersion.HIGH_LIMIT_V3_0.versionString() ); + return Arrays.asList( "v0.A.4", StoreVersion.HIGH_LIMIT_V3_0.versionString() ); } @Rule @@ -260,14 +263,14 @@ public void shouldCommunicateWhatCausesInabilityToUpgrade() catch ( StoreUpgrader.UnexpectedUpgradingStoreVersionException e ) { // then - assertFalse( StoreVersion.isEnterpriseStoreVersion( version ) ); File expectedFile = new File( workingDirectory, neostoreFilename ).getAbsoluteFile(); assertEquals( String.format( MESSAGE, expectedFile, version ), e.getMessage() ); } catch ( StoreUpgrader.UnexpectedUpgradingStoreFormatException e ) { // then - assertTrue( StoreVersion.isEnterpriseStoreVersion( version ) ); + assertNotSame( StandardFormatFamily.INSTANCE, + RecordFormatSelector.selectForVersion( version ).getFormatFamily()); assertEquals( String.format( StoreUpgrader.UnexpectedUpgradingStoreFormatException.MESSAGE, GraphDatabaseSettings.record_format.name() ), e.getMessage() ); } diff --git a/integrationtests/logs/http.log b/integrationtests/logs/http.log new file mode 100644 index 0000000000000..743126635813a --- /dev/null +++ b/integrationtests/logs/http.log @@ -0,0 +1,2 @@ +2016-08-29 17:34:26.028+0000 INFO [REQUEST] [AsyncLog @ 2016-08-29 17:34:26.027+0000] null - null [Mon Aug 29 19:34:26 CEST 2016] "/db/data/node?null" 201 -1 "null" "Java/1.8.0_101" 1472492066027 +2016-08-29 17:34:26.029+0000 INFO [REQUEST] [AsyncLog @ 2016-08-29 17:34:26.028+0000] 127.0.0.1 - null [Mon Aug 29 19:34:26 CEST 2016] "/db/data/batch?null" 200 -1 "null" "Java/1.8.0_101" 114