Skip to content

Commit

Permalink
Replace Provider with Supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed Dec 10, 2015
1 parent fc0095f commit b974d84
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 71 deletions.
Expand Up @@ -28,7 +28,7 @@
* Abstracts a meeting point between two threads, where a reference can change hands. It is essentially
* a latch where a reference to a value can be set while a thread waits on it.
*/
public class ConcurrentTransfer<TYPE> implements Consumer<TYPE>, Provider<TYPE>, Supplier<TYPE>
public class ConcurrentTransfer<TYPE> implements Consumer<TYPE>, Supplier<TYPE>
{
private final CountDownLatch latch = new CountDownLatch( 1 );
private TYPE value;
Expand All @@ -40,16 +40,6 @@ public void accept( TYPE value )
latch.countDown();
}

/**
* @deprecated use {@link #get()} instead
*/
@Deprecated
@Override
public TYPE instance()
{
return get();
}

@Override
public TYPE get()
{
Expand Down
34 changes: 0 additions & 34 deletions community/kernel/src/main/java/org/neo4j/helpers/Provider.java

This file was deleted.

Expand Up @@ -22,11 +22,11 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.function.Supplier;

import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.helpers.Args;
import org.neo4j.helpers.ArrayUtil;
import org.neo4j.helpers.Provider;
import org.neo4j.helpers.progress.ProgressListener;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache;
Expand Down Expand Up @@ -57,9 +57,9 @@
public class ApplyTransactionsCommand extends ArgsCommand
{
private final File from;
private final Provider<GraphDatabaseAPI> to;
private final Supplier<GraphDatabaseAPI> to;

public ApplyTransactionsCommand( File from, Provider<GraphDatabaseAPI> to )
public ApplyTransactionsCommand( File from, Supplier<GraphDatabaseAPI> to )
{
this.from = from;
this.to = to;
Expand All @@ -68,7 +68,7 @@ public ApplyTransactionsCommand( File from, Provider<GraphDatabaseAPI> to )
@Override
protected void run( Args args, PrintStream out ) throws Exception
{
TransactionIdStore txIdStore = to.instance().getDependencyResolver().resolveDependency(
TransactionIdStore txIdStore = to.get().getDependencyResolver().resolveDependency(
TransactionIdStore.class );
long fromTx = txIdStore.getLastCommittedTransaction().transactionId();
long toTx;
Expand All @@ -91,7 +91,7 @@ else if ( whereTo.equals( "last" ) )
toTx = Long.parseLong( whereTo );
}

long lastApplied = applyTransactions( from, to.instance(), fromTx, toTx, out );
long lastApplied = applyTransactions( from, to.get(), fromTx, toTx, out );
out.println( "Applied transactions up to and including " + lastApplied );
}

Expand Down
Expand Up @@ -25,13 +25,13 @@
import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

import org.neo4j.consistency.ConsistencyCheckService;
import org.neo4j.consistency.ConsistencyCheckService.Result;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.Args;
import org.neo4j.helpers.Provider;
import org.neo4j.helpers.progress.ProgressMonitorFactory;
import org.neo4j.io.fs.FileUtils;
import org.neo4j.kernel.GraphDatabaseAPI;
Expand Down Expand Up @@ -188,22 +188,8 @@ private ConsoleInput console( final File fromPath, final GraphDatabaseBuilder db
// should be restored. The commands has references to providers of things to accommodate for this.
final AtomicReference<Store> store =
new AtomicReference<>( new Store( dbBuilder ) );
final Provider<StoreAccess> storeAccess = new Provider<StoreAccess>()
{
@Override
public StoreAccess instance()
{
return store.get().access;
}
};
final Provider<GraphDatabaseAPI> dbAccess = new Provider<GraphDatabaseAPI>()
{
@Override
public GraphDatabaseAPI instance()
{
return store.get().db;
}
};
final Supplier<StoreAccess> storeAccess = () -> store.get().access;
final Supplier<GraphDatabaseAPI> dbAccess = () -> store.get().db;

ConsoleInput consoleInput = life.add( new ConsoleInput( in, out, prompt ) );
consoleInput.add( "apply", new ApplyTransactionsCommand( fromPath, dbAccess ) );
Expand Down
Expand Up @@ -24,8 +24,8 @@
import io.airlift.airline.Cli.CliBuilder;

import java.io.PrintStream;
import java.util.function.Supplier;

import org.neo4j.helpers.Provider;
import org.neo4j.kernel.impl.core.Token;
import org.neo4j.kernel.impl.store.LabelTokenStore;
import org.neo4j.kernel.impl.store.PropertyKeyTokenStore;
Expand Down Expand Up @@ -54,10 +54,10 @@ private interface Action
}

private final Cli<Action> cli;
private final Provider<StoreAccess> store;
private final Supplier<StoreAccess> store;

@SuppressWarnings( "unchecked" )
public DumpRecordsCommand( Provider<StoreAccess> store )
public DumpRecordsCommand( Supplier<StoreAccess> store )
{
this.store = store;
CliBuilder<Action> builder = Cli.<Action>builder( NAME )
Expand All @@ -79,7 +79,7 @@ public DumpRecordsCommand( Provider<StoreAccess> store )
@Override
public void run( String[] args, PrintStream out ) throws Exception
{
cli.parse( args ).run( store.instance(), out );
cli.parse( args ).run( store.get(), out );
}

@Override
Expand Down

0 comments on commit b974d84

Please sign in to comment.