Commit Graph

135 Commits

Author SHA1 Message Date
Avi Kivity
5bce7b84d0 Merge seastar upstream 2015-06-16 17:12:54 +03:00
Avi Kivity
56abdc4632 httpd: implement stop() for http_server
Aborts active accept() calls and shuts down.  Active connections are
still leaked.
2015-06-16 12:02:58 +03:00
Avi Kivity
8f9d3dc9b2 httpd: reformat main.cc 2015-06-16 12:02:32 +03:00
Avi Kivity
b3b553821f Merge branch 'master' of github.com:cloudius-systems/seastar into db
Contains patch from Amnon to update the calls to http set_routes().
2015-04-26 13:16:35 +03:00
Amnon Heiman
f06c12e031 http: fix crash due to set_routes() not managing lifetime correctly
When using the set_routes with the registry builder, the shared_ptr of
the registry builder should be captured.

In the original implementation the api_registery_builder captured this
parameter, but as the shared_ptr was not captured it was deleted,
causing the http to crash when running in debug.

In this implementation the method that use the registry creates a lambda
function and inside it calls the set_api_doc method, this allows to
catch the shared_ptr so it lives until the function complete.

It also replaces the c style cast to static_cast and add a FIXME note to
the routes implementation, that handlers should be deleted to prevent
memory leak.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-04-26 13:09:26 +03:00
Avi Kivity
74edad888f Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-04-22 10:12:16 +03:00
Takuya ASADA
991b77863d Use namespace on timer_set to prevent conflict with OSv's timer_set
Since we have same header on OSv too, we need to prevent conflict.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-04-19 10:33:36 +03:00
Avi Kivity
4fca9734c9 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-04-05 20:03:16 +03:00
Amnon Heiman
399f3d29c5 httpd main using the http_server_control to start the server
Use the http_server_control to start and configure the server and use
the api_registry_builder to register the demo api.

After the change a call to:

http://localhost:10000/api-doc/ will return the swagger doc file and a
call to:

http://localhost:10000/api-doc/demo/ will return the demo swagger file

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-04-05 11:39:56 +03:00
Amnon Heiman
dca4b25e8b http: Allows function handler to return future
Function handler in general and json function in particular are the
easiest way to add logic to to handler.

While in some cases the method can return immediately, there are cases
when it is required to perform an async operation, to support those
cases, the function handler was modified to use future.

If it receives an old style function, it would wrap the results in a
make_ready_future. This you could still assign a function like:

new function_handler([](const_req req) {
        return "hello";
    });

It would no also support a function that return a future json so it is
no possible to assign logic like:
new function_handler([](std::unique_ptr<request> req) {
return make_ready_future<json::json_return_type>("json-future");
});

For the future case note that auto-boxing still works, although you now
need to use make_ready_future.

The json_path was also modified to accept the new kind of function, to
support the common case of route definition based on the code
generation.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-04-03 13:12:28 +03:00
Avi Kivity
1ca426e49b Merge branch 'master' of github.com:cloudius-systems/seastar into urchin
Conflicts:
	configure.py
2015-04-03 00:03:15 +03:00
Amnon Heiman
006b061aba Adding hello world swagger demo
This demonstrate how to use a swagger definition file to create an API.

The swagger file demo.json define one api called hello_world, it has
both query and path parameters and return an object as a result.

The handler implementation simply places the given parameters in the
return object.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-30 15:38:41 +03:00
Amnon Heiman
2ff0f41cfb http adding file handler
File handlers support reading local file and return it as the result
for the http request.

There are two kind of handler, a file handler will return a specific
file when called. A directory handler expect to find a path parameter
called 'path' and would concatinate this parameter to the direcoty path.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-30 15:38:41 +03:00
Amnon Heiman
be33b31ae2 Httpd Adding function handlers
Most of the time, implementing an http handler consist of a small amount
of logic.

Function handlers are a simplified way of adding such a logic, they
accept a lambda expression of various types and eliminate the need to
create a type for the handlers.

The prefered way of creating a handler is by using the
json_request_function, it would use auto-boxing to return a json object.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-30 15:38:41 +03:00
Amnon Heiman
950d921df3 Http server handlers to use future
The http server handlers can sometimes need to perform async operation,
specifically, when reading files from the disk.  To support async
behavior the handlers handle function will return a future, that will be
propagate back, when the future will be ready it will return the reply
to be sent.

