Skip to content

Commit

Permalink
Expose catchup server through edition module for test
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Mar 19, 2018
1 parent 77fdc94 commit be2409a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public DataSourceModule( final PlatformModule platformModule, EditionModule edit
this.storeId = neoStoreDataSource::getStoreId;
this.kernelAPI = neoStoreDataSource::getKernel;

ProcedureGDSFactory gdsFactory = new ProcedureGDSFactory( platformModule, this, deps,
ProcedureGDSFactory gdsFactory = new ProcedureGDSFactory( platformModule, editionModule, this, deps,
editionModule.coreAPIAvailabilityGuard, editionModule.relationshipTypeTokenHolder );
procedures.registerComponent( GraphDatabaseService.class, gdsFactory::apply, true );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public class GraphDatabaseFacade implements GraphDatabaseAPI, EmbeddedProxySPI
private Schema schema;
private Supplier<IndexManager> indexManager;
private ThreadToStatementContextBridge statementContext;
protected EditionModule editionModule;
private SPI spi;
private TransactionalContextFactory contextFactory;
private Config config;
Expand Down Expand Up @@ -198,9 +199,10 @@ public GraphDatabaseFacade()
/**
* Create a new Core API facade, backed by the given SPI and using pre-resolved dependencies
*/
public void init( SPI spi, Guard guard, ThreadToStatementContextBridge txBridge, Config config,
public void init( EditionModule editionModule, SPI spi, Guard guard, ThreadToStatementContextBridge txBridge, Config config,
RelationshipTypeTokenHolder relationshipTypeTokenHolder )
{
this.editionModule = editionModule;
this.spi = spi;
this.config = config;
this.relationshipTypeTokenHolder = relationshipTypeTokenHolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public GraphDatabaseFacade initFacade( File storeDir, Config config, final Depen

ClassicCoreSPI spi = new ClassicCoreSPI( platform, dataSource, msgLog, coreAPIAvailabilityGuard );
graphDatabaseFacade.init(
edition,
spi,
dataSource.guard,
dataSource.threadToTransactionBridge,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,25 @@
import org.neo4j.kernel.impl.core.RelationshipTypeTokenHolder;
import org.neo4j.kernel.impl.coreapi.CoreAPIAvailabilityGuard;
import org.neo4j.kernel.impl.factory.DataSourceModule;
import org.neo4j.kernel.impl.factory.EditionModule;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacade;
import org.neo4j.kernel.impl.factory.PlatformModule;

public class ProcedureGDSFactory implements ThrowingFunction<Context,GraphDatabaseService,ProcedureException>
{
private final PlatformModule platform;
private final EditionModule editionModule;
private final DataSourceModule dataSource;
private final DependencyResolver resolver;
private final CoreAPIAvailabilityGuard availability;
private final ThrowingFunction<URL, URL, URLAccessValidationError> urlValidator;
private final RelationshipTypeTokenHolder relationshipTypeTokenHolder;

public ProcedureGDSFactory( PlatformModule platform, DataSourceModule dataSource, DependencyResolver resolver,
public ProcedureGDSFactory( PlatformModule platform, EditionModule editionModule, DataSourceModule dataSource, DependencyResolver resolver,
CoreAPIAvailabilityGuard coreAPIAvailabilityGuard, RelationshipTypeTokenHolder relationshipTypeTokenHolder )
{
this.platform = platform;
this.editionModule = editionModule;
this.dataSource = dataSource;
this.resolver = resolver;
this.availability = coreAPIAvailabilityGuard;
Expand All @@ -70,6 +73,7 @@ public GraphDatabaseService apply( Context context ) throws ProcedureException
}
GraphDatabaseFacade facade = new GraphDatabaseFacade();
facade.init(
editionModule,
new ProcedureGDBFacadeSPI(
platform,
dataSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void setUp()
{
queryService = mock( GraphDatabaseQueryService.class );
DependencyResolver resolver = mock( DependencyResolver.class );
EditionModule editionModule = mock( EditionModule.class );
Statement statement = mock( Statement.class, RETURNS_DEEP_STUBS );
readOperations = mock( ReadOperations.class );
ThreadToStatementContextBridge contextBridge = mock( ThreadToStatementContextBridge.class );
Expand All @@ -77,7 +78,7 @@ public void setUp()
when( resolver.resolveDependency( Config.class ) ).thenReturn( config );
when( statement.readOperations() ).thenReturn( readOperations );

graphDatabaseFacade.init( spi, guard, contextBridge, config, mock( RelationshipTypeTokenHolder.class ) );
graphDatabaseFacade.init( editionModule, spi, guard, contextBridge, config, mock( RelationshipTypeTokenHolder.class ) );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ protected CoreGraphDatabase()
{
}

public CoreGraphDatabase( File storeDir, Config config,
GraphDatabaseFacadeFactory.Dependencies dependencies )
public CoreGraphDatabase( File storeDir, Config config, GraphDatabaseFacadeFactory.Dependencies dependencies )
{
this( storeDir, config, dependencies, new HazelcastDiscoveryServiceFactory() );
}
Expand All @@ -57,4 +56,9 @@ public Role getRole()
{
return getDependencyResolver().resolveDependency( RaftMachine.class ).currentRole();
}

public void stopCatchupServer()
{
((EnterpriseCoreEditionModule) editionModule).stopCatchupServer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public class EnterpriseCoreEditionModule extends EditionModule
protected final Config config;
private final Supplier<Stream<Pair<AdvertisedSocketAddress,ProtocolStack>>> clientInstalledProtocols;
private final Supplier<Stream<Pair<SocketAddress,ProtocolStack>>> serverInstalledProtocols;
private CoreStateMachinesModule coreStateMachinesModule;
private final CoreServerModule coreServerModule;
private final CoreStateMachinesModule coreStateMachinesModule;

public enum RaftLogImplementation
{
Expand Down Expand Up @@ -294,7 +295,7 @@ public EnterpriseCoreEditionModule( final PlatformModule platformModule,

InstalledProtocolHandler serverInstalledProtocolHandler = new InstalledProtocolHandler();

CoreServerModule coreServerModule = new CoreServerModule( identityModule, platformModule, consensusModule, coreStateMachinesModule, clusteringModule,
this.coreServerModule = new CoreServerModule( identityModule, platformModule, consensusModule, coreStateMachinesModule, clusteringModule,
replicationModule, localDatabase, databaseHealthSupplier, clusterStateDirectory.get(), clientPipelineBuilderFactory,
serverPipelineBuilderFactory, serverInstalledProtocolHandler );

Expand Down Expand Up @@ -459,4 +460,9 @@ public void setupSecurityModule( PlatformModule platformModule, Procedures proce
{
EnterpriseEditionModule.setupEnterpriseSecurityModule( platformModule, procedures );
}

public void stopCatchupServer()
{
coreServerModule.catchupServer().stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public File raftLogDirectory()

public void stopCatchupServer()
{
throw new UnsupportedOperationException( "Not implemented" ); // TODO
database.stopCatchupServer();
}

int discoveryPort()
Expand Down

0 comments on commit be2409a

Please sign in to comment.