Skip to content

Commit

Permalink
[core-edge] Do not delete store on startup.
Browse files Browse the repository at this point in the history
Previously we deleted and rebuilt the whole store from the raft log
on every startup. This commit adds raft index into the transaction
log, so that we can safely recover and deduce exactly which committed
transactions from the raft log need to be appended to the transaction
log.
  • Loading branch information
martinfurmanski authored and apcj committed Dec 8, 2015
1 parent ef4ff5c commit dc1dffe
Show file tree
Hide file tree
Showing 45 changed files with 700 additions and 723 deletions.
Expand Up @@ -130,6 +130,7 @@ public String toString( TimeZone timeZone )
"time=" + timestamp( timeWritten, timeZone ) + "," +
"lastCommittedTxWhenTransactionStarted=" + lastCommittedTxWhenTransactionStarted + "," +
"additionalHeaderLength=" + (additionalHeader == null ? -1 : additionalHeader.length) + "," +
(additionalHeader == null ? "" : Arrays.toString( additionalHeader ) ) + "," +
"position=" + startPosition + "," +
"checksum=" + checksum( this ) +
"]";
Expand Down
Expand Up @@ -95,7 +95,6 @@ public enum Timeouts implements RenewableTimeoutService.TimeoutName
private Role currentRole = Role.FOLLOWER;

private RaftLogShippingManager<MEMBER> logShipping;
private Set<Listener<LeadershipChange<MEMBER>>> leadershipChangeListeners = new HashSet<>();

public RaftInstance( MEMBER myself, TermStore termStore, VoteStore<MEMBER> voteStore, RaftLog entryLog,
long electionTimeout, long heartbeatInterval, RenewableTimeoutService renewableTimeoutService,
Expand Down Expand Up @@ -200,23 +199,6 @@ public ReadableRaftState<MEMBER> state()
return state;
}

/**
* These listeners will be notified from within the raft, so they should be short, efficient and
* not have dependencies on raft. Any substantial work must be scheduled on a some other thread.
*/
public void registerLeadershipChangeListener( Listener<LeadershipChange<MEMBER>> listener )
{
leadershipChangeListeners.add( listener );
}

private void notifyListenersOnLeadershipChange( MEMBER newLeader )
{
for ( Listener<LeadershipChange<MEMBER>> listener : leadershipChangeListeners )
{
listener.receive( new LeadershipChange<>( newLeader ) );
}
}

protected void handleOutcome( Outcome<MEMBER> outcome ) throws RaftStorageException
{
// Save interesting pre-state
Expand All @@ -241,12 +223,6 @@ else if ( oldLeader != null && oldLeader.equals( myself ) && !outcome.getLeader(

// Update state
state.update( outcome );

// Act after updating state
if ( oldLeader != state.leader() )
{
notifyListenersOnLeadershipChange( state.leader() );
}
}

public synchronized void handle( Serializable incomingMessage )
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit dc1dffe

Please sign in to comment.