com.swirlds.common.merkle.synchronization.views.CustomReconnectRoot Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swirlds-common Show documentation
Show all versions of swirlds-common Show documentation
Swirlds is a software platform designed to build fully-distributed applications that harness the power of the cloud without servers. Now you can develop applications with fairness in decision making, speed, trust and reliability, at a fraction of the cost of traditional server-based platforms.
/*
* Copyright (C) 2021-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.views;
import com.swirlds.common.merkle.MerkleNode;
import com.swirlds.common.merkle.synchronization.config.ReconnectConfig;
import com.swirlds.common.merkle.synchronization.stats.ReconnectMapStats;
import edu.umd.cs.findbugs.annotations.NonNull;
/**
* Nodes that are want to use a custom view for reconnect must extend this interface and
* return true for {@link MerkleNode#hasCustomReconnectView() hasCustomReconnectView()}.
*
* @param
* the type used by the view for the teacher
* @param
* the type used by the view for the learner
*/
public interface CustomReconnectRoot extends MerkleNode {
/**
*
* Build a view of this subtree to be used for reconnect by the teacher.
*
*
*
* It is ok if this view is not immediately ready for use, as long as the view eventually
* becomes ready for use (presumably when some background task has completed). If this is
* the case, then the {@link TeacherTreeView#waitUntilReady()} on the returned view should
* block until the view is ready to be used to perform a reconnect.
*
*
* @return a view representing this subtree
*/
TeacherTreeView buildTeacherView(final ReconnectConfig reconnectConfig);
/**
* Build a view of this subtree to be used for reconnect by the learner.
*
* @param mapStats a ReconnectMapStats object to collect reconnect metrics
* @return a view representing this subtree
*/
LearnerTreeView buildLearnerView(
final ReconnectConfig reconnectConfig, @NonNull final ReconnectMapStats mapStats);
/**
* If the original node in this position is of the correct type then the learner's node is initialized via
* this method. After this method is called, this node and its subtree should be entirely hashed, mutable,
* and should not cause the original to modified.
*
* @param originalNode
* the original node in the learner's tree in the root position of this subtree
*/
void setupWithOriginalNode(final MerkleNode originalNode);
/**
* Called on a node if there is no data to be copied.
*/
void setupWithNoData();
/**
* {@inheritDoc}
*/
@Override
default boolean hasCustomReconnectView() {
return true;
}
}