Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0ac34bc
Fix batch pin index calculation logic and improve logging
peterbroadhurst Feb 8, 2022
8bd5fd3
Rewind offset to one before the message that popped
peterbroadhurst Feb 9, 2022
5bdaad0
Re-work batch logic for simplicity, efficiency, and restart recovery
peterbroadhurst Feb 9, 2022
fb93472
Further refinement and testing
peterbroadhurst Feb 9, 2022
80c93cb
More enhancements on logic
peterbroadhurst Feb 9, 2022
dc1eae4
Private message send refactor to use batches always
peterbroadhurst Feb 10, 2022
1bd3735
Prepare to be merge helled
peterbroadhurst Feb 10, 2022
0e679f2
Merge branch 'main' of github.com:hyperledger/firefly into batch-v2
peterbroadhurst Feb 10, 2022
c4ef11d
Work through the changes for batch-only private xfers
peterbroadhurst Feb 10, 2022
9c55381
Tweaks
peterbroadhurst Feb 10, 2022
0c6912a
Rename "none" to "unpinned" now we have a TX for them
peterbroadhurst Feb 10, 2022
4630c3d
Correct the last pin index
peterbroadhurst Feb 10, 2022
dfdb167
Close out on UTs
peterbroadhurst Feb 10, 2022
1d3cc7d
Add exclusive table lock for event emission to ensure event detection…
peterbroadhurst Feb 11, 2022
73f3404
Merge with main
peterbroadhurst Feb 11, 2022
0108f36
Correct type of batch timer popped message
peterbroadhurst Feb 11, 2022
5dd72b7
Review comments
peterbroadhurst Feb 11, 2022
a6198ee
Add API for batch manager status
peterbroadhurst Feb 11, 2022
7d8d2eb
Add skip optimization
peterbroadhurst Feb 11, 2022
d004b4a
Skip early
peterbroadhurst Feb 11, 2022
5b47157
Assume overflow and full are false if addWork is a no-op
peterbroadhurst Feb 11, 2022
097f794
Reverse the order of the flushedSequences as we add them, to allow tr…
peterbroadhurst Feb 11, 2022
d2bdcc4
Addresss last set of review comments
peterbroadhurst Feb 11, 2022
b19cc8f
Only valid TX type for broadcast is batch_pin
peterbroadhurst Feb 11, 2022
42335d8
Make the logic clearer by shifting thing forwards and adding to the end
peterbroadhurst Feb 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -1239,6 +1240,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -3479,6 +3481,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -4294,6 +4297,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -4402,6 +4406,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -4705,6 +4710,7 @@ paths:
type:
enum:
- none
- unpinned
- batch_pin
- token_pool
- token_transfer
Expand Down Expand Up @@ -4839,6 +4845,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -4899,6 +4906,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -5046,6 +5054,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -5106,6 +5115,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -5263,6 +5273,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -6487,6 +6498,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -6741,6 +6753,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -7524,6 +7537,7 @@ paths:
enum:
- staged
- ready
- sent
- pending
- confirmed
- rejected
Expand Down Expand Up @@ -7807,6 +7821,7 @@ paths:
type:
enum:
- none
- unpinned
- batch_pin
- token_pool
- token_transfer
Expand Down Expand Up @@ -7917,6 +7932,7 @@ paths:
type:
enum:
- none
- unpinned
- batch_pin
- token_pool
- token_transfer
Expand Down Expand Up @@ -8681,5 +8697,64 @@ paths:
description: Success
default:
description: ""
/status/batchmanager:
get:
description: 'TODO: Description'
operationId: getStatusBatchManager
parameters:
- description: Server-side request timeout (millseconds, or set a custom suffix
like 10s)
in: header
name: Request-Timeout
schema:
default: 120s
type: string
responses:
"200":
content:
application/json:
schema:
properties:
processors:
items:
properties:
dispatcher:
type: string
name:
type: string
status:
properties:
averageBatchBytes:
format: int64
type: integer
averageBatchData:
format: double
type: number
averageBatchMessages:
format: double
type: number
averageFlushTimeMS:
format: int64
type: integer
blocked:
type: boolean
flushing: {}
lastFlushError:
type: string
lastFlushErrorTime: {}
lastFlushStartTime: {}
totalBatches:
format: int64
type: integer
totalErrors:
format: int64
type: integer
type: object
type: object
type: array
type: object
description: Success
default:
description: ""
servers:
- url: http://localhost:12345
42 changes: 42 additions & 0 deletions internal/apiserver/route_get_status_batchmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2022 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http"

"github.com/hyperledger/firefly/internal/batch"
"github.com/hyperledger/firefly/internal/i18n"
"github.com/hyperledger/firefly/internal/oapispec"
)

var getStatusBatchManager = &oapispec.Route{
Name: "getStatusBatchManager",
Path: "status/batchmanager",
Method: http.MethodGet,
PathParams: nil,
QueryParams: nil,
FilterFactory: nil,
Description: i18n.MsgTBD,
JSONInputValue: nil,
JSONOutputValue: func() interface{} { return &batch.ManagerStatus{} },
JSONOutputCodes: []int{http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
output = getOr(r.Ctx).BatchManager().Status()
return output, nil
},
}
42 changes: 42 additions & 0 deletions internal/apiserver/route_get_status_batchmanager_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/internal/batch"
"github.com/hyperledger/firefly/mocks/batchmocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func TestGetStatusBatching(t *testing.T) {
o, r := newTestAPIServer()
req := httptest.NewRequest("GET", "/api/v1/status/batchmanager", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mbm := &batchmocks.Manager{}
o.On("BatchManager").Return(mbm)
mbm.On("Status", mock.Anything, mock.Anything).
Return(&batch.ManagerStatus{}, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 200, res.Result().StatusCode)
}
1 change: 1 addition & 0 deletions internal/apiserver/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var routes = []*oapispec.Route{
getOpByID,
getOps,
getStatus,
getStatusBatchManager,
getSubscriptionByID,
getSubscriptions,
getTxnByID,
Expand Down
Loading