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 1 commit
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,55 @@
/*
* 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 counter.
* <p>
* Different reconnect algorithms may define the term "transfer" differently. Examples of a transfer: <br>
* * a lesson from the teacher, <br>
* * a query response to the teacher, <br>
* * a request from the learner, <br>
* * a response from the teacher.
*/
default void incrementTransfers() {}
artemananiev marked this conversation as resolved.
Show resolved Hide resolved

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

/**
* Gather stats about leaf nodes transfers.
* @param hashNum the number of hashes of leaf nodes transferred
* @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 incrementLeafNodes(int hashNum, int dataNum, int cleanDataNum) {}
}
artemananiev marked this conversation as resolved.
Show resolved Hide resolved