-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from betarixm/develop
Iteration 04
- Loading branch information
Showing
18 changed files
with
692 additions
and
55 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package kr.ac.postech.paranode.core | ||
|
||
case class KeyRange(from: Key, to: Key) { | ||
def includes(key: Key): Boolean = (from <= key) && (key <= to) | ||
|
||
def includes(record: Record): Boolean = includes(record.key) | ||
} |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package kr.ac.postech.paranode | ||
|
||
package object core { | ||
type KeyRange = (Key, Key) | ||
type Partition = (WorkerMetadata, Block) | ||
type Partition = (KeyRange, Block) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Progress Report | ||
|
||
> 11/10/2023 - 11/16/2023 | ||
## Completed Tasks | ||
|
||
- Make `Partition` into tuple of `KeyRange` and `Block` (#46) | ||
- Refactor `block.partition` with `groupBy` (#47) | ||
- Define `KeyRange` class (#48) | ||
- Test `gensort` on linux and macOS (#49) | ||
- Implement `Blocks` (#50) | ||
- Setup ScalaPB (#51) | ||
- Write gRPC `proto` (#52) | ||
- Implement Exchange RPC Service (#54) | ||
- Implement Master RPC Service (#55) | ||
|
||
## Assigned Tasks | ||
|
||
- Merge proto related branches and implement (#62) | ||
- @betarixm | ||
- Implement Worker Server (#63) | ||
- @hataehyeok | ||
- Implement Exchange Server (#64) | ||
- @leejiwon1125 | ||
- Implement Master Server (#65) | ||
- @leejiwon1125 | ||
- CLI and Initialize (#66) | ||
- @leejiwon1125 |
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,3 @@ | ||
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6") | ||
|
||
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.11" |
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,16 @@ | ||
syntax = "proto3"; | ||
|
||
package kr.ac.postech.paranode.rpc; | ||
|
||
service Exchange { | ||
|
||
rpc SaveRecords (GetMyRecordsRequest) returns (GetMyRecordsReply) {} | ||
} | ||
|
||
message GetMyRecordsRequest { | ||
repeated string records = 1; | ||
} | ||
|
||
message GetMyRecordsReply { | ||
bool isNice = 1; | ||
} |
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,19 @@ | ||
syntax = "proto3"; | ||
|
||
package kr.ac.postech.paranode.rpc; | ||
|
||
// The greeting service definition. | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
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,18 @@ | ||
syntax = "proto3"; | ||
|
||
package kr.ac.postech.paranode.rpc; | ||
|
||
service Master { | ||
|
||
rpc RegisterWorkerDirectory (RegisterRequest) returns (RegisterReply) {} | ||
} | ||
|
||
message RegisterRequest { | ||
string ipAddress = 1; | ||
repeated string inputDirectory = 2; | ||
string outputDirectory = 3; | ||
} | ||
|
||
message RegisterReply { | ||
bool isRegistered = 1; | ||
} |
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,47 @@ | ||
syntax = "proto3"; | ||
|
||
package kr.ac.postech.paranode.rpc; | ||
|
||
service Worker { | ||
|
||
rpc SampleKeys (SampleRequest) returns (SampleReply) {} | ||
rpc MakePartitions (PartitionRequest) returns (PartitionReply) {} | ||
rpc ExchangeWithOtherWorker (ExchangeRequest) returns (ExchangeReply) {} | ||
rpc Merge (MergeRequest) returns (MergeReply) {} | ||
} | ||
|
||
message SampleRequest { | ||
int32 numberOfKeys = 1; | ||
} | ||
|
||
message SampleReply { | ||
repeated string sampledKeys = 1; | ||
bool isNice = 2; | ||
} | ||
|
||
message PartitionRequest { | ||
|
||
message WorkerPartition { | ||
string workerIpAddress = 1; | ||
string startKey = 2; | ||
string endKey = 3; | ||
} | ||
repeated WorkerPartition partitions = 1; | ||
|
||
} | ||
|
||
message PartitionReply { | ||
bool isNice = 1; | ||
} | ||
|
||
message ExchangeRequest { } | ||
|
||
message ExchangeReply { | ||
bool isNice = 1; | ||
} | ||
|
||
message MergeRequest { } | ||
|
||
message MergeReply { | ||
bool isNice = 1; | ||
} |
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,56 @@ | ||
package kr.ac.postech.paranode.rpc | ||
|
||
import io.grpc.ManagedChannel | ||
import io.grpc.ManagedChannelBuilder | ||
import kr.ac.postech.paranode.rpc.exchange.ExchangeGrpc | ||
import kr.ac.postech.paranode.rpc.exchange.ExchangeGrpc.ExchangeBlockingStub | ||
import kr.ac.postech.paranode.rpc.exchange.GetMyRecordsReply | ||
import kr.ac.postech.paranode.rpc.exchange.GetMyRecordsRequest | ||
|
||
import java.util.concurrent.TimeUnit | ||
import java.util.logging.Logger | ||
|
||
object ExchangeClient { | ||
def apply(host: String, port: Int): ExchangeClient = { | ||
val channel = ManagedChannelBuilder | ||
.forAddress(host, port) | ||
.usePlaintext() | ||
.build | ||
val blockingStub = ExchangeGrpc.blockingStub(channel) | ||
new ExchangeClient(channel, blockingStub) | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
val client = ExchangeClient("localhost", 30050) | ||
try { | ||
val response = client.SaveRecords() | ||
|
||
println("My records is: " + response.isNice) | ||
} finally { | ||
client.shutdown() | ||
} | ||
} | ||
} | ||
|
||
class ExchangeClient private ( | ||
private val channel: ManagedChannel, | ||
private val blockingStub: ExchangeBlockingStub | ||
) { | ||
private[this] val logger = Logger.getLogger(classOf[WorkerClient].getName) | ||
|
||
def shutdown(): Unit = { | ||
channel.shutdown.awaitTermination(5, TimeUnit.SECONDS) | ||
} | ||
|
||
def SaveRecords(): GetMyRecordsReply = { | ||
logger.info( | ||
"Try to save my records" | ||
) | ||
|
||
val request = GetMyRecordsRequest() | ||
val response = blockingStub.saveRecords(request) | ||
logger.info("My records is: " + response.isNice) | ||
|
||
response | ||
} | ||
} |
Oops, something went wrong.