Skip to content

Commit

Permalink
Simplify page warmer stop, fix method name spelling error.
Browse files Browse the repository at this point in the history
Use plain sync block in PAgeCacheWarmer stop.
Rename Files.createOrOpenAsOuputStream -> Files.createOrOpenAsOutputStream
  • Loading branch information
MishaDemianenko committed Mar 28, 2018
1 parent 502c38f commit ddc6c08
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 20 deletions.
Expand Up @@ -66,7 +66,7 @@
import static java.lang.String.format;
import static org.neo4j.consistency.internal.SchemaIndexExtensionLoader.instantiateKernelExtensions;
import static org.neo4j.consistency.internal.SchemaIndexExtensionLoader.loadIndexProviders;
import static org.neo4j.io.file.Files.createOrOpenAsOuputStream;
import static org.neo4j.io.file.Files.createOrOpenAsOutputStream;
import static org.neo4j.kernel.configuration.Settings.FALSE;
import static org.neo4j.kernel.configuration.Settings.TRUE;
import static org.neo4j.kernel.impl.factory.DatabaseInfo.COMMUNITY;
Expand Down Expand Up @@ -219,7 +219,7 @@ public Result runFullConsistencyCheck( final File storeDir, Config config, Progr
{
try
{
return new PrintWriter( createOrOpenAsOuputStream( fileSystem, reportFile, true ) );
return new PrintWriter( createOrOpenAsOutputStream( fileSystem, reportFile, true ) );
}
catch ( IOException e )
{
Expand Down
2 changes: 1 addition & 1 deletion community/io/src/main/java/org/neo4j/io/file/Files.java
Expand Up @@ -42,7 +42,7 @@ private Files()
* @return An output stream
* @throws IOException If an error occurs creating directories or opening the file
*/
public static OutputStream createOrOpenAsOuputStream( FileSystemAbstraction fileSystem, File file, boolean append ) throws IOException
public static OutputStream createOrOpenAsOutputStream( FileSystemAbstraction fileSystem, File file, boolean append ) throws IOException
{
if ( file.getParentFile() != null )
{
Expand Down
Expand Up @@ -39,7 +39,7 @@
import org.neo4j.logging.RotatingFileOutputStreamSupplier;
import org.neo4j.scheduler.JobScheduler;

import static org.neo4j.io.file.Files.createOrOpenAsOuputStream;
import static org.neo4j.io.file.Files.createOrOpenAsOutputStream;

public class StoreLogService extends AbstractLogService implements Lifecycle
{
Expand Down Expand Up @@ -170,7 +170,7 @@ private StoreLogService( LogProvider userLogProvider,
FormattedLogProvider internalLogProvider;
if ( internalLogRotationThreshold == 0 )
{
OutputStream outputStream = createOrOpenAsOuputStream( fileSystem, internalLog, true );
OutputStream outputStream = createOrOpenAsOutputStream( fileSystem, internalLog, true );
internalLogProvider = internalLogBuilder.toOutputStream( outputStream );
rotationListener.accept( internalLogProvider );
this.closeable = outputStream;
Expand Down
Expand Up @@ -37,7 +37,7 @@
import org.neo4j.io.NullOutputStream;
import org.neo4j.io.fs.FileSystemAbstraction;

import static org.neo4j.io.file.Files.createOrOpenAsOuputStream;
import static org.neo4j.io.file.Files.createOrOpenAsOutputStream;

/**
* A {@link Supplier} of {@link OutputStream}s backed by on-disk files, which
Expand Down Expand Up @@ -335,7 +335,7 @@ void rotate()

private OutputStream openOutputFile() throws IOException
{
return createOrOpenAsOuputStream( fileSystem, outputFile, true );
return createOrOpenAsOutputStream( fileSystem, outputFile, true );
}

private void shiftArchivedOutputFiles() throws IOException
Expand Down
Expand Up @@ -57,7 +57,7 @@
import static org.neo4j.graphdb.factory.GraphDatabaseSettings.data_directory;
import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_memory;
import static org.neo4j.helpers.collection.Iterables.append;
import static org.neo4j.io.file.Files.createOrOpenAsOuputStream;
import static org.neo4j.io.file.Files.createOrOpenAsOutputStream;

public abstract class AbstractInProcessServerBuilder implements TestServerBuilder
{
Expand Down Expand Up @@ -130,7 +130,7 @@ public ServerControls newServer()
final OutputStream logOutputStream;
try
{
logOutputStream = createOrOpenAsOuputStream( fileSystem, new File( serverFolder, "neo4j.log" ), true );
logOutputStream = createOrOpenAsOutputStream( fileSystem, new File( serverFolder, "neo4j.log" ), true );
}
catch ( IOException e )
{
Expand Down
Expand Up @@ -75,7 +75,7 @@ public class PageCacheWarmer implements NeoStoreFileListing.StoreFileProvider
private final PageCache pageCache;
private final ExecutorService executor;
private final PageLoaderFactory pageLoaderFactory;
private volatile boolean stopped;
private boolean stopped;

PageCacheWarmer( FileSystemAbstraction fs, PageCache pageCache, JobScheduler scheduler )
{
Expand Down Expand Up @@ -114,15 +114,9 @@ public synchronized Resource addFilesTo( Collection<StoreFileMetadata> coll ) th
return Resource.EMPTY;
}

public void stop()
public synchronized void stop()
{
stopped = true;
synchronized ( this )
{
// This synchronised block means we'll wait for any reheat() or profile() to notice our raised stopped flag,
// before we return to the caller. This helps avoid races, e.g. if the page cache is closed while this page
// cache warmer is still holding on to some mapped pages.
}
executor.shutdown();
}

Expand All @@ -133,7 +127,7 @@ public void stop()
* reheating was stopped early via {@link #stop()}.
* @throws IOException if anything goes wrong while reading the profiled data back in.
*/
public synchronized OptionalLong reheat() throws IOException
synchronized OptionalLong reheat() throws IOException
{
long pagesLoaded = 0;
List<PagedFile> files = pageCache.listExistingMappings();
Expand Down
Expand Up @@ -36,7 +36,7 @@
import org.neo4j.logging.RotatingFileOutputStreamSupplier;
import org.neo4j.scheduler.JobScheduler;

import static org.neo4j.io.file.Files.createOrOpenAsOuputStream;
import static org.neo4j.io.file.Files.createOrOpenAsOutputStream;
import static org.neo4j.kernel.impl.query.QueryLogger.NO_LOG;

class DynamicLoggingQueryExecutionMonitor extends LifecycleAdapter implements QueryExecutionMonitor
Expand Down Expand Up @@ -191,7 +191,7 @@ private void buildRotatingLog( long rotationThreshold, int maxArchives ) throws

private void buildNonRotatingLog() throws IOException
{
OutputStream logOutputStream = createOrOpenAsOuputStream( fileSystem, currentQueryLogFile, true );
OutputStream logOutputStream = createOrOpenAsOutputStream( fileSystem, currentQueryLogFile, true );
log = logBuilder.toOutputStream( logOutputStream );
closable = logOutputStream;
}
Expand Down

0 comments on commit ddc6c08

Please sign in to comment.