Skip to content

Commit

Permalink
add resource tracker argument to various places in the interest of co…
Browse files Browse the repository at this point in the history
…mpilation
  • Loading branch information
fickludd committed Feb 19, 2018
1 parent 8554f4e commit 3be5f94
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class TestResourceProcedure
{
public static abstract class SimulateFailureBaseException extends RuntimeException
abstract static class SimulateFailureBaseException extends RuntimeException
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.junit.rules.ExpectedException;

import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.api.ResourceTracker;
import org.neo4j.kernel.api.StubResourceManager;
import org.neo4j.kernel.api.exceptions.ProcedureException;
import org.neo4j.kernel.api.security.AnonymousContext;
import org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest;
Expand All @@ -36,6 +38,8 @@ public class AuthProceduresTest extends KernelIntegrationTest
@Rule
public ExpectedException exception = ExpectedException.none();

private final ResourceTracker<AutoCloseable> resourceTracker = new StubResourceManager();

@Test
public void shouldFailWhenDeprecatedChangePasswordWithStaticAccessModeInDbmsMode() throws Throwable
{
Expand All @@ -49,7 +53,10 @@ public void shouldFailWhenDeprecatedChangePasswordWithStaticAccessModeInDbmsMode

// When
dbmsOperations()
.procedureCallDbms( procedureName( "dbms", "changePassword" ), inputArray, AnonymousContext.none() );
.procedureCallDbms( procedureName( "dbms", "changePassword" ),
inputArray,
AnonymousContext.none(),
resourceTracker );
}

@Test
Expand All @@ -64,7 +71,10 @@ public void shouldFailWhenChangePasswordWithStaticAccessModeInDbmsMode() throws
exception.expectMessage( "Anonymous cannot change password" );

// When
dbmsOperations().procedureCallDbms( procedureName( "dbms", "security", "changePassword" ), inputArray, AnonymousContext.none() );
dbmsOperations().procedureCallDbms( procedureName( "dbms", "security", "changePassword" ),
inputArray,
AnonymousContext.none(),
resourceTracker );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.neo4j.causalclustering.discovery.ReadReplicaAddresses;
import org.neo4j.causalclustering.identity.MemberId;
import org.neo4j.collection.RawIterator;
import org.neo4j.kernel.api.ResourceTracker;
import org.neo4j.kernel.api.exceptions.ProcedureException;
import org.neo4j.kernel.api.proc.CallableProcedure;
import org.neo4j.kernel.api.proc.Context;
Expand Down Expand Up @@ -70,7 +71,8 @@ public ClusterOverviewProcedure( CoreTopologyService discoveryService,
}

@Override
public RawIterator<Object[],ProcedureException> apply( Context ctx, Object[] input ) throws ProcedureException
public RawIterator<Object[],ProcedureException> apply(
Context ctx, Object[] input, ResourceTracker resourceTracker ) throws ProcedureException
{
List<ReadWriteEndPoint> endpoints = new ArrayList<>();
CoreTopology coreTopology = discoveryService.coreServers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.neo4j.causalclustering.identity.MemberId;
import org.neo4j.collection.RawIterator;
import org.neo4j.helpers.AdvertisedSocketAddress;
import org.neo4j.kernel.api.ResourceTracker;
import org.neo4j.kernel.api.exceptions.ProcedureException;
import org.neo4j.kernel.api.proc.CallableProcedure;
import org.neo4j.kernel.api.proc.Context;
Expand Down Expand Up @@ -86,7 +87,8 @@ public GetServersProcedure( CoreTopologyService discoveryService, LeaderLocator
}

@Override
public RawIterator<Object[],ProcedureException> apply( Context ctx, Object[] input ) throws ProcedureException
public RawIterator<Object[],ProcedureException> apply(
Context ctx, Object[] input, ResourceTracker resourceTracker ) throws ProcedureException
{
List<ReadWriteRouteEndPoint> writeEndpoints = writeEndpoints();
List<ReadWriteRouteEndPoint> readEndpoints = readEndpoints();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.neo4j.causalclustering.discovery.procedures;

import org.neo4j.collection.RawIterator;
import org.neo4j.kernel.api.ResourceTracker;
import org.neo4j.kernel.api.exceptions.ProcedureException;
import org.neo4j.kernel.api.proc.CallableProcedure;
import org.neo4j.kernel.api.proc.Context;
Expand All @@ -43,7 +44,8 @@ abstract class RoleProcedure extends CallableProcedure.BasicProcedure
}

@Override
public RawIterator<Object[],ProcedureException> apply( Context ctx, Object[] input ) throws ProcedureException
public RawIterator<Object[],ProcedureException> apply(
Context ctx, Object[] input, ResourceTracker resourceTracker ) throws ProcedureException
{
return RawIterator.<Object[],ProcedureException>of( new Object[]{role().name()} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void shouldProvideOverviewOfCoreServersAndReadReplicas() throws Exception
NullLogProvider.getInstance() );

// when
final List<Object[]> members = asList( procedure.apply( null, new Object[0] ) );
final List<Object[]> members = asList( procedure.apply( null, new Object[0], null ) );

// then
assertThat( members, IsIterableContainingInOrder.contains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void shouldReturnEndpointsInDifferentOrders() throws Exception
private Object[] getEndpoints( GetServersProcedure proc )
throws org.neo4j.kernel.api.exceptions.ProcedureException
{
List<Object[]> results = asList( proc.apply( null, new Object[0] ) );
List<Object[]> results = asList( proc.apply( null, new Object[0], null ) );
Object[] rows = results.get( 0 );
List<Map<String,Object[]>> servers = (List<Map<String,Object[]>>) rows[1];
Map<String,Object[]> endpoints = servers.get( serverClass );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void ttlShouldBeInSeconds() throws Exception
new GetServersProcedure( coreTopologyService, leaderLocator, config, getInstance() );

// when
List<Object[]> results = asList( proc.apply( null, new Object[0] ) );
List<Object[]> results = asList( proc.apply( null, new Object[0], null ) );

// then
Object[] rows = results.get( 0 );
Expand Down Expand Up @@ -361,7 +361,7 @@ public void shouldReturnNoWriteEndpointsIfThereIsNoAddressForTheLeader() throws
@SuppressWarnings( "unchecked" )
private ClusterView run( GetServersProcedure proc ) throws ProcedureException
{
final Object[] rows = asList( proc.apply( null, new Object[0] ) ).get( 0 );
final Object[] rows = asList( proc.apply( null, new Object[0], null ) ).get( 0 );
assertEquals( config.get( cluster_routing_ttl ) / 1000, /* ttl */(long) rows[0] );
return ClusterView.parse( (List<Map<String,Object>>) rows[1] );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void shouldReturnLeader() throws Exception
RoleProcedure proc = new CoreRoleProcedure( raft );

// when
RawIterator<Object[], ProcedureException> result = proc.apply( null, null );
RawIterator<Object[], ProcedureException> result = proc.apply( null, null, null );

// then
assertEquals( Role.LEADER.name(), single( result )[0]);
Expand All @@ -58,7 +58,7 @@ public void shouldReturnFollower() throws Exception
RoleProcedure proc = new CoreRoleProcedure( raft );

// when
RawIterator<Object[], ProcedureException> result = proc.apply( null, null );
RawIterator<Object[], ProcedureException> result = proc.apply( null, null, null );

// then
assertEquals( Role.FOLLOWER.name(), single( result )[0]);
Expand All @@ -71,7 +71,7 @@ public void shouldReturnReadReplica() throws Exception
RoleProcedure proc = new ReadReplicaRoleProcedure();

// when
RawIterator<Object[], ProcedureException> result = proc.apply( null, null );
RawIterator<Object[], ProcedureException> result = proc.apply( null, null, null );

// then
assertEquals( Role.READ_REPLICA.name(), single( result )[0]);
Expand Down

0 comments on commit 3be5f94

Please sign in to comment.