When switching from direct function call to future, there is also a need
to switch from references to pointers.

Note that while the request will be discarded, the reply will be
propagate back via the future to the caller.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-30 15:38:41 +03:00
Avi Kivity
9639a7207e Merge branch 'master' of github.com:cloudius-systems/seastar into db
Conflicts:
	test.py
2015-03-10 13:06:02 +02:00
Amnon Heiman
427a6165b3 using the routes and request from the http directory
This use the routes and the reqeuest found in the http directory and
move all files but main to the http directory

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-08 21:55:57 +02:00
Amnon Heiman
100a667ab8 httpd to use the reply class and support error code 2015-03-08 21:55:57 +02:00
Amnon Heiman
8a760f23f9 Break the httpd implementation to a library/main
We would like to extend the httpd capabilities and use it for the API
implementation.

The first step is to make it a library with main that calls an instanse.
This break the implementation to a header file, implementation and main,
that simply calls the implementation.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-08 21:55:57 +02:00
Amnon Heiman
722bf0fe1f request_parser is missing pragma once 2015-03-08 21:55:57 +02:00
Avi Kivity
5902243dc5 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Global adjustment due to the removal of future<>::rescue().
2015-03-05 11:00:11 +02:00
Tomasz Grabiec
83963b23d3 Replace rescue() usages with then_wrapped()
They are pretty much the same. This change removes rescue().
2015-03-04 17:34:59 +01:00
Raphael S. Carvalho
89ec1f8f6a slab: Add reclaimer functionality
Basic explanation of the reclaimer algorithm:
- Each slab page has a descriptor containing information about it, such as
refcnt, vector of free objects, link into LRU, etc.
- The LRU list will only contain slab pages which items are unused, so as
to make the reclaiming process faster and easier. Maintaining the LRU of slab
pages has a performance penalty of ~1.3%. Shlomi suggested an approach where
LRU would no longer exist and timestamp would be used instead to keep track of
recency. Reclaimer would then iterate through all slab pages checking for an
unused slab page with the lowest timestamp.
- Reclaimer will get the least-recently-used slab page from the LRU list,
do all the management stuff required, and iterate through the page erasing any
of the items there contained. Once reclaimer was called, it's likely that slab
memory usage is calibrated, thus slab pages shouldn't be allocated anymore.
- Reclaimer is enabled by default but can be disabled by specifying the slab
size using the application parameter --max-slab-size.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-03-04 17:40:58 +02:00
Avi Kivity
d39c844ea3 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Conflicts:
	configure.py
	database.cc (added missing include)
	utils/serialize.hh (added missing inlines)
2015-02-26 17:57:18 +02:00
Raphael S. Carvalho
aa6d850228 memcached: Integrate slab allocator
* Item structure was changed to work with slab, where its last field
is used to access key, value, and ascii prefix, respectively.
* Item structured was worked to have a smaller footprint. It was
reduced from 104 bytes to 72 bytes.
* Reclaimer was temporarily disabled.
* Global LRU was removed from the cache. Now LRU eviction is done
on a per-slab-class basis, whenever the slab allocator runs out of
slab pages.
* Fragmentation issue is naturally solved with the slab algorithm,
where slab classes have chunks of the same size.
2015-02-25 19:29:36 -03:00
Raphael S. Carvalho
66117b2697 memcached: Expiry should be stored as a 32-bit value
Expiration time is a 32-bit value as specified by memcached protocol.
Thus, no need to store it as a 64-bit value. When the value is needed,
convert it to the target type. Change intended to save space from
item structure.
In addition, there is no need to insert an entry into _alive when
expiration time is zero, meaning item will never expire.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-25 19:29:36 -03:00
Raphael S. Carvalho
b461b42ce8 memcached: Revert flashcached
Flashcached integration was done relying on certain similarities between
flashcached and memcached. Old assumptions no longer hold.
As a result, the current code is terrible to integrate the slab allocator
into it, while keeping flashcached alive.
This patch reverts flashcached from memcached. It should be re-integrated
in the future, but definitely in a better way.
2015-02-25 19:29:36 -03:00
Avi Kivity
83430355c2 Merge branch 'master' of github.com:cloudius-systems/seastar into db
LICENSE moved to LICENSE.seastar, since (at least for now) urchin is
not open source.

