Skip to content

Commit

Permalink
The Data Collector
Browse files Browse the repository at this point in the history
Introduce a new data-collector module which holds new Data Collector
functionality. There will eventually exist one Collector per database,
with the ability to collect various statistical operational data on the
database and it's usage pattern. Collection is controlled via procedures,
and a stub of the most fundamental procedure (retrieve) is included here.
  • Loading branch information
fickludd committed Dec 1, 2018
1 parent efd2df5 commit ce28a80
Show file tree
Hide file tree
Showing 13 changed files with 1,517 additions and 0 deletions.
3 changes: 3 additions & 0 deletions community/common/src/main/java/org/neo4j/scheduler/Group.java
Expand Up @@ -59,6 +59,9 @@ public enum Group
/** Thread pool for parallel Cypher query execution. */
CYPHER_WORKER( "CypherWorker", ExecutorServiceFactory.workStealing() ),

// DATA COLLECTOR
DATA_COLLECTOR( "DataCollector" ),

// BOLT.
/** Network IO threads for the Bolt protocol. */
BOLT_NETWORK_IO( "BoltNetworkIO" ),
Expand Down
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.internal.collector

import org.neo4j.cypher.ExecutionEngineFunSuite

class DataCollectorAcceptanceTest extends ExecutionEngineFunSuite {

test("should retrieve correct section") {
val res = execute("CALL db.stats.retrieve('teddybear')")
res.toList should be(Seq(Map("section" -> "teddybear", "data" -> Map())))
}
}
Expand Up @@ -43,6 +43,12 @@ trait RewindableExecutionResult {
def size: Long = result.size
def head(str: String): AnyRef = result.head(str)

def single: Map[String, AnyRef] =
if (result.size == 1)
result.head
else
throw new IllegalStateException(s"Result should have one row, but had ${result.size}")

def executionPlanDescription(): InternalPlanDescription = planDescription

def executionPlanString(): String = planDescription.toString
Expand Down
695 changes: 695 additions & 0 deletions community/data-collector/LICENSE.txt

Large diffs are not rendered by default.

437 changes: 437 additions & 0 deletions community/data-collector/LICENSES.txt

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions community/data-collector/NOTICE.txt
@@ -0,0 +1,62 @@
Neo4j
Copyright © 2002-2018 Neo4j Sweden AB (referred to in this notice as "Neo4j")
[http://neo4j.com]

This product includes software ("Software") developed by Neo4j.

The copyright in the bundled Neo4j graph database (including the
Software) is owned by Neo4j. The Software developed and owned
by Neo4j is licensed under the GNU GENERAL PUBLIC LICENSE Version 3
(http://www.fsf.org/licensing/licenses/gpl-3.0.html) ("GPL")
to all third parties and that license, as required by the GPL, is
included in the LICENSE.txt file.

However, if you have executed an End User Software License and Services
Agreement or an OEM Software License and Support Services Agreement, or
another commercial license agreement with Neo4j or one of its
affiliates (each, a "Commercial Agreement"), the terms of the license in
such Commercial Agreement will supersede the GPL and you may use the
software solely pursuant to the terms of the relevant Commercial
Agreement.

Full license texts are found in LICENSES.txt.


Third-party licenses
--------------------

Apache Software License, Version 2.0
Apache Commons Lang
Lucene Core
Lucene Memory
Netty/All-in-One

BSD - Scala License
Scala Library

BSD License
Scala Compiler

Bouncy Castle License
Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs
Bouncy Castle Provider

Eclipse Distribution License - v 1.0
Eclipse Collections API
Eclipse Collections Main Library

Eclipse Public License - v 1.0
Eclipse Collections API
Eclipse Collections Main Library

Dependencies with multiple licenses
-----------------------------------

Eclipse Collections API
Eclipse Distribution License - v 1.0
Eclipse Public License - v 1.0

Eclipse Collections Main Library
Eclipse Distribution License - v 1.0
Eclipse Public License - v 1.0

145 changes: 145 additions & 0 deletions community/data-collector/pom.xml
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.neo4j</groupId>
<artifactId>parent</artifactId>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>

<properties>
<license-text.header>headers/GPL-3-header.txt</license-text.header>
<licensing.prepend.text>licensing/notice-gpl-prefix.txt</licensing.prepend.text>
<moduleName>org.neo4j.common</moduleName>
</properties>

<modelVersion>4.0.0</modelVersion>
<artifactId>neo4j-data-collector</artifactId>
<version>3.5.0-SNAPSHOT</version>

<packaging>jar</packaging>
<name>Neo4j - Data Collector</name>
<description>The Neo4j data collector deamon.</description>
<url>http://components.neo4j.org/${project.artifactId}/${project.version}</url>

<scm>
<connection>scm:git:git://github.com/neo4j/neo4j.git</connection>
<developerConnection>scm:git:git@github.com:neo4j/neo4j.git</developerConnection>
<url>https://github.com/neo4j/neo4j</url>
</scm>

<licenses>
<license>
<name>GNU General Public License, Version 3</name>
<url>http://www.gnu.org/licenses/gpl-3.0-standalone.html</url>
<comments>The software ("Software") developed and owned by Neo4j Sweden AB (referred to in this notice as "Neo4j") is
licensed under the GNU GENERAL PUBLIC LICENSE Version 3 to all third
parties and that license is included below.

However, if you have executed an End User Software License and Services
Agreement or an OEM Software License and Support Services Agreement, or
another commercial license agreement with Neo4j or one of its
affiliates (each, a "Commercial Agreement"), the terms of the license in
such Commercial Agreement will supersede the GNU GENERAL PUBLIC LICENSE
Version 3 and you may use the Software solely pursuant to the terms of
the relevant Commercial Agreement.
</comments>
</license>
</licenses>

<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.scalastyle</groupId>
<artifactId>scalastyle-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<verbose>false</verbose>
<failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<failOnWarning>false</failOnWarning>
<inputEncoding>UTF-8</inputEncoding>
<sourceDirectory>${basedir}/src/main/scala</sourceDirectory>
<testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory>
<configLocation>${project.basedir}/../scalastyle_config.xml</configLocation>
<outputFile>${basedir}/target/scalastyle-output.xml</outputFile>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>

<!-- scala -->

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
</dependency>

<!-- neo4j -->

<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-procedure-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>${project.version}</version>
</dependency>

<!-- neo4j testing -->

<!-- Test are located with other IT tests to solve problems with depending of TestGraphDatabaseFactory et.c. -->

<!-- tests -->

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.internal.collector;

import java.util.Collections;
import java.util.stream.Stream;

import org.neo4j.procedure.Description;
import org.neo4j.procedure.Mode;
import org.neo4j.procedure.Name;
import org.neo4j.procedure.Procedure;

@SuppressWarnings( "WeakerAccess" )
public class CollectorProcedures
{
@Description( "Retrieve statistical data about the current database." )
@Procedure( name = "db.stats.retrieve", mode = Mode.READ )
public Stream<RetrieveResult> retrieve( @Name( value = "section", defaultValue = "all" ) String section )
{
return Stream.of( new RetrieveResult( section, Collections.emptyMap() ) );
}
}
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.internal.collector;

import org.neo4j.internal.kernel.api.Kernel;
import org.neo4j.internal.kernel.api.exceptions.KernelException;
import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.scheduler.JobScheduler;
import org.neo4j.util.Preconditions;

public class DataCollectorModule
{
private DataCollectorModule()
{
}

public static void setupDataCollector( Procedures procedures,
JobScheduler jobScheduler,
Kernel kernel ) throws KernelException
{
Preconditions.checkState( kernel != null, "Kernel was null" );
procedures.registerProcedure( CollectorProcedures.class );
}
}
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.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.internal.collector;
import java.util.Map;

@SuppressWarnings( "WeakerAccess" )
public class RetrieveResult
{
public final String section;
public final Map<String, Object> data;
public RetrieveResult( String section, Map<String,Object> data )
{
this.section = section;
this.data = data;
}
}
5 changes: 5 additions & 0 deletions community/neo4j/pom.xml
Expand Up @@ -73,6 +73,11 @@ the relevant Commercial Agreement.
<artifactId>neo4j-udc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-data-collector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher</artifactId>
Expand Down

0 comments on commit ce28a80

Please sign in to comment.