admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Quintiq file version 2.0
#parent: #root
Method QuitAsBootNode
{
  Description: 'Quit being a BootNode, the new BootNode must be a known System within the Domain.'
  TextBody:
  [*
    // Jacky CHAN Apr-28-2016 (created)
    // Refresh values from model settings
    SettingsEngine::SettingsEngine().ProcessUpdates();
    
    bootNodeHost := LibDEF_Util::GetSettingValueBootNodeHostName();
    bootNodePort := LibDEF_Util::GetSettingValueBootNodePortNumber();
    
    event := this.EventCreate( bootNodeHost, bootNodePort, false );
    
    // if another system is a BootNode
    if( bootNodeHost <> "" and bootNodePort > 0 )
    {
      // convert localhost to current host name
      bootNodeHost := LibDEF_Util::ConvertLocalhost( bootNodeHost );
    
      detail := "Host name: " + bootNodeHost + "; Port number: " + [String]bootNodePort;
    
      newBootNode := LibDEF_System::FindSystemByCoordinate( this, bootNodeHost, bootNodePort );
      if( not isnull( newBootNode ) )
      {
        newBootNode.SetAsBootNode();
    
        // Updates the IntegrationEvent with BootNode's information
        event.Update( newBootNode );
    
        LibDEF_Util::EventLog( event, "This System is no longer the BootNode." );
        LibDEF_Util::EventLog( event, "Another System has become the BootNode. BootNode has been updated. " + detail );
        LibDEF_Util::EventLog( event, "Sending request to peers to synchronize configuration." );
        LibDEF_IntegrationEvent::EventComplete( event );
    
        // request all other Systems (including the new BootNode) to read model settings
        traverse( this.GetOtherPeers( true ), Elements, system )
        {
          this.SendConfigurationRequestSyncConfig( system );
        }
      }
      else
      {
        LibDEF_Util::EventLogError( event,
                                    "Failed to quit as BootNode.",
                                    "Cannot quit as BootNode, the new BootNode must be a known System within the Domain. Check the model settings." );
      }
    }
    else
    {
      LibDEF_Util::EventLogError( event,
                                  "Failed to quit as BootNode.",
                                  "To let the BootNode System leave the domain, another System must be assigned as the BootNode first. Check the model settings." );
    
    }
  *]
}