Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/records/I_RecDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ struct RecRawStat {
uint32_t version;
};

struct RecRawStatBlock;

// This defines the interface to the low level stat block operations
// The implementation of this was moved out of the records library due to a circular dependency this produced.
// look for the implementation of RecRawStatBlockOps in iocore/eventsystem
struct RecRawStatBlockOps {
virtual int raw_stat_clear_sum(RecRawStatBlock *rsb, int id) = 0;
virtual int raw_stat_clear_count(RecRawStatBlock *rsb, int id) = 0;
virtual int raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total) = 0;
virtual int raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) = 0;
virtual int raw_stat_clear(RecRawStatBlock *rsb, int id) = 0;
};

// WARNING! It's advised that developers do not modify the contents of
// the RecRawStatBlock. ^_^
struct RecRawStatBlock {
Expand All @@ -159,6 +172,7 @@ struct RecRawStatBlock {
int num_stats; // number of stats in this block
int max_stats; // maximum number of stats for this block
ink_mutex mutex;
RecRawStatBlockOps *ops;
};

//-------------------------------------------------------------------------
Expand Down
16 changes: 3 additions & 13 deletions include/records/I_RecProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,12 @@
#include "I_EventSystem.h"

//-------------------------------------------------------------------------
// Initialization/Starting
// RawStat Registration
//-------------------------------------------------------------------------
int RecProcessInit(Diags *diags = nullptr);
int RecProcessInitMessage();
int RecProcessStart();

//-------------------------------------------------------------------------
// Setters for manipulating internal sleep intervals
//-------------------------------------------------------------------------
void RecProcess_set_raw_stat_sync_interval_ms(int ms);
void RecProcess_set_config_update_interval_ms(int ms);
void RecProcess_set_remote_sync_interval_ms(int ms);
using RecRawStatBlockAllocator = RecRawStatBlock *(*)(int num_stats);

//-------------------------------------------------------------------------
// RawStat Registration
//-------------------------------------------------------------------------
void SetRecAllocateRawStatBlockAllocator(RecRawStatBlockAllocator);
RecRawStatBlock *RecAllocateRawStatBlock(int num_stats);

int _RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id,
Expand Down
5 changes: 3 additions & 2 deletions iocore/eventsystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ add_library(inkevent SHARED
UnixEvent.cc
UnixEventProcessor.cc
ConfigProcessor.cc
)
target_include_directories(inkevent PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
RecRawStatsImpl.cc)
target_include_directories(inkevent PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(inkevent ${PCRE_LIBRARIES} ${OPENSSL_LIBRARIES} yaml-cpp::yaml-cpp tscpputil resolv libswoc tscore records_p)
1 change: 1 addition & 0 deletions iocore/eventsystem/I_EventSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "I_VConnection.h"
#include "records/I_RecProcess.h"
#include "I_SocketManager.h"
#include "RecProcess.h"

static constexpr ts::ModuleVersion EVENT_SYSTEM_MODULE_PUBLIC_VERSION(1, 0, ts::ModuleVersion::PUBLIC);

Expand Down
2 changes: 2 additions & 0 deletions iocore/eventsystem/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ libinkevent_a_SOURCES = \
Processor.cc \
ProtectedQueue.cc \
ProxyAllocator.cc \
RecProcess.cc \
RecRawStatsImpl.cc \
SocketManager.cc \
Tasks.cc \
Thread.cc \
Expand Down
51 changes: 5 additions & 46 deletions src/records/RecProcess.cc → iocore/eventsystem/RecProcess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
#include "records/P_RecFile.h"

// Marks whether the message handler has been initialized.
static bool message_initialized_p = false;
static bool g_started = false;
static bool g_started = false;
static EventNotify g_force_req_notify;
static int g_rec_raw_stat_sync_interval_ms = REC_RAW_STAT_SYNC_INTERVAL_MS;
static int g_rec_config_update_interval_ms = REC_CONFIG_UPDATE_INTERVAL_MS;
Expand All @@ -44,27 +43,6 @@ static Event *raw_stat_sync_cont_event;
static Event *config_update_cont_event;
static Event *sync_cont_event;

//-------------------------------------------------------------------------
// i_am_the_record_owner, only used for librecords_p.a
//-------------------------------------------------------------------------
bool
i_am_the_record_owner(RecT rec_type)
{
switch (rec_type) {
case RECT_CONFIG:
case RECT_PROCESS:
case RECT_NODE:
case RECT_LOCAL:
case RECT_PLUGIN:
return true;
default:
ink_assert(!"Unexpected RecT type");
return false;
}

return false;
}

//-------------------------------------------------------------------------
// Simple setters for the intervals to decouple this from the proxy
//-------------------------------------------------------------------------
Expand Down Expand Up @@ -160,6 +138,8 @@ struct sync_cont : public Continuation {
}
};

void SetupRecRawStatBlockAllocator();

//-------------------------------------------------------------------------
// RecProcessInit
//-------------------------------------------------------------------------
Expand All @@ -168,6 +148,8 @@ RecProcessInit(Diags *_diags)
{
static bool initialized_p = false;

SetupRecRawStatBlockAllocator();

if (initialized_p) {
return REC_ERR_OKAY;
}
Expand All @@ -181,29 +163,6 @@ RecProcessInit(Diags *_diags)
return REC_ERR_OKAY;
}

void
RecMessageInit()
{
message_initialized_p = true;
}
//-------------------------------------------------------------------------
// RecProcessInitMessage
//-------------------------------------------------------------------------
int
RecProcessInitMessage()
{
static bool initialized_p = false;

if (initialized_p) {
return REC_ERR_OKAY;
}

RecMessageInit();
initialized_p = true;

return REC_ERR_OKAY;
}

//-------------------------------------------------------------------------
// RecProcessStart
//-------------------------------------------------------------------------
Expand Down
40 changes: 40 additions & 0 deletions iocore/eventsystem/RecProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/** @file

Public RecProcess declarations

@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once

#include "records/I_RecDefs.h"
#include "tscore/Diags.h"

//-------------------------------------------------------------------------
// Initialization/Starting
//-------------------------------------------------------------------------
int RecProcessInit(Diags *diags = nullptr);
int RecProcessStart();

//-------------------------------------------------------------------------
// Setters for manipulating internal sleep intervals
//-------------------------------------------------------------------------
void RecProcess_set_raw_stat_sync_interval_ms(int ms);
void RecProcess_set_config_update_interval_ms(int ms);
void RecProcess_set_remote_sync_interval_ms(int ms);
Loading