Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reconnect): introduce ReconnectMapStats interface #13027

Merged
merged 3 commits into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed 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.
*/

package com.swirlds.common.merkle.synchronization.stats;

/**
* An interface that helps gather statistics about the reconnect of tree-like data structures, such as VirtualMaps.
* <p>
* An implementation could gather aggregate statistics for all maps, or it could gather the counters for a specific
* map and then also optionally delegate to another instance of the interface that would compute aggregate stats
* for all maps.
* <p>
* All the methods have default no-op implementations to help with stubbing of the instances until an implementation
* is ready, or in tests.
*/
public interface ReconnectMapStats {
/**
* Increment a transfers from teacher counter.
* <p>
* Different reconnect algorithms may define the term "transfer" differently. Examples of a transfer from teacher: <br>
* * a lesson from the teacher, <br>
* * a response from the teacher per a prior request from the learner.
*/
default void incrementTransfersFromTeacher() {}

/**
* Increment a transfers from learner counter.
* <p>
* Different reconnect algorithms may define the term "transfer" differently. Examples of a transfer from learner: <br>
* * a query response to the teacher for a single hash, <br>
* * a request from the learner.
*/
default void incrementTransfersFromLearner() {}

/**
* Gather stats about internal nodes hashes transfers.
* @param hashNum the number of hashes of internal nodes transferred
* @param cleanHashNum the number of hashes transferred unnecessarily because they were clean
*/
default void incrementInternalHashes(int hashNum, int cleanHashNum) {}

/**
* Gather stats about internal nodes data transfers.
* @param dataNum the number of data payloads of internal nodes transferred (for non-VirtualMap trees)
* @param cleanDataNum the number of data payloads transferred unnecessarily because they were clean
*/
default void incrementInternalData(int dataNum, int cleanDataNum) {}

/**
* Gather stats about leaf nodes hashes transfers.
* @param hashNum the number of hashes of leaf nodes transferred
* @param cleanHashNum the number of hashes transferred unnecessarily because they were clean
*/
default void incrementLeafHashes(int hashNum, int cleanHashNum) {}

/**
* Gather stats about leaf nodes data transfers.
* @param dataNum the number of data payloads of leaf nodes transferred
* @param cleanDataNum the number of data payloads transferred unnecessarily because they were clean
*/
default void incrementLeafData(int dataNum, int cleanDataNum) {}
}
artemananiev marked this conversation as resolved.
Show resolved Hide resolved