Commit Graph

29 Commits

Author SHA1 Message Date
Pavel Emelyanov
67b63768e4 api: Capture and use db in cache_service handlers
Now the sharded<database>& argument is there, so it can replace ctx one
on handlers lambdas.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2025-08-26 11:50:11 +03:00
Pavel Emelyanov
596d4640ff api: Add sharded<database>& arg to set_cache_service()
The reference is already available in set_server_column_family(), pass
it further so that "cache" handlers are able to use it (next patch).

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2025-08-26 11:49:35 +03:00
Pavel Emelyanov
ffd25f0c16 api: Patch callers of map_reduce_cf(_raw)? to use sharded<database>
There are some of them left that still pass http_context. These handlers
will eventually get their captured sharded database reference, but for
now make them explicitly use one from context. This will allow to
de-templatize map_reduce_cf... helpers making the code simpler.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2025-08-18 11:43:55 +03:00
Avi Kivity
f3eade2f62 treewide: relicense to ScyllaDB-Source-Available-1.0
Drop the AGPL license in favor of a source-available license.
See the blog post [1] for details.

[1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
2024-12-18 17:45:13 +02:00
Pavel Emelyanov
456dbc122b api: Unset cache_service endpoints on stop
They currently stay registered long after the dependent services get
stopped. There's a need for batch unsetting (scylladb/seastar#1620), so
currently only this explicit listing :(

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-07-24 18:51:32 +03:00
Pavel Emelyanov
d8009ed843 api/cache_service: Don't use database to perform map+reduce on
The sharded<database> is used as a map_reduce0() method provider,
there's no real need in database itself. Simple smp::map_reduce()
would work just as good.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>

Closes scylladb/scylladb#19364
2024-06-21 19:47:25 +03:00
Kefu Chai
c03141b4b2 api: do not include unused headers
these unused includes were identified by clangd. see
https://clangd.llvm.org/guides/include-cleaner#unused-include-warning
for more details on the "Unused include" warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-06-13 09:32:51 +08:00
Pavel Emelyanov
def5fed619 api: Fix stats reported for row cache
Here are three endpoints in the api/cache_service that report "metrics"
for the row cache and the values they return

    - entries:  number of partitions
    - size:     number of partitions
    - capacity: used space

The size and capacity seem very inaccurate.

Comment says, that in C* the size should be weighted, but scylla doesn't
support weight of entries in cache. Also, capacity is configurable via
row_cache_size_in_mb config option or set_row_cache_capacity_in_mb API
call, but Scylla doesn't support both either.

This patch suggestes changing return values for size and capacity endpoints.

Despite row cache doesn't support weights, it's natural to return
used_space in bytes as the value, which is more accurate to what "size"
means rather than number of entries.

The capacity may return back total memory size, because this is what
Scylla really does -- row cache growth is only limited by other memory
consumers, not by configured limits.

fixes: #9418

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>

Closes scylladb/scylladb#17724
2024-03-12 13:44:59 +02:00
Kefu Chai
063b3be8a7 api: reference httpd::* symbols like 'httpd::*'
it turns out we have `using namespace httpd;` in seastar's
`request_parser.rl`, and we should not rely on this statement to
expose the symbols in `seatar::httpd` to `seastar` namespace.
in this change,

* api/*.hh: all httpd symbols are referenced by `httpd::*`
  instead of being referenced as if they are in `seastar`.
* api/*.cc: add `using namespace seastar::httpd`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-07 18:21:03 +08:00
Kefu Chai
5522080f80 api: s/request/http::request/
seastar::httpd::request was deprecated in favor of `seastar::http::request`
since bdd5d929891d2cb821eca25896e25ed4ff658b7a.
so let's use the latter. this change also silences the warning of:

```
/home/kefu/dev/scylladb/api/authorization_cache.cc: In function ‘void api::set_authorization_cache(http_context&, seastar::httpd::routes&, seastar::sharded<auth::service>&)’:
/home/kefu/dev/scylladb/api/authorization_cache.cc:19:104: error: ‘using seastar::httpd::request = struct seastar::http::request’ is deprecated: Use http::request instead [-Werror=deprecated-declarations]
   19 |     httpd::authorization_cache_json::authorization_cache_reset.set(r, [&auth_service] (std::unique_ptr<request> req) -> future<json::json_return_type> {
      |                                                                                                        ^~~~~~~
```

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-07 14:03:42 +08:00
Kefu Chai
0cb842797a treewide: do not define/capture unused variables
these warnings are found by Clang-17 after removing
`-Wno-unused-lambda-capture` and '-Wno-unused-variable' from
the list of disabled warnings in `configure.py`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-15 22:57:18 +02:00
Avi Kivity
fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00
Avi Kivity
bbad8f4677 replica: move ::database, ::keyspace, and ::table to replica namespace
Move replica-oriented classes to the replica namespace. The main
classes moved are ::database, ::keyspace, and ::table, but a few
ancillary classes are also moved. There are certainly classes that
should be moved but aren't (like distributed_loader) but we have
to start somewhere.

References are adjusted treewide. In many cases, it is obvious that
a call site should not access the replica (but the data_dictionary
instead), but that is left for separate work.

scylla-gdb.py is adjusted to look for both the new and old names.
2022-01-07 12:04:38 +02:00
Avi Kivity
a55b434a2b treewide: extent copyright statements to present day 2021-06-06 19:18:49 +03:00
Pavel Emelyanov
83fe0427d2 api/cache_service: Relax getting partitions count
This patch has two goals -- speed up the total partitions
calculations (walking databases is faster than walking tables),
and get rid og row_cache._partitions.size() call, which will
not be available on new _partitions collection implementation.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Message-Id: <20200423133900.27818-1-xemul@scylladb.com>
2020-04-23 17:47:58 +02:00
Pavel Emelyanov
6ede253479 api/cache_service: Fix get_row_capacity calculation
Current code gets table->row_cache->cache_tracker->region and sums
up the region's used space for all tables found.

The problem is that all row_cache-s share the same cache_tracker
object from the database, thus the resulting number is not correct.

Fix this by walking cache_tracker-s from databases instead.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Message-Id: <20200423133755.27187-1-xemul@scylladb.com>
2020-04-23 17:05:52 +03:00
Tomasz Grabiec
62c76abf71 row_cache: Rename num_entries() to partitions() for clarity 2017-07-04 13:55:06 +02:00
Amnon Heiman
a4be7afbb0 API: cache_capacity should use uint for summing
Using integer as a type for the map_reduce causes number over overflow.

Fixes #1801

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
Message-Id: <1479299425-782-1-git-send-email-amnon@scylladb.com>
2016-11-16 13:55:46 +01:00
Calle Wilund
0181fc8159 api::cache_service: Add (dummy) calls for key&counter metrics 2016-11-08 12:22:04 +00:00
Amnon Heiman
ad34f80e6f API: change cache_service, column_family and storage_proxy to rate
object

The API would expose now the rate_moving_average and
rate_moving_average_and_histogram.

The old end points remains for the transition period, but marked as
depricated.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2016-05-17 11:56:52 +03: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
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Amnon Heiman
12a92939bf API: cache service save priod time to return 0
We do not save the cache, so the get for save priod in second should
return 0, to indicate never like it is done in origin.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-09-10 18:21:40 +03:00
Amnon Heiman
1238240eea API: Return 0 for key and counter cache's metrics
Until we'll support key and counter cache, it is reasonable to return 0
for their statistic and sizes.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-09-10 12:42:14 +03:00
Amnon Heiman
fe9f7b4d04 API: Call unimplemented for stub API methods that are stubed
The API contains stub API methods, this adds a call to unimplemented
method in each of the stubed method that is not implemented.

The return remains the same to help the compiler deduce the return type
of the lambda function.

After this patch a call to an unimplemented API function will return
500.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-09-08 19:14:30 +03:00
Amnon Heiman
a43b3badaf API: Add row related method to cache_service API
This adds the implementation for get_row_hits, get_row_requests,
get_row_hit_rate, row_enries, row_size and row_capacity

The implementation is based on the column-family map reduce

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-08-17 20:09:07 +03:00
Amnon Heiman
b6fa2187af Cleanup the cache_service API
This replaces the void method in the cache service API to be json_void

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-07-15 14:20:28 +03:00
Amnon Heiman
a64c4da4ea Adding stub implementation for the chace service metrics
This adds a stub implementation for the cache service metrics for key,
row and counters.

A call to the API would return the correct type but with a stub value.
After this patch the following url will be available:
/cache_service/metrics/key/capacity
/cache_service/metrics/key/hits
/cache_service/metrics/key/requests
/cache_service/metrics/key/hit_rate
/cache_service/metrics/key/size
/cache_service/metrics/key/entries
/cache_service/metrics/row/capacity
/cache_service/metrics/row/hits
/cache_service/metrics/row/requests
/cache_service/metrics/row/hit_rate
/cache_service/metrics/row/size
/cache_service/metrics/row/entries
/cache_service/metrics/counter/capacity
/cache_service/metrics/counter/hits
/cache_service/metrics/counter/requests
/cache_service/metrics/counter/hit_rate
/cache_service/metrics/counter/size
/cache_service/metrics/counter/entries

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-07-01 10:03:44 +03:00
Amnon Heiman
4258b005db API: Adding stub implementation for the cache service
This adds a stub implementation for the cache_service. It also register
the API doc.
The cache_service doc will be available at:
http://localhost:10000/api-doc/cache_service/

The stub implementation returns the correct value type with stubbed
values.

After this patch the following path will be available:
/cache_service/row_cache_save_period
/cache_service/key_cache_save_period
/cache_service/counter_cache_save_period
/cache_service/row_cache_keys_to_save
/cache_service/key_cache_keys_to_save
/cache_service/counter_cache_keys_to_save
/cache_service/invalidate_key_cache
/cache_service/invalidate_counter_cache
/cache_service/row_cache_capacity
/cache_service/key_cache_capacity
/cache_service/counter_cache_capacity
/cache_service/save_caches

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-06-24 14:30:08 +03:00