WIP: yank out more unused cruft
This commit is contained in:
parent
6cd3b8d0ec
commit
87ec988353
3 changed files with 3 additions and 114 deletions
|
@ -545,31 +545,6 @@ checksum_list2(Sock, EpochID, File) ->
|
|||
ReqID, {low_checksum_list, EpochID, File}),
|
||||
do_pb_request_common(Sock, ReqID, Req).
|
||||
|
||||
checksum_list_fast(Sock, 0) ->
|
||||
{ok, <<".\n">> = _Line} = w_recv(Sock, 2),
|
||||
[];
|
||||
checksum_list_fast(Sock, Remaining) ->
|
||||
Num = erlang:min(Remaining, 1024*1024),
|
||||
{ok, Bytes} = w_recv(Sock, Num),
|
||||
[Bytes|checksum_list_fast(Sock, Remaining - byte_size(Bytes))].
|
||||
|
||||
checksum_list_finish(Chunks) ->
|
||||
Bin = case Chunks of
|
||||
[X] ->
|
||||
X;
|
||||
_ ->
|
||||
iolist_to_binary(Chunks)
|
||||
end,
|
||||
[begin
|
||||
CSumLen = byte_size(Line) - 16 - 1 - 8 - 1,
|
||||
<<OffsetHex:16/binary, " ", SizeHex:8/binary, " ",
|
||||
CSum:CSumLen/binary>> = Line,
|
||||
{machi_util:hexstr_to_int(OffsetHex),
|
||||
machi_util:hexstr_to_int(SizeHex),
|
||||
machi_util:hexstr_to_bin(CSum)}
|
||||
end || Line <- re:split(Bin, "\n", [{return, binary}]),
|
||||
Line /= <<>>].
|
||||
|
||||
delete_migration2(Sock, EpochID, File) ->
|
||||
ReqID = <<"id">>,
|
||||
Req = machi_pb_translate:to_pb_request(
|
||||
|
@ -683,6 +658,6 @@ w_recv({w,tcp,Sock}, Amt) ->
|
|||
w_send({w,tcp,Sock}, IoData) ->
|
||||
gen_tcp:send(Sock, IoData).
|
||||
|
||||
w_setopts({w,tcp,Sock}, Opts) ->
|
||||
inet:setopts(Sock, Opts).
|
||||
%% w_setopts({w,tcp,Sock}, Opts) ->
|
||||
%% inet:setopts(Sock, Opts).
|
||||
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
%% -------------------------------------------------------------------
|
||||
%%
|
||||
%% Copyright (c) 2007-2015 Basho Technologies, Inc. All Rights Reserved.
|
||||
%%
|
||||
%% This file is provided to you 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.
|
||||
%%
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
%% @doc High level protocol server-side processing (temporary?)
|
||||
|
||||
-module(machi_pb_server).
|
||||
|
||||
-include("machi.hrl").
|
||||
-include("machi_pb.hrl").
|
||||
-include("machi_projection.hrl").
|
||||
|
||||
-define(SERVER_CMD_READ_TIMEOUT, 600*1000).
|
||||
|
||||
-export([run_loop/2]).
|
||||
|
||||
run_loop(Sock, P_srvr_list) ->
|
||||
ok = inet:setopts(Sock, ?PB_PACKET_OPTS),
|
||||
{ok, Clnt} = machi_cr_client:start_link(P_srvr_list),
|
||||
protocol_buffers_loop(Sock, Clnt).
|
||||
|
||||
protocol_buffers_loop(Sock, Clnt) ->
|
||||
case gen_tcp:recv(Sock, 0, ?SERVER_CMD_READ_TIMEOUT) of
|
||||
{ok, Bin} ->
|
||||
R = do_pb_request(catch machi_pb:decode_mpb_request(Bin), Clnt),
|
||||
Resp = machi_pb:encode_mpb_response(R),
|
||||
ok = gen_tcp:send(Sock, Resp),
|
||||
protocol_buffers_loop(Sock, Clnt);
|
||||
{error, SockError} ->
|
||||
Msg = io_lib:format("Socket error ~w", [SockError]),
|
||||
R = #mpb_errorresp{code=1, msg=Msg},
|
||||
Resp = machi_pb:encode_mpb_response(R),
|
||||
_ = (catch gen_tcp:send(Sock, Resp)),
|
||||
(catch gen_tcp:close(Sock)),
|
||||
exit(normal)
|
||||
end.
|
||||
|
||||
do_pb_request(PB_request, Clnt) ->
|
||||
{ReqID, Cmd, Result} =
|
||||
case machi_pb_translate:from_pb_request(PB_request) of
|
||||
{RqID, {high_echo, Msg}=CMD} ->
|
||||
Rs = Msg,
|
||||
{RqID, CMD, Rs};
|
||||
{RqID, {high_auth, _User, _Pass}} ->
|
||||
{RqID, not_implemented};
|
||||
{RqID, {high_append_chunk, _todoPK, Prefix, ChunkBin, TaggedCSum,
|
||||
ChunkExtra}=CMD} ->
|
||||
Chunk = {TaggedCSum, ChunkBin},
|
||||
Rs = machi_cr_client:append_chunk_extra(Clnt, Prefix, Chunk,
|
||||
ChunkExtra),
|
||||
|
||||
{RqID, CMD, Rs};
|
||||
{RqID, {high_write_chunk, File, Offset, ChunkBin, TaggedCSum}=CMD} ->
|
||||
Chunk = {TaggedCSum, ChunkBin},
|
||||
Rs = machi_cr_client:write_chunk(Clnt, File, Offset, Chunk),
|
||||
{RqID, CMD, Rs};
|
||||
{RqID, {high_read_chunk, File, Offset, Size}=CMD} ->
|
||||
Rs = machi_cr_client:read_chunk(Clnt, File, Offset, Size),
|
||||
{RqID, CMD, Rs};
|
||||
{RqID, {high_checksum_list, File}=CMD} ->
|
||||
Rs = machi_cr_client:checksum_list(Clnt, File),
|
||||
{RqID, CMD, Rs};
|
||||
{RqID, {high_list_files}=CMD} ->
|
||||
Rs = machi_cr_client:list_files(Clnt),
|
||||
{RqID, CMD, Rs};
|
||||
{RqID, {high_error, ErrCode, ErrMsg}=CMD} ->
|
||||
Rs = {ErrCode, ErrMsg},
|
||||
{RqID, CMD, Rs}
|
||||
end,
|
||||
machi_pb_translate:to_pb_response(ReqID, Cmd, Result).
|
|
@ -484,7 +484,7 @@ to_pb_response(ReqID, {low_wedge_status, _BogusEpochID}, Resp) ->
|
|||
{error, _}=Error ->
|
||||
Status = conv_from_status(Error),
|
||||
#mpb_ll_response{req_id=ReqID,
|
||||
wedge_status=#mpb_ll_wedgestatusresp{status=Error}};
|
||||
wedge_status=#mpb_ll_wedgestatusresp{status=Status}};
|
||||
{Wedged_p, EpochID} ->
|
||||
PB_Wedged = conv_from_boolean(Wedged_p),
|
||||
PB_EpochID = conv_from_epoch_id(EpochID),
|
||||
|
|
Loading…
Reference in a new issue