Skip to content

Commit a17ad08

Browse files
authored
Merge pull request #398 from basho/mas-i1775-fetchclocksmodrange
Mas i1775 fetchclocksmodrange
2 parents 3c6c0d2 + 475fad0 commit a17ad08

File tree

4 files changed

+100
-312
lines changed

4 files changed

+100
-312
lines changed

include/riakc.hrl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
-define(PROTO_MAJOR, 1).
2424
-define(PROTO_MINOR, 0).
2525
-define(DEFAULT_PB_TIMEOUT, 60000).
26+
-define(DEFAULT_AAEFOLD_TIMEOUT, 3600000).
2627
-define(FIRST_RECONNECT_INTERVAL, 100).
2728
-define(MAX_RECONNECT_INTERVAL, 30000).
2829

@@ -137,7 +138,7 @@
137138
mapred_call_timeout | mapred_stream_timeout |
138139
mapred_stream_call_timeout | mapred_bucket_timeout |
139140
mapred_bucket_call_timeout | mapred_bucket_stream_call_timeout |
140-
search_timeout | search_call_timeout |
141+
search_timeout | search_call_timeout | aaefold_timeout |
141142
timeout.
142143

143144
-type continuation() :: 'undefined' | binary().

rebar.config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
{platform_define, "^19", deprecated_19},
1313
{platform_define, "^20", deprecated_19},
1414
{platform_define, "^21", deprecated_19},
15-
{platform_define, "^22", deprecated_19}
15+
{platform_define, "^22", deprecated_19},
16+
{platform_define, "^23", deprecated_19}
1617
]}.
1718

1819
{deps, [
19-
{riak_pb, {git, "https://github.com/basho/riak_pb", {tag, "riak_kv-3.0.1"}}}
20+
{riak_pb, {git, "https://github.com/basho/riak_pb", {branch, "develop-3.0"}}}
2021
]}.
2122

