-
Notifications
You must be signed in to change notification settings - Fork 29
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
1 parent
37977ff
commit 0b69989
Showing
4 changed files
with
36 additions
and
2 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
27 changes: 27 additions & 0 deletions
27
Modules/Examples/Protocol Benchmarks/src/main/scala/probench/clients/EtcdClient.scala
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,27 @@ | ||
package probench.clients | ||
|
||
import io.etcd.jetcd | ||
import io.etcd.jetcd.ByteSequence | ||
import probench.data | ||
import probench.data.KVOperation | ||
import rdts.base.Uid | ||
|
||
class EtcdClient(val name: Uid, val endpoints: List[String]) extends Client(name) { | ||
|
||
private val etcdClient = jetcd.Client.builder().endpoints(endpoints*).build() | ||
private val kvClient = etcdClient.getKVClient | ||
|
||
override def handleOpImpl(op: KVOperation[String, String]): Unit = { | ||
op match | ||
case data.KVOperation.Read(opKey) => | ||
val key = ByteSequence.from(opKey.getBytes) | ||
val res = kvClient.get(key).get().getKvs.get(0) | ||
println(s"${res.getKey}=${res.getValue}") | ||
case data.KVOperation.Write(opKey, opValue) => | ||
val key = ByteSequence.from(opKey.getBytes) | ||
val value = ByteSequence.from(opValue.getBytes) | ||
kvClient.put(key, value).get() | ||
println(s"$opKey=$opValue; OK") | ||
} | ||
|
||
} |
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