Search in sources :

Example 21 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class CatchupPollingProcess method copyStore.

private void copyStore() {
    MemberId upstream;
    try {
        upstream = selectionStrategyPipeline.bestUpstreamDatabase();
    } catch (UpstreamDatabaseSelectionException e) {
        log.warn("Could not find upstream database from which to copy store", e);
        return;
    }
    StoreId localStoreId = localDatabase.storeId();
    downloadDatabase(upstream, localStoreId);
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) StoreId(org.neo4j.causalclustering.identity.StoreId) UpstreamDatabaseSelectionException(org.neo4j.causalclustering.readreplica.UpstreamDatabaseSelectionException)

Example 22 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class RaftMembershipManager method append.

@Override
public void append(long baseIndex, RaftLogEntry... entries) throws IOException {
    for (RaftLogEntry entry : entries) {
        if (entry.content() instanceof RaftGroup) {
            RaftGroup<MemberId> raftGroup = (RaftGroup<MemberId>) entry.content();
            if (state.uncommittedMemberChangeInLog()) {
                log.warn("Appending with uncommitted membership change in log");
            }
            if (state.append(baseIndex, new HashSet<>(raftGroup.getMembers()))) {
                log.info("Appending new member set %s", state);
                storage.persistStoreData(state);
                updateMemberSets();
            } else {
                log.warn("Appending member set was ignored. Current state: %s, Appended set: %s, Log index: %d%n", state, raftGroup, baseIndex);
            }
        }
        baseIndex++;
    }
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)

Example 23 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class Leader method sendHeartbeats.

static void sendHeartbeats(ReadableRaftState ctx, Outcome outcome) throws IOException {
    long commitIndex = ctx.commitIndex();
    long commitIndexTerm = ctx.entryLog().readEntryTerm(commitIndex);
    Heartbeat heartbeat = new Heartbeat(ctx.myself(), ctx.term(), commitIndex, commitIndexTerm);
    for (MemberId to : replicationTargets(ctx)) {
        outcome.addOutgoingMessage(new RaftMessages.Directed(to, heartbeat));
    }
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) Heartbeat(org.neo4j.causalclustering.core.consensus.RaftMessages.Heartbeat) RaftMessages(org.neo4j.causalclustering.core.consensus.RaftMessages)

Example 24 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class RaftLogShippingManager method onMembershipChanged.

@Override
public synchronized void onMembershipChanged() {
    if (lastLeaderContext == null || !running) {
        return;
    }
    HashSet<MemberId> toBeRemoved = new HashSet<>(logShippers.keySet());
    toBeRemoved.removeAll(membership.replicationMembers());
    for (MemberId member : toBeRemoved) {
        RaftLogShipper logShipper = logShippers.remove(member);
        if (logShipper != null) {
            logShipper.stop();
        }
    }
    for (MemberId replicationMember : membership.replicationMembers()) {
        ensureLogShipperRunning(replicationMember, lastLeaderContext);
    }
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) HashSet(java.util.HashSet)

Example 25 with MemberId

use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.

the class DistributedOperation method deserialize.

public static DistributedOperation deserialize(ReadableChannel channel) throws IOException, EndOfStreamException {
    long mostSigBits = channel.getLong();
    long leastSigBits = channel.getLong();
    MemberId owner = new MemberId.Marshal().unmarshal(channel);
    GlobalSession globalSession = new GlobalSession(new UUID(mostSigBits, leastSigBits), owner);
    long localSessionId = channel.getLong();
    long sequenceNumber = channel.getLong();
    LocalOperationId localOperationId = new LocalOperationId(localSessionId, sequenceNumber);
    ReplicatedContent content = new CoreReplicatedContentMarshal().unmarshal(channel);
    return new DistributedOperation(content, globalSession, localOperationId);
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) GlobalSession(org.neo4j.causalclustering.core.replication.session.GlobalSession) LocalOperationId(org.neo4j.causalclustering.core.replication.session.LocalOperationId) UUID(java.util.UUID)

Aggregations

MemberId (org.neo4j.causalclustering.identity.MemberId)114 Test (org.junit.Test)83 HashMap (java.util.HashMap)26 CoreTopology (org.neo4j.causalclustering.discovery.CoreTopology)16 CoreServerInfo (org.neo4j.causalclustering.discovery.CoreServerInfo)15 LeaderLocator (org.neo4j.causalclustering.core.consensus.LeaderLocator)13 ReadReplicaTopology (org.neo4j.causalclustering.discovery.ReadReplicaTopology)12 DirectNetworking (org.neo4j.causalclustering.core.consensus.DirectNetworking)10 RaftTestFixture (org.neo4j.causalclustering.core.consensus.RaftTestFixture)10 CoreTopologyService (org.neo4j.causalclustering.discovery.CoreTopologyService)10 Log (org.neo4j.logging.Log)10 ClusterId (org.neo4j.causalclustering.identity.ClusterId)9 ArrayList (java.util.ArrayList)8 UUID (java.util.UUID)8 RaftMessages (org.neo4j.causalclustering.core.consensus.RaftMessages)8 TopologyService (org.neo4j.causalclustering.discovery.TopologyService)7 ByteBuf (io.netty.buffer.ByteBuf)6 File (java.io.File)6 RaftLogEntry (org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)6 HashSet (java.util.HashSet)5