2223
{edoc_opts, [

src/riakc_pb_socket.erl

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
search/3, search/4, search/5, search/6,
7272
get_index/4, get_index/5, get_index/6, get_index/7, %% @deprecated
7373
get_index_eq/4, get_index_range/5, get_index_eq/5, get_index_range/6,
74-
aae_merge_root/2, aae_merge_branches/3, aae_fetch_clocks/3,
74+
aae_merge_root/2, aae_merge_branches/3,
75+
aae_fetch_clocks/3, aae_fetch_clocks/4,
7576
aae_range_tree/7, aae_range_clocks/5, aae_range_replkeys/5,
7677
aae_find_keys/5, aae_find_tombs/5, aae_reap_tombs/6, aae_erase_keys/6,
7778
aae_list_buckets/1, aae_list_buckets/2,
@@ -1191,12 +1192,21 @@ default_timeout(OpTimeout) ->
11911192
{ok, EnvTimeout} ->
11921193
EnvTimeout;
11931194
undefined ->
1194-
case application:get_env(riakc, timeout) of
1195-
{ok, Timeout} ->
1196-
Timeout;
1197-
undefined ->
1198-
?DEFAULT_PB_TIMEOUT
1199-
end
1195+
modified_default(OpTimeout)
1196+
end.
1197+
1198+
%% @doc
1199+
%% Change the default for those that will almost certainly require a longer
1200+
%% timeout
1201+
-spec modified_default(timeout_name()) -> timeout().
1202+
modified_default(aaefold_timeout) ->
1203+
?DEFAULT_AAEFOLD_TIMEOUT;
1204+
modified_default(_) ->
1205+
case application:get_env(riakc, timeout) of
1206+
{ok, Timeout} ->
1207+
Timeout;
1208+
undefined ->
1209+
?DEFAULT_PB_TIMEOUT
12001210
end.
12011211

12021212
%% @doc Send a pre-encoded msg over the protocol buffer connection
@@ -1346,7 +1356,7 @@ replace_coverage(Pid, Bucket, Cover, Other) ->
13461356
{ok, {root, binary()}} |
13471357
{error, any()}.
13481358
aae_merge_root(Pid, NVal) ->
1349-
Timeout = default_timeout(get_coverage_timeout),
1359+
Timeout = default_timeout(aaefold_timeout),
13501360
call_infinity(Pid,
13511361
{req,
13521362
#rpbaaefoldmergerootnvalreq{n_val = NVal},
@@ -1361,7 +1371,7 @@ aae_merge_root(Pid, NVal) ->
13611371
{ok, {branches, [{BranchId::integer(), Branch::binary()}]}} |
13621372
{error, any()}.
13631373
aae_merge_branches(Pid, NVal, Branches) ->
1364-
Timeout = default_timeout(get_coverage_timeout),
1374+
Timeout = default_timeout(aaefold_timeout),
13651375
call_infinity(Pid,
13661376
{req,
13671377
#rpbaaefoldmergebranchnvalreq{n_val = NVal,
@@ -1380,12 +1390,32 @@ aae_merge_branches(Pid, NVal, Branches) ->
13801390
binary()}]}} |
13811391
{error, any()}.
13821392
aae_fetch_clocks(Pid, NVal, Segments) ->
1383-
Timeout = default_timeout(get_coverage_timeout),
1384-
call_infinity(Pid,
1385-
{req,
1386-
#rpbaaefoldfetchclocksnvalreq{n_val = NVal,
1387-
id_filter = Segments},
1388-
Timeout}).
1393+
aae_fetch_clocks(Pid, NVal, Segments, all).
1394+
1395+
-spec aae_fetch_clocks(pid(),
1396+
NVal::pos_integer(),
1397+
Segments::list(pos_integer()),
1398+
ModifiedRange::modified_range()|all) ->
1399+
{ok, {keysclocks,
1400+
[{{riakc_obj:bucket(),
1401+
riakc_obj:key()},
1402+
binary()}]}} |
1403+
{error, any()}.
1404+
aae_fetch_clocks(Pid, NVal, Segments, ModifiedRange) ->
1405+
Timeout = default_timeout(aaefold_timeout),
1406+
Req =
1407+
case ModifiedRange of
1408+
all ->
1409+
#rpbaaefoldfetchclocksnvalreq{n_val = NVal,
1410+
id_filter = Segments};
1411+
{MRL, MRH} ->
1412+
#rpbaaefoldfetchclocksnvalreq{n_val = NVal,
1413+
id_filter = Segments,
1414+
modified_range = true,
1415+
last_mod_start = MRL,
1416+
last_mod_end = MRH}
1417+
end,
1418+
call_infinity(Pid, {req, Req, Timeout}).
13891419

