Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connection details to listQueries #7928

Merged
merged 11 commits into from
Sep 16, 2016
Merged

Conversation

systay
Copy link
Contributor

@systay systay commented Sep 13, 2016

This adds connection details to the output of the procedure listQueries.

Depending on how the user is connecting to Neo4j, different outputs will be seen in the result table. Bolt and REST report connection address, whereas an embedded session will just be listed as embedded.

Copy link
Contributor

@MishaDemianenko MishaDemianenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@systay @boggle first round of review completed, couple of small comments

req.getLocalName(),
req.getLocalAddr(),
req.getLocalPort(),
req.getAuthType()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please note that AuthType can be null

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but this seems not to be even used. Possibly there's a need for some large clean-ups here, but I don't think we should perform that as a part of this PR. Essentially any null-Strings gotten from the Request will simply be passed on transparently to InternalJettyServletRequest users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

representing it as an optional will help a lot for example, printing AuthType: default is much better then print AuthType: null

{
return new RequestData(
req.getRemoteAddr(),
req.getRemoteHost(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please note that in case if implementation of servlet api will try to resolve fully qualified name
that can take significant time

assertEquals( "127.0.0.1", req.getRemoteAddr());
assertEquals( "localhost", req.getRemoteHost());
assertEquals( true, req.isSecure() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue

format("server-session\t%s", username) :
format("server-session\thttp\t%s\t%s\t%s", request.getRemoteAddr(), request.getRequestURI(), username );
new QuerySource( "server-session" ) :
new QuerySource( "server-session", "http", request.getRemoteAddr(), request.getRequestURI() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like it should be request.getScheme() instead of http always

@@ -216,6 +219,7 @@ public void init( SPI spi, Config config )
.getOrCreateRelationshipIndex( InternalAutoIndexing.RELATIONSHIP_AUTO_INDEX, null ) ),
spi.autoIndexing().relationships() );
this.indexManager = new IndexManagerImpl( spi::currentStatement, idxProvider, nodeAutoIndexer, relAutoIndexer );
this.contextFactorySupplier = lazySingleton( () -> new Neo4jTransactionalContextFactory( spi, locker ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need contextFactory to be supplier at all? why not just create instance of Neo4jTransactionalContextFactory like:

this.contextFactory = new Neo4jTransactionalContextFactory( spi, locker );

and use it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lazy instantiation is needed as the spi is not fully configured during the GraphDatabaseFacade.init. Only creating the factory at first use solves this problem with little fuss.

@@ -270,4 +267,9 @@ public AccessMode accessMode()
{
return mode;
}

public static Function<TransactionalContext, String> describe()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think this belongs to this class

executingQuery.queryText(),
executingQuery.queryParameters(),
locker
graph,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we use newly introduced context factory for this sort of things?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using several private field which are more easily accessed here. Renamed the method instead to improved clarity.

Neo4jTransactionalContext transactionalContext =
new Neo4jTransactionalContext(
databaseQueryService, transaction, statement, "", Collections.emptyMap(), propertyContainerLocker );
//<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think we should ever resolve conflicts in this way

@@ -131,10 +131,6 @@ private Lifecycle createEmptyAdapter()

static class QueryLogger implements QueryExecutionMonitor
{
private static final MetadataKey<Long> START_TIME = new MetadataKey<>( Long.class, "start time" );
private static final MetadataKey<String> QUERY_STRING = new MetadataKey<>( String.class, "query string" );
private static final MetadataKey<Map<String,Object>> PARAMS = new MetadataKey<>( paramsClass(), "parameters" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static method paramsClass is not used anymore and should be deleted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Override
public String toString()
{
return toString( '\t' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use return String.join( "\t", parts ); instead

@fickludd
Copy link
Contributor

@MishaDemianenko Thanks for catching some sloppy parts of this code. Addressed most and commented on others.

@fickludd fickludd force-pushed the 3.1-list-queries branch 2 times, most recently from 79b394f to e5bd626 Compare September 15, 2016 14:00
@@ -197,7 +195,7 @@ public GraphDatabaseFacade()
/**
* Create a new Core API facade, backed by the given SPI.
*/
public void init( SPI spi, Config config )
public void initSPI( SPI spi, Config config )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initSPI is a bit confusing imho, since it looks like we initialise SPI here, but actually we just provide facade with dependencies, so i would keep old name instead

@@ -197,7 +195,7 @@ public GraphDatabaseFacade()
/**
* Create a new Core API facade, backed by the given SPI.
*/
public void init( SPI spi, Config config )
public void initSPI( SPI spi, Config config )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it work if in init method we just provide dependencies - store them as fields and then do al initialisation of fields all together in next method together with context factory?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this, but it failed a lot of tests that do not need the TransactionalContextFactory. It seems like here is work to do, but I would rather not spend more time on this is the scope of this PR.

boggle and others added 11 commits September 16, 2016 13:40
… field

o This aligns procedures better with how Cypher itself handles return columns and probably should have been like this initially
When adding connection details to ExecutingQuery, there was no longer
any need to keep QuerySession around. Instead, query logging (the main
user of QuerySession) can now get it's data through the TransactionContext
which includes an ExecutingQuery.
@craigtaverner craigtaverner merged commit 3389ff3 into neo4j:3.1 Sep 16, 2016
@craigtaverner craigtaverner deleted the 3.1-list-queries branch September 16, 2016 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants