File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
server/src/main/java/org/elasticsearch/gateway Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -107,9 +107,10 @@ private void initializeClusterState(ClusterName clusterName) throws IOException
107107 }
108108
109109 public void setLocalNode (DiscoveryNode localNode ) {
110- previousClusterState = ClusterState .builder (previousClusterState )
111- .nodes (DiscoveryNodes .builder ().add (localNode ).localNodeId (localNode .getId ()).build ())
112- .build ();
110+ assert previousClusterState .nodes ().getLocalNode () == null : "setLocalNode must only be called once" ;
111+ previousClusterState = ClusterState .builder (previousClusterState )
112+ .nodes (DiscoveryNodes .builder ().add (localNode ).localNodeId (localNode .getId ()).build ())
113+ .build ();
113114 }
114115
115116 protected void upgradeMetaData (MetaDataIndexUpgradeService metaDataIndexUpgradeService , MetaDataUpgrader metaDataUpgrader )
@@ -195,7 +196,7 @@ public long getCurrentTerm() {
195196
196197 @ Override
197198 public ClusterState getLastAcceptedState () {
198- assert previousClusterState .nodes ().getSize () > 0 : "Call setLocalNode before calling this method" ;
199+ assert previousClusterState .nodes ().getLocalNode () != null : "Call setLocalNode before calling this method" ;
199200 return previousClusterState ;
200201 }
201202
You can’t perform that action at this time.
0 commit comments