Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/main/java/com/github/shyiko/mysql/binlog/GtidSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public UUIDSet getUUIDSet(String uuid) {
return map.get(uuid);
}

/**
* Add or replace the UUIDSet
* @param uuidSet UUIDSet to be added
* @return the old {@link UUIDSet} for the server given in uuidSet param,
* or {@code null} if there are no UUIDSet for the given server.
*/
public UUIDSet putUUIDSet(UUIDSet uuidSet) {
return map.put(uuidSet.getUUID(), uuidSet);
}

/**
* @param gtid GTID ("source_id:transaction_id")
* @return whether or not gtid was added to the set (false if it was already there)
Expand Down Expand Up @@ -170,7 +180,7 @@ public static final class UUIDSet {
private String uuid;
private List<Interval> intervals;

UUIDSet(String uuid, List<Interval> intervals) {
public UUIDSet(String uuid, List<Interval> intervals) {
this.uuid = uuid;
this.intervals = intervals;
if (intervals.size() > 1) {
Expand Down Expand Up @@ -339,7 +349,7 @@ public static final class Interval implements Comparable<Interval> {
private long start;
private long end;

Interval(long start, long end) {
public Interval(long start, long end) {
this.start = start;
this.end = end;
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/github/shyiko/mysql/binlog/GtidSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,14 @@ public void testMultipleIntervalsThatMayBeAdjacent() {
assertEquals(gtidSet.toString(), UUID + ":1-199:1000-1033:1035-1036:1038-1039");
}

@Test
public void testPutUUIDSet() {
GtidSet gtidSet = new GtidSet(UUID + ":1-191");
UUIDSet uuidSet = gtidSet.getUUIDSet(UUID);
GtidSet gtidSet2 = new GtidSet(UUID + ":1-190");
UUIDSet uuidSet2 = gtidSet2.getUUIDSet(UUID);
gtidSet.putUUIDSet(uuidSet2);
assertEquals(gtidSet, gtidSet2);
}

}