Conflicts:
	apps/seastar/main.cc
2015-02-22 16:23:59 +02:00
Avi Kivity
7f8d88371a Add LICENSE, NOTICE, and copyright headers to all source files.
The two files imported from the OSv project retain their original licenses.
2015-02-19 16:52:34 +02:00
Avi Kivity
7c5755e76c Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-02-18 20:01:12 +02:00
Gleb Natapov
f7cade107b seawreck: abort on a connection error 2015-02-18 16:52:56 +02:00
Avi Kivity
8a94845e78 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-02-17 12:40:20 +02:00
Gleb Natapov
9ee05fdddc seawreck: exit after test is done 2015-02-16 09:54:08 +02:00
Avi Kivity
39596a0334 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Conflicts:
	configure.py
2015-02-15 09:58:29 +02:00
Avi Kivity
a258f290b5 seawreck: fix include 2015-02-12 14:43:12 +02:00
Avi Kivity
ebc2ebbf12 Upgrade http_client to an application, not a test
and rename it to 'seawreck', after wrk.
2015-02-12 14:21:44 +02:00
Raphael S. Carvalho
20151b7b2a memcached: capture port by value
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-12 10:00:37 +02:00
Raphael S. Carvalho
c725014614 memcached: add option to listen on a different port
useful when testing multiple memcached servers.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-10 19:27:43 +02:00
Avi Kivity
ee58c77008 httpd: fix unbounded memory use in eerror handling
httpd uses recursion for its read loop:

  future<> read() {
     _read_buf.consume().then([] {
        ...
        if more work:
           return read();
     });
  }

However, after error handling was added, it looks like this:

  future<> read() {
     _read_buf.consume().then([] {
        ...
        if more work:
           return read();
     }).rescue(...);
  }

The problem is that rescue() is called for every iteration of the loop,
instead of for the loop in its entirety.  This means that a rescue
continuation is allocated for every processed request, but they will only
be called after the entire loop terminates.  This results in tons of
allocated memory.

Fix by moving error handling to the end of the loop (and incidentally using
do_until() instead of recursion).
2015-02-10 12:00:32 +02:00
Tomasz Grabiec
911c514a70 Merge branch 'master' of github.com:cloudius-systems/seastar 2015-02-09 10:11:15 +01:00
Avi Kivity
4b28eb638f Merge branch 'asias/tcp_v1' of github.com:cloudius-systems/seastar-dev
tcp queue from Asias: "Contains both fixes and improvemnts".
2015-02-07 20:20:57 +02:00
Raphael S. Carvalho
2195f77879 memcached: stats: rename evicted to evictions
Change for compliance with stock memcached.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-07 19:57:19 +02:00
Asias He
2289b03354 httpd: Fix RST handling
I found wrk sometimes sends RST instead a FIN to close a connection. In
this case, we will reset the connection and go to CLOSED state. However
httpd will not delete this, so we will have leaked connections in CLOSED
state.

Fix by handling the exception and sending an empty response as we do in
EOF case. Here we do not pass the exception to upper layer again,
otherwise httpd will be very noise.
2015-02-05 16:57:58 +08:00
Tomasz Grabiec
5049ed8ae6 Merge branch 'master' of github.com:cloudius-systems/seastar 2015-01-30 09:34:58 +01:00
Avi Kivity
24d5c319a3 httpd: return Server and Date headers
Required by some benchmarks.
2015-01-27 18:57:59 +02:00
Avi Kivity
d5540bf3da Merge branch 'master' into db 2015-01-27 15:09:31 +02:00
Gleb Natapov
7a92efe8d1 core: add local engine accessor function
Do not use thread local engine variable directly, but use accessor
instead.
2015-01-27 14:46:49 +02:00
Avi Kivity
0f14fdab68 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-01-20 13:03:58 +02:00
Gleb Natapov
57bcec15c7 memcached: flush cache during destruction.
Also add assert to item's cancel() function. It cannot be called after
cache is flushed.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
2015-01-15 18:25:30 +02:00
Avi Kivity
cf8161b532 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-01-14 17:02:12 +02:00