Commit Graph

82 Commits

Author SHA1 Message Date
Nadav Har'El
e7ef6149d7 abstract_replication_strategy: add get_primary_ranges() method
Add a abstract_replication_strategy::get_primary_ranges() method, which is
very similar to the existing get_ranges(), except that only the "primary"
owner of each range will return it in its list.

This is needed for the "primary range" repair option, which asks to repair
only the primary range. This option is useful when the user plans to start
a repair on *all* nodes, we shouldn't repair the same token range multiple
times, so each range should be repaired by only one of the nodes.

abstract_replication_strategy::get_primary_ranges() is similar to Origin's
StorageService.getPrimaryRangesForEndpoint().

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-08-22 20:05:32 +03:00
Vlad Zolotarov
5f13ebad30 locator: create/reset_snitch(): improve the error message for a not-supported case
Fixes issue #124

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-16 12:55:33 +03:00
Vlad Zolotarov
6bffb9232e locator: added i_endpoint_snitch::reset_snitch()
Resets the global snitch with the new value

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:44:43 +03:00
Vlad Zolotarov
ef1c7deff4 locator: introduce i_endpoint_snitch::pause_io() and resume_io() methods
resume_io() is different from start() in that it won't try to read to configuration
and will only restart the periodic I/O task (if any).

This also means that resume_io() may not fail while start() will return an
exceptional future if it fails to read the configuration.

pause_io() is a counterpart of resume_io() - it stops the periodic I/O task (if any).
After it returns a ready future - snitch will not try to read any configuration until
either start() or resume_io() are called.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:38:04 +03:00
Vlad Zolotarov
b9389d4907 locator: Get rid of using the global distributed<snitch_ptr> from inside the snitch
- production_snitch_base: Store a distributed object pointer in the snitch.
   - i_endpoint_snitch::init_snitch_obj(): Set the distributed<> mentioned above.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:37:57 +03:00
Vlad Zolotarov
08ccffc701 locator::i_endpoint_snitch: added init_snitch_obj()
Initializes the given distributed<snitch_ptr> object but
not start()s the local snitch instances.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:33:26 +03:00
Vlad Zolotarov
f9b67f60c2 locator::i_endpoint_snitch: Remove not used _snitch_is_ready promise
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:21:25 +03:00
Vlad Zolotarov
a3cda17bfb locator::gossiping_property_file_snitch: simplify the start()
- Call for read_property_file() directly from the start().
   - Immediately return ready future from the start() for non-IO
     CPUs.
   - Remove the not needed invoke_on_all() invocations.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:21:18 +03:00
Vlad Zolotarov
0b17f2ad75 locator: simple and rack_inferring snitches: add "override" qualifier to get_name() method
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:19:06 +03:00
Vlad Zolotarov
c9f9d8164e locator::gossiping_property_file_snitch: make get_name() public as it should be
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:19:06 +03:00
Vlad Zolotarov
31dbca22d7 locator: snitch_base.hh: cleanups
- Fixed a typo.
   - snitch_ptr: make operator= return a reference to the parent object.
   - i_endpoint_snitch: set the _state in a default start() implementation.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-12 16:18:58 +03:00
Nadav Har'El
f74eedce7d replication: add get_ranges() function
This patch adds a method get_ranges() to replication-strategy.
It returns the list of token ranges held by the given endpoint.

It will be used by the replication code, which needs to know
in particular which token ranges are held by *this* node.

This function is the analogue of Origin's getAddressRanges().get(endpoint).
As in Origin, also here the implementation is not meant to be efficient,
and will not be used in the fast path.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-08-10 12:16:55 +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
793a4fabf9 locator: Drop the _logger suffix from logger name
We know it's a logger.
2015-08-04 10:49:38 +03:00
Nadav Har'El
b229f1bc61 Fix abstract_replication_strategy's logger
The existing code tried to make the logger a function-local static object.
This attempt is commendable, because it means the logger is only created
when first used - if used at all. But it doesn't play well with our logging
infrastructure, which *assumes* that all logger objects are created during
initialization, and register themselves, to make it possible to implement
the "--logger-log-level" and "--help-loggers" command line parameters.

