Masterthesis

This commit is contained in:
hoernschen 2020-11-27 05:52:27 +01:00
parent 473dc4a495
commit 4479fcf7f4
7 changed files with 28 additions and 57 deletions

View file

@ -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
1 Iteration Start End
2 1 1602853607 1602853727
3 2 1602853727 1602853847
4 3 1602853847 1602853967
5 4 1602853967 1602854087
6 5 1602854087 1602854207
7 6 1602854207 1602854327
8 7 1602854327 1602854447
9 8 1602854447 1602854567
10 9 1602854567 1602854687
11 10 1602854687 1602854807

View file

@ -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()

View file

@ -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,7 +176,7 @@ 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)
}
@ -186,8 +184,7 @@ func SendMessageHandler(w http.ResponseWriter, r *http.Request) {
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)
}
}
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{

1
go.mod
View file

@ -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
)

View file

@ -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)
}

BIN
sqlite.db

Binary file not shown.

View file

@ -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,