Commit Graph

47 Commits

Author SHA1 Message Date
Asias He
937f28d2f1 Convert to use dht::partition_range_vector and dht::token_range_vector 2016-12-19 14:08:50 +08:00
Asias He
e5485f3ea6 Get rid of query::partition_range
Use dht::partition_range instead
2016-12-19 08:09:25 +08:00
Asias He
d1178fa299 Convert to use dht::token_range 2016-12-19 08:04:29 +08:00
Asias He
e523803a5d token_metadata: Introduce interval_to_range helper
It is used to convert a boost::icl::interval<token> interval back to a
range<token>.
2016-12-12 11:09:26 +08:00
Avi Kivity
a35136533d Convert ring_position and token ranges to be nonwrapping
Wrapping ranges are a pain, so we are moving wrap handling to the edges.

Since cql can't generate wrapping ranges, this means thrift and the ring
maintenance code; also range->ring transformations need to merge the first
and last ranges.

Message-Id: <1478105905-31613-1-git-send-email-avi@scylladb.com>
2016-11-02 21:04:11 +02:00
Asias He
089734474b token_metadata: Speed up pending_endpoints_for
pending_endpoints_for is called frequently by
storage_proxy::create_write_response_handler when doing cql query.

Before this patch, each call to pending_endpoints_for involves
converting a multimap (std::unordered_multimap<range<token>,
inet_address>>) to map (std::unordered_map<range<token>,
std::unordered_set<inet_address>>).

To speed up the token to pending endpoint mapping search, a interval map
is introduced. It is faster than searching the map linearly and can
avoid caching the token/pending endpoint mapping.

With this patch, the operations per second drop during adding node
period gets much better.

Before:
45K to 10K

After:
45k to 38K

(The number is measured with the streaming code skipping to send data to
rule out the streaming factor.)

Refs: #1223
2016-05-17 17:32:15 +08:00
Asias He
ffe91b5755 token_metadata: Do not assert in get_host_id
Throw an exception instead of assert.
2016-04-13 14:53:27 +08:00
Pekka Enberg
38a54df863 Fix pre-ScyllaDB copyright statements
People keep tripping over the old copyrights and copy-pasting them to
new files. Search and replace "Cloudius Systems" with "ScyllaDB".

Message-Id: <1460013664-25966-1-git-send-email-penberg@scylladb.com>
2016-04-08 08:12:47 +03:00
Asias He
f7fccc6efb locator: Fix get token from a range<token>
With a range{t1, t2}, if t2 == {}, the range.end() will contain no
value. Fix getting t2 in this case.

Fixes #911.
Message-Id: <4462e499d706d275c03b116c4645e8aaee7821e1.1456128310.git.asias@scylladb.com>
2016-02-23 14:29:26 +01:00
Asias He
3793bb7be1 token_metadata: Add get_endpoint_to_token_map_for_reading 2015-12-09 12:30:52 +08:00
Asias He
1cc7887ffb token_metadata: Do nothing if tokens is empty.
When replacing a node, we might ignore the tokens so that the tokens is
empty. In this case, we will have

   std::unordered_map<inet_address, std::unordered_set<token>> = {ip, {}}

passed to token_metadata::update_normal_tokens(std::unordered_map<inet_address,
std::unordered_set<token>>& endpoint_tokens)

and hit the assert

   assert(!tokens.empty());
2015-12-09 12:30:52 +08:00
Asias He
110a18987e token_metadata: Print Token changing ownership from
Needed by test.
2015-12-09 12:30:52 +08:00
Asias He
e9a4d93d1b storage_service: Fix added node not showing up in nodetool in status joining
The get_token_endpoint API should return a map of tokens to endpoints,
including the bootstrapping ones.

Use get_local_storage_service().get_token_to_endpoint_map() for it.

$ nodetool -p 7100 status

Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens  Owns    Host ID Rack
UN  127.0.0.1  12645      256     ?  eac5b6cf-5fda-4447-8104-a7bf3b773aba  rack1
UN  127.0.0.2  12635      256     ?  2ad1b7df-c8ad-4cbc-b1f1-059121d2f0c7  rack1
UN  127.0.0.3  12624      256     ?  61f82ea7-637d-4083-acc9-567e0c01b490  rack1
UJ  127.0.0.4  ?          256     ?  ced2725e-a5a4-4ac3-86de-e1c66cecfb8d  rack1

Fixes #617
2015-12-09 10:43:51 +08:00
Asias He
aaca88a1e7 token_metadata: Add print_pending_ranges for debug print
Signed-off-by: Pekka Enberg <penberg@scylladb.com>
2015-11-30 11:07:42 +02:00
Asias He
efda753c0c token_metadata: Implement pending_endpoints_for
It is used in storage_proxy::create_write_response_handler. The second
argument should be keyspace name instead of the keyspace class.

Refs: #539
2015-11-11 09:41:21 +02:00
Asias He
cb8b0eedfc token_metadata: Fix set_difference in calculate_pending_ranges
std::set_difference requires the container to be sorted.
2015-11-09 08:43:04 +08:00
Asias He
c90e9c97f5 token_metadata: Add add_moving_endpoint 2015-11-09 08:43:04 +08:00
Asias He
ada2466e18 token_metadata: Add clone_after_all_settled
Needed by storage_service::range_relocator::calculate_to_from_streams.
2015-11-09 08:43:04 +08:00
Vlad Zolotarov
b3504f9b1f locator::token_metadata: added topology::update_endpoint(ep) and update_topology(ep)
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-10-30 00:16:53 +02:00
Asias He
142f29483a token_metadata: Implement add_leaving_endpoint 2015-10-20 21:32:30 +08:00
Asias He
c96bc8bbd2 token_metadata: Implement calculate_pending_ranges 2015-10-20 21:32:14 +08:00
Asias He
b1c92f377d token_metadata: Add get_pending_ranges
One version returns only the ranges
   std::vector<range<token>>

