Skip to content

Commit

Permalink
feat(reconnect): introduce ReconnectMapStats interface (#13027)
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
  • Loading branch information
anthony-swirldslabs committed May 6, 2024
1 parent 02bb02e commit ed42123
Showing 1 changed file with 75 additions and 0 deletions.
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) {}
}

0 comments on commit ed42123

Please sign in to comment.