diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java index 14141eba67abb..35b2f36b02d94 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java @@ -33,11 +33,11 @@ import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PagedFile; -import org.neo4j.kernel.impl.store.id.IdGeneratorFactory; -import org.neo4j.kernel.impl.store.id.IdType; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.store.id.IdGenerator; +import org.neo4j.kernel.impl.store.id.IdGeneratorFactory; import org.neo4j.kernel.impl.store.id.IdGeneratorImpl; +import org.neo4j.kernel.impl.store.id.IdType; import org.neo4j.kernel.impl.store.record.AbstractBaseRecord; import org.neo4j.kernel.impl.store.record.Record; import org.neo4j.kernel.impl.store.record.RecordLoad; @@ -67,12 +67,12 @@ public abstract class CommonAbstractStore protected final IdGeneratorFactory idGeneratorFactory; protected final Log log; protected PagedFile storeFile; + protected final String storeVersion; private IdGenerator idGenerator; private boolean storeOk = true; private Throwable causeOfStoreNotOk; private final String typeDescriptor; - private final String storeVersion; /** * Opens and validates the store contained in fileName diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/MetaDataStore.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/MetaDataStore.java index 7f41b7641a901..f5185130857e2 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/MetaDataStore.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/MetaDataStore.java @@ -28,10 +28,9 @@ import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PagedFile; -import org.neo4j.kernel.impl.store.format.lowlimit.LowLimit; +import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.store.id.IdGeneratorFactory; import org.neo4j.kernel.impl.store.id.IdType; -import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.store.record.NeoStoreActualRecord; import org.neo4j.kernel.impl.store.record.NeoStoreRecord; import org.neo4j.kernel.impl.store.record.Record; @@ -152,7 +151,8 @@ protected void initialiseNewStoreFile( PagedFile file ) throws IOException { super.initialiseNewStoreFile( file ); - StoreId storeId = new StoreId(); + long storeVersionAsLong = MetaDataStore.versionStringToLong( storeVersion ); + StoreId storeId = new StoreId( storeVersionAsLong ); storeFile = file; setCreationTime( storeId.getCreationTime() ); @@ -164,7 +164,7 @@ protected void initialiseNewStoreFile( PagedFile file ) throws IOException setCurrentLogVersion( 0 ); setLastCommittedAndClosedTransactionId( BASE_TX_ID, BASE_TX_CHECKSUM, BASE_TX_LOG_VERSION, BASE_TX_LOG_BYTE_OFFSET ); - setStoreVersion( MetaDataStore.versionStringToLong( LowLimit.STORE_VERSION ) ); + setStoreVersion( storeVersionAsLong ); setGraphNextProp( -1 ); setLatestConstraintIntroducingTx( 0 ); @@ -298,7 +298,7 @@ static int getPageSize( PageCache pageCache ) public StoreId getStoreId() { - return new StoreId( getCreationTime(), getRandomNumber(), getUpgradeTime(), upgradeTxIdField ); + return new StoreId( getCreationTime(), getRandomNumber(), getStoreVersion(), getUpgradeTime(), upgradeTxIdField ); } public long getUpgradeTime() diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/StoreId.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/StoreId.java index 51d05954e433b..822fd3b5a652c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/StoreId.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/StoreId.java @@ -34,7 +34,7 @@ public final class StoreId implements Externalizable { public static final long CURRENT_STORE_VERSION = versionStringToLong( LowLimit.STORE_VERSION ); - public static final StoreId DEFAULT = new StoreId( -1, -1, -1, -1 ); + public static final StoreId DEFAULT = new StoreId( -1, -1, -1, -1, -1 ); private static final Random r = new SecureRandom(); @@ -44,24 +44,23 @@ public final class StoreId implements Externalizable private long upgradeTime; private long upgradeId; - public StoreId() + private StoreId() + { + //For the readExternal method. + } + + public StoreId( long storeVersion ) { // If creationTime == upgradeTime && randomNumber == upgradeId then store has never been upgraded long currentTimeMillis = System.currentTimeMillis(); long randomLong = r.nextLong(); - + this.storeVersion = storeVersion; this.creationTime = currentTimeMillis; this.randomId = randomLong; - this.storeVersion = CURRENT_STORE_VERSION; this.upgradeTime = currentTimeMillis; this.upgradeId = randomLong; } - public StoreId( long creationTime, long randomId, long upgradeTime, long upgradeId ) - { - this( creationTime, randomId, CURRENT_STORE_VERSION, upgradeTime, upgradeId ); - } - public StoreId( long creationTime, long randomId, long storeVersion, long upgradeTime, long upgradeId ) { this.creationTime = creationTime; @@ -153,12 +152,12 @@ public int hashCode() public String toString() { return "StoreId{" + - "creationTime=" + creationTime + - ", randomId=" + randomId + - ", storeVersion=" + storeVersion + - ", upgradeTime=" + upgradeTime + - ", upgradeId=" + upgradeId + - '}'; + "creationTime=" + creationTime + + ", randomId=" + randomId + + ", storeVersion=" + storeVersion + + ", upgradeTime=" + upgradeTime + + ", upgradeId=" + upgradeId + + '}'; } private static boolean equal( long first, long second ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/InternalRecordFormatSelector.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/InternalRecordFormatSelector.java index 85444d1ab19a0..ceab992ca8834 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/InternalRecordFormatSelector.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/InternalRecordFormatSelector.java @@ -19,9 +19,7 @@ */ package org.neo4j.kernel.impl.store.format; -import org.neo4j.helpers.Service; -import org.neo4j.kernel.configuration.Config; -import org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory; +import org.neo4j.kernel.impl.store.format.lowlimit.LowLimit; /** * Selects format to use for databases in this JVM, using a system property. By default uses the safest @@ -30,29 +28,13 @@ */ public class InternalRecordFormatSelector { - public static RecordFormats select( Config config ) + public static RecordFormats select() { - String key = config.get( GraphDatabaseFacadeFactory.Configuration.record_type ); - RecordFormats.Factory potentialCandidate = null; - for ( RecordFormats.Factory candidate : Service.load( RecordFormats.Factory.class ) ) - { - String candidateId = candidate.getKeys().iterator().next(); - if ( candidateId.equals( key ) ) - { - return candidate.newInstance(); - } - else if ( potentialCandidate == null || candidateId.equals( "highlimit" ) ) - { - potentialCandidate = candidate; - } - } - if ( key.equals( "" ) ) - { - return potentialCandidate.newInstance(); - } - else - { - throw new IllegalArgumentException( "Invalid configuration for record format." ); - } + //todo: uncomment this loop once high-limits store migration is done. +// for ( RecordFormats.Factory candidate : Service.load( RecordFormats.Factory.class ) ) +// { +// return candidate.newInstance(); +// } + return LowLimit.RECORD_FORMATS; } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/lowlimit/LowLimitFactory.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/lowlimit/LowLimitFactory.java deleted file mode 100644 index 4ab38e9a83830..0000000000000 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/lowlimit/LowLimitFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.neo4j.kernel.impl.store.format.lowlimit; - -import org.neo4j.helpers.Service; -import org.neo4j.kernel.impl.store.format.RecordFormats; - -@Service.Implementation(RecordFormats.Factory.class) -public class LowLimitFactory extends RecordFormats.Factory -{ - public LowLimitFactory() - { - super( "lowlimit" ); - } - - @Override - public RecordFormats newInstance( ) - { - return LowLimit.RECORD_FORMATS; - } -} diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/StoreIdTestFactory.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/StoreIdTestFactory.java new file mode 100644 index 0000000000000..e24347453803c --- /dev/null +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/StoreIdTestFactory.java @@ -0,0 +1,45 @@ +/* + * 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; + +import org.neo4j.kernel.impl.store.format.InternalRecordFormatSelector; +import org.neo4j.kernel.impl.store.format.RecordFormats; + +public class StoreIdTestFactory +{ + private static long currentStoreVersionAsLong() + { + RecordFormats select = InternalRecordFormatSelector.select(); + return MetaDataStore.versionStringToLong( select.storeVersion() ); + } + + public static StoreId newStoreIdForCurrentVersion() + { + return new StoreId( currentStoreVersionAsLong() ); + } + + public static StoreId newStoreIdForCurrentVersion( long creationTime, long randomId, long upgradeTime, long + upgradeId ) + { + RecordFormats select = InternalRecordFormatSelector.select(); + return new StoreId( creationTime, randomId, MetaDataStore.versionStringToLong( select.storeVersion() ), + upgradeTime, upgradeId ); + } +} \ No newline at end of file diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/lowlimit/LowLimitTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/lowlimit/LowLimitTest.java new file mode 100644 index 0000000000000..d7e68d69dbdce --- /dev/null +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/lowlimit/LowLimitTest.java @@ -0,0 +1,35 @@ +/* + * 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.lowlimit; + +import org.junit.Test; + +import org.neo4j.kernel.impl.store.format.InternalRecordFormatSelector; + +import static org.junit.Assert.assertEquals; + +public class LowLimitTest +{ + @Test + public void shouldResolveLowLimitsRecordFormat() throws Exception + { + assertEquals( LowLimit.RECORD_FORMATS.storeVersion(), InternalRecordFormatSelector.select().storeVersion() ); + } +} \ No newline at end of file diff --git a/enterprise/com/src/test/java/org/neo4j/com/MadeUpServerProcess.java b/enterprise/com/src/test/java/org/neo4j/com/MadeUpServerProcess.java index dccf5cbae88f0..2bd735d0c5109 100644 --- a/enterprise/com/src/test/java/org/neo4j/com/MadeUpServerProcess.java +++ b/enterprise/com/src/test/java/org/neo4j/com/MadeUpServerProcess.java @@ -19,9 +19,10 @@ */ package org.neo4j.com; -import org.neo4j.kernel.impl.store.StoreId; import org.neo4j.test.subprocess.SubProcess; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; + public class MadeUpServerProcess extends SubProcess implements ServerInterface { private static final long serialVersionUID = 1L; @@ -34,7 +35,7 @@ public class MadeUpServerProcess extends SubProcess response = diff --git a/enterprise/com/src/test/java/org/neo4j/com/storecopy/ResponsePackerTest.java b/enterprise/com/src/test/java/org/neo4j/com/storecopy/ResponsePackerTest.java index f49263fbe29be..f5ec6751e9320 100644 --- a/enterprise/com/src/test/java/org/neo4j/com/storecopy/ResponsePackerTest.java +++ b/enterprise/com/src/test/java/org/neo4j/com/storecopy/ResponsePackerTest.java @@ -29,7 +29,7 @@ import org.neo4j.cursor.IOCursor; import org.neo4j.function.Suppliers; import org.neo4j.helpers.collection.Visitor; -import org.neo4j.kernel.impl.store.StoreId; +import org.neo4j.kernel.impl.store.StoreIdTestFactory; import org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation; import org.neo4j.kernel.impl.transaction.DeadSimpleTransactionIdStore; import org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore; @@ -57,7 +57,7 @@ public void shouldHaveFixedTargetTransactionIdEvenIfLastTransactionIdIsMoving() final long targetTransactionId = 8L; final TransactionIdStore transactionIdStore = new DeadSimpleTransactionIdStore( targetTransactionId, 0, 0, 0 ); ResponsePacker packer = new ResponsePacker( transactionStore, transactionIdStore, - Suppliers.singleton( new StoreId() ) ); + Suppliers.singleton( StoreIdTestFactory.newStoreIdForCurrentVersion() ) ); // WHEN Response response = packer.packTransactionStreamResponse( requestContextStartingAt( 5L ), null ); diff --git a/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/storecopy/LocalDatabaseTest.java b/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/storecopy/LocalDatabaseTest.java index fdbca0229c275..83e6e187b246c 100644 --- a/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/storecopy/LocalDatabaseTest.java +++ b/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/storecopy/LocalDatabaseTest.java @@ -19,13 +19,11 @@ */ package org.neo4j.coreedge.catchup.storecopy; -import java.io.File; - import org.junit.Test; +import java.io.File; + import org.neo4j.coreedge.catchup.storecopy.edge.CopiedStoreRecovery; -import org.neo4j.coreedge.catchup.storecopy.LocalDatabase; -import org.neo4j.coreedge.catchup.storecopy.StoreFiles; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.NeoStoreDataSource; import org.neo4j.kernel.impl.store.StoreId; @@ -34,8 +32,8 @@ import static junit.framework.TestCase.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - import static org.neo4j.function.Suppliers.singleton; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; public class LocalDatabaseTest { @@ -43,7 +41,7 @@ public class LocalDatabaseTest public void shouldRetrieveStoreId() throws Throwable { // given - StoreId storeId = new StoreId(); + StoreId storeId = newStoreIdForCurrentVersion(); // when NeoStoreDataSource neoStoreDataSource = mock( NeoStoreDataSource.class ); diff --git a/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/TxPullResponseEncodeDecodeTest.java b/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/TxPullResponseEncodeDecodeTest.java index 80339d571bc75..af4f4272564a7 100644 --- a/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/TxPullResponseEncodeDecodeTest.java +++ b/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/TxPullResponseEncodeDecodeTest.java @@ -23,10 +23,9 @@ import org.junit.Test; import org.neo4j.coreedge.catchup.CatchupClientProtocol; -import org.neo4j.coreedge.catchup.tx.edge.TxPullResponseDecoder; -import org.neo4j.coreedge.catchup.tx.edge.TxPullResponse; import org.neo4j.coreedge.catchup.tx.core.TxPullResponseEncoder; -import org.neo4j.kernel.impl.store.StoreId; +import org.neo4j.coreedge.catchup.tx.edge.TxPullResponse; +import org.neo4j.coreedge.catchup.tx.edge.TxPullResponseDecoder; import org.neo4j.kernel.impl.store.record.NodeRecord; import org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation; import org.neo4j.kernel.impl.transaction.command.Command; @@ -37,11 +36,10 @@ import org.neo4j.kernel.impl.transaction.log.entry.OnePhaseCommit; import static java.util.Arrays.asList; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; - import static org.neo4j.coreedge.catchup.CatchupClientProtocol.NextMessage; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; public class TxPullResponseEncodeDecodeTest { @@ -56,7 +54,7 @@ public void shouldEncodeAndDecodePullResponseMessage() new TxPullResponseDecoder( protocol ) ); // given - TxPullResponse sent = new TxPullResponse( new StoreId(), newCommittedTransactionRepresentation() ); + TxPullResponse sent = new TxPullResponse( newStoreIdForCurrentVersion(), newCommittedTransactionRepresentation() ); // when channel.writeOutbound( sent ); diff --git a/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/edge/ApplyPulledTransactionsTest.java b/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/edge/ApplyPulledTransactionsTest.java index 88ff6160df0a3..39fbd37155dfd 100644 --- a/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/edge/ApplyPulledTransactionsTest.java +++ b/enterprise/core-edge/src/test/java/org/neo4j/coreedge/catchup/tx/edge/ApplyPulledTransactionsTest.java @@ -38,8 +38,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; - import static org.neo4j.function.Suppliers.singleton; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; public class ApplyPulledTransactionsTest { @@ -47,7 +47,7 @@ public class ApplyPulledTransactionsTest public void shouldApplyTransaction() throws Exception { // given - StoreId storeId = new StoreId( 1, 1, 1, 1 ); + StoreId storeId = newStoreIdForCurrentVersion( 1, 1, 1, 1 ); TransactionApplier transactionApplier = mock( TransactionApplier.class ); @@ -73,7 +73,7 @@ public void shouldApplyTransaction() throws Exception public void shouldLogIfTransactionCannotBeApplied() throws Exception { // given - StoreId storeId = new StoreId( 1, 1, 1, 1 ); + StoreId storeId = newStoreIdForCurrentVersion( 1, 1, 1, 1 ); TransactionApplier transactionApplier = mock( TransactionApplier.class ); TransactionIdStore transactionIdStore = mock(TransactionIdStore.class); @@ -105,7 +105,7 @@ public void shouldLogIfTransactionCannotBeApplied() throws Exception public void shouldNotApplyTransactionsThatHaveAlreadyBeenApplied() throws Exception { // given - StoreId storeId = new StoreId( 1, 1, 1, 1 ); + StoreId storeId = newStoreIdForCurrentVersion( 1, 1, 1, 1 ); TransactionApplier transactionApplier = mock( TransactionApplier.class ); diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/MasterClientTest.java b/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/MasterClientTest.java index edb82c2de2453..bff7a7c7fea94 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/MasterClientTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/MasterClientTest.java @@ -51,6 +51,7 @@ import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory; import org.neo4j.kernel.impl.store.MismatchingStoreIdException; import org.neo4j.kernel.impl.store.StoreId; +import org.neo4j.kernel.impl.store.StoreIdTestFactory; import org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation; import org.neo4j.kernel.impl.transaction.command.Commands; import org.neo4j.kernel.impl.transaction.log.LogPosition; @@ -73,7 +74,6 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - import static org.neo4j.com.storecopy.ResponseUnpacker.NO_OP_RESPONSE_UNPACKER; import static org.neo4j.com.storecopy.TransactionCommittingResponseUnpacker.DEFAULT_BATCH_SIZE; import static org.neo4j.helpers.collection.MapUtil.stringMap; @@ -99,12 +99,13 @@ public class MasterClientTest public void newClientsShouldNotIgnoreStoreIdDifferences() throws Throwable { // Given - MasterImpl.SPI masterImplSPI = MasterImplTest.mockedSpi( new StoreId( 1, 2, 3, 4 ) ); + MasterImpl.SPI masterImplSPI = + MasterImplTest.mockedSpi( StoreIdTestFactory.newStoreIdForCurrentVersion( 1, 2, 3, 4 ) ); when( masterImplSPI.getTransactionChecksum( anyLong() ) ).thenReturn( 5L ); newMasterServer( masterImplSPI ); - StoreId storeId = new StoreId( 5, 6, 7, 8 ); + StoreId storeId = StoreIdTestFactory.newStoreIdForCurrentVersion( 5, 6, 7, 8 ); MasterClient214 masterClient214 = newMasterClient214( storeId ); // When diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/MasterEpochTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/MasterEpochTest.java index 5d1c7802b56e2..c035ab7269266 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/MasterEpochTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/MasterEpochTest.java @@ -23,7 +23,6 @@ import org.neo4j.cluster.ClusterSettings; import org.neo4j.com.RequestContext; -import org.neo4j.kernel.impl.store.id.IdType; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.ha.com.master.ConversationManager; import org.neo4j.kernel.ha.com.master.HandshakeResult; @@ -34,6 +33,7 @@ import org.neo4j.kernel.ha.id.IdAllocation; import org.neo4j.kernel.impl.store.StoreId; import org.neo4j.kernel.impl.store.id.IdRange; +import org.neo4j.kernel.impl.store.id.IdType; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -41,9 +41,9 @@ import static org.mockito.Matchers.anyLong; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - import static org.neo4j.collection.primitive.PrimitiveLongCollections.EMPTY_LONG_ARRAY; import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; public class MasterEpochTest { @@ -55,7 +55,7 @@ public void shouldFailSubsequentRequestsAfterAllocateIdsAfterMasterSwitch() thro IdAllocation servedIdAllocation = idAllocation( 0, 999 ); when( spi.allocateIds( any( IdType.class ) ) ).thenReturn( servedIdAllocation ); when( spi.getTransactionChecksum( anyLong() ) ).thenReturn( 10L ); - StoreId storeId = new StoreId(); + StoreId storeId = newStoreIdForCurrentVersion(); MasterImpl master = new MasterImpl( spi, mock( ConversationManager.class ), mock( MasterImpl.Monitor.class ), new Config( stringMap( ClusterSettings.server_id.name(), "1" ) ) ); diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/TestMasterCommittingAtSlave.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/TestMasterCommittingAtSlave.java index 49826cdab59ef..a9f4650bf86bd 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/TestMasterCommittingAtSlave.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/TestMasterCommittingAtSlave.java @@ -36,8 +36,8 @@ import org.neo4j.com.TransactionStreamResponse; import org.neo4j.helpers.Exceptions; import org.neo4j.helpers.collection.MapUtil; -import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.DefaultFileSystemAbstraction; +import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.ha.com.master.Slave; import org.neo4j.kernel.ha.com.master.SlavePriorities; @@ -45,7 +45,6 @@ import org.neo4j.kernel.ha.com.master.Slaves; import org.neo4j.kernel.ha.transaction.CommitPusher; import org.neo4j.kernel.ha.transaction.TransactionPropagator; -import org.neo4j.kernel.impl.store.StoreId; import org.neo4j.kernel.impl.util.Neo4jJobScheduler; import org.neo4j.logging.AssertableLogProvider; import org.neo4j.logging.AssertableLogProvider.LogMatcher; @@ -61,6 +60,7 @@ import static org.junit.Assert.assertTrue; import static org.neo4j.kernel.ha.com.master.SlavePriorities.givenOrder; import static org.neo4j.kernel.ha.com.master.SlavePriorities.roundRobin; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; import static org.neo4j.logging.AssertableLogProvider.Level.ERROR; public class TestMasterCommittingAtSlave @@ -279,7 +279,8 @@ public Response pullUpdates( long txId ) } calledWithTxId.add( txId ); - return new TransactionStreamResponse<>( null, new StoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP ); + return new TransactionStreamResponse<>( null, newStoreIdForCurrentVersion(), TransactionStream.EMPTY, + ResourceReleaser.NO_OP ); } Long popCalledTx() diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java index a3a42f36f1d44..f14fb67b60bee 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java @@ -99,6 +99,7 @@ import static org.neo4j.kernel.ha.cluster.modeswitch.HighAvailabilityModeSwitcher.MASTER; import static org.neo4j.kernel.ha.cluster.modeswitch.HighAvailabilityModeSwitcher.SLAVE; import static org.neo4j.kernel.ha.cluster.modeswitch.HighAvailabilityModeSwitcherTest.storeSupplierMock; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; public class HighAvailabilityMemberStateMachineTest { @@ -339,7 +340,7 @@ public void whenSlaveOnlyIsElectedStayInPending() throws Throwable public void whenHAModeSwitcherSwitchesToSlaveTheOtherModeSwitcherDoNotGetTheOldMasterClient() throws Throwable { InstanceId me = new InstanceId( 1 ); - StoreId storeId = new StoreId(); + StoreId storeId = newStoreIdForCurrentVersion(); HighAvailabilityMemberContext context = mock( HighAvailabilityMemberContext.class ); when( context.getMyId() ).thenReturn( me ); AvailabilityGuard guard = mock( AvailabilityGuard.class ); diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/SwitchToSlaveTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/SwitchToSlaveTest.java index 20d3d20e14f88..31c3e0a623728 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/SwitchToSlaveTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/SwitchToSlaveTest.java @@ -95,6 +95,7 @@ import static org.mockito.Mockito.when; import static org.mockito.Mockito.withSettings; import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; public class SwitchToSlaveTest { @@ -103,7 +104,7 @@ public class SwitchToSlaveTest private final FileSystemAbstraction fs = mock( FileSystemAbstraction.class ); private final MasterClient masterClient = mock( MasterClient.class ); private final RequestContextFactory requestContextFactory = mock( RequestContextFactory.class ); - private final StoreId storeId = new StoreId( 42, 42, 42, 42 ); + private final StoreId storeId = newStoreIdForCurrentVersion( 42, 42, 42, 42 ); @Test public void shouldRestartServicesIfCopyStoreFails() throws Throwable @@ -154,7 +155,7 @@ public void shouldHandleBranchedStoreWhenMyStoreIdDiffersFromMasterStoreId() thr when( response.response() ).thenReturn( new HandshakeResult( 1, 2 ) ); when( masterClient.handshake( anyLong(), any( StoreId.class ) ) ).thenReturn( response ); - StoreId storeId = new StoreId( 1, 2, 3, 4 ); + StoreId storeId = newStoreIdForCurrentVersion( 1, 2, 3, 4 ); TransactionIdStore transactionIdStore = mock( TransactionIdStore.class ); when( transactionIdStore.getLastCommittedTransaction() ).thenReturn( new TransactionId( 42, 42 ) ); diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplConversationStopFuzzIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplConversationStopFuzzIT.java index c54f9d7a7dbe6..12f3e847477a5 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplConversationStopFuzzIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplConversationStopFuzzIT.java @@ -42,7 +42,6 @@ import org.neo4j.com.storecopy.StoreWriter; import org.neo4j.function.Factory; import org.neo4j.helpers.Clock; -import org.neo4j.kernel.impl.store.id.IdType; import org.neo4j.kernel.api.exceptions.TransactionFailureException; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.ha.cluster.ConversationSPI; @@ -52,6 +51,7 @@ import org.neo4j.kernel.impl.locking.Locks; import org.neo4j.kernel.impl.locking.ResourceTypes; import org.neo4j.kernel.impl.store.StoreId; +import org.neo4j.kernel.impl.store.id.IdType; import org.neo4j.kernel.impl.transaction.TransactionRepresentation; import org.neo4j.kernel.impl.transaction.log.TransactionIdStore; import org.neo4j.kernel.impl.util.JobScheduler; @@ -66,6 +66,7 @@ import static org.neo4j.cluster.ClusterSettings.server_id; import static org.neo4j.helpers.collection.MapUtil.stringMap; import static org.neo4j.kernel.ha.HaSettings.lock_read_timeout; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; /** * Current test will try to emulate client master conversation lifecycle @@ -83,7 +84,7 @@ public class MasterImplConversationStopFuzzIT private static final int numberOfOperations = 1_000; private static final int numberOfResources = 100; - public static final StoreId StoreId = new StoreId(); + public static final StoreId StoreId = newStoreIdForCurrentVersion(); private final LifeSupport life = new LifeSupport(); private final ExecutorService executor = Executors.newFixedThreadPool( numberOfWorkers + 1 ); diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplTest.java index 30a88bed6af33..69dde6b2981d8 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/com/master/MasterImplTest.java @@ -65,6 +65,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import static org.neo4j.kernel.impl.store.StoreIdTestFactory.newStoreIdForCurrentVersion; public class MasterImplTest { @@ -106,7 +107,7 @@ public void givenStartedAndAccessibleWhenNewLockSessionThenSucceeds() throws Thr MasterImpl instance = new MasterImpl( spi, mock( ConversationManager.class ), mock( MasterImpl.Monitor.class ), config ); instance.start(); - HandshakeResult handshake = instance.handshake( 1, new StoreId() ).response(); + HandshakeResult handshake = instance.handshake( 1, newStoreIdForCurrentVersion() ).response(); // When try @@ -135,7 +136,7 @@ public void failingToStartTxShouldNotLeadToNPE() throws Throwable MasterImpl instance = new MasterImpl( spi, conversationManager, mock( MasterImpl.Monitor.class ), config ); instance.start(); - Response response = instance.handshake( 1, new StoreId() ); + Response response = instance.handshake( 1, newStoreIdForCurrentVersion() ); HandshakeResult handshake = response.response(); // When @@ -190,7 +191,7 @@ public Void answer( InvocationOnMock invocation ) throws Throwable ConversationManager conversationManager = new ConversationManager( conversationSpi, config ); final MasterImpl master = new MasterImpl( spi, conversationManager, mock( Monitor.class ), config ); master.start(); - HandshakeResult handshake = master.handshake( 1, new StoreId() ).response(); + HandshakeResult handshake = master.handshake( 1, newStoreIdForCurrentVersion() ).response(); // WHEN final RequestContext context = new RequestContext( handshake.epoch(), 1, 2, 0, 0 ); @@ -234,7 +235,7 @@ public void shouldNotAllowCommitIfThereIsNoMatchingLockSession() throws Throwabl MasterImpl master = new MasterImpl( spi, conversationManager, mock( MasterImpl.Monitor.class ), config ); master.start(); - HandshakeResult handshake = master.handshake( 1, new StoreId() ).response(); + HandshakeResult handshake = master.handshake( 1, newStoreIdForCurrentVersion() ).response(); RequestContext ctx = new RequestContext( handshake.epoch(), 1, 2, 0, 0 ); @@ -269,7 +270,7 @@ public void shouldAllowCommitIfClientHoldsNoLocks() throws Throwable MasterImpl master = new MasterImpl( spi, conversationManager, mock( MasterImpl.Monitor.class ), config ); master.start(); - HandshakeResult handshake = master.handshake( 1, new StoreId() ).response(); + HandshakeResult handshake = master.handshake( 1, newStoreIdForCurrentVersion() ).response(); int no_lock_session = -1; RequestContext ctx = new RequestContext( handshake.epoch(), 1, no_lock_session, 0, 0 ); @@ -298,7 +299,7 @@ public void shouldAllowStartNewTransactionAfterClientSessionWasRemovedOnTimeout( when( spi.isAccessible() ).thenReturn( true ); when( conversationSpi.acquireClient() ).thenReturn( client ); master.start(); - HandshakeResult handshake = master.handshake( 1, new StoreId() ).response(); + HandshakeResult handshake = master.handshake( 1, newStoreIdForCurrentVersion() ).response(); RequestContext requestContext = new RequestContext( handshake.epoch(), machineId, 0, 0, 0); // When diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFactory.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFactory.java index dc7aa8f42c5ac..b19410349823d 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFactory.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitFactory.java @@ -1,3 +1,22 @@ +/* + * 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.helpers.Service; diff --git a/enterprise/kernel/src/main/resources/META-INF/services/org.neo4j.kernel.impl.store.format.RecordFormats$Factory b/enterprise/kernel/src/main/resources/META-INF/services/org.neo4j.kernel.impl.store.format.RecordFormats$Factory new file mode 100644 index 0000000000000..34e1474a78ff6 --- /dev/null +++ b/enterprise/kernel/src/main/resources/META-INF/services/org.neo4j.kernel.impl.store.format.RecordFormats$Factory @@ -0,0 +1 @@ +org.neo4j.kernel.impl.store.format.highlimit.HighLimitFactory \ No newline at end of file diff --git a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitTest.java b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitTest.java new file mode 100644 index 0000000000000..3fc8d94f0a28e --- /dev/null +++ b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/HighLimitTest.java @@ -0,0 +1,37 @@ +/* + * 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.junit.Ignore; +import org.junit.Test; + +import org.neo4j.kernel.impl.store.format.InternalRecordFormatSelector; + +import static org.junit.Assert.assertEquals; + +public class HighLimitTest +{ + @Ignore("enable once other features are done.") + @Test + public void shouldResolveHighLimitsRecordFormat() throws Exception + { + assertEquals( HighLimit.RECORD_FORMATS.storeVersion(), InternalRecordFormatSelector.select().storeVersion()); + } +} \ No newline at end of file