Skip to content

Commit

Permalink
WIP: Auxiliary transaction state infrastructure.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Oct 4, 2018
1 parent 4f169bb commit d62a6e4
Show file tree
Hide file tree
Showing 22 changed files with 505 additions and 49 deletions.
Expand Up @@ -54,6 +54,8 @@
import org.neo4j.kernel.impl.api.CommitProcessFactory; import org.neo4j.kernel.impl.api.CommitProcessFactory;
import org.neo4j.kernel.impl.api.DatabaseSchemaState; import org.neo4j.kernel.impl.api.DatabaseSchemaState;
import org.neo4j.kernel.impl.api.ExplicitIndexProvider; import org.neo4j.kernel.impl.api.ExplicitIndexProvider;
import org.neo4j.kernel.impl.api.ExplicitIndexTransactionStateProvider;
import org.neo4j.kernel.impl.api.KernelAuxTransactionStateManager;
import org.neo4j.kernel.impl.api.KernelImpl; import org.neo4j.kernel.impl.api.KernelImpl;
import org.neo4j.kernel.impl.api.KernelTransactionMonitorScheduler; import org.neo4j.kernel.impl.api.KernelTransactionMonitorScheduler;
import org.neo4j.kernel.impl.api.KernelTransactionTimeoutMonitor; import org.neo4j.kernel.impl.api.KernelTransactionTimeoutMonitor;
Expand Down Expand Up @@ -597,13 +599,16 @@ private NeoStoreKernelModule buildKernel( LogFiles logFiles, TransactionAppender
buildStatementOperations( cpuClockRef, heapAllocationRef ) ); buildStatementOperations( cpuClockRef, heapAllocationRef ) );


TransactionHooks hooks = new TransactionHooks(); TransactionHooks hooks = new TransactionHooks();
KernelAuxTransactionStateManager auxTxStateManager = new KernelAuxTransactionStateManager();
auxTxStateManager.registerProvider( new ExplicitIndexTransactionStateProvider( indexConfigStore, explicitIndexProvider ) );
dataSourceDependencies.satisfyDependency( auxTxStateManager );


KernelTransactions kernelTransactions = life.add( KernelTransactions kernelTransactions = life.add(
new KernelTransactions( config, statementLocksFactory, constraintIndexCreator, statementOperationParts, schemaWriteGuard, new KernelTransactions( config, statementLocksFactory, constraintIndexCreator, statementOperationParts, schemaWriteGuard,
transactionHeaderInformationFactory, transactionCommitProcess, indexConfigStore, explicitIndexProvider, hooks, transactionMonitor, transactionHeaderInformationFactory, transactionCommitProcess, auxTxStateManager, hooks,
databaseAvailabilityGuard, tracers, storageEngine, procedures, transactionIdStore, clock, cpuClockRef, heapAllocationRef, transactionMonitor, databaseAvailabilityGuard, tracers, storageEngine, procedures, transactionIdStore, clock, cpuClockRef,
accessCapability, autoIndexing, explicitIndexStore, versionContextSupplier, collectionsFactorySupplier, constraintSemantics, heapAllocationRef, accessCapability, autoIndexing, explicitIndexStore, versionContextSupplier, collectionsFactorySupplier,
databaseSchemaState, indexingService, tokenHolders, getDatabaseName(), dataSourceDependencies ) ); constraintSemantics, databaseSchemaState, indexingService, tokenHolders, getDatabaseName(), dataSourceDependencies ) );


buildTransactionMonitor( kernelTransactions, clock, config ); buildTransactionMonitor( kernelTransactions, clock, config );


Expand Down
Expand Up @@ -23,6 +23,7 @@


import org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException; import org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException;
import org.neo4j.kernel.api.ExplicitIndex; import org.neo4j.kernel.api.ExplicitIndex;
import org.neo4j.kernel.api.txstate.aux.AuxiliaryTransactionState;
import org.neo4j.kernel.impl.index.IndexEntityType; import org.neo4j.kernel.impl.index.IndexEntityType;
import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordState; import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordState;


