-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
5052662
to
7eddd37
Compare
bf0a849
to
851b19a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req.getLocalName(), | ||
req.getLocalAddr(), | ||
req.getLocalPort(), | ||
req.getAuthType() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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() ); |
There was a problem hiding this comment.
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() ); |
There was a problem hiding this comment.
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 ) ); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" ); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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' ); |
There was a problem hiding this comment.
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
af211bd
to
0bac6ab
Compare
@MishaDemianenko Thanks for catching some sloppy parts of this code. Addressed most and commented on others. |
79b394f
to
e5bd626
Compare
@@ -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 ) |
There was a problem hiding this comment.
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 ) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
… 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.
e5bd626
to
3389ff3
Compare
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
.