Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stackdump committed Apr 23, 2019
1 parent 4757ff6 commit c310bda
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/interfaces/state.go
Expand Up @@ -326,6 +326,7 @@ type IState interface {
IsSyncingDBSigs() bool
DidCreateLastBlockFromDBState() bool
GetUnsyncedServers(dbheight uint32) []IHash
GetIgnoreDone() bool

// Access to Holding Queue
LoadHoldingMap() map[[32]byte]IMsg
Expand Down
4 changes: 4 additions & 0 deletions state/state.go
Expand Up @@ -2948,3 +2948,7 @@ func (s *State) IsActive(id activations.ActivationType) bool {

return rval
}

func (s *State) GetIgnoreDone() bool {
return s.IgnoreDone
}
73 changes: 73 additions & 0 deletions wsapi/wsapi.go
Expand Up @@ -87,6 +87,8 @@ func Start(state interfaces.IState) {
server.Post("/v2", HandleV2)
server.Get("/v2", HandleV2)

server.Get("/status", HandleStatus)

// start the debugging api if we are not on the main network
if state.GetNetworkName() != "MAIN" {
server.Post("/debug", HandleDebug)
Expand Down Expand Up @@ -801,6 +803,77 @@ func HandleHeights(ctx *web.Context) {
returnMsg(ctx, jsonResp.Result, true)
}

type statusResponse struct {
Version string
NodeName string
BootTime int64
CurrentTime int64
CurrentBlockStartTime int64
CurrentMinuteStartTime int64
CurrentMinute int
LeaderHeight uint32
HighestSavedBlock uint32
HighestKnownBlock uint32
DBHeightComplete uint32

This comment has been minimized.

Copy link
@stackdump

stackdump Jul 12, 2019

Author Contributor

DBHeightComplete shows 0 all the time – need to fix it [DeFacto] Anton IlzheevToday at 10:55 AM

EntryBlockDBHeightComplete uint32
EntryBlockDBHeightProcessing uint32
Syncing bool
SyncingEOMs bool
SyncingDBSigs bool
Running bool
IgnoreDone bool

This comment has been minimized.

Copy link
@stackdump

stackdump Jul 12, 2019

Author Contributor

This flag doesn't seem to match the 'I' in the control panel - if there is different ideas of what 'ignore' is we need to somehow specify or add a new field - otherwise just need to document how this works.

This comment has been minimized.

Copy link
@stackdump

stackdump Jul 12, 2019

Author Contributor

Also there is confusion about how --startdelay may affect Ignore


[DeFacto] Anton IlzheevToday at 12:30 PM
Right now (600 startdelay, 15 minutes passed after restart) I still see "I" in control panel
And node not following minutes…
Let's wait 3-5 minutes more until "I" disappears from control panel
If forget about Ignore, is it possible to make node telling "I am following minutes"? Or it is not possible to determine using data from single node? @[Factom Inc] Matt York

This comment has been minimized.

Copy link
@ilzheev

ilzheev Jul 12, 2019

Contributor

Using startdelay=600:

0-9 minute: ignoreDone false, "I" in CP
10-19 minute: ignoreDone true, "I" in CP
19-20 minute+: ignoreDone true, no "I" in CP

Using startdelay=0:

0-30 sec: ignoreDone false, "I" in CP
30 sec+: ignoreDone true, no "I" in CP
  1. I understand how ignoreDone flag works, but "I" in CP changes randomly (0 delay after ignoreDone in case of startdelay=0, 9-10 minutes delay (in additional to startdelay) after ignoreDone in case of startdelay=600)
  2. Looks like ignoreDone flag is unusable for our task — when it's true (ignore finished), node is still not ready — not following minutes & not fully synced...

Any ideas if we may add "isFollowingMinutes"? Would be more useful for our case.

This comment has been minimized.

Copy link
@Emyrk

Emyrk Jul 12, 2019

Contributor

I think we should spend some time to figure out how accurate the I in the CP is.
The CP is a delayed copy of the state.

As for the following of minutes. When you exit I, it does not mean you are following minutes. It means you are requesting missing messages (iirc). To tell if you are following minutes is difficult, as you can follow minutes a full block (maybe 2?) behind.

Role string
}

func HandleStatus(ctx *web.Context) {
ServersMutex.Lock()
s := ctx.Server.Env["state"].(interfaces.IState)
ServersMutex.Unlock()

feds := s.GetFedServers(s.GetLLeaderHeight())
audits := s.GetAuditServers(s.GetLLeaderHeight())
role := "follower"
foundRole := false
for _, fed := range feds {
if !foundRole && s.GetIdentityChainID().IsSameAs(fed.GetChainID()) {
role = "leader"
break
}
}
for _, aud := range audits {
if !foundRole && s.GetIdentityChainID().IsSameAs(aud.GetChainID()) {
role = "audit"
}
}

jsonResp := primitives.NewJSON2Response()
jsonResp.ID = 0
jsonResp.Result = statusResponse{

This comment has been minimized.

Copy link
@stackdump

stackdump Jul 1, 2019

Author Contributor

I think it would be better to get this from <*state>.LastDisplayState
may need to add some attributes to get every field that is required

This comment has been minimized.

Copy link
@Emyrk

Emyrk Jul 12, 2019

Contributor

If we are putting this in the api, I'd advise against using displaystate. The control panel really needs a better method of obtaining it's data in a thread safe way.

Ideally the control panel could get all the info it needs from the api, and then the control panel would not need special access. So if we add this type of info to the api, it's a step towards that. A lot of the data you are querying for is thread safe too. Any primitive on the state should be safe.

This comment has been minimized.

Copy link
@stackdump

stackdump Jul 12, 2019

Author Contributor

@Emyrk so if we just tweak this a little - we should be good?

This comment has been minimized.

Copy link
@Emyrk

Emyrk Jul 12, 2019

Contributor

I'm not opposed to querying the data as you have now. I'd have to run through the list to ensure they are just primitive variables on state.

If this is being added to the api though, we should maybe try and determine exactly what we want to export, as we would then have to maintain this endpoint.

s.GetFactomdVersion(),
s.GetFactomNodeName(),
s.GetBootTime(),
s.GetCurrentTime(),
s.GetCurrentBlockStartTime(),
s.GetCurrentMinuteStartTime(),
s.GetCurrentMinute(),
s.GetLeaderHeight(),
s.GetHighestSavedBlk(),
s.GetHighestKnownBlock(),
s.GetEntryBlockDBHeightComplete(),
s.GetDBHeightComplete(),
s.GetEntryBlockDBHeightProcessing(),
s.IsSyncing(),
s.IsSyncingEOMs(),
s.IsSyncingDBSigs(),
s.Running(),
s.GetIgnoreDone(),
role,
}

// REVIEW: should we only conditionally return status 200 if some precondition is met
ctx.Write([]byte(jsonResp.String()))
}

/*********************************************************
* Support Functions
*********************************************************/
Expand Down

0 comments on commit c310bda

Please sign in to comment.