Skip to content

Commit

Permalink
Assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Ershov committed Nov 27, 2018
1 parent d91ad3c commit 24c43fa
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ private void initializeClusterState(ClusterName clusterName) throws IOException
}

public void setLocalNode(DiscoveryNode localNode) {
previousClusterState = ClusterState.builder(previousClusterState)
.nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).build())
.build();
assert previousClusterState.nodes().getLocalNode() == null : "setLocalNode must only be called once";
previousClusterState = ClusterState.builder(previousClusterState)
.nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).build())
.build();
}

protected void upgradeMetaData(MetaDataIndexUpgradeService metaDataIndexUpgradeService, MetaDataUpgrader metaDataUpgrader)
Expand Down Expand Up @@ -195,7 +196,7 @@ public long getCurrentTerm() {

@Override
public ClusterState getLastAcceptedState() {
assert previousClusterState.nodes().getSize() > 0 : "Call setLocalNode before calling this method";
assert previousClusterState.nodes().getLocalNode() != null : "Call setLocalNode before calling this method";
return previousClusterState;
}

Expand Down

0 comments on commit 24c43fa

Please sign in to comment.