diff --git a/1602853607 Baseline Measurement Windows.csv b/1602853607 Baseline Measurement Windows.csv deleted file mode 100644 index bb48dda..0000000 --- a/1602853607 Baseline Measurement Windows.csv +++ /dev/null @@ -1,11 +0,0 @@ -Iteration,Start,End -1,1602853607,1602853727 -2,1602853727,1602853847 -3,1602853847,1602853967 -4,1602853967,1602854087 -5,1602854087,1602854207 -6,1602854207,1602854327 -7,1602854327,1602854447 -8,1602854447,1602854567 -9,1602854567,1602854687 -10,1602854687,1602854807 diff --git a/config/config.go b/config/config.go index abe58da..a5bc5e3 100644 --- a/config/config.go +++ b/config/config.go @@ -2,8 +2,6 @@ package config import ( "time" - - "github.com/lestrrat-go/backoff" ) var ServerName string = "Hoernschen's Matrix Server" @@ -25,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/entities/event/eventController.go b/entities/event/eventController.go index 9fde86d..d960652 100644 --- a/entities/event/eventController.go +++ b/entities/event/eventController.go @@ -2,7 +2,6 @@ package event import ( "bytes" - "context" "encoding/json" "errors" "fmt" @@ -17,9 +16,8 @@ import ( "git.nutfactory.org/hoernschen/Matrix/entities/user" "git.nutfactory.org/hoernschen/Matrix/utils" - //"github.com/cenkalti/backoff/v4" + "github.com/cenkalti/backoff/v4" "github.com/gorilla/mux" - "github.com/lestrrat-go/backoff" ) func New( @@ -178,16 +176,15 @@ func SendMessageHandler(w http.ResponseWriter, r *http.Request) { for _, server := range servers { if server != config.Homeserver { log.Printf("Send Transaction to %s", server) - /* - operation := func() error { - return SendTransaction(transaction, server, config.HttpString, config.AuthentificationCheck) - } - notify := func(err error, duration time.Duration) { - log.Printf("Error Sending Transaction, retrying in %ss: %s", duration/1000000000, err) - } - backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) - */ - go retryTransaction(transaction, server, config.HttpString, config.AuthentificationCheck) + + operation := func() error { + return SendTransaction(transaction, server, config.HttpString, config.AuthentificationCheck) + } + notify := func(err error, duration time.Duration) { + log.Printf("Error Sending Transaction, retrying in %ss: %s", duration/1000000000, err) + } + backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) + } } response := createEventResponse{ @@ -199,20 +196,6 @@ func SendMessageHandler(w http.ResponseWriter, r *http.Request) { } } -func retryTransaction(transactionToSend *Transaction, server string, httpString string, authCheck bool) (err error) { - b, cancel := config.BackoffPolicy.Start(context.Background()) - defer cancel() - - for backoff.Continue(b) { - err := SendTransaction(transactionToSend, server, httpString, authCheck) - if err == nil { - return nil - } - } - err = errors.New("Not able to send transaction") - return -} - func CreateStateEventHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") errResponse := utils.CheckRequest(r) @@ -294,14 +277,13 @@ func CreateStateEventHandler(w http.ResponseWriter, r *http.Request) { return } for _, server := range servers { - /*operation := func() error { + operation := func() error { return SendTransaction(transaction, server, config.HttpString, config.AuthentificationCheck) } notify := func(err error, duration time.Duration) { log.Printf("Error Sending Transaction, retrying in %ss: %s", duration/1000000000, err) } - go backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify)*/ - go retryTransaction(transaction, server, config.HttpString, config.AuthentificationCheck) + go backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) } response := createEventResponse{ diff --git a/go.mod b/go.mod index 5043d3e..0e48f00 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,5 @@ go 1.14 require ( github.com/cenkalti/backoff/v4 v4.1.0 github.com/gorilla/mux v1.8.0 - github.com/lestrrat-go/backoff v1.0.0 github.com/mattn/go-sqlite3 v1.14.4 ) diff --git a/main.go b/main.go index 5ba2bdd..43a5603 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "log" "net/http" "os" - "time" "git.nutfactory.org/hoernschen/Matrix/config" "git.nutfactory.org/hoernschen/Matrix/entities/device" @@ -15,7 +14,6 @@ import ( "git.nutfactory.org/hoernschen/Matrix/entities/user" "git.nutfactory.org/hoernschen/Matrix/utils/database" "git.nutfactory.org/hoernschen/Matrix/utils/router" - "github.com/lestrrat-go/backoff" ) var keyPath = "./ssl.key" @@ -72,11 +70,6 @@ func main() { config.VerifyKeys = make(map[string]map[string][]byte) os.Remove("sqlite.db") - config.BackoffPolicy = backoff.NewExponential( - backoff.WithInterval(500*time.Millisecond), - backoff.WithMaxRetries(16), - ) - if err := database.InitDB("sqlite.db"); err != nil { log.Fatal(err) } diff --git a/sqlite.db b/sqlite.db index 46f09c4..70ef887 100644 Binary files a/sqlite.db and b/sqlite.db differ diff --git a/workloadGenerator.go b/workloadGenerator.go index ead2b88..70a87dd 100644 --- a/workloadGenerator.go +++ b/workloadGenerator.go @@ -22,7 +22,7 @@ import ( "git.nutfactory.org/hoernschen/Matrix/utils" ) -var BaseLineTest = true +var BaseLineTest = false var systemParamsIndex = 0 @@ -47,8 +47,6 @@ var users = []map[string][]string{ "user2", "user3", "user4", - "user5", - "user6", }, }, map[string][]string{ @@ -85,20 +83,34 @@ var users = []map[string][]string{ "user4", }, }, + map[string][]string{ + "localhost": []string{ + "user1", + "user2", + "user3", + "user4", + }, + }, } +/* var servers = []string{ "143.93.38.207", "143.93.38.208", "143.93.38.209", } +*/ + +var servers = []string{ + "localhost", +} var systemParams = []SystemParams{ SystemParams{ Id: "111111111", BytesToSend: 280, MessagesPerSecond: 1.0, - Distribution: users[1], + Distribution: users[3], Packetloss: 1, MinutesNotAvailable: 0, Consensus: true,