Skip to content

Commit

Permalink
Merge pull request #148 from acompany-develop/feature/takahashi/delet…
Browse files Browse the repository at this point in the history
…e_init_triple

Delete initTripleStore function
  • Loading branch information
KotaTakahashi9320 authored Mar 27, 2023
2 parents a7f3e2d + b2d2e18 commit e1627d1
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 171 deletions.
20 changes: 0 additions & 20 deletions packages/server/beaver_triple_service/server/engine_to_bts/e2b.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,6 @@ func (s *server) GetTriples(ctx context.Context, in *pb.GetTriplesRequest) (*pb.
}, nil
}

func (s *server) InitTripleStore(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error) {
claims, ok := ctx.Value("claims").(*jwt_types.Claim)
if !ok {
return nil, status.Error(codes.Internal, "failed claims type assertions")
}

partyId, err := GetPartyIdFromClaims(claims)
if err != nil {
return nil, err
}
logger.Infof("partyId: %d \n", partyId)

err = tg.InitTripleStore()
if err != nil {
return nil, err
}

return &emptypb.Empty{}, err
}

func (s *server) DeleteJobIdTriple(ctx context.Context, in *pb.DeleteJobIdTripleRequest) (*emptypb.Empty, error) {
claims, ok := ctx.Value("claims").(*jwt_types.Claim)
if !ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
ts "github.com/acompany-develop/QuickMPC/packages/server/beaver_triple_service/triple_store"
utils "github.com/acompany-develop/QuickMPC/packages/server/beaver_triple_service/utils"
pb "github.com/acompany-develop/QuickMPC/proto/engine_to_bts"
emptypb "google.golang.org/protobuf/types/known/emptypb"

"google.golang.org/grpc/metadata"
)
Expand Down Expand Up @@ -180,22 +179,6 @@ func TestGetTriplesFailedUnknownType(t *testing.T) {
}
}

func TestInitTripleStore(t * testing.T) {
conn := s.GetConn()
defer conn.Close()
client := pb.NewEngineToBtsClient(conn)

ctx, err := getContext()
if err != nil {
t.Fatal(err)
}

_,err = client.InitTripleStore(ctx, &emptypb.Empty{})
if err != nil {
t.Fatal(err)
}
}

func TestDeleteJobIdTriple(t * testing.T) {
conn := s.GetConn()
defer conn.Close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ func GetTriples(claims *jwt_types.Claim, jobId uint32, partyId uint32, amount ui
return triples, nil
}

func InitTripleStore() error {
// Dbを初期化
Db.Triples = map[uint32](map[uint32]([]*pb.Triple)){}
return nil
}

func DeleteJobIdTriple(jobId uint32) error {
// jobIdに紐付いたTripleを削除
delete(Db.Triples, jobId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,29 +167,6 @@ func TestTripleGenerator_Float_1000000_1(t *testing.T) {
testTripleGenerator(t, 1000000, 1, pb.Type_TYPE_FLOAT)
}

func TestInitTripleStore(t *testing.T) {
claims, err := getClaims()
if err != nil {
t.Fatal(err)
}

jobId := uint32(1)
partyId := uint32(1)
amount := uint32(10)
triple_type := pb.Type_TYPE_FLOAT
_, err = tg.GetTriples(claims, jobId, partyId, amount, triple_type)
if err != nil {
t.Fatal(err)
}

err = tg.InitTripleStore()
if err != nil {
t.Fatal(err)
}

testDbIsEmpty(t)
}

func TestDeleteJobIdTriple(t *testing.T) {
claims, err := getClaims()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@ class Client
return triples;
}

void initTripleStore()
{
grpc::Status status;
google::protobuf::Empty request, response;

// リトライポリシーに従ってリクエストを送る
auto retry_manager = RetryManager("BTS", "initTripleStore");
do
{
grpc::ClientContext context;
const std::string token = Config::getInstance()->cc_to_bts_token;
context.AddMetadata("authorization", "bearer " + token);
status = stub_->InitTripleStore(&context, request, &response);
} while (retry_manager.retry(status));
}

void deleteJobIdTriple(const unsigned int job_id)
{
grpc::Status status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cc_library(
],
deps = [
"//config_parse:config_parse",
"//client/computation_to_bts:client",
"//server/computation_to_computation_container:server",
"//server/computation_to_computation_container_for_job:server",
"//server/manage_to_computation_container:server",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <string>
#include <thread>

#include "client/computation_to_bts/client.hpp"
#include "config_parse/config_parse.hpp"
#include "job/job_manager.hpp"
#include "logging/logger.hpp"
Expand All @@ -26,9 +25,6 @@ int main()

grpc::EnableDefaultHealthCheckService(true);

auto cc_to_bts = qmpc::ComputationToBts::Client::getInstance();
cc_to_bts->initTripleStore();

const std::string ctc_my_ip_str("0.0.0.0:" + ctoc_ip.port);
std::thread th1(qmpc::ComputationToComputation::Server::runServer, ctc_my_ip_str);
const std::string ctc_for_j_my_ip_str("0.0.0.0:" + ctoc_for_j_ip.port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,6 @@ void readTriplesTest(const unsigned int jobIdMax, const unsigned int amount)

TEST(ComputationToBtsTest, ReadTriplesTest10_10000) { readTriplesTest(10, 10000); }

TEST(ComputationToBtsTest, InitTripleStoreTest)
{
const unsigned int jobIdMax = 5;
const unsigned int amount = 1000;
Config *conf = Config::getInstance();
auto cc_to_bts = qmpc::ComputationToBts::Client::getInstance();

if (conf->party_id == 1)
{
for (unsigned int jobId = 1; jobId <= jobIdMax; jobId++)
{
auto triples = cc_to_bts->readTriples<FixedPoint>(jobId, amount);
}

// BTSの初期化
cc_to_bts->initTripleStore();
}

// partyで足並みを揃えるため
sync();

readTriplesTest(jobIdMax, amount);
}

TEST(ComputationToBtsTest, DeleteJobIdTripleTest)
{
const unsigned int jobIdMax = 5;
Expand Down
39 changes: 16 additions & 23 deletions proto/engine_to_bts/engine_to_bts.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion proto/engine_to_bts/engine_to_bts.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "google/protobuf/empty.proto";

service EngineToBts {
rpc GetTriples(GetTriplesRequest) returns (GetTriplesResponse) {}
rpc InitTripleStore(google.protobuf.Empty) returns (google.protobuf.Empty) {}
rpc DeleteJobIdTriple(DeleteJobIdTripleRequest) returns (google.protobuf.Empty) {}
}

Expand Down
36 changes: 0 additions & 36 deletions proto/engine_to_bts/engine_to_bts_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1627d1

Please sign in to comment.