-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
283 additions
and
4 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
66 changes: 66 additions & 0 deletions
66
src/main/java/io/debezium/connector/vitess/connection/HeartbeatMessage.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
package io.debezium.connector.vitess.connection; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
|
||
public class HeartbeatMessage implements ReplicationMessage { | ||
|
||
private final Instant commitTime; | ||
private final Operation operation; | ||
|
||
public HeartbeatMessage(Instant commitTime) { | ||
this.commitTime = commitTime; | ||
this.operation = Operation.HEARTBEAT; | ||
} | ||
|
||
@Override | ||
public Operation getOperation() { | ||
return Operation.HEARTBEAT; | ||
} | ||
|
||
@Override | ||
public Instant getCommitTime() { | ||
return commitTime; | ||
} | ||
|
||
@Override | ||
public String getTransactionId() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public String getTable() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public String getShard() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public List<Column> getOldTupleList() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public List<Column> getNewTupleList() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HeartbeatMessage{" | ||
+ "commitTime=" | ||
+ commitTime | ||
+ ", operation=" | ||
+ operation | ||
+ '}'; | ||
} | ||
} |
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
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
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
70 changes: 70 additions & 0 deletions
70
src/test/java/io/debezium/connector/vitess/connection/HeartbeatMessageTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
package io.debezium.connector.vitess.connection; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
|
||
import java.time.Instant; | ||
|
||
import org.junit.Test; | ||
|
||
public class HeartbeatMessageTest { | ||
|
||
@Test | ||
public void getOperation() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThat(message.getOperation()).isEqualTo(ReplicationMessage.Operation.HEARTBEAT); | ||
} | ||
|
||
@Test | ||
public void getCommitTime() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThat(message.getCommitTime()).isEqualTo(Instant.EPOCH); | ||
} | ||
|
||
@Test | ||
public void getTransactionId() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThatThrownBy(() -> message.getTransactionId()) | ||
.isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
|
||
@Test | ||
public void getTable() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThatThrownBy(() -> message.getTable()) | ||
.isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
|
||
@Test | ||
public void getShard() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThatThrownBy(() -> message.getShard()) | ||
.isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
|
||
@Test | ||
public void getOldTupleList() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThatThrownBy(() -> message.getOldTupleList()) | ||
.isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
|
||
@Test | ||
public void getNewTupleList() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThatThrownBy(() -> message.getNewTupleList()) | ||
.isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
ReplicationMessage message = new HeartbeatMessage(Instant.EPOCH); | ||
assertThat(message.toString()).isEqualTo("HeartbeatMessage{commitTime=1970-01-01T00:00:00Z, operation=HEARTBEAT}"); | ||
} | ||
} |
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