13901420
%% @doc generate a tictac tree by folding over a range of keys
13911421
%% in`Bucket'. The fold can be limited to the keys in `KeyRange' which
@@ -1414,7 +1444,7 @@ aae_fetch_clocks(Pid, NVal, Segments) ->
14141444
{ok, {tree, Tree::any()}} | {error, any()}.
14151445
aae_range_tree(Pid, BucketType, KeyRange, TreeSize,
14161446
SegmentFilter, ModifiedRange, HashMethod) ->
1417-
Timeout = default_timeout(get_coverage_timeout),
1447+
Timeout = default_timeout(aaefold_timeout),
14181448
{KR, SK, EK} =
14191449
case KeyRange of
14201450
all ->
@@ -1478,7 +1508,7 @@ aae_range_tree(Pid, BucketType, KeyRange, TreeSize,
14781508
binary()}]}} |
14791509
{error, any()}.
14801510
aae_range_clocks(Pid, BucketType, KeyRange, SegmentFilter, ModifiedRange) ->
1481-
Timeout = default_timeout(get_coverage_timeout),
1511+
Timeout = default_timeout(aaefold_timeout),
14821512
{KR, SK, EK} =
14831513
case KeyRange of
14841514
all ->
@@ -1534,7 +1564,7 @@ aae_range_clocks(Pid, BucketType, KeyRange, SegmentFilter, ModifiedRange) ->
15341564
{ok, non_neg_integer()} |
15351565
{error, any()}.
15361566
aae_range_replkeys(Pid, BucketType, KeyRange, ModifiedRange, QueueName) ->
1537-
Timeout = default_timeout(get_coverage_timeout),
1567+
Timeout = default_timeout(aaefold_timeout),
15381568
{KR, SK, EK} =
15391569
case KeyRange of
15401570
all ->
@@ -1597,7 +1627,7 @@ aae_range_replkeys(Pid, BucketType, KeyRange, ModifiedRange, QueueName) ->
15971627
{error, any()} when
15981628
Query :: {sibling_count, pos_integer()} | {object_size, pos_integer()}.
15991629
aae_find_keys(Pid, BucketType, KeyRange, ModifiedRange, Query) ->
1600-
Timeout = default_timeout(get_coverage_timeout),
1630+
Timeout = default_timeout(aaefold_timeout),
16011631
{KR, SK, EK} =
16021632
case KeyRange of
16031633
all ->
@@ -1648,7 +1678,7 @@ aae_find_keys(Pid, BucketType, KeyRange, ModifiedRange, Query) ->
16481678
{ok, {keys, list({riakc_obj:key(), pos_integer()})}} |
16491679
{error, any()}.
16501680
aae_find_tombs(Pid, BucketType, KeyRange, SegmentFilter, ModifiedRange) ->
1651-
Timeout = default_timeout(get_coverage_timeout),
1681+
Timeout = default_timeout(aaefold_timeout),
16521682
{KR, SK, EK} =
16531683
case KeyRange of
16541684
all ->
@@ -1717,7 +1747,7 @@ aae_reap_tombs(Pid,
17171747
BucketType, KeyRange,
17181748
SegmentFilter, ModifiedRange,
17191749
ChangeMethod) ->
1720-
Timeout = default_timeout(get_coverage_timeout),
1750+
Timeout = default_timeout(aaefold_timeout),
17211751
{KR, SK, EK} =
17221752
case KeyRange of
17231753
all ->
@@ -1797,7 +1827,7 @@ aae_erase_keys(Pid,
17971827
BucketType, KeyRange,
17981828
SegmentFilter, ModifiedRange,
17991829
ChangeMethod) ->
1800-
Timeout = default_timeout(get_coverage_timeout),
1830+
Timeout = default_timeout(aaefold_timeout),
18011831
{KR, SK, EK} =
18021832
case KeyRange of
18031833
all ->
@@ -1878,7 +1908,7 @@ aae_erase_keys(Pid,
18781908
{ok, {stats, list({Key::atom(), Val::atom() | list()})}} |
18791909
{error, any()}.
18801910
aae_object_stats(Pid, BucketType, KeyRange, ModifiedRange) ->
1881-
Timeout = default_timeout(get_coverage_timeout),
1911+
Timeout = default_timeout(aaefold_timeout),
18821912
{KR, SK, EK} =
18831913
case KeyRange of
18841914
all ->
@@ -1920,12 +1950,12 @@ aae_object_stats(Pid, BucketType, KeyRange, ModifiedRange) ->
19201950
%% detecting in the query. Will default to 1.
19211951
-spec aae_list_buckets(pid()) -> list(riakc_obj:bucket()).
19221952
aae_list_buckets(Pid) ->
1923-
Timeout = default_timeout(get_coverage_timeout),
1953+
Timeout = default_timeout(aaefold_timeout),
19241954
call_infinity(Pid, {req, #rpbaaefoldlistbucketsreq{}, Timeout}).
19251955

19261956
-spec aae_list_buckets(pid(), pos_integer()) -> list(riakc_obj:bucket()).
19271957
aae_list_buckets(Pid, MinNVal) when is_integer(MinNVal), MinNVal > 0 ->
1928-
Timeout = default_timeout(get_coverage_timeout),
1958+
Timeout = default_timeout(aaefold_timeout),
19291959
call_infinity(Pid,
19301960
{req,
19311961
#rpbaaefoldlistbucketsreq{n_val = MinNVal},

0 commit comments

Comments
 (0)