So the logger needs to be a global object, not a function-local object.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-08-03 12:36:28 +03: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
Shlomi Livne
78b0554cce simple_strategy: coding convention fixes
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-07-19 12:45:25 +03:00
Shlomi Livne
c2ba0df3a9 calculate_natural_endpoints limit retuned ips by replication factor
calculate_natural_endpoints needs to limit the list of returned
addresses by the replication_factor current impl will return all nodes
in cluster

for reference origins code:

while (endpoints.size() < replicas && iter.hasNext())
{
    InetAddress ep = metadata.getEndpoint(iter.next());
    if (!endpoints.contains(ep))
        endpoints.add(ep);
    }
}

Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-07-17 10:33:11 +02:00
Tomasz Grabiec
cce2c648c5 Merge branch 'dev/gleb/for_urchin' from seastar-dev.git
Beginning of read implementation for range queries from Gleb.
2015-07-15 12:53:43 +03:00
Avi Kivity
99a15de9e5 logger: de-thread_local-ize logger
The logger class constructor registers itself with the logger registry,
in order to enable dynamically setting log levels.  However, since
thread_local variables may be (and are) initialized at the time of first
use, when the program starts up no loggers are registered.

Fix by making loggers global, not thread_local.  This requires that the
registry use locking to prevent registration happening on different threads
from corrupting the registry.

Note that technically global variables can also be initialized at the
point of first use, and there is no portable way for classes to self-register.
However this is the best we can do.
2015-07-14 17:18:11 +03:00
Gleb Natapov
7fbe154a26 token_metadata: add include_min handling in tokens_iterator
Sometimes it is needed to include minimum token during wrap around while
iterating over all tokens. This support was omitted in initial
tokens_iterator implementation, add it now.
2015-07-14 12:22:37 +03:00
Calle Wilund
806fc04b37 token_metadata.hh : implement get_all_endpoints
+ add number_of_endpoints()
2015-07-08 10:50:46 +02:00
Vlad Zolotarov
f8d2679728 locator: add a virtual get_name() method to snitch classes
Add a pure virtual i_endpoint_snitch::get_name() method that
should return the corresponding Java-name of a snitch
class instance.

