Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lets StorageEngine be in charge of providing CommandReader
For this that aspect was broken out from LogEntryVersion into a CommandReaderFactory interface. LogEntryVersion is now responsible of providing parser for log entries, command reading is just one aspect of one of the entries, the COMMAND entry. It's OK to have neo4j, regardless of which StorageEngine is used (hypothetical since there's currently only one), be in charge of log entry layout, but StorageEngine must be in charge of the command part. Since LogEntryVersion was a public enum and provided CommandReader most users of log entry reading didn't have a concept of a specific log entry parser since it just used whatever LogEntryVersion provided. Now LogEntryReader is injected in many places and even HaRequestType, which was enums had to be changed to be able to accept a LogEntryReader instance.is injected in many places and even HaRequestType, which was enums had to be changed to be able to accept a LogEntryReader instance.
- Loading branch information
1 parent
0e69b03
commit 1c7c466
Showing
64 changed files
with
851 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/CommandReaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2002-2015 "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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.storageengine; | ||
|
||
import org.neo4j.kernel.impl.transaction.command.CommandReader; | ||
import org.neo4j.kernel.impl.transaction.log.entry.LogEntry; | ||
import org.neo4j.kernel.impl.transaction.log.entry.LogEntryVersion; | ||
|
||
/** | ||
* Provides {@link CommandReader} instances for specific entry versions. | ||
*/ | ||
public interface CommandReaderFactory | ||
{ | ||
/** | ||
* Given {@code version} give back a {@link CommandReader} capable of reading such commands. | ||
* | ||
* @param version {@link LogEntry} version. | ||
* @return {@link CommandReader} for reading commands of that version. | ||
*/ | ||
CommandReader byVersion( LogEntryVersion version ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageCommandReaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2002-2015 "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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.storageengine.impl.recordstorage; | ||
|
||
import org.neo4j.kernel.impl.storageengine.CommandReaderFactory; | ||
import org.neo4j.kernel.impl.transaction.command.CommandReader; | ||
import org.neo4j.kernel.impl.transaction.command.PhysicalLogCommandReaderV1_9; | ||
import org.neo4j.kernel.impl.transaction.command.PhysicalLogCommandReaderV2_0; | ||
import org.neo4j.kernel.impl.transaction.command.PhysicalLogCommandReaderV2_1; | ||
import org.neo4j.kernel.impl.transaction.command.PhysicalLogCommandReaderV2_2_4; | ||
import org.neo4j.kernel.impl.transaction.command.PhysicalLogNeoCommandReaderV2_2; | ||
import org.neo4j.kernel.impl.transaction.log.entry.LogEntryVersion; | ||
|
||
public class RecordStorageCommandReaderFactory implements CommandReaderFactory | ||
{ | ||
// All supported readers. Key/index is LogEntryVersion ordinal. | ||
private final CommandReader[] readers; | ||
|
||
public RecordStorageCommandReaderFactory() | ||
{ | ||
LogEntryVersion[] versions = LogEntryVersion.values(); | ||
readers = new CommandReader[versions.length]; | ||
readers[LogEntryVersion.V1_9.ordinal()] = new PhysicalLogCommandReaderV1_9(); | ||
readers[LogEntryVersion.V2_0.ordinal()] = new PhysicalLogCommandReaderV2_0(); | ||
readers[LogEntryVersion.V2_1.ordinal()] = new PhysicalLogCommandReaderV2_1(); | ||
readers[LogEntryVersion.V2_2.ordinal()] = new PhysicalLogNeoCommandReaderV2_2(); | ||
readers[LogEntryVersion.V2_2_4.ordinal()] = new PhysicalLogCommandReaderV2_2_4(); | ||
readers[LogEntryVersion.V2_3.ordinal()] = new PhysicalLogCommandReaderV2_2_4(); | ||
for ( int i = 0; i < versions.length; i++ ) | ||
{ | ||
if ( versions[i] == null ) | ||
{ | ||
throw new IllegalStateException( "Version " + versions[i] + " not handled" ); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public CommandReader byVersion( LogEntryVersion version ) | ||
{ | ||
int key = version.ordinal(); | ||
if ( key >= readers.length ) | ||
{ | ||
throw new IllegalArgumentException( "Unsupported entry version " + version ); | ||
} | ||
return readers[key]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.