Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reporter can now report environment variables and the output of dbms.…
…listTransactions(). Windows file paths should work correctly now with .toUri() doing the escaping.
- Loading branch information
Showing
9 changed files
with
220 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
community/dbms/src/main/java/org/neo4j/dbms/diagnostics/jmx/Reports.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.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.dbms.diagnostics.jmx; | ||
|
||
import org.neo4j.jmx.Description; | ||
import org.neo4j.jmx.ManagementInterface; | ||
|
||
@ManagementInterface( name = Reports.NAME ) | ||
@Description( "Reports operations" ) | ||
public interface Reports | ||
{ | ||
String NAME = "Reports"; | ||
|
||
@Description( "List all active transactions" ) | ||
String listTransactions(); | ||
|
||
@Description( "Returns a map if the current environment variables" ) | ||
String getEnvironmentVariables(); | ||
} |
88 changes: 88 additions & 0 deletions
88
community/dbms/src/main/java/org/neo4j/dbms/diagnostics/jmx/ReportsBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.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.dbms.diagnostics.jmx; | ||
|
||
import java.util.Map; | ||
|
||
import org.neo4j.graphdb.QueryExecutionException; | ||
import org.neo4j.graphdb.Transaction; | ||
import org.neo4j.jmx.impl.ManagementBeanProvider; | ||
import org.neo4j.jmx.impl.ManagementData; | ||
import org.neo4j.jmx.impl.Neo4jMBean; | ||
import org.neo4j.kernel.internal.GraphDatabaseAPI; | ||
|
||
public class ReportsBean extends ManagementBeanProvider | ||
{ | ||
public ReportsBean() | ||
{ | ||
super( Reports.class ); | ||
} | ||
|
||
@Override | ||
protected Neo4jMBean createMBean( ManagementData management ) | ||
{ | ||
return new ReportsImpl( management, false ); | ||
} | ||
|
||
@Override | ||
protected Neo4jMBean createMXBean( ManagementData management ) | ||
{ | ||
return new ReportsImpl( management, true ); | ||
} | ||
|
||
private static class ReportsImpl extends Neo4jMBean implements Reports | ||
{ | ||
private final GraphDatabaseAPI graphDatabaseAPI; | ||
|
||
ReportsImpl( ManagementData management, boolean isMXBean ) | ||
{ | ||
super( management, isMXBean ); | ||
graphDatabaseAPI = management.getKernelData().graphDatabase(); | ||
} | ||
|
||
@Override | ||
public String listTransactions() | ||
{ | ||
String res; | ||
try ( Transaction tx = graphDatabaseAPI.beginTx() ) | ||
{ | ||
res = graphDatabaseAPI.execute( "CALL dbms.listTransactions()" ).resultAsString(); | ||
|
||
tx.success(); | ||
} | ||
catch ( QueryExecutionException e ) | ||
{ | ||
res = "dbms.listTransactions() is not available"; | ||
} | ||
return res; | ||
} | ||
|
||
@Override | ||
public String getEnvironmentVariables() | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
for ( Map.Entry<String,String> env : System.getenv().entrySet() ) | ||
{ | ||
sb.append( env.getKey() ).append( '=' ).append( env.getValue() ).append( '\n' ); | ||
} | ||
return sb.toString(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...unity/dbms/src/main/resources/META-INF/services/org.neo4j.jmx.impl.ManagementBeanProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.neo4j.dbms.diagnostics.jmx.ReportsBean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.