Patch is also available on dev:/snitch-get-name-v1

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-07-06 10:11:30 +02:00
Gleb Natapov
b175d276ab implement get_natural_endpoints for local_strategy
abstract_replication_strategy::get_natural_endpoints()
does some token calculations before calling strategy specific
calculate_natural_endpoints(), but system table may be read before
token metadata (needed for token calculations) is ready. Fix that by
specializing local_strategy's get_natural_endpoints() to skip token
calculation.
2015-07-06 09:57:14 +02:00
Vlad Zolotarov
fa60555ddd locator: network_topology_strategy: make get_datacenters() public
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-07-02 13:01:00 +03:00
Vlad Zolotarov
888a33f9d2 locator: add a replication strategy type field to abstract_replication_strategy
This is meant to exclude the exceptions throwing when we want to
branch on a specific instance type (Java's instanceof call).

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-07-02 12:26:34 +03: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
9a6e6b4ae1 locator: added network_topology_strategy class
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v2:
   - Use new location of a sequenced_set.
   - Indentation.
   - Use all caps in a FIXME word.
2015-06-29 18:50:49 +03:00
Vlad Zolotarov
5a19187802 locator: simple_strategy: use ring_range and sequenced_set in calculate_natural_endpoints()
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v2:
   - Use new location of sequenced_set.
2015-06-29 18:45:09 +03:00
Vlad Zolotarov
310f4b6724 locator: abstract_replication_strategy: added a counter for natural endpoints cache hits
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 18:43:58 +03:00
Vlad Zolotarov
d03122fdaf locator: abstract_replication_strategy: added natural endpoints caching
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 18:43:58 +03:00
Vlad Zolotarov
314710b766 locator: abstract_replication_strategy: added replication_strategy_logger
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 18:43:58 +03:00
Vlad Zolotarov
4b0cec624e locator: added abstract_replication_strategy::validate_replication_factor()
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 18:43:58 +03:00
Vlad Zolotarov
f3dbdf758f locator: abstract_replication_strategy: Comment out an unused member
_keyspace back reference is not used at the moment.
Not deleting since we may need it when we add more code (quite soon).

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 18:43:58 +03:00
Vlad Zolotarov
214343036e locator: token_metadata: added ring_range() method
Returns an iterable range object to traverse the token ring

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v2:
   - Use boost::iterator_range instead of tokens_range class.
   - Make tokens_iterator inherit from std::iterator<std::input_iterator_tag, token>.
2015-06-29 18:43:45 +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
b9631f5ff0 locator: token_metadata: added a get_topology() method
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
Vlad Zolotarov
ebce44e20c locator: abstract_replication_strategy::abstract_replication_strategy(): remove a class name padding
We are registering short names instead

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 14:35:47 +03:00
Vlad Zolotarov
d17494a7e3 locator: simple_strategy: register a short name and optimize get_replication_factor()
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 14:35:47 +03:00
Vlad Zolotarov
7e73afccab locator: local_strategy: register a short name creator
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 14:35:47 +03:00
Vlad Zolotarov
e47e0dcde9 locator: moved endpoint_dc_rack from db::system_keyspace to locator namespace
This is meant to resolve to dependecy loop between token_metadata.hh
and system_keyspace.hh.

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
67bb1ba132 gossiping_property_file_snitch: Register creators for all parameters set options.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-22 23:18:40 +03:00
Vlad Zolotarov
3520d4de10 locator: introduce a global distributed<snitch_ptr> i_endpoint_snitch::snitch_instance()
Snitch class semantics defined to be per-Node. To make it so we
introduce here a static member in an i_endpoint_snitch class that
has to contain the pointer to the relevant snitch class instance.

Since the snitch contents are not always pure const it has to be per
shard, therefore we'll make it a "distributed". All the I/O is going
to take place on a single shard and if there are changes - they are going
to be propagated to the rest of the shards.

The application is responsible to initialize this distributed<shnitch>
before it's used for the first time.

This patch effectively reverts most of the "locator: futurize
snitch creation" a2594015f9 patch - the part that modifies the
code that was creating the snitch instance. Since snitch is
created explicitly by the application and all the rest of the code
simply assumes that the above global is initialized we won't need
all those changes any more and the code will get back to be nice and simple
as it was before the patch above.

So, to summarize, this patch does the following:
   - Reverts the changes introduced by a2594015f9 related to the fact that
     every time a replication strategy was created there should have been created
     a snitch that would have been stored in this strategy object. More specifically,
     methods like keyspace::create_replication_strategy() do not return a future<>
     any more and this allows to simplify the code that calls it significantly.
   - Introduce the global distributed<snitch_ptr> object:
      - It belongs to the i_endpoint_snitch class.
      - There has been added a corresponding interface to access both global and
        shard-local instances.
      - locator::abstract_replication_strategy::create_replication_strategy() does
        not accept snitch_ptr&& - it'll get and pass the corresponding shard-local
        instance of the snitch to the replication strategy's constructor by itself.
      - Adjusted the existing snitch infrastructure to the new semantics:
         - Modified the create_snitch() to create and start all per-shard snitch
           instances and update the global variable.
         - Introduced a static i_endpoint_snitch::stop_snitch() function that properly
           stops the global distributed snitch.
         - Added the code to the gossiping_property_file_snitch that distributes the
           changed data to all per-shard snitch objects.
         - Made all existing snitches classes properly maintain their state in order
           to be able to shut down cleanly.
         - Patched both urchin and cql_query_test to initialize a snitch instance before
           all other services.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v6:
   - Rebased to the current master.
   - Extended a commit message a little - the summary.

New in v5:
   - database::create_keyspace(): added a missing _keyspaces.emplace()

New in v4:
   - Kept the database::create_keyspace() to return future<> by Glauber's request
     and added a description to this method that needs to be changed when Glauber
     adds his bits that require this interface.
2015-06-22 23:18:31 +03:00
Avi Kivity
acb56b580f abstract_replication_strategy: work around missing _snitch in cql_query_test 2015-06-22 15:28:22 +03:00
Avi Kivity
de26b3a75c Merge "Update system keyspace rs to local_strategy" from Shlomi
"local_strategy is used for system keyspaces to allow query / update of
tables without the need to have snitch or token metadata avilable

without this patch updating of system tables (e.g. insert system.local ...)
fails."
2015-06-22 14:27:57 +03:00
Shlomi Livne
afe0f7dc85 Add support for local_strategy
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-06-22 13:19:37 +03:00