Skip to content

Commit

Permalink
Moved store size function to new interface and deprecated the old one.
Browse files Browse the repository at this point in the history
  • Loading branch information
klaren committed Jul 3, 2017
1 parent c6be09e commit fdf09f2
Show file tree
Hide file tree
Showing 7 changed files with 596 additions and 216 deletions.
14 changes: 5 additions & 9 deletions community/jmx/src/main/java/org/neo4j/jmx/StoreFile.java
Expand Up @@ -20,7 +20,9 @@
package org.neo4j.jmx; package org.neo4j.jmx;


@ManagementInterface( name = StoreFile.NAME ) @ManagementInterface( name = StoreFile.NAME )
@Description( "Information about the sizes of the different parts of the Neo4j graph store" ) @Description( "This bean is deprecated, use StoreSize bean instead; " +
"Information about the sizes of the different parts of the Neo4j graph store" )
@Deprecated
public interface StoreFile public interface StoreFile
{ {
String NAME = "Store file sizes"; String NAME = "Store file sizes";
Expand All @@ -37,19 +39,13 @@ public interface StoreFile
@Description( "The amount of disk space used to store relationships, in bytes." ) @Description( "The amount of disk space used to store relationships, in bytes." )
long getRelationshipStoreSize(); long getRelationshipStoreSize();


@Description( "The amount of disk space used to store properties " @Description( "The amount of disk space used to store properties " +
+ "(excluding string values and array values), in bytes." ) "(excluding string values and array values), in bytes." )
long getPropertyStoreSize(); long getPropertyStoreSize();


@Description( "The amount of disk space used to store string properties, in bytes." ) @Description( "The amount of disk space used to store string properties, in bytes." )
long getStringStoreSize(); long getStringStoreSize();


@Description( "The amount of disk space used to store array properties, in bytes." ) @Description( "The amount of disk space used to store array properties, in bytes." )
long getArrayStoreSize(); long getArrayStoreSize();

@Description( "The amount of disk space used by all logical logs, in bytes." )
long getAllLogicalLogsSize();

@Description( "The amount of disk space used by all indices, in bytes" )
long getIndexStoreSize();
} }
60 changes: 60 additions & 0 deletions community/jmx/src/main/java/org/neo4j/jmx/StoreSize.java
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2002-2017 "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.jmx;

@ManagementInterface( name = StoreSize.NAME )
@Description( "Information about the disk space used by different parts of the Neo4j graph store" )
public interface StoreSize
{
String NAME = "Store sizes";

@Description( "Disk space used by the transaction logs, in bytes." )
long getTransactionLogsSize();

@Description( "Disk space used to store nodes, in bytes." )
long getNodeStoreSize();

@Description( "Disk space used to store relationships, in bytes." )
long getRelationshipStoreSize();

@Description( "Disk space used to store properties (excluding string values and array values), in bytes." )
long getPropertyStoreSize();

@Description( "Disk space used to store string properties, in bytes." )
long getStringStoreSize();

@Description( "Disk space used to store array properties, in bytes." )
long getArrayStoreSize();

@Description( "Disk space used to store labels, in bytes" )
long getLabelStoreSize();

@Description( "Disk space used to store counters, in bytes" )
long getCountStoreSize();

@Description( "Disk space used to store schemas (index and constrain declarations), in bytes" )
long getSchemaStoreSize();

@Description( "Disk space used to store all indices, in bytes" )
long getIndexStoreSize();

@Description( "Disk space used by whole store, in bytes." )
long getTotalStoreSize();
}
71 changes: 2 additions & 69 deletions community/jmx/src/main/java/org/neo4j/jmx/impl/StoreFileBean.java
Expand Up @@ -28,14 +28,9 @@
import org.neo4j.io.fs.FileUtils; import org.neo4j.io.fs.FileUtils;
import org.neo4j.jmx.StoreFile; import org.neo4j.jmx.StoreFile;
import org.neo4j.kernel.NeoStoreDataSource; import org.neo4j.kernel.NeoStoreDataSource;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.impl.api.LegacyIndexProviderLookup;
import org.neo4j.kernel.impl.store.MetaDataStore; import org.neo4j.kernel.impl.store.MetaDataStore;
import org.neo4j.kernel.impl.transaction.log.LogFile; import org.neo4j.kernel.impl.transaction.log.LogFile;
import org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles;
import org.neo4j.kernel.impl.transaction.state.DataSourceManager; import org.neo4j.kernel.impl.transaction.state.DataSourceManager;
import org.neo4j.kernel.spi.legacyindex.IndexImplementation;


