Commit Graph

19 Commits

Author SHA1 Message Date
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
ddfd417c13 locator: Make calculate_natural_endpoints take extra token_metadata parameter
When adding/removing a node, we need to use a temporary token_metadata
with pending tokens.
2015-10-13 15:45:55 +08:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Pekka Enberg
47b84d9660 locator: Fix minor formatting issues
Fix minor formatting issues introduced in commit
b8211c436b
("locator/abstract_replication_strategy: Add validate_options() helper").

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-09-01 09:45:15 +03:00
Pekka Enberg
b8211c436b locator/abstract_replication_strategy: Add validate_options() helper
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-31 11:54:56 +03:00
Pekka Enberg
cff9eb520b locator/abstract_replication_strategy: Add recognized_options() helper
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>
2015-08-31 11:54:31 +03:00
Amnon Heiman
3d27fa442b strategy: make some of the function const
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>
2015-08-25 19:39:13 +03: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
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
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
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
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
Gleb Natapov
2d409250f2 remove ad-hoc token_metadata creation 2015-06-15 12:51:09 +03:00
Vlad Zolotarov
a2594015f9 locator: futurize snitch creation
- Forbid explicit snitch creation with constructor.
   - Allow the creation of snitches only with locator::make_snitch() template
     function.

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

New in v4:
   - Make sure the snitch is stopped before it's destroyed when _snitch_is_ready
     is returned in an exceptional state.

New in v2:
   - Change snitch_ptr to be std::unique_ptr<i_endpoint_snitch>
   - abstract_replication_strategy::create_replication_strategy(): explicitly
     specify (template) types of create_object() parameters.
   - Re-arrange the loop in marge_keyspaces() so that lambdas that depend on
     "this" complete before there is a chance that "this" gets destroyed.
   - create_keyspace(): Don't add a new keyspace if a keyspace with this name
     already exists.
   - i_endpoint_snitch: added a stop() virtual method
      - Added a stop() pure virtual method.
      - Added an enum class snitch_state and a _state member initialized to snitch_state::initializing,
        added an assert() in a destructor requiring _state to become snitch_state::stopped,
        which should be set when stop() is complete.
   - rack_inferring_snitch: added a stop() method.
   - simple_snitch: added a stop() method.
   - Added stop() methods to abstract_replication_strategy and keyspace.
   - Updated database::stop() to wait for all keyspaces in _keyspaces to stop.
2015-06-09 15:33:38 +03:00
Asias He
4dfd445466 locator: Return optional for token_metadata::get_endpoint 2015-05-27 13:06:33 +08:00
Gleb Natapov
57ac231cd2 convert some snitch related classes 2015-04-21 18:24:35 +03:00
Gleb Natapov
d0a1e35a86 class factory
In Java it is possible to create an object by knowing its class name in
runtime. Replication strategies are created this way (I presume class
name comes from configuration somehow), so when I translated the code to
urchin I wrote replication_strategy_registry class to map a class name to
a factory function. Now I see that this is used in other places too (I
see that snitch class created in the same way), so instead of repeating
the same code for each class hierarchy that is created from its name in
origin this patch tries to introduce an infrastructure to do that easily.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2015-04-15 22:37:28 +03: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