Skip to content

Commit 437ca0f

Browse files
Bohdan Kurylovychborzun
authored andcommitted
Moved the auto-flush props from FlushSettings into AutoFlushSettings
Moved the auto-flush specific properties (auto_flush_num_events, auto_flush_interval, events_per_single_flush) from FlushSettings into AutoFlushSettings with following changes: - the return type of `events_per_single_flush` changed to int; - the AutoFlushSettings is now part of the private API. Also, removed all the auto-flush functional and integration tests, because the auto-flush mechanism is no longer part of public API. Relates to: OLPEDGE-826 Signed-off-by: Bohdan Kurylovych <[email protected]>
1 parent e8627ad commit 437ca0f

File tree

7 files changed

+59
-535
lines changed

7 files changed

+59
-535
lines changed

olp-cpp-sdk-dataservice-write/include/olp/dataservice/write/FlushSettings.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,6 @@ namespace dataservice {
3030
namespace write {
3131

3232
struct DATASERVICE_WRITE_API FlushSettings {
33-
/**
34-
* How many requests can be cached before an auto flush event is triggered.
35-
*/
36-
int auto_flush_num_events = 20;
37-
38-
/**
39-
* The period (in seconds) between sequential auto flush events when using
40-
* interval based auto-flush. Setting 0 indicates this feature is disabled.
41-
*/
42-
int auto_flush_interval = 0;
43-
44-
/**
45-
@brief The maximum number of partitions to be flushed each time.Set
46-
boost::none to flush all partitions. Non-positive number will flush nothing.
47-
*/
48-
boost::optional<int> events_per_single_flush = boost::none;
49-
5033
/**
5134
@brief The maximum number of requests that can be stored
5235
boost::none to store all requests. Must be positive.

olp-cpp-sdk-dataservice-write/src/AutoFlushController.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "AutoFlushController.h"
2121

22+
#include <olp/dataservice/write/StreamLayerClient.h>
2223
#include "BackgroundTaskCollection.h"
2324
#include "StreamLayerClientImpl.h"
2425
#include "TimeUtils.h"
@@ -59,10 +60,10 @@ class EnabledAutoFlushControllerImpl
5960
EnabledAutoFlushControllerImpl<ClientImpl, FlushResponse>> {
6061
public:
6162
EnabledAutoFlushControllerImpl(
62-
std::shared_ptr<ClientImpl> client_impl, FlushSettings flush_settings,
63+
std::shared_ptr<ClientImpl> client_impl, AutoFlushSettings flush_settings,
6364
std::shared_ptr<FlushEventListener<FlushResponse>> listener)
6465
: client_impl_(client_impl),
65-
flush_settings_(flush_settings),
66+
flush_settings_(std::move(flush_settings)),
6667
listener_(listener),
6768
background_task_col_(),
6869
cancel_mutex_(),
@@ -169,9 +170,7 @@ class EnabledAutoFlushControllerImpl
169170
auto id = self->background_task_col_.AddTask();
170171

171172
const auto num_requests_to_flush =
172-
self->flush_settings_.events_per_single_flush
173-
? *(self->flush_settings_.events_per_single_flush)
174-
: 0;
173+
self->flush_settings_.events_per_single_flush;
175174
model::FlushRequest request =
176175
model::FlushRequest().WithNumberOfRequestsToFlush(
177176
num_requests_to_flush);
@@ -224,15 +223,16 @@ class EnabledAutoFlushControllerImpl
224223

225224
private:
226225
std::weak_ptr<ClientImpl> client_impl_;
227-
FlushSettings flush_settings_;
226+
AutoFlushSettings flush_settings_;
228227
std::shared_ptr<FlushEventListener<FlushResponse>> listener_;
229228
BackgroundTaskCollection<size_t> background_task_col_;
230229
std::mutex cancel_mutex_;
231230
std::map<size_t, olp::client::CancellationToken> cancel_token_map_;
232231
bool is_cancelled_{false};
233232
};
234233

235-
AutoFlushController::AutoFlushController(const FlushSettings& flush_settings)
234+
AutoFlushController::AutoFlushController(
235+
const AutoFlushSettings& flush_settings)
236236
: flush_settings_(flush_settings),
237237
impl_(std::make_shared<DisabledAutoFlushControllerImpl>()) {}
238238

olp-cpp-sdk-dataservice-write/src/AutoFlushController.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919

2020
#pragma once
2121

22+
#include <future>
2223
#include <memory>
2324

2425
#include <olp/dataservice/write/FlushEventListener.h>
25-
#include <olp/dataservice/write/StreamLayerClient.h>
26+
#include "AutoFlushSettings.h"
2627

2728
namespace olp {
2829
namespace dataservice {
2930
namespace write {
3031

3132
class AutoFlushController {
3233
public:
33-
AutoFlushController(const FlushSettings& flush_settings);
34+
AutoFlushController(const AutoFlushSettings& flush_settings);
3435

3536
template <typename ClientImpl, typename FlushResponse>
3637
void Enable(std::shared_ptr<ClientImpl> client_impl,
@@ -56,7 +57,7 @@ class AutoFlushController {
5657
};
5758

5859
private:
59-
FlushSettings flush_settings_;
60+
AutoFlushSettings flush_settings_;
6061
std::shared_ptr<AutoFlushControllerImpl> impl_;
6162
};
6263

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2019 HERE Europe B.V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
#pragma once
21+
22+
namespace olp {
23+
namespace dataservice {
24+
namespace write {
25+
26+
struct AutoFlushSettings {
27+
/**
28+
* How many requests can be cached before an auto flush event is triggered.
29+
*/
30+
int auto_flush_num_events = 20;
31+
32+
/**
33+
* The period (in seconds) between sequential auto flush events when using
34+
* interval based auto-flush. Setting 0 indicates this feature is disabled.
35+
*/
36+
int auto_flush_interval = 0;
37+
38+
/**
39+
@brief The maximum number of partitions to be flushed each time.Set
40+
0 to flush all partitions. Non-positive number will flush nothing.
41+
*/
42+
int events_per_single_flush = 0;
43+
};
44+
45+
} // namespace write
46+
} // namespace dataservice
47+
} // namespace olp

olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ StreamLayerClientImpl::StreamLayerClientImpl(HRN catalog,
9090
cache_(settings_.cache),
9191
cache_mutex_(),
9292
flush_settings_(std::move(flush_settings)),
93-
auto_flush_controller_(new AutoFlushController(flush_settings_)) {}
93+
auto_flush_controller_(new AutoFlushController(AutoFlushSettings{})) {}
9494

9595
CancellationToken StreamLayerClientImpl::InitApiClients(
9696
const std::shared_ptr<CancellationContext>& cancel_context,

0 commit comments

Comments
 (0)