Skip to content

Commit

Permalink
Supporting code for new consistency checker.
Browse files Browse the repository at this point in the history
* Improved progress reporting helpers.
* Interfaces to allow alternative window pool implementations.
* Settings concerning new window pool implementation.
  • Loading branch information
apcj committed Oct 5, 2012
1 parent b66dd82 commit fce075d
Show file tree
Hide file tree
Showing 59 changed files with 2,956 additions and 387 deletions.
Expand Up @@ -696,6 +696,11 @@ public void validate( Locale locale, String value )

@Override
public Long valueOf(String rawValue, Config config)
{
return parseNumberOfBytes( rawValue );
}

public static Long parseNumberOfBytes( String rawValue )
{
String mem = rawValue.toLowerCase();
long multiplier = 1;
Expand All @@ -714,7 +719,7 @@ else if ( mem.endsWith( "g" ) )
multiplier = 1024 * 1024 * 1024;
mem = mem.substring( 0, mem.length() - 1 );
}

return Long.parseLong( mem.trim() ) * multiplier;
}
}
Expand Down
Expand Up @@ -104,6 +104,19 @@ public abstract class GraphDatabaseSettings
@Description( "Enable this to specify a parser other than the default one." )
public static final OptionsSetting cypher_parser_version = new CypherParserSetting();

// Store files

@Description("The directory where the database files are located.")
public static final GraphDatabaseSetting.DirectorySetting store_dir = new GraphDatabaseSetting.DirectorySetting( "store_dir", true, true);

@Description("The base name for the Neo4j Store files, either an absolute path or relative to the store_dir setting. This should generally not be changed.")
@Default("neostore")
public static final GraphDatabaseSetting.FileSetting neo_store = new GraphDatabaseSetting.FileSetting( "neo_store", store_dir, true, true);

@Description("The base name for the logical log files, either an absolute path or relative to the store_dir setting. This should generally not be changed.")
@Default("nioneo_logical.log")
public static final GraphDatabaseSetting.FileSetting logical_log = new GraphDatabaseSetting.FileSetting( "logical_log", store_dir, true, true);

// Remote logging
@Description( "Whether to enable logging to a remote server or not." )
@Default(FALSE)
Expand Down Expand Up @@ -170,6 +183,26 @@ public abstract class GraphDatabaseSettings
@Description( "Tell Neo4j to use memory mapped buffers for accessing the native storage layer." )
public static final UseMemoryMappedBuffers use_memory_mapped_buffers = new UseMemoryMappedBuffers();

@Description( "Target size for pages of mapped memory." )
@Default("1M")
public static final GraphDatabaseSetting<Long> mapped_memory_page_size = new NumberOfBytesSetting("mapped_memory_page_size");

@Description( "The size to allocate for a memory mapping pool to be shared between all stores." )
@Default("500M")
public static final GraphDatabaseSetting<Long> all_stores_total_mapped_memory_size = new NumberOfBytesSetting("all_stores_total_mapped_memory_size");

@Description( "Tell Neo4j to regularly log memory mapping statistics." )
@Default("false")
public static final GraphDatabaseSetting<Boolean> log_mapped_memory_stats = new BooleanSetting("log_mapped_memory_stats");

@Description("The file where Neo4j will record memory mapping statistics.")
@Default("mapped_memory_stats.log")
public static final GraphDatabaseSetting.FileSetting log_mapped_memory_stats_filename = new GraphDatabaseSetting.FileSetting( "log_mapped_memory_stats_filename", store_dir, true, true );

@Description( "The number of records to be loaded between regular logging of memory mapping statistics." )
@Default("1000000")
public static final GraphDatabaseSetting<Integer> log_mapped_memory_stats_interval = new IntegerSetting("log_mapped_memory_stats_interval", "Must be a number");

@Description( "The size to allocate for memory mapping the node store." )
@Default("20M")
public static final Setting nodestore_mapped_memory_size = new NumberOfBytesSetting("neostore.nodestore.db.mapped_memory");
Expand Down Expand Up @@ -297,19 +330,6 @@ public abstract class GraphDatabaseSettings
@Deprecated
public static StringSetting gc_monitor_threshold = new StringSetting( "gc_monitor_threshold", GraphDatabaseSetting.ANY, "Must be non-empty." );

// Store files

@Description("The directory where the database files are located.")
public static final GraphDatabaseSetting.DirectorySetting store_dir = new GraphDatabaseSetting.DirectorySetting( "store_dir", true, true);

@Description("The base name for the Neo4j Store files, either an absolute path or relative to the store_dir setting. This should generally not be changed.")
@Default("neostore")
public static final GraphDatabaseSetting.FileSetting neo_store = new GraphDatabaseSetting.FileSetting( "neo_store", store_dir, true, true);

@Description("The base name for the logical log files, either an absolute path or relative to the store_dir setting. This should generally not be changed.")
@Default("nioneo_logical.log")
public static final GraphDatabaseSetting.FileSetting logical_log = new GraphDatabaseSetting.FileSetting( "logical_log", store_dir, true, true);

// Old GCR size settings, using string values

