Commit b157020f authored by pfandzelter's avatar pfandzelter
Browse files

Merge branch 'tp/add-data-versioning' into 'main'

Add Data Versioning with Version Vectors

See merge request !144
parents ebbd389d 052f954b
Pipeline #40070 failed with stages
in 11 minutes and 4 seconds
......@@ -25,5 +25,8 @@
<env name="PATH" value="$GoBinDirs$" />
</envs>
</TaskOptions>
<enabled-global>
<option value="go fmt" />
</enabled-global>
</component>
</project>
\ No newline at end of file
......@@ -236,7 +236,7 @@ Furthermore, the `fred` process that talks to DynamoDB should have IAM keys conf
To create a table named `fred` (this must be passed in as command-line parameter `--dynamo-table=fred`) using the AWS CLI:
```bash
AWS_PAGER="" aws dynamodb create-table --table-name fred --attribute-definitions "AttributeName=Key,AttributeType=S AttributeName=Value,AttributeType=S AttributeName=Expiry,AttributeType=N" --key-schema "AttributeName=Key,KeyType=HASH" --provisioned-throughput "ReadCapacityUnits=1,WriteCapacityUnits=1"
AWS_PAGER="" aws dynamodb create-table --table-name fred --attribute-definitions "AttributeName=Key,AttributeType=S" --key-schema "AttributeName=Key,KeyType=HASH" --provisioned-throughput "ReadCapacityUnits=1,WriteCapacityUnits=1"
AWS_PAGER="" aws dynamodb update-time-to-live --table-name fred --time-to-live-specification "Enabled=true, AttributeName=Expiry"
```
......
......@@ -9,6 +9,8 @@ import (
"strings"
"syscall"
"git.tu-berlin.de/mcc-fred/fred/pkg/dynamo"
"git.tu-berlin.de/mcc-fred/fred/pkg/storageclient"
"github.com/caarlos0/env/v6"
"github.com/go-errors/errors"
"github.com/mmcloughlin/geohash"
......@@ -17,11 +19,9 @@ import (
"git.tu-berlin.de/mcc-fred/fred/pkg/api"
"git.tu-berlin.de/mcc-fred/fred/pkg/badgerdb"
"git.tu-berlin.de/mcc-fred/fred/pkg/dynamo"
"git.tu-berlin.de/mcc-fred/fred/pkg/etcdnase"
"git.tu-berlin.de/mcc-fred/fred/pkg/fred"
"git.tu-berlin.de/mcc-fred/fred/pkg/peering"
"git.tu-berlin.de/mcc-fred/fred/pkg/storageclient"
)
type fredConfig struct {
......
......@@ -34,7 +34,7 @@ type Server struct {
}
// PutItemTrigger calls HandleUpdate on the Inthandler
func (s *Server) PutItemTrigger(_ context.Context, request *trigger.PutItemTriggerRequest) (*trigger.TriggerResponse, error) {
func (s *Server) PutItemTrigger(_ context.Context, request *trigger.PutItemTriggerRequest) (*trigger.Empty, error) {
log.Debug().Msgf("Trigger Node has rcvd PutItem. In: %#v", request)
s.log = append(s.log, LogEntry{
......@@ -44,11 +44,11 @@ func (s *Server) PutItemTrigger(_ context.Context, request *trigger.PutItemTrigg
Val: request.Val,
})
return &trigger.TriggerResponse{Status: trigger.EnumTriggerStatus_TRIGGER_OK}, nil
return &trigger.Empty{}, nil
}
// DeleteItemTrigger calls this Method on the Inthandler
func (s *Server) DeleteItemTrigger(_ context.Context, request *trigger.DeleteItemTriggerRequest) (*trigger.TriggerResponse, error) {
func (s *Server) DeleteItemTrigger(_ context.Context, request *trigger.DeleteItemTriggerRequest) (*trigger.Empty, error) {
log.Debug().Msgf("Trigger Node has rcvd DeleteItem. In: %#v", request)
s.log = append(s.log, LogEntry{
......@@ -57,7 +57,7 @@ func (s *Server) DeleteItemTrigger(_ context.Context, request *trigger.DeleteIte
ID: request.Id,
})
return &trigger.TriggerResponse{Status: trigger.EnumTriggerStatus_TRIGGER_OK}, nil
return &trigger.Empty{}, nil
}
func startServer(cert string, key string, ca string, host string, wsHost string) {
......@@ -129,7 +129,7 @@ func main() {
host := flag.String("host", ":3333", "Host for the server to listen to")
wsHost := flag.String("wshost", ":80", "Host for the server to listen to")
loglevel := flag.String("loglevel", "dev", "dev=>pretty, prod=>json")
loghandler := flag.String("log-handler", "dev", "dev=>pretty, prod=>json")
cert := flag.String("cert", "", "certificate file for grpc server")
key := flag.String("key", "", "key file for grpc server")
ca := flag.String("ca-file", "", "CA root for grpc server")
......@@ -139,14 +139,14 @@ func main() {
// Setup Logging
// In Dev the ConsoleWriter has nice colored output, but is not very fast.
// In Prod the default handler is used. It writes json to stdout and is very fast.
if *loglevel == "dev" {
if *loghandler == "dev" {
log.Logger = log.Output(
zerolog.ConsoleWriter{
Out: os.Stderr,
NoColor: false,
},
)
} else if *loglevel != "prod" {
} else if *loghandler != "prod" {
log.Fatal().Msg("Log Handler has to be either dev or prod")
}
......
......@@ -42,6 +42,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM=
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/DistributedClocks/GoVector v0.0.0-20210402100930-db949c81a0af h1:dZA/5RPZb4h+6EPdMIyQ1SE62NBBGIp6O1UNowh+Ozg=
github.com/DistributedClocks/GoVector v0.0.0-20210402100930-db949c81a0af/go.mod h1:KhO62KYM3s2gEKM3ESiiI4pgvEPHz96Y1R1ceFpyVBg=
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
......@@ -78,8 +80,38 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
github.com/aws/aws-sdk-go v1.36.22 h1:kkQdiotYI9RlGoAoMPbQyHKsl9oyT+vz/w2cN6EUZKs=
github.com/aws/aws-sdk-go v1.36.22/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go-v2 v1.7.1 h1:TswSc7KNqZ/K1Ijt3IkpXk/2+62vi3Q82Yrr5wSbRBQ=
github.com/aws/aws-sdk-go-v2 v1.7.1/go.mod h1:L5LuPC1ZgDr2xQS7AmIec/Jlc7O/Y1u2KxJyNVab250=
github.com/aws/aws-sdk-go-v2/config v1.5.0 h1:tRQcWXVmO7wC+ApwYc2LiYKfIBoIrdzcJ+7HIh6AlR0=
github.com/aws/aws-sdk-go-v2/config v1.5.0/go.mod h1:RWlPOAW3E3tbtNAqTwvSW54Of/yP3oiZXMI0xfUdjyA=
github.com/aws/aws-sdk-go-v2/credentials v1.3.1 h1:fFeqL5+9kwFKsCb2oci5yAIDsWYqn/Nga8oQ5bIasI8=
github.com/aws/aws-sdk-go-v2/credentials v1.3.1/go.mod h1:r0n73xwsIVagq8RsxmZbGSRQFj9As3je72C2WzUIToc=
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.1.3 h1:xhdETBWOQEjxB2GIIuYNPPZcdzGfNxs8tQk+sXBUdSE=
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.1.3/go.mod h1:fiHL5545D891qYHNkErIZtJ57nQbZWdgbkeL+EkjqZQ=
github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.1.3 h1:4yE8dpeaCOOMS4bry9IS01qmODLJ8I5JjxraGdSh97Q=
github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.1.3/go.mod h1:PpfY11KyH7NJWPclM1nB4PAKcfG2kcjAayyvuZkuVJw=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.3.0 h1:s4vtv3Mv1CisI3qm2HGHi1Ls9ZtbCOEqeQn6oz7fTyU=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.3.0/go.mod h1:2LAuqPx1I6jNfaGDucWfA2zqQCYCOMCDHiCOciALyNw=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.0.1 h1:1Q713GXCiz97619PtNTG/DU23x3SZHQE+PM54QBwUqw=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.0.1/go.mod h1:H2dIRXkSkAPkxIA74UD1wYu0eS+cQxJcPKSmsfeZLUc=
github.com/aws/aws-sdk-go-v2/internal/ini v1.1.1 h1:SDLwr1NKyowP7uqxuLNdvFZhjnoVWxNv456zAp+ZFjU=
github.com/aws/aws-sdk-go-v2/internal/ini v1.1.1/go.mod h1:Zy8smImhTdOETZqfyn01iNOe0CNggVbPjCajyaz6Gvg=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.4.1 h1:+aMPn6HsRIl/Mk5Ese2wwxYQsHbVIQbtgk5v+7S1FkE=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.4.1/go.mod h1:jGJgc16tA1bFltVx7X2FHGxU8y2Zn9MwhsRO+aIwFMM=
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.3.1 h1:6GnCq+bpGvZILetZj2N5dBnVeRkJu6HTiQwto9ppIyk=
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.3.1/go.mod h1:1XusTaDIArK1QoAGZJzgRq/wzkNy7gZderQDZuPx93g=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.2.1 h1:s/uV8UyMB4UcO0ERHxG9BJhYJAD9MiY0QeYvJmlC7PE=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.2.1/go.mod h1:v33JQ57i2nekYTA70Mb+O18KeH4KqhdqxTJZNK1zdRE=
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.0.1 h1:Dd3LTXIKaAlcBeAd5xuxifyrjCJNHDZDUeAFm1Rhsn4=
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.0.1/go.mod h1:wyrFI6fQZ148qNco6W7ZxTfkVuf1EfQKZckAWOA1mPg=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.1 h1:VJe/XEhrfyfBLupcGg1BfUSK2VMZNdbDcZQ49jnp+h0=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.1/go.mod h1:zceowr5Z1Nh2WVP8bf/3ikB41IZW59E4yIYbg+pC6mw=
github.com/aws/aws-sdk-go-v2/service/sso v1.3.1 h1:H2ZLWHUbbeYtghuqCY5s/7tbBM99PAwCioRJF8QvV/U=
github.com/aws/aws-sdk-go-v2/service/sso v1.3.1/go.mod h1:J3A3RGUvuCZjvSuZEcOpHDnzZP/sKbhDWV2T1EOzFIM=
github.com/aws/aws-sdk-go-v2/service/sts v1.6.0 h1:Y9r6mrzOyAYz4qKaluSH19zqH1236il/nGbsPKOUT0s=
github.com/aws/aws-sdk-go-v2/service/sts v1.6.0/go.mod h1:q7o0j7d7HrJk/vr9uUt3BVRASvcU7gYZB9PUgPiByXg=
github.com/aws/smithy-go v1.6.0 h1:T6puApfBcYiTIsaI+SYWqanjMt5pc3aoyyDrI+0YH54=
github.com/aws/smithy-go v1.6.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg=
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
......@@ -227,6 +259,7 @@ github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjI
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c=
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
github.com/dgraph-io/badger/v3 v3.2103.0 h1:abkD2EnP3+6Tj8h5LI1y00dJ9ICKTIAzvG9WmZ8S2c4=
github.com/dgraph-io/badger/v3 v3.2103.0/go.mod h1:GHMCYxuDWyzbHkh4k3yyg4PM61tJPFfEGSMbE3Vd5QE=
......@@ -355,6 +388,10 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho=
github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1XL80yAn+A=
github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE=
github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
......@@ -369,8 +406,9 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
......@@ -466,8 +504,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
......@@ -688,6 +727,8 @@ github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI=
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
......@@ -850,8 +891,9 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
......@@ -932,6 +974,7 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
......@@ -942,8 +985,9 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
......@@ -1080,8 +1124,9 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
......
......@@ -91,7 +91,7 @@ func (m *ClientsMgr) ReadFromAnywhere(ctx context.Context, request *alexandraPro
} else {
log.Debug().Msgf("Reading from client returned data: %#v", res)
if !responsesClosed {
responses <- readResponse{error: false, data: res.Data}
responses <- readResponse{error: false, data: res.Data[0].Val}
}
}
}
......@@ -156,5 +156,5 @@ func (m *ClientsMgr) ReadFromAnywhere(ctx context.Context, request *alexandraPro
return nil, fmt.Errorf("ReadFromAnywhere: cannot read from fastest client. err=%v", err)
}
return &alexandraProto.ReadResponse{Data: result.Data}, nil
return &alexandraProto.ReadResponse{Data: result.Data[0].Val}, nil
}
......@@ -82,7 +82,7 @@ func (c *Client) updateItemSpeed(elapsed time.Duration) {
}
}
func (c *Client) CreateKeygroup(ctx context.Context, keygroup string, mutable bool, expiry int64) (*fredClients.StatusResponse, error) {
func (c *Client) CreateKeygroup(ctx context.Context, keygroup string, mutable bool, expiry int64) (*fredClients.Empty, error) {
res, err := c.Client.CreateKeygroup(ctx, &fredClients.CreateKeygroupRequest{
Keygroup: keygroup,
Mutable: mutable,
......@@ -91,7 +91,7 @@ func (c *Client) CreateKeygroup(ctx context.Context, keygroup string, mutable bo
return res, err
}
func (c *Client) DeleteKeygroup(ctx context.Context, keygroup string) (*fredClients.StatusResponse, error) {
func (c *Client) DeleteKeygroup(ctx context.Context, keygroup string) (*fredClients.Empty, error) {
res, err := c.Client.DeleteKeygroup(ctx, &fredClients.DeleteKeygroupRequest{Keygroup: keygroup})
return res, err
}
......@@ -111,9 +111,9 @@ func (c *Client) Read(ctx context.Context, keygroup string, id string) (*fredCli
}
// Update also updates the moving average item speed
func (c *Client) Update(ctx context.Context, keygroup string, id string, data string) (*fredClients.StatusResponse, error) {
func (c *Client) Update(ctx context.Context, keygroup string, id string, data string) (*fredClients.Empty, error) {
start := time.Now()
res, err := c.Client.Update(ctx, &fredClients.UpdateRequest{
_, err := c.Client.Update(ctx, &fredClients.UpdateRequest{
Keygroup: keygroup,
Id: id,
Data: data,
......@@ -122,13 +122,13 @@ func (c *Client) Update(ctx context.Context, keygroup string, id string, data st
elapsed := time.Since(start)
c.updateItemSpeed(elapsed)
}
return res, err
return &fredClients.Empty{}, err
}
// Delete also updates the moving average item speed
func (c *Client) Delete(ctx context.Context, keygroup string, id string) (*fredClients.StatusResponse, error) {
func (c *Client) Delete(ctx context.Context, keygroup string, id string) (*fredClients.Empty, error) {
start := time.Now()
res, err := c.Client.Delete(ctx, &fredClients.DeleteRequest{
_, err := c.Client.Delete(ctx, &fredClients.DeleteRequest{
Keygroup: keygroup,
Id: id,
})
......@@ -136,7 +136,7 @@ func (c *Client) Delete(ctx context.Context, keygroup string, id string) (*fredC
elapsed := time.Since(start)
c.updateItemSpeed(elapsed)
}
return res, err
return &fredClients.Empty{}, err
}
// Append also updates the moving average item speed
......@@ -153,7 +153,7 @@ func (c *Client) Append(ctx context.Context, keygroup string, data string) (*fre
return res, err
}
func (c *Client) AddReplica(ctx context.Context, keygroup string, nodeID string, expiry int64) (*fredClients.StatusResponse, error) {
func (c *Client) AddReplica(ctx context.Context, keygroup string, nodeID string, expiry int64) (*fredClients.Empty, error) {
res, err := c.Client.AddReplica(ctx, &fredClients.AddReplicaRequest{
Keygroup: keygroup,
NodeId: nodeID,
......@@ -167,7 +167,7 @@ func (c *Client) GetKeygroupReplica(ctx context.Context, keygroup string) (*fred
return res, err
}
func (c *Client) RemoveReplica(ctx context.Context, keygroup string, nodeID string) (*fredClients.StatusResponse, error) {
func (c *Client) RemoveReplica(ctx context.Context, keygroup string, nodeID string) (*fredClients.Empty, error) {
return c.Client.RemoveReplica(ctx, &fredClients.RemoveReplicaRequest{
Keygroup: keygroup,
NodeId: nodeID,
......@@ -179,14 +179,14 @@ func (c *Client) GetReplica(ctx context.Context, nodeID string) (*fredClients.Ge
}
func (c *Client) GetAllReplica(ctx context.Context) (*fredClients.GetAllReplicaResponse, error) {
return c.Client.GetAllReplica(ctx, &fredClients.GetAllReplicaRequest{})
return c.Client.GetAllReplica(ctx, &fredClients.Empty{})
}
func (c *Client) GetKeygroupTriggers(ctx context.Context, keygroup string) (*fredClients.GetKeygroupTriggerResponse, error) {
return c.Client.GetKeygroupTriggers(ctx, &fredClients.GetKeygroupTriggerRequest{Keygroup: keygroup})
}
func (c *Client) AddTrigger(ctx context.Context, keygroup string, triggerID string, triggerHost string) (*fredClients.StatusResponse, error) {
func (c *Client) AddTrigger(ctx context.Context, keygroup string, triggerID string, triggerHost string) (*fredClients.Empty, error) {
return c.Client.AddTrigger(ctx, &fredClients.AddTriggerRequest{
Keygroup: keygroup,
TriggerId: triggerID,
......@@ -194,23 +194,23 @@ func (c *Client) AddTrigger(ctx context.Context, keygroup string, triggerID stri
})
}
func (c *Client) RemoveTrigger(ctx context.Context, keygroup, triggerID string) (*fredClients.StatusResponse, error) {
func (c *Client) RemoveTrigger(ctx context.Context, keygroup, triggerID string) (*fredClients.Empty, error) {
return c.Client.RemoveTrigger(ctx, &fredClients.RemoveTriggerRequest{
Keygroup: keygroup,
TriggerId: triggerID,
})
}
func (c *Client) AddUser(ctx context.Context, user, keygroup string, role fredClients.UserRole) (*fredClients.StatusResponse, error) {
return c.Client.AddUser(ctx, &fredClients.UserRequest{
func (c *Client) AddUser(ctx context.Context, user, keygroup string, role fredClients.UserRole) (*fredClients.Empty, error) {
return c.Client.AddUser(ctx, &fredClients.AddUserRequest{
User: user,
Keygroup: keygroup,
Role: role,
})
}
func (c *Client) RemoveUser(ctx context.Context, user, keygroup string, role fredClients.UserRole) (*fredClients.StatusResponse, error) {
return c.Client.RemoveUser(ctx, &fredClients.UserRequest{
func (c *Client) RemoveUser(ctx context.Context, user, keygroup string, role fredClients.UserRole) (*fredClients.Empty, error) {
return c.Client.RemoveUser(ctx, &fredClients.RemoveUserRequest{
User: user,
Keygroup: keygroup,
Role: role,
......
......@@ -44,7 +44,7 @@ func (s *Server) GetReplica(ctx context.Context, request *alexandraProto.GetRepl
}
func (s *Server) GetAllReplica(ctx context.Context, request *alexandraProto.GetAllReplicaRequest) (*alexandraProto.GetAllReplicaResponse, error) {
res, err := s.clientsMgr.GetFastestClient().Client.GetAllReplica(ctx, &fredClients.GetAllReplicaRequest{})
res, err := s.clientsMgr.GetFastestClient().Client.GetAllReplica(ctx, &fredClients.Empty{})
if err != nil {
return nil, err
......
......@@ -19,7 +19,7 @@ import (
//)
func (s *Server) AddUser(ctx context.Context, request *alexandraProto.UserRequest) (*alexandraProto.Empty, error) {
_, err := s.clientsMgr.GetClientTo(s.lighthouse).Client.AddUser(ctx, &fredClients.UserRequest{
_, err := s.clientsMgr.GetClientTo(s.lighthouse).Client.AddUser(ctx, &fredClients.AddUserRequest{
User: request.User,
Keygroup: request.Keygroup,
Role: fredClients.UserRole(request.Role),
......@@ -33,7 +33,7 @@ func (s *Server) AddUser(ctx context.Context, request *alexandraProto.UserReques
}
func (s *Server) RemoveUser(ctx context.Context, request *alexandraProto.UserRequest) (*alexandraProto.Empty, error) {
_, err := s.clientsMgr.GetClientTo(s.lighthouse).Client.RemoveUser(ctx, &fredClients.UserRequest{
_, err := s.clientsMgr.GetClientTo(s.lighthouse).Client.RemoveUser(ctx, &fredClients.RemoveUserRequest{
User: request.User,
Keygroup: request.Keygroup,
Role: fredClients.UserRole(request.Role),
......
......@@ -10,6 +10,7 @@ import (
"git.tu-berlin.de/mcc-fred/fred/pkg/fred"
"git.tu-berlin.de/mcc-fred/fred/proto/client"
"github.com/DistributedClocks/GoVector/govec/vclock"
"github.com/go-errors/errors"
"github.com/rs/zerolog/log"
"google.golang.org/grpc"
......@@ -20,12 +21,11 @@ import (
// Server handles GRPC Requests and calls the according functions of the exthandler
type Server struct {
e fred.ExtHandler
e *fred.ExtHandler
roots *x509.CertPool
isProxied bool
proxyHost string
proxyPort string
*grpc.Server
}
......@@ -133,7 +133,7 @@ func (s *Server) CheckCert(ctx context.Context) (string, error) {
}
// NewServer creates a new Server for requests from Fred Clients
func NewServer(host string, handler fred.ExtHandler, certFile string, keyFile string, caFile string, isProxied bool, proxy string) *Server {
func NewServer(host string, handler *fred.ExtHandler, certFile string, keyFile string, caFile string, isProxied bool, proxy string) *Server {
if certFile == "" {
log.Fatal().Msg("API server: no certificate file given")
}
......@@ -219,47 +219,44 @@ func (s *Server) Close() error {
return nil
}
func statusResponseFromError(err error) (*client.StatusResponse, error) {
if err == nil {
return &client.StatusResponse{Status: client.EnumStatus_OK}, nil
}
log.Debug().Msgf("API Server is returning error: %#v", err)
return &client.StatusResponse{Status: client.EnumStatus_ERROR, ErrorMessage: err.Error()}, err
}
// CreateKeygroup calls this method on the exthandler
func (s *Server) CreateKeygroup(ctx context.Context, request *client.CreateKeygroupRequest) (*client.StatusResponse, error) {
func (s *Server) CreateKeygroup(ctx context.Context, request *client.CreateKeygroupRequest) (*client.Empty, error) {
log.Info().Msgf("API Server has rcvd CreateKeygroup. In: %#v", request)
user, err := s.CheckCert(ctx)
if err != nil {
return statusResponseFromError(err)
return nil, err
}
err = s.e.HandleCreateKeygroup(user, fred.Keygroup{Name: fred.KeygroupName(request.Keygroup), Mutable: request.Mutable, Expiry: int(request.Expiry)})
return statusResponseFromError(err)
if err != nil {
return nil, err
}
return &client.Empty{}, nil
}
// DeleteKeygroup calls this method on the exthandler
func (s *Server) DeleteKeygroup(ctx context.Context, request *client.DeleteKeygroupRequest) (*client.StatusResponse, error) {
func (s *Server) DeleteKeygroup(ctx context.Context, request *client.DeleteKeygroupRequest) (*client.Empty, error) {
log.Info().Msgf("API Server has rcvd DeleteKeygroup. In: %#v", request)
user, err := s.CheckCert(ctx)
if err != nil {
return statusResponseFromError(err)
return nil, err
}
err = s.e.HandleDeleteKeygroup(user, fred.Keygroup{Name: fred.KeygroupName(request.Keygroup)})
return statusResponseFromError(err)
if err != nil {
return nil, err
}
return &client.Empty{}, nil
}
// Read calls this method on the exthandler
......@@ -269,18 +266,35 @@ func (s *Server) Read(ctx context.Context, request *client.ReadRequest) (*client
user, err := s.CheckCert(ctx)
if err != nil {
_, err = statusResponseFromError(err)
return nil, err
}
res, err := s.e.HandleRead(user, fred.Item{Keygroup: fred.KeygroupName(request.Keygroup), ID: request.Id})
var version vclock.VClock
if request.Version != nil {
version = vclock.VClock{}.CopyFromMap(request.Version.Version)
}
res, err := s.e.HandleRead(user, fred.Item{Keygroup: fred.KeygroupName(request.Keygroup), ID: request.Id}, version)
if err != nil {
log.Debug().Msgf("API Server is returning error: %#v", err)
return &client.ReadResponse{}, err
return nil, err
}
data := make([]*client.Item, len(res))
for i := 0; i < len(res); i++ {
data[i] = &client.Item{
Id: res[i].ID,
Val: res[i].Val,
Version: res[i].Version.GetMap(),
}
}
return &client.ReadResponse{Data: res.Val}, nil
return &client.ReadResponse{
Data: data,
}, nil
}
......@@ -291,7 +305,6 @@ func (s *Server) Scan(ctx context.Context, request *client.ScanRequest) (*client
user, err := s.CheckCert(ctx)
if err != nil {
_, err = statusResponseFromError(err)
return nil, err
}
......@@ -299,16 +312,17 @@ func (s *Server) Scan(ctx context.Context, request *client.ScanRequest) (*client
if err != nil {
log.Debug().Msgf("API Server is returning error: %#v", err)
return &client.ScanResponse{}, err
return nil, err
}
data := make([]*client.Data, len(res))
data := make([]*client.Item, len(res))
for i := 0; i < len(res); i++ {
data[i] = &client.Data{
Id: res[i].ID,
Val: res[i].Val,
data[i] = &client.Item{
Id: res[i].ID,
Val: res[i].Val,
Version: res[i].Version.GetMap(),
}
}
......@@ -325,14 +339,13 @@ func (s *Server) Append(ctx context.Context, request *client.AppendRequest) (*cl
user, err := s.CheckCert(ctx)
if err != nil {
_, err = statusResponseFromError(err)
return nil, err
}
res, err := s.e.HandleAppend(user, fred.Item{Keygroup: fred.KeygroupName(request.Keygroup), Val: request.Data})
if err != nil {
return &client.AppendResponse{}, err
return nil, err
}