Another version returns a map
   std::unordered_map<range<token>, std::unordered_set<inet_address>>
which is converted from
   std::unordered_multimap<range<token>, inet_address>

They are needed by token_metadata::pending_endpoints_for,
storage_service::get_all_ranges_with_strict_sources_for and
storage_service::decommission.
2015-10-13 15:45:55 +08:00
Asias He
b860f6a393 token_metadata: Add get_pending_ranges_mm
Helper for get_pending_ranges.
2015-10-13 15:45:55 +08:00
Asias He
3d0d02816d token_metadata: Add get_primary_ranges_for and get_primary_range_for
Given tokens, return ranges the tokens present. For example, with t1 and
t2, it returns ranges:

(token before t1, t1]
(token before t2, t2]
2015-10-13 15:45:55 +08:00
Asias He
542b1394d7 token_metadata: Add get_predecessor
It is used to get the previous token of this token in the ring.
2015-10-13 15:45:55 +08:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Amnon Heiman
6d875f1ec1 token_metadata: Add const when applicable
This patch adds a const version for get_datacenter_endpoints and
get_topology.

It modified the token iterator to use a const version of token_metadata
and it make first_token, first_token_index, tokens_end and ring_range to
be a const method.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-08-25 19:39:13 +03:00
Asias He
c42df5b40d token_metadata: Enable remove_from_moving 2015-08-04 20:39:33 +08:00
Asias He
9dc155a8ef token_metadata: Make get_endpoint_for_host_id return optional 2015-08-04 20:39:32 +08:00
Asias He
66f5cfaf39 token_metadata: Add remove_endpoint 2015-08-04 20:39:32 +08:00
Tomasz Grabiec
6882e6ca50 storage_proxy: Fix range splitting when split point is exlcluded by lower bound
If we had a range (x; ...] then x is excluded, but token iterator was
initialized with x. The splitting loop would exit prematurely because
it would detect that the token is outside the range.

The fix is to teach ring_range() to recognize this and always give
tokens which are not smaller than the range's lower bound.
2015-07-22 10:27:48 +02:00
Avi Kivity
5b00c72137 Merge "locator: network_topology_strategy" from Vlad
"This series aims to add the network_topology_strategy class.
It adds a few things that were missing in the token_metadata and
abstract_replication_strategy classes on the way:
   - Full topology (a.k.a. Topology) class implementation.
   - ring_range (a.k.a. TokenMetadata.ringIterator). The implementation
     is partial since we don't implement the "inclideMin" parameter.
   - endpoints caching in the abstract_replication_strategy.
   - Add-only Java's LinkedHashSet implementation - sequenced_set.

Then we add the network_topology_strategy class itself and the corresponding
unit test that validates the functionality of both the strategy class and of
the caching mechanism."

Conflicts:
	locator/token_metadata.hh
2015-06-29 18:54:40 +03:00
Vlad Zolotarov
61657bebe6 locator: token_metadata::update_normal_tokens() - call _topology.add_endpoint(endpoint)
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 14:35:47 +03:00
Vlad Zolotarov
306287a5d5 locator: added topology class implementation
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 14:35:47 +03:00
Amnon Heiman
b4d2180b9b Token metadata: Enhencing the API
This expose the _leaving_endpoints, _moving_endpoints and
_bootstrap_tokens.

It also changes the signature of get_endpoint_to_host_id_map_for_reading
from auto so the compiler will be able to resolve the method signature
outside of the cc file.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-06-25 11:48:58 +03:00
Vlad Zolotarov
ea274a0eda locator: Fix a typo in a token_metadata constructor
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-22 09:16:24 +02:00
Asias He
8467db11aa token_metadata: Print _sorted_tokens in debug
_sorted_tokens is used by replication code.
2015-06-04 17:12:10 +08:00
Asias He
0c98a4413f token_metadata: Add _leaving_endpoints and _moving_endpoints 2015-06-04 17:12:09 +08:00
Asias He
42a2f24c77 token_metadata: Add add_bootstrap_tokens and remove_bootstrap_tokens 2015-06-04 17:12:09 +08:00
Asias He
6b263e46eb token_metadata: Add is_member 2015-06-04 17:12:09 +08:00
Asias He
06a792d6be token_metadata: Add get_host_id and friends 2015-06-04 17:12:09 +08:00
Asias He
05939af7c7 token_metadata: Move update_host_id to source file 2015-06-01 11:33:11 +08:00
Asias He
4c23121b47 token_metadata: Add helper to print debug info for _token_metadata 2015-06-01 11:24:39 +08:00
Asias He
6bffee5e11 token_metadata: Add update_host_id
Use std::unordered_map instead of boost:bimap. std::unordered_map is
much much easier to use. It is a premature optimization to user bimap.
We can iterate the map to check if host_id is unique. Modification of
host_id is not a frequent or performance sensitive operation anyway.
2015-06-01 11:24:38 +08:00
Amnon Heiman
df7a06c8dc token_metadata expose the token and token mapping
This adds an API that expose the token to endpoint mapping and the token
that are associate with an address.

Both method will be used by the API to expose the tokens.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-27 15:29:49 +03:00
Asias He
4dfd445466 locator: Return optional for token_metadata::get_endpoint 2015-05-27 13:06:33 +08:00
Gleb Natapov
47ac784425 replication strategy
This patch converts (for very small value of 'converts') some
replication related classes. Only static topology is supported (it is
created in keyspace::create_replication_strategy()). During mutation
no replication is done, since messaging service is not ready yet,
only endpoints are calculated.
2015-04-02 16:16:39 +02:00