Introduce a subscribers_list class that exposes 3 methods:
- push_back(s) - adds a new element s to the back of the list
- remove(s) - removes an element s from the list
- for_each(f) - invoke f on each element of the list
- make a subscriber_list store shared_ptr to a subscriber
to allow removing (currently it stores a naked pointer to the object).
subscribers_list allows push_back() and remove() to be called while
another thread (e.g. seastar::async()) is in the middle of for_each().
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
New in v2:
- Simplify subscribers_list::remove() method.
- load_broadcaster: inherit from enable_shared_from_this instead
of async_sharded_service.
This snitch in addition to what EC2Snitch does registers
a reconnectable_snitch_helper that will make messenger_service
connect to internal IPs when it connects to the nodes in the same
data center with the current Node.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
New in v4:
- Added dual license in newly added files.
New in v3:
- Returned the Apache license.
New in v2:
- Update the license to the latest version. ;)
reconnectable_snitch_helper implements i_endpoint_state_change_subscriber
and triggers reconnect using the internal IP to the nodes in the
same data center when one of the following events happen:
- on_join()
- on_change() - when INTERNAL_IP state is changed
- on_alive()
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
New in v4:
- Added dual license for newly added files.
New in v3:
- Fix reconnect() logic.
- Returned the Apache license.
- Check if the new local address is not already stored in the cache.
- Get rid of get_ep_addr().
New in v2:
- Update the license to the latest version. ;)
Added load_config() function that reads AWS info and property file
and distributes the read values on all shards.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Make production_snitch_base constructor signature consistent with
the rest of production snitches.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
A non-empty default value of a configuration file name was preventing
the db::config::get_conf_dir() to kick in when a default snitch constructor
was used (this is the way it's always used from scylla).
Fixes issue #459
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
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.
Given the current token_metadata and the new token which will be
inserted into the ring after bootstrap, calculate the ranges this new
node will be responsible for.
This is needed by boot_strapper::bootstrap().
This snitch will read the EC2 availability zone and set the DC
and RACK as follows:
If availability zone is "us-east-1d", then
DC="us-east" and RACK="1d".
If cassandra-rackdc.properties contains "dc_suffix" field then
DC will be appended with its value.
For instance if dc_suffix=_1_cassandra, then in the example above
DC=us-east_1_cassandra
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
- Move property file parsing code into production_snitch_base class.
- Make a parsing code more general:
- Save the parsed keys in the hash table.
- Check only two types of errors:
- Repeating keys.
- Add a set of all supported keys and add the check for a key
being supported.
- Added production_snitch_base.cc file.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Add a helper function for obtaining a vector of supported replication
strategy options. This is needed for validation.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
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>
This patch adds const for some of the methods that are not actually
changing the object content.
This is useful when using a const reference to the object.
calculate_natural_endpoints and has_sufficient_replicas where set as
const. The override was added where it was missing.
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
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>
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>
- 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>
Initializes the given distributed<snitch_ptr> object but
not start()s the local snitch instances.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
- 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>