Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidating the Core and Replica topology differences into one happ…
…y shared difference
- Loading branch information
Mark Needham
committed
Mar 15, 2017
1 parent
893f2f4
commit bec8770
Showing
7 changed files
with
125 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...rise/causal-clustering/src/main/java/org/neo4j/causalclustering/discovery/Difference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
/* | |||
* Copyright (c) 2002-2017 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Affero General Public License as | |||
* published by the Free Software Foundation, either version 3 of the | |||
* License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Affero General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.causalclustering.discovery; | |||
|
|||
import org.neo4j.causalclustering.identity.MemberId; | |||
|
|||
class Difference | |||
{ | |||
private MemberId memberId; | |||
private CatchupServerAddress server; | |||
|
|||
private Difference( MemberId memberId, CatchupServerAddress server ) | |||
{ | |||
this.memberId = memberId; | |||
this.server = server; | |||
} | |||
|
|||
static Difference asDifference( CoreTopology topology, MemberId memberId ) | |||
{ | |||
return new Difference( memberId, topology.find( memberId ).orElse( null ) ); | |||
} | |||
|
|||
static Difference asDifference( ReadReplicaTopology topology, MemberId memberId ) | |||
{ | |||
return new Difference( memberId, topology.find( memberId ).orElse( null ) ); | |||
} | |||
|
|||
@Override | |||
public String toString() | |||
{ | |||
return String.format( "{memberId=%s, info=%s}", memberId, server ); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...sal-clustering/src/main/java/org/neo4j/causalclustering/discovery/TopologyDifference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
/* | |||
* Copyright (c) 2002-2017 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Affero General Public License as | |||
* published by the Free Software Foundation, either version 3 of the | |||
* License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Affero General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.causalclustering.discovery; | |||
|
|||
import java.util.Set; | |||
|
|||
class TopologyDifference | |||
{ | |||
private Set<Difference> added; | |||
private Set<Difference> removed; | |||
|
|||
TopologyDifference( Set<Difference> added, Set<Difference> removed ) | |||
{ | |||
this.added = added; | |||
this.removed = removed; | |||
} | |||
|
|||
Set<Difference> added() | |||
{ | |||
return added; | |||
} | |||
|
|||
Set<Difference> removed() | |||
{ | |||
return removed; | |||
} | |||
|
|||
boolean hasChanges() | |||
{ | |||
return added.size() > 0 || removed.size() > 0; | |||
} | |||
|
|||
@Override | |||
public String toString() | |||
{ | |||
return String.format( "{added=%s, removed=%s}", added, removed ); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters