From a21bbcca0ee703fb331dffdb7a9dae1716ee0a89 Mon Sep 17 00:00:00 2001 From: hoernschen Date: Fri, 27 Nov 2020 05:46:17 +0100 Subject: [PATCH] Masterthesis --- 1602787120 Baseline Measurement.csv | 11 - config/config.go | 2 - config/configController.go | 7 - entities/collection/collectionController.go | 46 ++-- main.go | 24 --- sqlite.db | Bin 53248 -> 53248 bytes utils/database/databaseConnector.go | 1 - utils/encryptionService.go | 34 --- workloadGenerator.go | 226 +++++++++++--------- 9 files changed, 140 insertions(+), 211 deletions(-) delete mode 100644 1602787120 Baseline Measurement.csv diff --git a/1602787120 Baseline Measurement.csv b/1602787120 Baseline Measurement.csv deleted file mode 100644 index 3e61a7b..0000000 --- a/1602787120 Baseline Measurement.csv +++ /dev/null @@ -1,11 +0,0 @@ -Iteration,Start,End -1,1602787120,1602787240 -2,1602787240,1602787360 -3,1602787360,1602787480 -4,1602787480,1602787600 -5,1602787600,1602787720 -6,1602787720,1602787840 -7,1602787840,1602787961 -8,1602787961,1602788081 -9,1602788081,1602788201 -10,1602788201,1602788321 diff --git a/config/config.go b/config/config.go index 313e8aa..efb23c2 100644 --- a/config/config.go +++ b/config/config.go @@ -23,8 +23,6 @@ var Signing bool var Encryption bool var HttpString string -//var BackoffPolicy *backoff.Exponential - func SetDefaultParams() { Packetloss = 0.0 UnavailableTill = time.Now().Unix() diff --git a/config/configController.go b/config/configController.go index 74029ce..c898b11 100644 --- a/config/configController.go +++ b/config/configController.go @@ -49,13 +49,6 @@ func SetParams(w http.ResponseWriter, r *http.Request) { func Reset(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") - /* - if err := device.InitServerSigningKey(); err != nil { - log.Fatal(err) - } - config.VerifyKeys = make(map[string]map[string][]byte) - */ - database.DB.Close() os.Remove("sqlite.db") diff --git a/entities/collection/collectionController.go b/entities/collection/collectionController.go index 1d4c8ce..744364f 100644 --- a/entities/collection/collectionController.go +++ b/entities/collection/collectionController.go @@ -88,26 +88,26 @@ func PostInboxHandler(w http.ResponseWriter, r *http.Request) { } if foundObject == nil { _ = object.CreateObject(newActivity.Object) - /* - if err != nil { - w.WriteHeader(http.StatusBadRequest) - if err := json.NewEncoder(w).Encode(fmt.Sprintf("Database Error Creating Object: %s", err)); err != nil { - panic(err) - } - return - } - */ - } - _ = CreateCollectionObject(utils.GenerateInboxUrl(actorName), newActivity.Object.Id) - /* + if err != nil { w.WriteHeader(http.StatusBadRequest) - if err := json.NewEncoder(w).Encode(fmt.Sprintf("Database Error Creating Collection Object: %s", err)); err != nil { + if err := json.NewEncoder(w).Encode(fmt.Sprintf("Database Error Creating Object: %s", err)); err != nil { panic(err) } return } - */ + + } + _ = CreateCollectionObject(utils.GenerateInboxUrl(actorName), newActivity.Object.Id) + + if err != nil { + w.WriteHeader(http.StatusBadRequest) + if err := json.NewEncoder(w).Encode(fmt.Sprintf("Database Error Creating Collection Object: %s", err)); err != nil { + panic(err) + } + return + } + log.Printf("%s to %s: %s", newActivity.Actor, newActivity.To, newActivity.Object.Content) } else { w.WriteHeader(http.StatusBadRequest) @@ -231,8 +231,6 @@ func PostOutboxHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Error Sending Activity, retrying in %ss: %s", duration/1000000000, err) } backoff.RetryNotify(operation, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 16), notify) - - //go retryActivity(newActivity, recipient, token) } response := OutboxResponse{ @@ -246,22 +244,6 @@ func PostOutboxHandler(w http.ResponseWriter, r *http.Request) { } } -/* -func retryActivity(activityToSend *activity.Activity, recipient string, token string) (err error) { - b, cancel := config.BackoffPolicy.Start(context.Background()) - defer cancel() - - for backoff.Continue(b) { - err := SendActivity(activityToSend, recipient, token) - if err == nil { - return nil - } - } - err = errors.New("Not able to send activity") - return -} -*/ - func GetReciepientsForActivity(activityToSend *activity.Activity) (err error, recipientsWithoutDuplicates []string) { recipients := []string{} if strings.Contains(activityToSend.To, config.Homeserver) { diff --git a/main.go b/main.go index 53eeac9..ef631ea 100644 --- a/main.go +++ b/main.go @@ -33,20 +33,8 @@ var routes = router.Routes{ router.Route{"GetPost", "GET", "/{actorName}/posts/{postId}", object.GetPostHandler}, // Collections - /* - router.Route{"GetInbox", "GET", "/{actorName}/inbox", collection.GetInboxHandler}, - router.Route{"GetOutbox", "GET", "/{actorName}/outbox", collection.GetOutboxHandler}, - router.Route{"GetFollowers", "GET", "/{actorName}/followers", collection.GetFollowersHandler}, - router.Route{"GetFollowing", "GET", "/{actorName}/following", collection.GetFollowingHandler}, - router.Route{"GetLiked", "GET", "/{actorName}/liked", collection.GetLikedHandler}, - */ router.Route{"PostInbox", "POST", "/{actorName}/inbox/", collection.PostInboxHandler}, router.Route{"PostOutbox", "POST", "/{actorName}/outbox/", collection.PostOutboxHandler}, - /* - router.Route{"PostFollowers", "POST", "/{actorName}/followers", collection.PostFollowersHandler}, - router.Route{"PostFollowing", "POST", "/{actorName}/following", collection.PostFollowingHandler}, - router.Route{"PostLiked", "POST", "/{actorName}/liked", collection.PostLikedHandler}, - */ } func main() { @@ -57,18 +45,6 @@ func main() { } log.Printf("Start homeserver on name %s", config.Homeserver) - /* - if err := device.InitServerSigningKey(); err != nil { - log.Fatal(err) - } - config.VerifyKeys = make(map[string]map[string][]byte) - */ - /* - config.BackoffPolicy = backoff.NewExponential( - backoff.WithInterval(500*time.Millisecond), - backoff.WithMaxRetries(16), - ) - */ os.Remove("sqlite.db") if err := database.InitDB("sqlite.db"); err != nil { diff --git a/sqlite.db b/sqlite.db index f7bc89867e1e8a5b96951290106c309dc4a44776..90f72da2fe1dd0f25e1e2522f9f9c37c3b1790d1 100644 GIT binary patch literal 53248 zcmeI5No*U}8OON{SCJe$jzcSUVmgZ(Bbm(3rGc7AG9}TX6p11w+dv@9Mv)dbagn6} zfx!qZP@oM8w1*TuB*!3V4z5q>C2)}{(~`WLr@yM$2fm%JtgzM`%2k9?hp?`O&d#I<~zt z_FOO!XxCSbS}dQwnvc!pGBcyOYq9C{wHIP$Qm17!GrE-)3|w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