Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that Time Constrained federates receive messages in timestamped order #323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ public enum MessageType

// Management Object Model (150-159)
SetServiceReporting ( (short)150 ),
SetExceptionReporting ( (short)151 );
SetExceptionReporting ( (short)151 ),

// Reserved for future use (160-253)

// RESERVED (UPDATE/SEND - 254, 255 - Above)

// Messages that are for processing within a specific federation
// ...
FederationLBTS((short) 255);
// ...


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.portico2.common.services.time.msg;

import org.portico.utils.messaging.PorticoMessage;
import org.portico2.common.messaging.MessageType;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

public class FederationLBTS extends PorticoMessage {
//----------------------------------------------------------
// STATIC VARIABLES
//----------------------------------------------------------
private static final long serialVersionUID = 98121116105109L;

//----------------------------------------------------------
// INSTANCE VARIABLES
//----------------------------------------------------------
private double federationLBTS;

//----------------------------------------------------------
// CONSTRUCTORS
//----------------------------------------------------------
public FederationLBTS(double federationLBTS) {
this.federationLBTS = federationLBTS;
}

//----------------------------------------------------------
// INSTANCE METHODS
//----------------------------------------------------------

@Override
public MessageType getType() {
return MessageType.FederationLBTS;
}

public double getFederationLBTS() {
return federationLBTS;
}

public void setFederationLBTS(double federationLBTS) {
this.federationLBTS = federationLBTS;
}

/////////////////////////////////////////////////////////////
/////////////////// Serialization Methods ///////////////////
/////////////////////////////////////////////////////////////
public void readExternal( ObjectInput input ) throws IOException, ClassNotFoundException
{
super.readExternal( input );
this.federationLBTS = input.readDouble();
}

public void writeExternal( ObjectOutput output ) throws IOException
{
super.writeExternal( output );

output.writeDouble(this.federationLBTS);
}

//----------------------------------------------------------
// STATIC METHODS
//----------------------------------------------------------
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.portico2.lrc.services.pubsub.outgoing.UnsubscribeObjectClassHandler;
import org.portico2.lrc.services.sync.outgoing.AchieveSyncPointHandler;
import org.portico2.lrc.services.sync.outgoing.RegisterSyncPointHandler;
import org.portico2.lrc.services.time.incoming.FederationLBTSHandler;
import org.portico2.lrc.services.time.incoming.TimeAdvanceGrantHandler;
import org.portico2.lrc.services.time.outgoing.DisableAsyncDeliveryHandler;
import org.portico2.lrc.services.time.outgoing.DisableTimeConstrainedHandler;
Expand Down Expand Up @@ -204,6 +205,7 @@ private static void loadIeee1516e( LRC lrc )
in.register( MessageType.EnableTimeRegulation, new TimeRegulationEnabledCallbackHandler() );
in.register( MessageType.TimeAdvanceGrant, new TimeAdvanceGrantHandler() );
in.register( MessageType.TimeAdvanceGrant, new TimeAdvanceGrantCallbackHandler() );
in.register( MessageType.FederationLBTS, new FederationLBTSHandler());

// Ownership Management
in.register( MessageType.AttributeAcquire, new AttributeReleaseRequestIncomingHandler() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public PorticoMessage poll()
// it is! release it - we also need to remove it, so we'll poll
return this.tsoQueue.poll();
}
else if( message.getTimestamp() <= timeStatus.getRequestedTime() )
else if( message.getTimestamp() <= state.getFederationLbts() )
{
// it is! release it - we also need to remove it, so we'll poll
return this.tsoQueue.poll();
Expand Down
9 changes: 9 additions & 0 deletions codebase/src/java/portico/org/portico2/lrc/LRCState.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class LRCState

// Time related settings //
private TimeStatus timeStatus;
private double federationLbts;
private boolean ticking;
private boolean callbacksEnabled;
private boolean immediateCallbacks;
Expand Down Expand Up @@ -423,6 +424,14 @@ public void setTicking( boolean ticking )
this.ticking = ticking;
}

public double getFederationLbts() {
return federationLbts;
}

public void setFederationLbts(double federationLbts) {
this.federationLbts = federationLbts;
}

public double getCurrentTime()
{
return timeStatus.getCurrentTime();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.portico2.lrc.services.time.incoming;

import org.portico.lrc.compat.JConfigurationException;
import org.portico.lrc.compat.JException;
import org.portico2.common.messaging.MessageContext;
import org.portico2.common.services.time.msg.FederationLBTS;
import org.portico2.lrc.LRCMessageHandler;

import java.util.Map;

public class FederationLBTSHandler extends LRCMessageHandler {
//----------------------------------------------------------
// STATIC VARIABLES
//----------------------------------------------------------

//----------------------------------------------------------
// INSTANCE VARIABLES
//----------------------------------------------------------

//----------------------------------------------------------
// CONSTRUCTORS
//----------------------------------------------------------

//----------------------------------------------------------
// INSTANCE METHODS
//----------------------------------------------------------
@Override
public void configure( Map<String,Object> properties ) throws JConfigurationException
{
super.configure( properties );
}

@Override
public void process(MessageContext context) throws JException {
FederationLBTS message = context.getRequest(FederationLBTS.class, this);

double federationLBTS = message.getFederationLBTS();

lrcState.setFederationLbts(federationLBTS);

if (logger.isDebugEnabled()) {
logger.debug("FEDERATION LBTS advanced to time ["+federationLBTS+"]");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.portico.lrc.compat.JException;
import org.portico2.common.messaging.MessageContext;
import org.portico2.common.services.time.data.TimeStatus;
import org.portico2.common.services.time.msg.FederationLBTS;
import org.portico2.common.services.time.msg.TimeAdvanceGrant;
import org.portico2.common.services.time.msg.TimeAdvanceRequest;
import org.portico2.rti.services.RTIMessageHandler;
Expand Down Expand Up @@ -70,7 +71,16 @@ public void process( MessageContext context ) throws JException
// record the time advance request in the time manager
TimeStatus status = timeManager.getTimeStatus( federate );
status.timeAdvanceRequested( newTime );
double oldLbts = timeManager.getLBTS();
double federationLbts = timeManager.recalculateLBTS();

if (federationLbts > oldLbts) {
// Update the LRCs on the new LBTS, so they can release TSO messages with a lower timestamp
FederationLBTS federationLbtsMessage = new FederationLBTS(federationLbts);
federationLbtsMessage.setImmediateProcessingFlag(true);
federationLbtsMessage.setIsFromRti(true);
queueBroadcast(federationLbtsMessage);
}

//////////////////////////////////
// Is the federate CONSTRAINED? //
Expand Down