import static org.neo4j.kernel.impl.store.StoreFactory.NODE_STORE_NAME; import static org.neo4j.kernel.impl.store.StoreFactory.NODE_STORE_NAME;
import static org.neo4j.kernel.impl.store.StoreFactory.PROPERTY_ARRAYS_STORE_NAME; import static org.neo4j.kernel.impl.store.StoreFactory.PROPERTY_ARRAYS_STORE_NAME;
Expand Down Expand Up @@ -67,11 +62,7 @@ static class StoreFileImpl extends Neo4jMBean implements StoreFile


private File storePath; private File storePath;
private LogFile logFile; private LogFile logFile;
private PhysicalLogFiles physicalLogFiles;
private FileSystemAbstraction fs; private FileSystemAbstraction fs;
private LegacyIndexProviderLookup legacyIndexProviderLookup;
private SchemaIndexProvider schemaIndexProvider;
private LabelScanStore labelScanStore;


StoreFileImpl( ManagementData management ) throws NotCompliantMBeanException StoreFileImpl( ManagementData management ) throws NotCompliantMBeanException
{ {
Expand All @@ -86,11 +77,6 @@ static class StoreFileImpl extends Neo4jMBean implements StoreFile
public void registered( NeoStoreDataSource ds ) public void registered( NeoStoreDataSource ds )
{ {
logFile = resolveDependency( ds, LogFile.class ); logFile = resolveDependency( ds, LogFile.class );
physicalLogFiles = resolveDependency( ds, PhysicalLogFiles.class );
legacyIndexProviderLookup = resolveDependency( ds, LegacyIndexProviderLookup.class );
schemaIndexProvider = resolveDependency( ds, SchemaIndexProvider.class );
labelScanStore = resolveDependency( ds, LabelScanStore.class );

storePath = resolvePath( ds ); storePath = resolvePath( ds );
} }


Expand All @@ -103,7 +89,6 @@ private <T> T resolveDependency( NeoStoreDataSource ds, Class<T> clazz )
public void unregistered( NeoStoreDataSource ds ) public void unregistered( NeoStoreDataSource ds )
{ {
logFile = null; logFile = null;
physicalLogFiles = null;
storePath = null; storePath = null;
} }


Expand Down Expand Up @@ -133,47 +118,12 @@ public long getLogicalLogSize()
return logFile == null ? 0 : FileUtils.size( fs, logFile.currentLogFile() ); return logFile == null ? 0 : FileUtils.size( fs, logFile.currentLogFile() );
} }


private long sizeOf( String name )
{
return storePath == null ? 0 : FileUtils.size( fs, new File( storePath, name ) );
}

@Override @Override
public long getArrayStoreSize() public long getArrayStoreSize()
{ {
return sizeOf( ARRAY_STORE ); return sizeOf( ARRAY_STORE );
} }


@Override
public long getAllLogicalLogsSize()
{
TotalSizeVersionVisitor logVersionVisitor = new TotalSizeVersionVisitor( fs );

physicalLogFiles.accept( logVersionVisitor );

return logVersionVisitor.getTotalSize();
}

@Override
public long getIndexStoreSize()
{
long size = 0L;

// Add legacy indices
for ( IndexImplementation index : legacyIndexProviderLookup.all() )
{
size += FileUtils.size( fs, index.getIndexImplementationDirectory( storePath ) );
}

// Add schema index
size += FileUtils.size( fs, schemaIndexProvider.getSchemaIndexStoreDirectory( storePath ) );

// Add label index
size += FileUtils.size( fs, labelScanStore.getLabelScanStoreFile() );

return size;
}

@Override @Override
public long getNodeStoreSize() public long getNodeStoreSize()
{ {
Expand All @@ -198,26 +148,9 @@ public long getStringStoreSize()
return sizeOf( STRING_STORE ); return sizeOf( STRING_STORE );
} }


private static class TotalSizeVersionVisitor implements PhysicalLogFiles.LogVersionVisitor private long sizeOf( String name )
{ {
private final FileSystemAbstraction fs; return storePath == null ? 0 : FileUtils.size( fs, new File( storePath, name ) );
private long totalSize;

TotalSizeVersionVisitor( FileSystemAbstraction fs )
{
this.fs = fs;
}

long getTotalSize()
{
return totalSize;
}

@Override
public void visit( File file, long logVersion )
{
totalSize += FileUtils.size( fs, file );
}
} }
} }
} }

0 comments on commit fdf09f2

Please sign in to comment.