Use 'bool' type in PB spec where feasible
This commit is contained in:
parent
3c6f1be5d0
commit
c65424569d
4 changed files with 28 additions and 33 deletions
|
@ -181,7 +181,7 @@ message Mpb_AppendChunkReq {
|
|||
optional uint32 chunk_extra = 20;
|
||||
optional string preferred_file_name = 21;
|
||||
/* Fail the operation if our preferred file name is not available */
|
||||
optional uint32 flag_fail_preferred = 22;
|
||||
optional bool flag_fail_preferred = 22 [default=false];
|
||||
}
|
||||
|
||||
message Mpb_AppendChunkResp {
|
||||
|
@ -210,15 +210,15 @@ message Mpb_ReadChunkReq {
|
|||
|
||||
// Use flag_no_checksum=non-zero to skip returning the chunk's checksum.
|
||||
// TODO: not implemented yet.
|
||||
optional uint32 flag_no_checksum = 20 [default=0];
|
||||
optional bool flag_no_checksum = 20 [default=false];
|
||||
|
||||
// Use flag_no_chunk=non-zero to skip returning the chunk (which
|
||||
// only makes sense if flag_no_checksum is not set).
|
||||
// TODO: not implemented yet.
|
||||
optional uint32 flag_no_chunk = 21 [default=0];
|
||||
optional bool flag_no_chunk = 21 [default=false];
|
||||
|
||||
// TODO: not implemented yet.
|
||||
optional uint32 flag_needs_trimmed = 22 [default=0];
|
||||
optional bool flag_needs_trimmed = 22 [default=false];
|
||||
}
|
||||
|
||||
message Mpb_ReadChunkResp {
|
||||
|
@ -401,7 +401,7 @@ message Mpb_LL_AppendChunkReq {
|
|||
optional uint32 chunk_extra = 20;
|
||||
optional string preferred_file_name = 21;
|
||||
/* Fail the operation if our preferred file name is not available */
|
||||
optional uint32 flag_fail_preferred = 22;
|
||||
optional bool flag_fail_preferred = 22 [default=false];
|
||||
}
|
||||
|
||||
message Mpb_LL_AppendChunkResp {
|
||||
|
@ -437,14 +437,14 @@ message Mpb_LL_ReadChunkReq {
|
|||
|
||||
// Use flag_no_checksum=non-zero to skip returning the chunk's checksum.
|
||||
// TODO: not implemented yet.
|
||||
optional uint32 flag_no_checksum = 20 [default=0];
|
||||
optional bool flag_no_checksum = 20 [default=false];
|
||||
|
||||
// Use flag_no_chunk=non-zero to skip returning the chunk (which
|
||||
// only makes sense if flag_checksum is not set).
|
||||
// TODO: not implemented yet.
|
||||
optional uint32 flag_no_chunk = 21 [default=0];
|
||||
optional bool flag_no_chunk = 21 [default=false];
|
||||
|
||||
optional uint32 flag_needs_trimmed = 22 [default=0];
|
||||
optional bool flag_needs_trimmed = 22 [default=false];
|
||||
}
|
||||
|
||||
message Mpb_LL_ReadChunkResp {
|
||||
|
@ -465,7 +465,7 @@ message Mpb_LL_TrimChunkReq {
|
|||
required uint64 offset = 12;
|
||||
required uint32 size = 13;
|
||||
|
||||
optional uint32 trigger_gc = 20 [default=0];
|
||||
optional bool trigger_gc = 20 [default=false];
|
||||
}
|
||||
|
||||
message Mpb_LL_TrimChunkResp {
|
||||
|
@ -506,7 +506,7 @@ message Mpb_LL_WedgeStatusReq {
|
|||
message Mpb_LL_WedgeStatusResp {
|
||||
required Mpb_GeneralStatusCode status = 1;
|
||||
optional Mpb_EpochID epoch_id = 2;
|
||||
optional uint32 wedged_flag = 3;
|
||||
optional bool wedged_flag = 3;
|
||||
}
|
||||
|
||||
// Low level API: delete_migration()
|
||||
|
|
|
@ -91,9 +91,9 @@ from_pb_request(#mpb_ll_request{
|
|||
flag_no_chunk=PB_GetNoChunk,
|
||||
flag_needs_trimmed=PB_NeedsTrimmed}}) ->
|
||||
EpochID = conv_to_epoch_id(PB_EpochID),
|
||||
Opts = #read_opts{no_checksum=conv_to_boolean(PB_GetNoChecksum),
|
||||
no_chunk=conv_to_boolean(PB_GetNoChunk),
|
||||
needs_trimmed=conv_to_boolean(PB_NeedsTrimmed)},
|
||||
Opts = #read_opts{no_checksum=PB_GetNoChecksum,
|
||||
no_chunk=PB_GetNoChunk,
|
||||
needs_trimmed=PB_NeedsTrimmed},
|
||||
#mpb_chunkpos{file_name=File,
|
||||
offset=Offset,
|
||||
chunk_size=Size} = ChunkPos,
|
||||
|
@ -107,9 +107,8 @@ from_pb_request(#mpb_ll_request{
|
|||
file=File,
|
||||
offset=Offset,
|
||||
size=Size,
|
||||
trigger_gc=PB_TriggerGC}}) ->
|
||||
trigger_gc=TriggerGC}}) ->
|
||||
EpochID = conv_to_epoch_id(PB_EpochID),
|
||||
TriggerGC = conv_to_boolean(PB_TriggerGC),
|
||||
{ReqID, {low_trim_chunk, NSVersion, NS, EpochID, File, Offset, Size, TriggerGC}};
|
||||
from_pb_request(#mpb_ll_request{
|
||||
req_id=ReqID,
|
||||
|
@ -203,9 +202,9 @@ from_pb_request(#mpb_request{req_id=ReqID,
|
|||
flag_no_checksum=FlagNoChecksum,
|
||||
flag_no_chunk=FlagNoChunk,
|
||||
flag_needs_trimmed=NeedsTrimmed} = IR,
|
||||
Opts = #read_opts{no_checksum=machi_util:int2bool(FlagNoChecksum),
|
||||
no_chunk=machi_util:int2bool(FlagNoChunk),
|
||||
needs_trimmed=machi_util:int2bool(NeedsTrimmed)},
|
||||
Opts = #read_opts{no_checksum=FlagNoChecksum,
|
||||
no_chunk=FlagNoChunk,
|
||||
needs_trimmed=NeedsTrimmed},
|
||||
{ReqID, {high_read_chunk, File, Offset, Size, Opts}};
|
||||
from_pb_request(#mpb_request{req_id=ReqID,
|
||||
trim_chunk=IR=#mpb_trimchunkreq{}}) ->
|
||||
|
@ -311,11 +310,8 @@ from_pb_response(#mpb_ll_response{
|
|||
from_pb_response(#mpb_ll_response{
|
||||
req_id=ReqID,
|
||||
wedge_status=#mpb_ll_wedgestatusresp{
|
||||
epoch_id=PB_EpochID, wedged_flag=PB_Wedged}}) ->
|
||||
epoch_id=PB_EpochID, wedged_flag=Wedged_p}}) ->
|
||||
EpochID = conv_to_epoch_id(PB_EpochID),
|
||||
Wedged_p = if PB_Wedged == 1 -> true;
|
||||
PB_Wedged == 0 -> false
|
||||
end,
|
||||
{ReqID, {ok, {Wedged_p, EpochID}}};
|
||||
from_pb_response(#mpb_ll_response{
|
||||
req_id=ReqID,
|
||||
|
@ -444,9 +440,9 @@ to_pb_request(ReqID, {low_read_chunk, NSVersion, NS, EpochID, File, Offset, Size
|
|||
file_name=File,
|
||||
offset=Offset,
|
||||
chunk_size=Size},
|
||||
flag_no_checksum=machi_util:bool2int(FNChecksum),
|
||||
flag_no_chunk=machi_util:bool2int(FNChunk),
|
||||
flag_needs_trimmed=machi_util:bool2int(NeedsTrimmed)}};
|
||||
flag_no_checksum=FNChecksum,
|
||||
flag_no_chunk=FNChunk,
|
||||
flag_needs_trimmed=NeedsTrimmed}};
|
||||
to_pb_request(ReqID, {low_trim_chunk, NSVersion, NS, EpochID, File, Offset, Size, TriggerGC}) ->
|
||||
PB_EpochID = conv_from_epoch_id(EpochID),
|
||||
#mpb_ll_request{req_id=ReqID, do_not_alter=2,
|
||||
|
@ -613,13 +609,12 @@ to_pb_response(ReqID, {low_skip_wedge, {low_wedge_status}}, Resp) ->
|
|||
#mpb_ll_response{req_id=ReqID,
|
||||
wedge_status=#mpb_ll_wedgestatusresp{status=Status}};
|
||||
{Wedged_p, EpochID} ->
|
||||
PB_Wedged = conv_from_boolean(Wedged_p),
|
||||
PB_EpochID = conv_from_epoch_id(EpochID),
|
||||
#mpb_ll_response{req_id=ReqID,
|
||||
wedge_status=#mpb_ll_wedgestatusresp{
|
||||
status='OK',
|
||||
epoch_id=PB_EpochID,
|
||||
wedged_flag=PB_Wedged}}
|
||||
wedged_flag=Wedged_p}}
|
||||
end;
|
||||
to_pb_response(ReqID, {low_skip_wedge, {low_delete_migration, _EID, _Fl}}, Resp)->
|
||||
Status = conv_from_status(Resp),
|
||||
|
@ -992,7 +987,7 @@ conv_from_boolean(true) ->
|
|||
conv_from_append_opts(#append_opts{chunk_extra=ChunkExtra,
|
||||
preferred_file_name=Pref,
|
||||
flag_fail_preferred=FailPref}) ->
|
||||
{ChunkExtra, Pref, conv_from_boolean(FailPref)}.
|
||||
{ChunkExtra, Pref, FailPref}.
|
||||
|
||||
|
||||
conv_to_append_opts(#mpb_appendchunkreq{
|
||||
|
@ -1001,14 +996,14 @@ conv_to_append_opts(#mpb_appendchunkreq{
|
|||
flag_fail_preferred=FailPref}) ->
|
||||
#append_opts{chunk_extra=ChunkExtra,
|
||||
preferred_file_name=Pref,
|
||||
flag_fail_preferred=conv_to_boolean(FailPref)};
|
||||
flag_fail_preferred=FailPref};
|
||||
conv_to_append_opts(#mpb_ll_appendchunkreq{
|
||||
chunk_extra=ChunkExtra,
|
||||
preferred_file_name=Pref,
|
||||
flag_fail_preferred=FailPref}) ->
|
||||
#append_opts{chunk_extra=ChunkExtra,
|
||||
preferred_file_name=Pref,
|
||||
flag_fail_preferred=conv_to_boolean(FailPref)}.
|
||||
flag_fail_preferred=FailPref}.
|
||||
|
||||
conv_from_projection_v1(#projection_v1{epoch_number=Epoch,
|
||||
epoch_csum=CSum,
|
||||
|
|
|
@ -287,8 +287,6 @@ write_chunk(PidSpec, NSInfo, EpochID, File, Offset, Chunk, Timeout) ->
|
|||
Timeout) of
|
||||
{error, written}=Err ->
|
||||
Size = byte_size(Chunk),
|
||||
NSInfo = undefined,
|
||||
io:format(user, "TODO fix broken read_chunk mod ~s line ~w\n", [?MODULE, ?LINE]),
|
||||
case read_chunk(PidSpec, NSInfo, EpochID, File, Offset, Size, undefined, Timeout) of
|
||||
{ok, {[{File, Offset, Chunk2, _}], []}} when Chunk2 == Chunk ->
|
||||
%% See equivalent comment inside write_projection().
|
||||
|
|
|
@ -559,8 +559,10 @@ wait_until_stable(ExpectedChainState, FLUNames, MgrNames, Retries, Verbose) ->
|
|||
FCList = fc_list(),
|
||||
wait_until_stable1(ExpectedChainState, TickFun, FCList, Retries, Verbose).
|
||||
|
||||
wait_until_stable1(_ExpectedChainState, _TickFun, FCList, 0, _Verbose) ->
|
||||
wait_until_stable1(ExpectedChainState, _TickFun, FCList, 0, _Verbose) ->
|
||||
?V(" [ERROR] _ExpectedChainState ~p\n", [ExpectedChainState]),
|
||||
?V(" [ERROR] wait_until_stable failed.... : ~p~n", [chain_state(FCList)]),
|
||||
?V(" [ERROR] norm.... : ~p~n", [normalize_chain_state(chain_state(FCList))]),
|
||||
false;
|
||||
wait_until_stable1(ExpectedChainState, TickFun, FCList, Reties, Verbose) ->
|
||||
[TickFun(3, 0, 100) || _ <- lists:seq(1, 3)],
|
||||
|
|
Loading…
Reference in a new issue