machi/prototype/demo-day-hack/file0_repair_server.escript
Scott Lystig Fritchie 29868678a4 Add file0_test.escript (and big squash)
Small cleanups

Small cleanups

Refactoring argnames & order for more consistency

Add server-side-calculated MD5 checksum + logging

file:consult() style checksum management, too slow! 513K csums = 105 seconds, ouch

Much faster checksum recording

Add checksum_list. Alas, line-by-line I/O is slow, neh?

Much faster checksum listing

Add file0_verify_checksums.escript and supporting code

Adjust escript +A and -smp flags

Add file0_compare_filelists.escript

First draft of file0_repair_server.escript

First draft of file0_repair_server.escript, part 2

WIP of file0_repair_server.escript, part 3

WIP of file0_repair_server.escript, part 4

Basic repair works, it seems, hooray!

When checksum file ordering is different, try a cheap(?) 'cmp' on sorted results instead

Add README.md

Initial import of szone_chash.erl

Add file0_cc_make_projection.escript and supporting code

Add file0_cc_map_prefix.escript and supporting code

Change think-o: hash output is a chain, silly boy

Add file0_cc_1file_write_redundant.escript and support

Add file0_cc_read_client.escript and supporting code

Add examples/servers.map & file0_start_servers.escript

WIP: working on file0_cc_migrate_files.escript

File migration finished, works, yay!

Add basic 'what am I' docs to each script

Add file0_server_daemon.escript

Minor fixes

Fix broken unit test

Add basho_bench run() commands for append & read ops with projection

Add to examples dir

WIP: erasure coding hack, part 1

Fix broken unit test

WIP: erasure coding hack, part 2

WIP: erasure coding hack, part 3, EC data write is finished!

WIP: erasure coding hack, part 4, EC data read still in progress

WIP: erasure coding hack, part 5, EC data read still in progress

WIP: erasure coding hack, part 5b, EC data read still in progress

WIP: erasure coding hack, EC data read finished!

README update, part 1

README update, part 2

Oops, put back the printed ouput for file-write-client and 1file-write-redundant-client

README update, part 3

Fix 'user' output bug in list-client

Ugly hacks to get output/no-output from write clients

Clean up minor output bugs

Clean up minor output bugs, part 2

README update, part 4

Clean up minor output bugs, part 3

Clean up minor output bugs, part 5

Clean up minor output bugs, part 6

README update, part 6

README update, part 7

README update, part 7

README update, part 8

Final edits/fixes for demo day

Fix another oops in the README/demo day script
2015-03-02 20:57:17 +09:00

69 lines
2.7 KiB
Erlang

#!/usr/bin/env escript
%% -*- erlang -*-
%%! +A 0 -smp disable -noinput -noshell
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2007-2014 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.
%%
%% -------------------------------------------------------------------
-module(file0_repair_server).
-compile(export_all).
-mode(compile). % for escript use
-define(NO_MODULE, true).
-include("./file0.erl").
main([]) ->
io:format("Use: Repair a server, *uni-directionally* from source -> destination.\n"),
io:format("Args: SrcHost SrcPort DstHost DstPort [ verbose check repair delete-source noverbose nodelete-source ]\n"),
erlang:halt(1);
main([SrcHost, SrcPortStr, DstHost, DstPortStr|Args]) ->
Src = {SrcHost, SrcPortStr},
SockSrc = escript_connect(SrcHost, SrcPortStr),
%% TODO is SockSrc2 necessary? Is SockDst2 necessary? If not, delete!
SockSrc2 = escript_connect(SrcHost, SrcPortStr),
ok = inet:setopts(SockSrc2, [{packet, raw}]),
SockDst = escript_connect(DstHost, DstPortStr),
SockDst2 = escript_connect(DstHost, DstPortStr),
Ps = make_repair_props(Args),
case proplists:get_value(mode, Ps) of
undefined -> io:format("NOTICE: default mode = check\n"),
timer:sleep(2*1000);
_ -> ok
end,
case proplists:get_value(verbose, Ps) of
true ->
io:format("Date & Time: ~p ~p\n", [date(), time()]),
io:format("Src: ~s ~s\n", [SrcHost, SrcPortStr]),
io:format("Dst: ~s ~s\n", [DstHost, DstPortStr]),
io:format("\n");
_ ->
ok
end,
%% Dst = {DstHost, DstPortStr},
X = escript_compare_servers(SockSrc, SockDst,
{SrcHost, SrcPortStr}, {DstHost, DstPortStr},
fun(_FileName) -> true end,
[null]),
[repair(File, Size, MissingList,
proplists:get_value(mode, Ps, check),
proplists:get_value(verbose, Ps, t),
SockSrc, SockSrc2, SockDst, SockDst2, Src) ||
{File, {Size, MissingList}} <- X].