yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method ReceiveRequestSyncNotification (
  String origin_node_id,
  String notification_info
)
{
  TextBody:
  [*
    slave_node := this.GetSlaveNode( origin_node_id );
    connector := this.DistributedServiceProviderBase().Connector();
    dsp := this.DistributedServiceProviderBase();
    
    dsp.Log( "Received sync request for slave " + origin_node_id + " for state " + notification_info, false )
    assert( not isnull( slave_node ), "Received request sync notification from unknown slave node" );
    
    requested_state := [Number] notification_info;
    state_message := select( this, OutboundMasterQueue.Message, msg, msg.StateSeqNr() = requested_state );
    
    // Currently we always do full sync since sending notification (in the else) won't work
    // while processing this incoming notifification. Might have to do with sync soap calls?
    if ( true or isnull( state_message ) or state_message.istype( DSP_FullSyncMessage ) )
    {
      // Full sync needed since requested state is not found  
      slave_node.LastSentOperationMessage( relset, this.OutboundMasterQueue().LastMessage() );
      connector_node := select( connector, Node, node, node.NodeId() = origin_node_id );
      this.DistributedServiceProviderBase().OnMasterNeedSentFullSync( connector_node );
      dsp.Log( "Requested full sync or sync state not available -> Requesting full sync", false );
    }
    else
    {
      // Full sync not needed, can just reset the message to be sent
      connector.SentNotification( origin_node_id
                                , DSP_DistributedServiceProviderBase::NotificationType_RequestSyncAck()
                                , ""
                                );
                                
      dsp.Log( "Requested sync state found -> Notified slave.", false);                            
    }
  *]
}