Skip to content

Commit

Permalink
Merge pull request #583 from apache/feature/scheduled_event_on_event_…
Browse files Browse the repository at this point in the history
…thread

Feature/scheduled event on event thread
  • Loading branch information
pnoltes authored Jul 11, 2023
2 parents f9e2875 + 95e6739 commit 456de19
Show file tree
Hide file tree
Showing 48 changed files with 3,133 additions and 334 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PointerAlignment: Left
SpacesBeforeTrailingComments: 1
SortIncludes: true
---
#Include regroup disabled by default.
#Include regroup disabled by default.
#IncludeBlocks: Regroup
#IncludeCategories:
##gtest headers
Expand Down
20 changes: 10 additions & 10 deletions bundles/logging/log_admin/gtest/src/LogAdminTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ TEST_F(LogBundleTestSuite, NrOfLogServices) {
EXPECT_EQ(1, control->nrOfLogServices(control->handle, nullptr)); //default the framework log services is available

//request "default" log service
long trkId1 = celix_bundleContext_trackService(ctx.get(), CELIX_LOG_SERVICE_NAME, NULL, NULL);
long trkId1 = celix_bundleContext_trackService(ctx.get(), CELIX_LOG_SERVICE_NAME, nullptr, nullptr);
EXPECT_EQ(2, control->nrOfLogServices(control->handle, nullptr));

//request "default" log service -> already created
long trkId2 = celix_bundleContext_trackService(ctx.get(), CELIX_LOG_SERVICE_NAME, NULL, NULL);
long trkId2 = celix_bundleContext_trackService(ctx.get(), CELIX_LOG_SERVICE_NAME, nullptr, nullptr);
EXPECT_EQ(2, control->nrOfLogServices(control->handle, nullptr));

//request a 'logger1' log service
Expand Down Expand Up @@ -224,7 +224,7 @@ TEST_F(LogBundleTestSuite, SinkLogControl) {

TEST_F(LogBundleTestSuite, LogServiceControl) {
//request "default" log service
long trkId1 = celix_bundleContext_trackService(ctx.get(), CELIX_LOG_SERVICE_NAME, NULL, NULL);
long trkId1 = celix_bundleContext_trackService(ctx.get(), CELIX_LOG_SERVICE_NAME, nullptr, nullptr);
celix_framework_waitForEmptyEventQueue(fw.get());
EXPECT_EQ(2, control->nrOfLogServices(control->handle, nullptr));

Expand Down Expand Up @@ -328,7 +328,7 @@ TEST_F(LogBundleTestSuite, LogServiceAndSink) {

//request a 'logger1' log service
long trkId;
std::atomic<celix_log_service_t*> logSvc;
std::atomic<celix_log_service_t*> logSvc{};
{
celix_service_tracking_options_t opts{};
opts.filter.serviceName = CELIX_LOG_SERVICE_NAME;
Expand Down Expand Up @@ -471,7 +471,7 @@ TEST_F(LogBundleTestSuite, LogAdminCmd) {
opts.filter.serviceName = CELIX_SHELL_COMMAND_SERVICE_NAME;
opts.use = [](void*, void *svc) {
auto* cmd = static_cast<celix_shell_command_t*>(svc);
char *cmdResult = NULL;
char *cmdResult = nullptr;
size_t cmdResultLen;
FILE *ss = open_memstream(&cmdResult, &cmdResultLen);
cmd->executeCommand(cmd->handle, "celix::log_admin", ss, ss); //overview
Expand All @@ -487,7 +487,7 @@ TEST_F(LogBundleTestSuite, LogAdminCmd) {

opts.use = [](void*, void *svc) {
auto* cmd = static_cast<celix_shell_command_t*>(svc);
char *cmdResult = NULL;
char *cmdResult = nullptr;
size_t cmdResultLen;
FILE *ss = open_memstream(&cmdResult, &cmdResultLen);
cmd->executeCommand(cmd->handle, "celix::log_admin log fatal", ss, ss); //all
Expand All @@ -504,7 +504,7 @@ TEST_F(LogBundleTestSuite, LogAdminCmd) {

opts.use = [](void*, void *svc) {
auto* cmd = static_cast<celix_shell_command_t*>(svc);
char *cmdResult = NULL;
char *cmdResult = nullptr;
size_t cmdResultLen;
FILE *ss = open_memstream(&cmdResult, &cmdResultLen);
cmd->executeCommand(cmd->handle, "celix::log_admin sink false", ss, ss); //all
Expand All @@ -523,9 +523,9 @@ TEST_F(LogBundleTestSuite, LogAdminCmd) {

opts.use = [](void*, void *svc) {
auto* cmd = static_cast<celix_shell_command_t*>(svc);
char *cmdResult = NULL;
char *cmdResult = nullptr;
size_t cmdResultLen;
char *errResult = NULL;
char *errResult = nullptr;
size_t errResultLen;
FILE *ss = open_memstream(&cmdResult, &cmdResultLen);
FILE *es = open_memstream(&errResult, &errResultLen);
Expand Down Expand Up @@ -586,7 +586,7 @@ TEST_F(LogBundleTestSuite, LogAdminCmd) {

opts.use = [](void*, void *svc) {
auto* cmd = static_cast<celix_shell_command_t*>(svc);
char *cmdResult = NULL;
char *cmdResult = nullptr;
size_t cmdResultLen;
FILE *ss = open_memstream(&cmdResult, &cmdResultLen);
cmd->executeCommand(cmd->handle, "celix::log_admin", ss, ss);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ void pubsub_topologyManager_removeMetricsService(void * handle, void *svc, const
celixThreadMutex_unlock(&manager->psaMetrics.mutex);
}


static celix_status_t pubsub_topologyManager_topology(pubsub_topology_manager_t *manager, const char *commandLine __attribute__((unused)), FILE *os, FILE *errorStream __attribute__((unused))) {
fprintf(os, "\n");

Expand Down
28 changes: 22 additions & 6 deletions bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,13 @@ extern "C" {

celix_framework_waitForEmptyEventQueue(framework);

bool imported = testImport->IsImported(testImport);
EXPECT_EQ(true, imported);
//Then endpointImported becomes true within 1 second
bool imported;
int iteration = 0;
do {
imported = testImport->IsImported(testImport);
usleep(1000);
} while (!imported && iteration++ < 1000);

rc = eplService->endpointRemoved(eplService->handle, endpoint, NULL);
EXPECT_EQ(CELIX_SUCCESS, rc);
Expand Down Expand Up @@ -544,8 +549,13 @@ extern "C" {

celix_framework_waitForEmptyEventQueue(framework);

bool imported = testImport->IsImported(testImport);
EXPECT_EQ(true, imported);
//Then endpointImported becomes true within 1 second
bool imported;
int iteration = 0;
do {
imported = testImport->IsImported(testImport);
usleep(1000);
} while (!imported && iteration++ < 1000);

rc = eplService->endpointRemoved(eplService->handle, endpoint, NULL);
EXPECT_EQ(CELIX_SUCCESS, rc);
Expand Down Expand Up @@ -636,8 +646,14 @@ extern "C" {

celix_framework_waitForEmptyEventQueue(framework);

celix_framework_waitForEmptyEventQueue(framework);
bool imported = testImport->IsImported(testImport);
//Then endpointImported becomes true within 1 second
bool imported;
int iteration = 0;
do {
imported = testImport->IsImported(testImport);
usleep(1000);
} while (!imported && iteration++ < 1000);

EXPECT_EQ(true, imported);

rc = eplService->endpointRemoved(eplService->handle, endpoint, NULL);
Expand Down
1 change: 1 addition & 0 deletions documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ bundles contains binaries depending on the stdlibc++ library.
* [Apache Celix Framework](framework.md)
* [Apache Celix Containers](containers.md)
* [Apache Celix Patterns](patterns.md)
* [Apache Celix Scheduled Events](scheduled_events.md)
* [Apache Celix CMake Commands](cmake_commands)
* [Apache Celix Sub Projects](subprojects.md)
* [Apache Celix Coding Conventions Guide](development/README.md)
35 changes: 18 additions & 17 deletions documents/framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,21 @@ So changing the environment variables after the framework is created will not ha

The following framework properties are supported:

| Framework Property | Default Value | Description |
|-------------------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CELIX_FRAMEWORK_CACHE_DIR | ".cache" | The directory where the Apache Celix framework will store its data. |
| CELIX_FRAMEWORK_CACHE_USE_TMP_DIR | "false" | If true, the Apache Celix framework will use the system temp directory for the cache directory. |
| CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE | "false" | If true, the Apache Celix framework will clean the cache directory on create. |
| CELIX_FRAMEWORK_FRAMEWORK_UUID | "" | The UUID of the Apache Celix framework. If not set, a random UUID will be generated. |
| CELIX_BUNDLES_PATH | "bundles" | The directories where the Apache Celix framework will search for bundles. Multiple directories can be provided separated by a colon. |
| CELIX_LOAD_BUNDLES_WITH_NODELETE | "false" | If true, the Apache Celix framework will load bundle libraries with the RTLD_NODELETE flags. Note for cmake build type Debug, the default is "true", otherwise the default is "false" |
| CELIX_FRAMEWORK_STATIC_EVENT_QUEUE_SIZE | "100" | The size of the static event queue. If more than 100 events in the queue are needed, dynamic memory allocation will be used. |
| CELIX_FRAMEWORK_AUTO_START_0 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_1 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_2 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_3 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_4 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_5 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_AUTO_INSTALL | "" | The bundles to install after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_LOGGING_DEFAULT_ACTIVE_LOG_LEVEL | "info" | The default active log level for created log services. Possible values are "trace", "debug", "info", "warning", "error" and "fatal". |
| Framework Property | Default Value | Description |
|--------------------------------------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CELIX_FRAMEWORK_CACHE_DIR | ".cache" | The directory where the Apache Celix framework will store its data. |
| CELIX_FRAMEWORK_CACHE_USE_TMP_DIR | "false" | If true, the Apache Celix framework will use the system temp directory for the cache directory. |
| CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE | "false" | If true, the Apache Celix framework will clean the cache directory on create. |
| CELIX_FRAMEWORK_FRAMEWORK_UUID | "" | The UUID of the Apache Celix framework. If not set, a random UUID will be generated. |
| CELIX_BUNDLES_PATH | "bundles" | The directories where the Apache Celix framework will search for bundles. Multiple directories can be provided separated by a colon. |
| CELIX_LOAD_BUNDLES_WITH_NODELETE | "false" | If true, the Apache Celix framework will load bundle libraries with the RTLD_NODELETE flags. Note for cmake build type Debug, the default is "true", otherwise the default is "false" |
| CELIX_FRAMEWORK_STATIC_EVENT_QUEUE_SIZE | "100" | The size of the static event queue. If more than 100 events in the queue are needed, dynamic memory allocation will be used. |
| CELIX_FRAMEWORK_AUTO_START_0 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_1 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_2 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_3 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_4 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_FRAMEWORK_AUTO_START_5 | "" | The bundles to install and start after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_AUTO_INSTALL | "" | The bundles to install after the framework is started. Multiple bundles can be provided separated by a space. |
| CELIX_LOGGING_DEFAULT_ACTIVE_LOG_LEVEL | "info" | The default active log level for created log services. Possible values are "trace", "debug", "info", "warning", "error" and "fatal". |
| CELIX_ALLOWED_PROCESSING_TIME_FOR_SCHEDULED_EVENT_IN_SECONDS | "2" | The allowed processing time for scheduled events in seconds, if processing takes longer a warning message will be logged. |
Loading

0 comments on commit 456de19

Please sign in to comment.