/**
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/main/java/org/neo4j/helpers/Args.java
Expand Up @@ -241,7 +241,7 @@ public static String jarUsage( Class<?> main, String... params )
{
// ignore
}
usage.append( main.getCanonicalName() );
usage.append( ' ' ).append( main.getCanonicalName() );
for ( String param : params )
{
usage.append( ' ' ).append( param );
Expand Down
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2002-2012 "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.helpers;

public class ProcessFailureException extends Exception
{
public ProcessFailureException( Throwable cause )
{
super( "Monitored process failed", cause );
}
}
162 changes: 5 additions & 157 deletions kernel/src/main/java/org/neo4j/helpers/ProgressIndicator.java
Expand Up @@ -25,77 +25,14 @@
* A generic interface for reporting progress by a tool. Can be implemented to
* support reporting progress from both a {@link SimpleProgress single source},
* or for the aggregate of {@link MultiProgress multiple sources}.
*
*
* @deprecated use {@link Progress} instead.
*
* @author Tobias Lindaaker <tobias.lindaaker@neotechnology.com>
*/
@Deprecated
public interface ProgressIndicator
{
/**
* A factory interface for creating {@link ProgressIndicator}s.
*
* @author Tobias Lindaaker <tobias.lindaaker@neotechnology.com>
*/
public interface Factory
{
Factory NONE = new Factory()
{
@Override
public ProgressIndicator newSimpleProgressIndicator( long total )
{
return ProgressIndicator.NONE;
}

@Override
public ProgressIndicator newMultiProgressIndicator( long total )
{
return ProgressIndicator.NONE;
}
};

ProgressIndicator newSimpleProgressIndicator( long total );

ProgressIndicator newMultiProgressIndicator( long total );
}

/**
* A factory implementation that creates progress indicators that log progress textually.
*
* @author Tobias Lindaaker <tobias.lindaaker@neotechnology.com>
*/
public final class Textual implements Factory
{
private final PrintStream out;

public Textual( PrintStream out )
{
this.out = out;
}

@Override
public SimpleProgress newSimpleProgressIndicator( long total )
{
return SimpleProgress.textual( out, total );
}

@Override
public MultiProgress newMultiProgressIndicator( long total )
{
return MultiProgress.textual( out, total );
}
}

/**
* Set the name of the current phase of the progress.
* This is an optional method that users of progress indication can use to notify the progress indicator
* of the name of the current phase, if the progress indicator supports it.
*
* A progress indicator can choose not to support this feature by implementing this method as a no-op.
* A progress indicator must support clients that don't invoke this method.
*
* @param phase the name of the current phase.
*/
void phase( String phase );

/**
* Update the current progress count for the current source.
*
Expand All @@ -113,17 +50,6 @@ public MultiProgress newMultiProgressIndicator( long total )
*/
void done( long totalProgress );

/**
* Signal that the entire progress has completed.
*
* This method is generally only used by processes that process multiple phases,
* where the {@link #done(long)} method is used to indicate the completion of a
* single phase, rather than the completion of the entire process.
*
* To not invoke this method from a process that only processes a single phase is perfectly acceptable.
*/
void done();

/**
* A {@link ProgressIndicator} that can report the progress for a single
* source.
Expand Down Expand Up @@ -175,12 +101,6 @@ long currentProgress( boolean incremental, long value )
return currentProgress = ( incremental ? ( currentProgress + value ) : value );
}

@Override
public void phase( String phase )
{
// default: do nothing
}

@Override
public void update( boolean incremental, long value )
{
Expand All @@ -194,7 +114,7 @@ public void done( long totalProgress )
done();
}

public void done()
void done()
{
if ( lastPermille < 1000 ) progress( lastPermille = 1000 );
}
Expand Down Expand Up @@ -315,12 +235,6 @@ public UnknownEndProgress(long stepSize, String doneMessage, PrintStream out)
this.out = out;
}

@Override
public void phase( String phase )
{
// default: do nothing
}

@Override
public void update( boolean incremental, long value )
{
Expand Down Expand Up @@ -358,71 +272,5 @@ public void done( long totalProgress )
if ( lastStep > 0 ) out.println();
out.println( "[" + totalProgress + " " + doneMessage + "]" );
}

@Override
public void done()
{
done( lastAbsolutePosition );
}
}

public abstract class Decorator implements ProgressIndicator
{
private final ProgressIndicator actual;

public Decorator( ProgressIndicator actual )
{
this.actual = actual;
}

@Override
public void phase( String phase )
{
actual.phase( phase );
}

@Override
public void update( boolean incremental, long value )
{
actual.update( incremental, value );
}

@Override
public void done( long totalProgress )
{
actual.done( totalProgress );
}

@Override
public void done()
{
actual.done();
}
}

/**
* A null object implementation of the ProgressIndicator interface.
*/
ProgressIndicator NONE = new ProgressIndicator()
{
@Override
public void phase( String phase )
{
}

@Override
public void update( boolean incremental, long value )
{
}

@Override
public void done( long totalProgress )
{
}

@Override
public void done()
{
}
};
}

0 comments on commit fce075d

Please sign in to comment.