Expand All @@ -32,7 +33,7 @@
* {@link TransactionState the transaction state} in order to be able to keep the implementation of * {@link TransactionState the transaction state} in order to be able to keep the implementation of
* {@link org.neo4j.kernel.impl.api.state.TxState transaction state} simple with no dependencies. * {@link org.neo4j.kernel.impl.api.state.TxState transaction state} simple with no dependencies.
*/ */
public interface ExplicitIndexTransactionState extends RecordState public interface ExplicitIndexTransactionState extends AuxiliaryTransactionState
{ {
ExplicitIndex nodeChanges( String indexName ) throws ExplicitIndexNotFoundKernelException; ExplicitIndex nodeChanges( String indexName ) throws ExplicitIndexNotFoundKernelException;


Expand Down
Expand Up @@ -19,9 +19,12 @@
*/ */
package org.neo4j.kernel.api.txstate; package org.neo4j.kernel.api.txstate;


import org.neo4j.kernel.api.txstate.aux.AuxiliaryTransactionState;

public interface TxStateHolder public interface TxStateHolder
{ {
TransactionState txState(); TransactionState txState();
AuxiliaryTransactionState auxiliaryTxState( Object providerIdentityKey );
ExplicitIndexTransactionState explicitIndexTxState(); ExplicitIndexTransactionState explicitIndexTxState();
boolean hasTxStateWithChanges(); boolean hasTxStateWithChanges();
} }
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.api.txstate.aux;

import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordState;

public interface AuxiliaryTransactionState extends RecordState, AutoCloseable
{

}
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.api.txstate.aux;

public class AuxiliaryTransactionStateCloseException extends RuntimeException
{
public AuxiliaryTransactionStateCloseException( String message, Exception cause )
{
super( message, cause );
}
}
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.api.txstate.aux;

import java.util.Collection;

import org.neo4j.internal.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.storageengine.api.StorageCommand;

public interface AuxiliaryTransactionStateHolder extends AutoCloseable
{
AuxiliaryTransactionState getState( Object providerIdentityKey );

boolean hasChanges();

boolean hasChanges( String providerIdentityKey );

void extractCommands( Collection<StorageCommand> extractedCommands ) throws TransactionFailureException;

@Override
void close() throws AuxiliaryTransactionStateCloseException;
}
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.api.txstate.aux;

public interface AuxiliaryTransactionStateManager
{
void registerProvider( AuxiliaryTransactionStateProvider provider );

void unregisterProvider( AuxiliaryTransactionStateProvider provider );

AuxiliaryTransactionStateHolder openStateHolder();
}
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.api.txstate.aux;

public interface AuxiliaryTransactionStateProvider
{
Object getIdentityKey();

AuxiliaryTransactionState createNewAuxiliaryTransactionState();
}
Expand Up @@ -100,4 +100,10 @@ public boolean checkIndexExistence( IndexEntityType entityType, String indexName
{ {
return txState.checkIndexExistence( entityType, indexName, config ); return txState.checkIndexExistence( entityType, indexName, config );
} }

@Override
public void close() throws Exception
{
txState.close();
}
} }
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.api;

import org.neo4j.kernel.api.txstate.aux.AuxiliaryTransactionState;
import org.neo4j.kernel.api.txstate.aux.AuxiliaryTransactionStateProvider;
import org.neo4j.kernel.impl.api.state.ExplicitIndexTransactionStateImpl;
import org.neo4j.kernel.impl.index.IndexConfigStore;

public class ExplicitIndexTransactionStateProvider implements AuxiliaryTransactionStateProvider
{
public static final String PROVIDER_KEY = "EXPLICIT INDEX TX STATE PROVIDER";

private final IndexConfigStore indexConfigStore;
private final ExplicitIndexProvider explicitIndexProviderLookup;

public ExplicitIndexTransactionStateProvider( IndexConfigStore indexConfigStore, ExplicitIndexProvider explicitIndexProviderLookup )
{
this.indexConfigStore = indexConfigStore;
this.explicitIndexProviderLookup = explicitIndexProviderLookup;
}

@Override
public Object getIdentityKey()
{
return PROVIDER_KEY;
}

@Override
public AuxiliaryTransactionState createNewAuxiliaryTransactionState()
{
return new CachingExplicitIndexTransactionState( new ExplicitIndexTransactionStateImpl( indexConfigStore, explicitIndexProviderLookup ) );
}
}

0 comments on commit d62a6e4

Please sign in to comment.