Skip to content

Commit

Permalink
core-edge: Automatic bootstrapping
Browse files Browse the repository at this point in the history
Previously there was some special tooling required to bootstrap a cluster
from a seed, but now we no longer require any of it. The long term intention
is to just be able to put a store seed, e.g. from a backup or stand-alone
import, into the initial member of a cluster (or all) and have it working.
  • Loading branch information
martinfurmanski authored and apcj committed Sep 17, 2016
1 parent ef770c8 commit 615656d
Show file tree
Hide file tree
Showing 50 changed files with 903 additions and 1,440 deletions.
Expand Up @@ -26,7 +26,7 @@
* @param <T> the type of the input to the operation * @param <T> the type of the input to the operation
* @param <E> the type of exception that may be thrown from the function * @param <E> the type of exception that may be thrown from the function
*/ */
public interface ThrowingConsumer<T, E extends Exception> public interface ThrowingConsumer<T, E extends Throwable>
{ {
/** /**
* Performs this operation on the given argument. * Performs this operation on the given argument.
Expand Down
Expand Up @@ -49,6 +49,7 @@


import static java.lang.String.format; import static java.lang.String.format;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;

import static org.neo4j.io.pagecache.PagedFile.PF_SHARED_READ_LOCK; import static org.neo4j.io.pagecache.PagedFile.PF_SHARED_READ_LOCK;
import static org.neo4j.io.pagecache.PagedFile.PF_SHARED_WRITE_LOCK; import static org.neo4j.io.pagecache.PagedFile.PF_SHARED_WRITE_LOCK;
import static org.neo4j.kernel.impl.store.format.standard.MetaDataRecordFormat.FIELD_NOT_PRESENT; import static org.neo4j.kernel.impl.store.format.standard.MetaDataRecordFormat.FIELD_NOT_PRESENT;
Expand Down Expand Up @@ -316,6 +317,17 @@ public StoreId getStoreId()
return new StoreId( getCreationTime(), getRandomNumber(), getStoreVersion(), getUpgradeTime(), upgradeTxIdField ); return new StoreId( getCreationTime(), getRandomNumber(), getStoreVersion(), getUpgradeTime(), upgradeTxIdField );
} }


public static StoreId getStoreId( PageCache pageCache, File neoStore ) throws IOException
{
return new StoreId(
getRecord( pageCache, neoStore, Position.TIME ),
getRecord( pageCache, neoStore, Position.RANDOM_NUMBER ),
getRecord( pageCache, neoStore, Position.STORE_VERSION ),
getRecord( pageCache, neoStore, Position.UPGRADE_TIME ),
getRecord( pageCache, neoStore, Position.UPGRADE_TRANSACTION_ID )
);
}

public long getUpgradeTime() public long getUpgradeTime()
{ {
assertNotClosed(); assertNotClosed();
Expand Down
Expand Up @@ -45,7 +45,6 @@


public class ReplicationModule public class ReplicationModule
{ {
public static final String LAST_FLUSHED_NAME = "last-flushed";
public static final String SESSION_TRACKER_NAME = "session-tracker"; public static final String SESSION_TRACKER_NAME = "session-tracker";


private final RaftReplicator replicator; private final RaftReplicator replicator;
Expand Down
Expand Up @@ -21,17 +21,15 @@


import java.io.IOException; import java.io.IOException;


import org.neo4j.coreedge.core.state.snapshot.CoreStateType;
import org.neo4j.coreedge.core.replication.session.GlobalSession; import org.neo4j.coreedge.core.replication.session.GlobalSession;
import org.neo4j.coreedge.core.replication.session.GlobalSessionTrackerState; import org.neo4j.coreedge.core.replication.session.GlobalSessionTrackerState;
import org.neo4j.coreedge.core.replication.session.LocalOperationId; import org.neo4j.coreedge.core.replication.session.LocalOperationId;
import org.neo4j.coreedge.core.state.snapshot.CoreSnapshot;
import org.neo4j.coreedge.core.state.storage.StateStorage; import org.neo4j.coreedge.core.state.storage.StateStorage;


public class SessionTracker public class SessionTracker
{ {
private final StateStorage<GlobalSessionTrackerState> sessionTrackerStorage; private final StateStorage<GlobalSessionTrackerState> sessionTrackerStorage;
private GlobalSessionTrackerState sessionState = new GlobalSessionTrackerState(); private GlobalSessionTrackerState sessionState = null;


public SessionTracker( StateStorage<GlobalSessionTrackerState> sessionTrackerStorage ) public SessionTracker( StateStorage<GlobalSessionTrackerState> sessionTrackerStorage )
{ {
Expand All @@ -40,7 +38,10 @@ public SessionTracker( StateStorage<GlobalSessionTrackerState> sessionTrackerSto


public void start() public void start()
{ {
sessionState = sessionTrackerStorage.getInitialState(); if ( sessionState == null )
{
sessionState = sessionTrackerStorage.getInitialState();
}
} }


public long getLastAppliedIndex() public long getLastAppliedIndex()
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 615656d

Please sign in to comment.