Skip to content

Commit

Permalink
Read epoch time from parameters file
Browse files Browse the repository at this point in the history
  • Loading branch information
aminst committed Oct 27, 2023
1 parent 5c56288 commit b7ebdf5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion cmd/router/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ func main() {
log.Fatal().Msgf("Failed to create client connections with shard node servers; %v", err)
}

parameters, err := config.ReadParameters(path.Join(*configsPath, "parameters.yaml"))
if err != nil {
log.Fatal().Msgf("Failed to read parameters from yaml file; %v", err)
}

tracingProvider, err := tracing.NewProvider(context.Background(), "router", "localhost:4317")
if err != nil {
log.Fatal().Msgf("Failed to create tracing provider; %v", err)
Expand All @@ -45,5 +50,5 @@ func main() {
}
defer stopTracingProvider(context.Background())

router.StartRPCServer(*ip, rpcClients, *routerID, *port)
router.StartRPCServer(*ip, rpcClients, *routerID, *port, parameters)
}
3 changes: 2 additions & 1 deletion configs/parameters.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
max-blocks-to-send: 5 # The maximum number of blocks to send from each shard node to the oram node during evictions
eviction-rate: 40 # How many ReadPath operations before eviction
batch-size: 1 # Size of each batch of requests
batch-size: 2 # Size of each batch of requests
epoch-time: 10 # How many milliseconds between each epoch
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Parameters struct {
MaxBlocksToSend int `yaml:"max-blocks-to-send"`
EvictionRate int `yaml:"eviction-rate"`
BatchSize int `yaml:"batch-size"`
EpochTime int `yaml:"epoch-time"`
}

func ReadRouterEndpoints(path string) ([]RouterEndpoint, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func startRouter() {
if err != nil {
log.Fatal().Msgf("Failed to create client connections with shard node servers; %v", err)
}
router.StartRPCServer("localhost", rpcClients, 0, 8745)
router.StartRPCServer("localhost", rpcClients, 0, 8745, config.Parameters{EpochTime: 10})
}

func startShardNode(replicaID int, rpcPort int, raftPort int, joinAddr string) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/router/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

pb "github.com/dsg-uwaterloo/oblishard/api/router"
"github.com/dsg-uwaterloo/oblishard/pkg/config"
"github.com/dsg-uwaterloo/oblishard/pkg/rpc"
"github.com/rs/zerolog/log"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -57,14 +58,14 @@ func (r *routerServer) Write(ctx context.Context, writeRequest *pb.WriteRequest)
return &pb.WriteReply{Success: writeResponse.success}, nil
}

func StartRPCServer(ip string, shardNodeRPCClients map[int]ReplicaRPCClientMap, routerID int, port int) {
func StartRPCServer(ip string, shardNodeRPCClients map[int]ReplicaRPCClientMap, routerID int, port int, parameters config.Parameters) {
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", ip, port))
if err != nil {
log.Fatal().Msgf("failed to listen: %v", err)
}
grpcServer := grpc.NewServer(grpc.UnaryInterceptor(rpc.ContextPropagationUnaryServerInterceptor()))

epochManager := newEpochManager(shardNodeRPCClients, 10*time.Millisecond)
epochManager := newEpochManager(shardNodeRPCClients, time.Duration(parameters.EpochTime)*time.Millisecond)
go epochManager.run()
routerServer := newRouterServer(routerID, epochManager)
pb.RegisterRouterServer(grpcServer, &routerServer)
Expand Down

0 comments on commit b7ebdf5

Please sign in to comment.