[ohla-devel] SF.net SVN: ohla: [113] trunk/rti/src/java/net/sf/ohla/rti
Status: Beta
Brought to you by:
mnewcomb
From: <mne...@us...> - 2007-02-13 02:47:48
|
Revision: 113 http://svn.sourceforge.net/ohla/?rev=113&view=rev Author: mnewcomb Date: 2007-02-12 18:47:48 -0800 (Mon, 12 Feb 2007) Log Message: ----------- - refactoring Modified Paths: -------------- trunk/rti/src/java/net/sf/ohla/rti/OHLARTIambassador.java trunk/rti/src/java/net/sf/ohla/rti1516/OHLARTIambassador.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/objects/ObjectManager.java trunk/rti/src/java/net/sf/ohla/rti1516/messages/callbacks/CallbackManager.java Added Paths: ----------- trunk/rti/src/java/net/sf/ohla/rti1516/federate/LocalFederate.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/LocalMessageRetractionManager.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/LocalRegionManager.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/LocalSynchronizationPoint.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/LocalTimeManager.java Removed Paths: ------------- trunk/rti/src/java/net/sf/ohla/rti1516/federate/Federate.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/FederateState.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/FederateSynchronizationPoint.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/MessageRetractionManager.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/RegionManager.java trunk/rti/src/java/net/sf/ohla/rti1516/federate/TimeManager.java Modified: trunk/rti/src/java/net/sf/ohla/rti/OHLARTIambassador.java =================================================================== --- trunk/rti/src/java/net/sf/ohla/rti/OHLARTIambassador.java 2007-02-13 02:39:35 UTC (rev 112) +++ trunk/rti/src/java/net/sf/ohla/rti/OHLARTIambassador.java 2007-02-13 02:47:48 UTC (rev 113) @@ -36,7 +36,7 @@ import net.sf.ohla.rti1516.OHLAObjectInstanceHandle; import net.sf.ohla.rti1516.OHLAParameterHandle; import net.sf.ohla.rti1516.OHLARegionHandleSet; -import net.sf.ohla.rti1516.federate.Federate; +import net.sf.ohla.rti1516.federate.LocalFederate; import net.sf.ohla.rti1516.fdd.ObjectClass; import org.slf4j.Logger; @@ -215,7 +215,7 @@ protected LogicalTimeIntervalFactory logicalTimeIntervalFactory; protected hla.rti1516.LogicalTimeIntervalFactory ieee1516LogicalTimeIntervalFactory; - public Federate getJoinedFederate() + public LocalFederate getJoinedFederate() { return rtiAmbassador.getJoinedFederate(); } Modified: trunk/rti/src/java/net/sf/ohla/rti1516/OHLARTIambassador.java =================================================================== --- trunk/rti/src/java/net/sf/ohla/rti1516/OHLARTIambassador.java 2007-02-13 02:39:35 UTC (rev 112) +++ trunk/rti/src/java/net/sf/ohla/rti1516/OHLARTIambassador.java 2007-02-13 02:47:48 UTC (rev 113) @@ -29,7 +29,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import net.sf.ohla.rti1516.fdd.FDD; -import net.sf.ohla.rti1516.federate.Federate; +import net.sf.ohla.rti1516.federate.LocalFederate; import net.sf.ohla.rti1516.filter.RequestResponseFilter; import net.sf.ohla.rti1516.messages.CreateFederationExecution; import net.sf.ohla.rti1516.messages.DestroyFederationExecution; @@ -193,9 +193,9 @@ */ protected Semaphore callbackSemaphore = new Semaphore(1, true); - protected Federate federate; + protected LocalFederate federate; - public Federate getJoinedFederate() + public LocalFederate getJoinedFederate() { return federate; } @@ -332,7 +332,7 @@ checkIfFederateAlreadyExecutionMember(); federate = - new Federate(federateType, federationName, federateAmbassador, + new LocalFederate(federateType, federationName, federateAmbassador, mobileFederateServices, rtiSession); return federate.getFederateHandle(); Deleted: trunk/rti/src/java/net/sf/ohla/rti1516/federate/Federate.java =================================================================== --- trunk/rti/src/java/net/sf/ohla/rti1516/federate/Federate.java 2007-02-13 02:39:35 UTC (rev 112) +++ trunk/rti/src/java/net/sf/ohla/rti1516/federate/Federate.java 2007-02-13 02:47:48 UTC (rev 113) @@ -1,4048 +0,0 @@ -/* - * Copyright (c) 2006, Michael Newcomb - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.ohla.rti1516.federate; - -import java.util.HashMap; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.Queue; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -import net.sf.ohla.rti1516.OHLAAttributeHandleFactory; -import net.sf.ohla.rti1516.OHLAAttributeHandleSetFactory; -import net.sf.ohla.rti1516.OHLAAttributeHandleValueMapFactory; -import net.sf.ohla.rti1516.OHLAAttributeSetRegionSetPairListFactory; -import net.sf.ohla.rti1516.OHLADimensionHandleFactory; -import net.sf.ohla.rti1516.OHLADimensionHandleSetFactory; -import net.sf.ohla.rti1516.OHLAFederateHandleFactory; -import net.sf.ohla.rti1516.OHLAFederateHandleSetFactory; -import net.sf.ohla.rti1516.OHLAInteractionClassHandleFactory; -import net.sf.ohla.rti1516.OHLAObjectClassHandleFactory; -import net.sf.ohla.rti1516.OHLAObjectInstanceHandleFactory; -import net.sf.ohla.rti1516.OHLAParameterHandleFactory; -import net.sf.ohla.rti1516.OHLAParameterHandleValueMapFactory; -import net.sf.ohla.rti1516.OHLARegionHandleSetFactory; -import net.sf.ohla.rti1516.fdd.FDD; -import net.sf.ohla.rti1516.federate.objects.ObjectManager; -import net.sf.ohla.rti1516.federate.TimeManager; -import net.sf.ohla.rti1516.messages.FederateRestoreComplete; -import net.sf.ohla.rti1516.messages.FederateRestoreNotComplete; -import net.sf.ohla.rti1516.messages.FederateSaveBegun; -import net.sf.ohla.rti1516.messages.FederateSaveComplete; -import net.sf.ohla.rti1516.messages.FederateSaveNotComplete; -import net.sf.ohla.rti1516.messages.GALTAdvanced; -import net.sf.ohla.rti1516.messages.JoinFederationExecution; -import net.sf.ohla.rti1516.messages.JoinFederationExecutionResponse; -import net.sf.ohla.rti1516.messages.QueryFederationRestoreStatus; -import net.sf.ohla.rti1516.messages.QueryFederationSaveStatus; -import net.sf.ohla.rti1516.messages.RegisterFederationSynchronizationPoint; -import net.sf.ohla.rti1516.messages.RequestAttributeValueUpdate; -import net.sf.ohla.rti1516.messages.RequestFederationRestore; -import net.sf.ohla.rti1516.messages.RequestFederationSave; -import net.sf.ohla.rti1516.messages.Retract; -import net.sf.ohla.rti1516.messages.SendInteraction; -import net.sf.ohla.rti1516.messages.SubscribeObjectClassAttributes; -import net.sf.ohla.rti1516.messages.SynchronizationPointAchieved; -import net.sf.ohla.rti1516.messages.UnsubscribeObjectClassAttributes; -import net.sf.ohla.rti1516.messages.callbacks.Callback; -import net.sf.ohla.rti1516.messages.callbacks.CallbackManager; -import net.sf.ohla.rti1516.messages.callbacks.ReceiveInteraction; -import net.sf.ohla.rti1516.messages.callbacks.ReflectAttributeValues; -import net.sf.ohla.rti1516.messages.callbacks.RemoveObjectInstance; -import net.sf.ohla.rti1516.messages.callbacks.TimeAdvanceGrant; - -import org.apache.mina.common.IoSession; -import org.apache.mina.common.WriteFuture; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.Marker; -import org.slf4j.MarkerFactory; - -import hla.rti1516.AsynchronousDeliveryAlreadyDisabled; -import hla.rti1516.AsynchronousDeliveryAlreadyEnabled; -import hla.rti1516.AttributeAcquisitionWasNotCanceled; -import hla.rti1516.AttributeAcquisitionWasNotRequested; -import hla.rti1516.AttributeAlreadyBeingAcquired; -import hla.rti1516.AttributeAlreadyBeingDivested; -import hla.rti1516.AttributeAlreadyOwned; -import hla.rti1516.AttributeDivestitureWasNotRequested; -import hla.rti1516.AttributeHandle; -import hla.rti1516.AttributeHandleFactory; -import hla.rti1516.AttributeHandleSet; -import hla.rti1516.AttributeHandleSetFactory; -import hla.rti1516.AttributeHandleValueMap; -import hla.rti1516.AttributeHandleValueMapFactory; -import hla.rti1516.AttributeNotDefined; -import hla.rti1516.AttributeNotOwned; -import hla.rti1516.AttributeNotPublished; -import hla.rti1516.AttributeNotRecognized; -import hla.rti1516.AttributeNotSubscribed; -import hla.rti1516.AttributeRegionAssociation; -import hla.rti1516.AttributeRelevanceAdvisorySwitchIsOff; -import hla.rti1516.AttributeRelevanceAdvisorySwitchIsOn; -import hla.rti1516.AttributeScopeAdvisorySwitchIsOff; -import hla.rti1516.AttributeScopeAdvisorySwitchIsOn; -import hla.rti1516.AttributeSetRegionSetPairList; -import hla.rti1516.AttributeSetRegionSetPairListFactory; -import hla.rti1516.CouldNotDiscover; -import hla.rti1516.CouldNotInitiateRestore; -import hla.rti1516.DeletePrivilegeNotHeld; -import hla.rti1516.DimensionHandle; -import hla.rti1516.DimensionHandleFactory; -import hla.rti1516.DimensionHandleSet; -import hla.rti1516.DimensionHandleSetFactory; -import hla.rti1516.FederateAlreadyExecutionMember; -import hla.rti1516.FederateAmbassador; -import hla.rti1516.FederateHandle; -import hla.rti1516.FederateHandleFactory; -import hla.rti1516.FederateHandleRestoreStatusPair; -import hla.rti1516.FederateHandleSaveStatusPair; -import hla.rti1516.FederateHandleSet; -import hla.rti1516.FederateHandleSetFactory; -import hla.rti1516.FederateHasNotBegunSave; -import hla.rti1516.FederateInternalError; -import hla.rti1516.FederateOwnsAttributes; -import hla.rti1516.FederateServiceInvocationsAreBeingReportedViaMOM; -import hla.rti1516.FederateUnableToUseTime; -import hla.rti1516.FederationExecutionDoesNotExist; -import hla.rti1516.IllegalName; -import hla.rti1516.InTimeAdvancingState; -import hla.rti1516.InteractionClassHandle; -import hla.rti1516.InteractionClassHandleFactory; -import hla.rti1516.InteractionClassNotDefined; -import hla.rti1516.InteractionClassNotPublished; -import hla.rti1516.InteractionClassNotRecognized; -import hla.rti1516.InteractionClassNotSubscribed; -import hla.rti1516.InteractionParameterNotDefined; -import hla.rti1516.InteractionParameterNotRecognized; -import hla.rti1516.InteractionRelevanceAdvisorySwitchIsOff; -import hla.rti1516.InteractionRelevanceAdvisorySwitchIsOn; -import hla.rti1516.InvalidAttributeHandle; -import hla.rti1516.InvalidDimensionHandle; -import hla.rti1516.InvalidFederateHandle; -import hla.rti1516.InvalidInteractionClassHandle; -import hla.rti1516.InvalidLogicalTime; -import hla.rti1516.InvalidLookahead; -import hla.rti1516.InvalidMessageRetractionHandle; -import hla.rti1516.InvalidObjectClassHandle; -import hla.rti1516.InvalidOrderName; -import hla.rti1516.InvalidOrderType; -import hla.rti1516.InvalidParameterHandle; -import hla.rti1516.InvalidRangeBound; -import hla.rti1516.InvalidRegion; -import hla.rti1516.InvalidRegionContext; -import hla.rti1516.InvalidTransportationName; -import hla.rti1516.InvalidTransportationType; -import hla.rti1516.JoinedFederateIsNotInTimeAdvancingState; -import hla.rti1516.LogicalTime; -import hla.rti1516.LogicalTimeAlreadyPassed; -import hla.rti1516.LogicalTimeInterval; -import hla.rti1516.MessageCanNoLongerBeRetracted; -import hla.rti1516.MessageRetractionHandle; -import hla.rti1516.MessageRetractionReturn; -import hla.rti1516.MobileFederateServices; -import hla.rti1516.NameNotFound; -import hla.rti1516.NoRequestToEnableTimeConstrainedWasPending; -import hla.rti1516.NoRequestToEnableTimeRegulationWasPending; -import hla.rti1516.ObjectClassHandle; -import hla.rti1516.ObjectClassHandleFactory; -import hla.rti1516.ObjectClassNotDefined; -import hla.rti1516.ObjectClassNotPublished; -import hla.rti1516.ObjectClassNotRecognized; -import hla.rti1516.ObjectClassRelevanceAdvisorySwitchIsOff; -import hla.rti1516.ObjectClassRelevanceAdvisorySwitchIsOn; -import hla.rti1516.ObjectInstanceHandle; -import hla.rti1516.ObjectInstanceHandleFactory; -import hla.rti1516.ObjectInstanceNameInUse; -import hla.rti1516.ObjectInstanceNameNotReserved; -import hla.rti1516.ObjectInstanceNotKnown; -import hla.rti1516.OrderType; -import hla.rti1516.OwnershipAcquisitionPending; -import hla.rti1516.ParameterHandle; -import hla.rti1516.ParameterHandleFactory; -import hla.rti1516.ParameterHandleValueMap; -import hla.rti1516.ParameterHandleValueMapFactory; -import hla.rti1516.RTIinternalError; -import hla.rti1516.RangeBounds; -import hla.rti1516.RegionDoesNotContainSpecifiedDimension; -import hla.rti1516.RegionHandle; -import hla.rti1516.RegionHandleSet; -import hla.rti1516.RegionHandleSetFactory; -import hla.rti1516.RegionInUseForUpdateOrSubscription; -import hla.rti1516.RegionNotCreatedByThisFederate; -import hla.rti1516.RequestForTimeConstrainedPending; -import hla.rti1516.RequestForTimeRegulationPending; -import hla.rti1516.ResignAction; -import hla.rti1516.RestoreFailureReason; -import hla.rti1516.RestoreInProgress; -import hla.rti1516.RestoreNotRequested; -import hla.rti1516.SaveFailureReason; -import hla.rti1516.SaveInProgress; -import hla.rti1516.SaveNotInitiated; -import hla.rti1516.ServiceGroup; -import hla.rti1516.SpecifiedSaveLabelDoesNotExist; -import hla.rti1516.SynchronizationPointFailureReason; -import hla.rti1516.SynchronizationPointLabelNotAnnounced; -import hla.rti1516.TimeConstrainedAlreadyEnabled; -import hla.rti1516.TimeConstrainedIsNotEnabled; -import hla.rti1516.TimeQueryReturn; -import hla.rti1516.TimeRegulationAlreadyEnabled; -import hla.rti1516.TimeRegulationIsNotEnabled; -import hla.rti1516.TransportationType; -import hla.rti1516.UnableToPerformSave; -import hla.rti1516.UnknownName; -import hla.rti1516.jlc.NullFederateAmbassador; - -public class Federate -{ - public static final String OHLA_FEDERATE_HOST_PROPERTY = - "ohla.federate.%s.host"; - public static final String OHLA_FEDERATE_PORT_PROPERTY = - "ohla.federate.%s.port"; - - protected final String federateType; - protected final String federationExecutionName; - protected final FederateAmbassador federateAmbassador; - protected final MobileFederateServices mobileFederateServices; - - protected final FederateAmbassador federateAmbassadorInterceptor = - new FederateAmbassadorInterceptor(); - - protected FederateHandle federateHandle; - - protected String federationName; - protected FDD fdd; - - protected FederateState federateState = FederateState.ACTIVE; - - protected ReadWriteLock federateStateLock = - new ReentrantReadWriteLock(true); - - protected FederateSaveState federateSaveState; - protected FederateSave federateSave; - - protected FederateRestoreState federateRestoreState; - protected FederateRestore federateRestore; - - protected Lock synchronizationPointLock = new ReentrantLock(true); - protected Map<String, FederateSynchronizationPoint> synchronizationPoints = - new HashMap<String, FederateSynchronizationPoint>(); - - protected boolean asynchronousDeliveryEnabled; - - protected ObjectManager objectManager = new ObjectManager(this); - protected RegionManager regionManager = new RegionManager(this); - protected MessageRetractionManager messageRetractionManager = - new MessageRetractionManager(this); - - protected TimeManager timeManager; - protected CallbackManager callbackManager = new CallbackManager(this); - - protected Lock futureTasksLock = new ReentrantLock(true); - protected Queue<TimestampedFutureTask> futureTasks = - new PriorityQueue<TimestampedFutureTask>(); - - protected AttributeHandleFactory attributeHandleFactory = - new OHLAAttributeHandleFactory(); - protected AttributeHandleSetFactory attributeHandleSetFactory = - new OHLAAttributeHandleSetFactory(); - protected AttributeHandleValueMapFactory attributeHandleValueMapFactory = - new OHLAAttributeHandleValueMapFactory(); - protected AttributeSetRegionSetPairListFactory attributeSetRegionSetPairListFactory = - new OHLAAttributeSetRegionSetPairListFactory(); - protected DimensionHandleFactory dimensionHandleFactory = - new OHLADimensionHandleFactory(); - protected DimensionHandleSetFactory dimensionHandleSetFactory = - new OHLADimensionHandleSetFactory(); - protected FederateHandleFactory federateHandleFactory = - new OHLAFederateHandleFactory(); - protected FederateHandleSetFactory federateHandleSetFactory = - new OHLAFederateHandleSetFactory(); - protected InteractionClassHandleFactory interactionClassHandleFactory = - new OHLAInteractionClassHandleFactory(); - protected ObjectClassHandleFactory objectClassHandleFactory = - new OHLAObjectClassHandleFactory(); - protected ObjectInstanceHandleFactory objectInstanceHandleFactory = - new OHLAObjectInstanceHandleFactory(); - protected ParameterHandleFactory parameterHandleFactory = - new OHLAParameterHandleFactory(); - protected ParameterHandleValueMapFactory parameterHandleValueMapFactory = - new OHLAParameterHandleValueMapFactory(); - protected RegionHandleSetFactory regionHandleSetFactory = - new OHLARegionHandleSetFactory(); - - /** - * The session with the RTI. - */ - protected IoSession rtiSession; - - protected final Logger log = LoggerFactory.getLogger(getClass()); - protected final Marker marker; - - public Federate(String federateType, String federationExecutionName, - FederateAmbassador federateAmbassador, - MobileFederateServices mobileFederateServices, - IoSession rtiSession) - throws FederationExecutionDoesNotExist, SaveInProgress, RestoreInProgress, - RTIinternalError - { - this.federateType = federateType; - this.federationExecutionName = federationExecutionName; - this.federateAmbassador = federateAmbassador; - this.mobileFederateServices = mobileFederateServices; - this.rtiSession = rtiSession; - - marker = MarkerFactory.getMarker(federateType); - - JoinFederationExecution joinFederationExecution = - new JoinFederationExecution( - federateType, federationExecutionName, mobileFederateServices); - WriteFuture writeFuture = rtiSession.write(joinFederationExecution); - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - - try - { - // TODO: set timeout - // - Object response = joinFederationExecution.getResponse(); - if (response instanceof JoinFederationExecutionResponse) - { - JoinFederationExecutionResponse joinFederationExecutionResponse = - (JoinFederationExecutionResponse) response; - - federateHandle = joinFederationExecutionResponse.getFederateHandle(); - fdd = joinFederationExecutionResponse.getFdd(); - - LogicalTime galt = joinFederationExecutionResponse.getGALT(); - timeManager = new TimeManager(this, mobileFederateServices, galt); - - log.info(marker, "joined federation execution: {}", federateHandle); - } - else if (response instanceof FederationExecutionDoesNotExist) - { - throw new FederationExecutionDoesNotExist( - (FederationExecutionDoesNotExist) response); - } - else if (response instanceof SaveInProgress) - { - throw new SaveInProgress((SaveInProgress) response); - } - else if (response instanceof RestoreInProgress) - { - throw new RestoreInProgress((RestoreInProgress) response); - } - else - { - assert false : String.format("unexpected response: %s", response); - } - } - catch (InterruptedException ie) - { - throw new RTIinternalError("interrupted awaiting timeout", ie); - } - catch (ExecutionException ee) - { - throw new RTIinternalError("unable to get response", ee); - } - } - - public FederateHandle getFederateHandle() - { - return federateHandle; - } - - public FederateAmbassador getFederateAmbassador() - { - return federateAmbassadorInterceptor; - } - - public FDD getFDD() - { - return fdd; - } - - public ObjectManager getObjectManager() - { - return objectManager; - } - - public RegionManager getRegionManager() - { - return regionManager; - } - - public MessageRetractionManager getMessageRetractionManager() - { - return messageRetractionManager; - } - - public TimeManager getTimeManager() - { - return timeManager; - } - - public CallbackManager getCallbackManager() - { - return callbackManager; - } - - public IoSession getRTISession() - { - return rtiSession; - } - - public boolean isAsynchronousDeliveryEnabled() - { - return asynchronousDeliveryEnabled; - } - - public void processFutureTasks(LogicalTime maxFutureTaskTimestamp) - { - futureTasksLock.lock(); - try - { - log.debug(marker, "processing future tasks: {}", maxFutureTaskTimestamp); - - for (TimestampedFutureTask timestampedFutureTask = futureTasks.peek(); - timestampedFutureTask != null && - timestampedFutureTask.getTime().compareTo( - maxFutureTaskTimestamp) <= 0; - timestampedFutureTask = futureTasks.peek()) - { - log.debug(marker, "processing future task: {}", timestampedFutureTask); - - try - { - timestampedFutureTask.run(); - } - catch (Throwable t) - { - log.error(marker, String.format("unable to execute scheduled task: %s", - timestampedFutureTask), t); - } - - futureTasks.poll(); - } - } - finally - { - futureTasksLock.unlock(); - } - } - - public boolean process(IoSession session, Object message) - { - log.debug(marker, "processing: {}", message); - - boolean processed = true; - if (message instanceof Callback) - { - if (message instanceof ReflectAttributeValues) - { - ReflectAttributeValues reflectAttributeValues = - (ReflectAttributeValues) message; - - timeManager.getTimeLock().readLock().lock(); - try - { - OrderType receivedOrderType = - reflectAttributeValues.getSentOrderType() == OrderType.TIMESTAMP && - timeManager.isTimeConstrained() ? OrderType.TIMESTAMP : - OrderType.RECEIVE; - reflectAttributeValues.setReceivedOrderType(receivedOrderType); - - if (receivedOrderType == OrderType.RECEIVE) - { - // receive order callbacks need to be held until released if we - // are constrained and in the time granted state if asynchronous - // delivery is disabled - // - boolean hold = timeManager.isTimeConstrainedAndTimeGranted() && - !isAsynchronousDeliveryEnabled(); - - callbackManager.add(reflectAttributeValues, hold); - } - else - { - // schedule the callback for the appropriate time - // - Future future = schedule( - reflectAttributeValues.getUpdateTime(), - new AddCallback(reflectAttributeValues)); - - // register the message retraction handle - // - messageRetractionManager.add( - reflectAttributeValues.getUpdateTime(), future, - reflectAttributeValues.getMessageRetractionHandle()); - } - } - finally - { - timeManager.getTimeLock().readLock().unlock(); - } - } - else if (message instanceof ReceiveInteraction) - { - ReceiveInteraction receiveInteraction = (ReceiveInteraction) message; - - timeManager.getTimeLock().readLock().lock(); - try - { - OrderType receivedOrderType = - receiveInteraction.getSentOrderType() == OrderType.TIMESTAMP && - timeManager.isTimeConstrained() ? OrderType.TIMESTAMP : - OrderType.RECEIVE; - - receiveInteraction.setReceivedOrderType(receivedOrderType); - - if (receivedOrderType == OrderType.RECEIVE) - { - // receive order callbacks need to be held until released if we - // are constrained and in the time granted state, if asynchronous - // delivery is disabled - // - boolean hold = timeManager.isTimeConstrainedAndTimeGranted() && - !isAsynchronousDeliveryEnabled(); - - callbackManager.add(receiveInteraction, hold); - } - else - { - // schedule the callback for the appropriate time - // - Future future = schedule(receiveInteraction.getSendTime(), - new AddCallback(receiveInteraction)); - - // register the message retraction handle - // - messageRetractionManager.add( - receiveInteraction.getSendTime(), future, - receiveInteraction.getMessageRetractionHandle()); - } - } - finally - { - timeManager.getTimeLock().readLock().unlock(); - } - } - else if (message instanceof RemoveObjectInstance) - { - RemoveObjectInstance removeObjectInstance = - (RemoveObjectInstance) message; - - timeManager.getTimeLock().readLock().lock(); - try - { - OrderType receivedOrderType = - removeObjectInstance.getSentOrderType() == OrderType.TIMESTAMP && - timeManager.isTimeConstrained() ? OrderType.TIMESTAMP : - OrderType.RECEIVE; - - removeObjectInstance.setReceivedOrderType(receivedOrderType); - - if (receivedOrderType == OrderType.RECEIVE) - { - // receive order callbacks need to be held until released if we - // are constrained and in the time granted state, if asynchronous - // delivery is disabled - // - boolean hold = timeManager.isTimeConstrainedAndTimeGranted() && - !isAsynchronousDeliveryEnabled(); - - callbackManager.add(removeObjectInstance, hold); - } - else - { - // schedule the callback for the appropriate time - // - Future future = schedule(removeObjectInstance.getDeleteTime(), - new AddCallback(removeObjectInstance)); - - // register the message retraction handle - // - messageRetractionManager.add( - removeObjectInstance.getDeleteTime(), future, - removeObjectInstance.getMessageRetractionHandle()); - } - } - finally - { - timeManager.getTimeLock().readLock().unlock(); - } - } - else - { - if (message instanceof TimeAdvanceGrant) - { - processFutureTasks(((TimeAdvanceGrant) message).getTime()); - } - - callbackManager.add((Callback) message); - } - } - else if (message instanceof GALTAdvanced) - { - GALTAdvanced galtAdvanced = (GALTAdvanced) message; - - LogicalTime galt = galtAdvanced.getGALT(); - - timeManager.galtAdvanced(galt); - } - else - { - processed = false; - } - return processed; - } - - public void resignFederationExecution(ResignAction resignAction) - throws OwnershipAcquisitionPending, FederateOwnsAttributes, - RTIinternalError - { - federateStateLock.writeLock().lock(); - try - { - objectManager.resignFederationExecution(resignAction); - - federateState = null; - } - finally - { - federateStateLock.writeLock().unlock(); - } - } - - public void registerFederationSynchronizationPoint(String label, byte[] tag) - throws SaveInProgress, RestoreInProgress, RTIinternalError - { - registerFederationSynchronizationPoint(label, tag, null); - } - - public void registerFederationSynchronizationPoint( - String label, byte[] tag, FederateHandleSet federateHandles) - throws SaveInProgress, RestoreInProgress, RTIinternalError - { - WriteFuture writeFuture; - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - writeFuture = rtiSession.write( - new RegisterFederationSynchronizationPoint( - label, tag, federateHandles)); - } - finally - { - federateStateLock.readLock().unlock(); - } - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - - public void synchronizationPointAchieved(String label) - throws SynchronizationPointLabelNotAnnounced, SaveInProgress, - RestoreInProgress, RTIinternalError - { - WriteFuture writeFuture = null; - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - synchronizationPointLock.lock(); - try - { - FederateSynchronizationPoint federateSynchronizationPoint = - synchronizationPoints.get(label); - if (federateSynchronizationPoint == null) - { - throw new SynchronizationPointLabelNotAnnounced(label); - } - else - { - federateSynchronizationPoint.synchronizationPointAchieved(); - - writeFuture = - rtiSession.write(new SynchronizationPointAchieved(label)); - } - } - finally - { - synchronizationPointLock.unlock(); - } - } - finally - { - federateStateLock.readLock().unlock(); - } - - if (writeFuture != null) - { - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - } - - public void requestFederationSave(String label) - throws SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.writeLock().lock(); - try - { - checkIfActive(); - - RequestFederationSave requestFederationSave = - new RequestFederationSave(label); - WriteFuture writeFuture = rtiSession.write(requestFederationSave); - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - - // TODO: set timeout - // - Object response = requestFederationSave.getResponse(); - if (response instanceof SaveInProgress) - { - throw new SaveInProgress((SaveInProgress) response); - } - else if (response instanceof RestoreInProgress) - { - throw new RestoreInProgress((RestoreInProgress) response); - } - else - { - assert response == null : - String.format("unexpected response: %s", response); - } - } - catch (InterruptedException ie) - { - throw new RTIinternalError("interrupted awaiting timeout", ie); - } - catch (ExecutionException ee) - { - throw new RTIinternalError("unable to get response", ee); - } - finally - { - federateStateLock.writeLock().unlock(); - } - } - - public void requestFederationSave(String label, LogicalTime saveTime) - throws LogicalTimeAlreadyPassed, InvalidLogicalTime, - FederateUnableToUseTime, SaveInProgress, RestoreInProgress, - RTIinternalError - { - federateStateLock.writeLock().lock(); - try - { - checkIfActive(); - - // no need to lock time manager because we have a write lock on the - // federate state - // - timeManager.checkIfLogicalTimeAlreadyPassed(saveTime); - - RequestFederationSave requestFederationSave = - new RequestFederationSave(label, saveTime); - WriteFuture writeFuture = rtiSession.write(requestFederationSave); - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - - // TODO: set timeout - // - Object response = requestFederationSave.getResponse(); - if (response instanceof LogicalTimeAlreadyPassed) - { - throw new LogicalTimeAlreadyPassed((LogicalTimeAlreadyPassed) response); - } - else if (response instanceof SaveInProgress) - { - throw new SaveInProgress((SaveInProgress) response); - } - else if (response instanceof RestoreInProgress) - { - throw new RestoreInProgress((RestoreInProgress) response); - } - else - { - assert false : String.format("unexpected response: %s", response); - } - } - catch (InterruptedException ie) - { - throw new RTIinternalError("interrupted awaiting timeout", ie); - } - catch (ExecutionException ee) - { - throw new RTIinternalError("unable to get response", ee); - } - finally - { - federateStateLock.writeLock().unlock(); - } - } - - public void federateSaveBegun() - throws SaveNotInitiated, RestoreInProgress, RTIinternalError - { - WriteFuture writeFuture; - - federateStateLock.readLock().lock(); - try - { - if (federateSaveState != FederateSaveState.INSTRUCTED_TO_SAVE) - { - throw new SaveNotInitiated(); - } - - writeFuture = rtiSession.write(new FederateSaveBegun()); - - federateSaveState = FederateSaveState.SAVING; - } - finally - { - federateStateLock.readLock().unlock(); - } - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - - public void federateSaveComplete() - throws FederateHasNotBegunSave, RestoreInProgress, RTIinternalError - { - WriteFuture writeFuture; - - federateStateLock.readLock().lock(); - try - { - checkIfRestoreInProgress(); - - if (federateSaveState != FederateSaveState.SAVING) - { - throw new FederateHasNotBegunSave(); - } - - writeFuture = rtiSession.write(new FederateSaveComplete(null)); - - federateSaveState = FederateSaveState.WAITING_FOR_FEDERATION_TO_SAVE; - } - finally - { - federateStateLock.readLock().unlock(); - } - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - - public void federateSaveNotComplete() - throws FederateHasNotBegunSave, RestoreInProgress, RTIinternalError - { - WriteFuture writeFuture; - - federateStateLock.readLock().lock(); - try - { - checkIfRestoreInProgress(); - - if (federateSaveState != FederateSaveState.SAVING) - { - throw new FederateHasNotBegunSave(); - } - - writeFuture = rtiSession.write(new FederateSaveNotComplete()); - - federateSaveState = FederateSaveState.WAITING_FOR_FEDERATION_TO_SAVE; - } - finally - { - federateStateLock.readLock().unlock(); - } - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - - public void queryFederationSaveStatus() - throws RestoreInProgress, RTIinternalError - { - WriteFuture writeFuture; - - federateStateLock.readLock().lock(); - try - { - checkIfRestoreInProgress(); - - writeFuture = rtiSession.write(new QueryFederationSaveStatus()); - } - finally - { - federateStateLock.readLock().unlock(); - } - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - - public void requestFederationRestore(String label) - throws SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - RequestFederationRestore requestFederationRestore = - new RequestFederationRestore(label); - WriteFuture writeFuture = rtiSession.write(requestFederationRestore); - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - - // TODO: set timeout - // - Object response = requestFederationRestore.getResponse(); - if (response instanceof SaveInProgress) - { - throw new SaveInProgress((SaveInProgress) response); - } - else if (response instanceof RestoreInProgress) - { - throw new RestoreInProgress((RestoreInProgress) response); - } - else - { - assert false : String.format("unexpected response: %s", response); - } - } - catch (InterruptedException ie) - { - throw new RTIinternalError("interrupted awaiting timeout", ie); - } - catch (ExecutionException ee) - { - throw new RTIinternalError("unable to get response", ee); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void federateRestoreComplete() - throws RestoreNotRequested, SaveInProgress, RTIinternalError - { - WriteFuture writeFuture; - - federateStateLock.readLock().lock(); - try - { - checkIfSaveInProgress(); - - if (federateRestoreState != FederateRestoreState.RESTORING) - { - throw new RestoreNotRequested(); - } - - writeFuture = rtiSession.write(new FederateRestoreComplete()); - - federateRestoreState = - FederateRestoreState.WAITING_FOR_FEDERATION_TO_RESTORE; - } - finally - { - federateStateLock.readLock().unlock(); - } - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - - public void federateRestoreNotComplete() - throws RestoreNotRequested, SaveInProgress, RTIinternalError - { - WriteFuture writeFuture; - - federateStateLock.readLock().lock(); - try - { - checkIfSaveInProgress(); - - if (federateRestoreState != FederateRestoreState.RESTORING) - { - throw new RestoreNotRequested(); - } - - writeFuture = rtiSession.write(new FederateRestoreNotComplete()); - - federateRestoreState = - FederateRestoreState.WAITING_FOR_FEDERATION_TO_RESTORE; - } - finally - { - federateStateLock.readLock().unlock(); - } - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - - public void queryFederationRestoreStatus() - throws SaveInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfSaveInProgress(); - - WriteFuture writeFuture = - rtiSession.write(new QueryFederationRestoreStatus()); - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void publishObjectClassAttributes( - ObjectClassHandle objectClassHandle, AttributeHandleSet attributeHandles) - throws ObjectClassNotDefined, AttributeNotDefined, SaveInProgress, - RestoreInProgress, RTIinternalError - { - // ensure we have a valid object class and attribute handles - // - fdd.checkIfAttributeNotDefined(objectClassHandle, attributeHandles); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.publishObjectClassAttributes( - objectClassHandle, attributeHandles); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void unpublishObjectClass(ObjectClassHandle objectClassHandle) - throws ObjectClassNotDefined, OwnershipAcquisitionPending, - SaveInProgress, RestoreInProgress, RTIinternalError - { - // ensure we have a valid object class handle - // - fdd.checkIfObjectClassNotDefined(objectClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.unpublishObjectClass(objectClassHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void unpublishObjectClassAttributes( - ObjectClassHandle objectClassHandle, AttributeHandleSet attributeHandles) - throws ObjectClassNotDefined, AttributeNotDefined, - OwnershipAcquisitionPending, SaveInProgress, RestoreInProgress, - RTIinternalError - { - // ensure we have a valid object class handle - // - fdd.checkIfObjectClassNotDefined(objectClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.unpublishObjectClassAttributes( - objectClassHandle, attributeHandles); - - // TODO: give up ownership of the specified attributes - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void publishInteractionClass( - InteractionClassHandle interactionClassHandle) - throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, - RTIinternalError - { - // ensure we have a valid interaction class handle - // - fdd.checkIfInteractionClassNotDefined(interactionClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.publishInteractionClass(interactionClassHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void unpublishInteractionClass( - InteractionClassHandle interactionClassHandle) - throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, - RTIinternalError - { - // ensure we have a valid interaction class handle - // - fdd.checkIfInteractionClassNotDefined(interactionClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.unpublishInteractionClass(interactionClassHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void subscribeObjectClassAttributes( - ObjectClassHandle objectClassHandle, AttributeHandleSet attributeHandles) - throws ObjectClassNotDefined, AttributeNotDefined, SaveInProgress, - RestoreInProgress, RTIinternalError - { - subscribeObjectClassAttributes(objectClassHandle, attributeHandles, false); - } - - public void subscribeObjectClassAttributesPassively( - ObjectClassHandle objectClassHandle, AttributeHandleSet attributeHandles) - throws ObjectClassNotDefined, AttributeNotDefined, SaveInProgress, - RestoreInProgress, RTIinternalError - { - subscribeObjectClassAttributes(objectClassHandle, attributeHandles, true); - } - - protected void subscribeObjectClassAttributes( - ObjectClassHandle objectClassHandle, AttributeHandleSet attributeHandles, - boolean passive) - throws ObjectClassNotDefined, AttributeNotDefined, SaveInProgress, - RestoreInProgress, RTIinternalError - { - // ensure we have a valid object class and attribute handles - // - fdd.checkIfAttributeNotDefined(objectClassHandle, attributeHandles); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.subscribeObjectClassAttributes( - objectClassHandle, attributeHandles, passive); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void unsubscribeObjectClass(ObjectClassHandle objectClassHandle) - throws ObjectClassNotDefined, SaveInProgress, RestoreInProgress, - RTIinternalError - { - // ensure we have a valid object class handle - // - fdd.checkIfObjectClassNotDefined(objectClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.unsubscribeObjectClass(objectClassHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void unsubscribeObjectClassAttributes( - ObjectClassHandle objectClassHandle, AttributeHandleSet attributeHandles) - throws ObjectClassNotDefined, AttributeNotDefined, SaveInProgress, - RestoreInProgress, RTIinternalError - { - // ensure we have a valid object class handle - // - fdd.checkIfObjectClassNotDefined(objectClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.unsubscribeObjectClassAttributes( - objectClassHandle, attributeHandles); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void subscribeInteractionClass( - InteractionClassHandle interactionClassHandle) - throws InteractionClassNotDefined, - FederateServiceInvocationsAreBeingReportedViaMOM, SaveInProgress, - RestoreInProgress, RTIinternalError - { - subscribeInteractionClass(interactionClassHandle, false); - } - - public void subscribeInteractionClassPassively( - InteractionClassHandle interactionClassHandle) - throws InteractionClassNotDefined, - FederateServiceInvocationsAreBeingReportedViaMOM, SaveInProgress, - RestoreInProgress, RTIinternalError - { - subscribeInteractionClass(interactionClassHandle, true); - } - - protected void subscribeInteractionClass( - InteractionClassHandle interactionClassHandle, boolean passive) - throws InteractionClassNotDefined, - FederateServiceInvocationsAreBeingReportedViaMOM, SaveInProgress, - RestoreInProgress, RTIinternalError - { - // ensure we have a valid interaction class handle - // - fdd.checkIfInteractionClassNotDefined(interactionClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.subscribeInteractionClass(interactionClassHandle, passive); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void unsubscribeInteractionClass( - InteractionClassHandle interactionClassHandle) - throws InteractionClassNotDefined, SaveInProgress, RestoreInProgress, - RTIinternalError - { - // ensure we have a valid interaction class handle - // - fdd.checkIfInteractionClassNotDefined(interactionClassHandle); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.unsubscribeInteractionClass(interactionClassHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void reserveObjectInstanceName(String name) - throws IllegalName, SaveInProgress, RestoreInProgress, RTIinternalError - { - if (name.startsWith("HLA")) - { - throw new IllegalName(String.format("starts with 'HLA': %s", name)); - } - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.reserveObjectInstanceName(name); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public ObjectInstanceHandle registerObjectInstance( - ObjectClassHandle objectClassHandle) - throws ObjectClassNotDefined, ObjectClassNotPublished, SaveInProgress, - RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - return objectManager.registerObjectInstance(objectClassHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public ObjectInstanceHandle registerObjectInstance( - ObjectClassHandle objectClassHandle, String name) - throws ObjectClassNotDefined, ObjectClassNotPublished, - ObjectInstanceNameNotReserved, ObjectInstanceNameInUse, - SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - return objectManager.registerObjectInstance(objectClassHandle, name); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void updateAttributeValues( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleValueMap attributeValues, byte[] tag) - throws ObjectInstanceNotKnown, AttributeNotDefined, AttributeNotOwned, - SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.updateAttributeValues( - objectInstanceHandle, attributeValues, tag); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public MessageRetractionReturn updateAttributeValues( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleValueMap attributeValues, byte[] tag, LogicalTime updateTime) - throws ObjectInstanceNotKnown, AttributeNotDefined, AttributeNotOwned, - InvalidLogicalTime, SaveInProgress, RestoreInProgress, - RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - MessageRetractionHandle messageRetractionHandle = null; - - timeManager.getTimeLock().readLock().lock(); - try - { - timeManager.updateAttributeValues(updateTime); - - OrderType sentOrderType = - timeManager.isTimeRegulating() && updateTime != null ? - OrderType.TIMESTAMP : OrderType.RECEIVE; - - if (sentOrderType == OrderType.TIMESTAMP) - { - messageRetractionHandle = messageRetractionManager.add(updateTime); - } - - objectManager.updateAttributeValues( - objectInstanceHandle, attributeValues, tag, updateTime, - messageRetractionHandle, sentOrderType); - } - finally - { - timeManager.getTimeLock().readLock().unlock(); - } - - return new MessageRetractionReturn(messageRetractionHandle != null, - messageRetractionHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void sendInteraction( - InteractionClassHandle interactionClassHandle, - ParameterHandleValueMap parameterValues, byte[] tag) - throws InteractionClassNotPublished, InteractionClassNotDefined, - InteractionParameterNotDefined, SaveInProgress, RestoreInProgress, - RTIinternalError - { - // ensure we have a valid interaction class and parameter handles - // - fdd.checkIfInteractionParameterNotDefined( - interactionClassHandle, parameterValues.keySet()); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.sendInteraction( - interactionClassHandle, parameterValues, tag); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public MessageRetractionReturn sendInteraction( - InteractionClassHandle interactionClassHandle, - ParameterHandleValueMap parameterValues, byte[] tag, LogicalTime sendTime) - throws InteractionClassNotPublished, InteractionClassNotDefined, - InteractionParameterNotDefined, InvalidLogicalTime, SaveInProgress, - RestoreInProgress, RTIinternalError - { - // ensure we have a valid interaction class and parameter handles - // - fdd.checkIfInteractionParameterNotDefined( - interactionClassHandle, parameterValues.keySet()); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - MessageRetractionHandle messageRetractionHandle = null; - - timeManager.getTimeLock().readLock().lock(); - try - { - timeManager.sendInteraction(sendTime); - - OrderType sentOrderType = - timeManager.isTimeRegulating() && sendTime != null ? - OrderType.TIMESTAMP : OrderType.RECEIVE; - - if (sentOrderType == OrderType.TIMESTAMP) - { - messageRetractionHandle = messageRetractionManager.add(sendTime); - } - - objectManager.sendInteraction( - interactionClassHandle, parameterValues, tag, sendTime, - messageRetractionHandle, sentOrderType); - } - finally - { - timeManager.getTimeLock().readLock().unlock(); - } - - return new MessageRetractionReturn(messageRetractionHandle != null, - messageRetractionHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void deleteObjectInstance( - ObjectInstanceHandle objectInstanceHandle, byte[] tag) - throws ObjectInstanceNotKnown, DeletePrivilegeNotHeld, SaveInProgress, - RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.deleteObjectInstance(objectInstanceHandle, tag); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public MessageRetractionReturn deleteObjectInstance( - ObjectInstanceHandle objectInstanceHandle, byte[] tag, - LogicalTime deleteTime) - throws ObjectInstanceNotKnown, DeletePrivilegeNotHeld, InvalidLogicalTime, - SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - MessageRetractionHandle messageRetractionHandle = null; - - timeManager.getTimeLock().readLock().lock(); - try - { - timeManager.deleteObjectInstance(deleteTime); - - OrderType sentOrderType = - timeManager.isTimeRegulating() && deleteTime != null ? - OrderType.TIMESTAMP : OrderType.RECEIVE; - - if (sentOrderType == OrderType.TIMESTAMP) - { - messageRetractionHandle = messageRetractionManager.add(deleteTime); - } - - objectManager.deleteObjectInstance( - objectInstanceHandle, tag, deleteTime, messageRetractionHandle, - sentOrderType); - } - finally - { - timeManager.getTimeLock().readLock().unlock(); - } - - return new MessageRetractionReturn(messageRetractionHandle != null, - messageRetractionHandle); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void localDeleteObjectInstance( - ObjectInstanceHandle objectInstanceHandle) - throws ObjectInstanceNotKnown, FederateOwnsAttributes, - OwnershipAcquisitionPending, SaveInProgress, RestoreInProgress, - RTIinternalError - { - objectManager.localDeleteObjectInstance(objectInstanceHandle); - } - - public void changeAttributeTransportationType( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleSet attributeHandles, TransportationType transportationType) - throws ObjectInstanceNotKnown, AttributeNotDefined, AttributeNotOwned, - SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.changeAttributeTransportationType( - objectInstanceHandle, attributeHandles, transportationType); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void changeInteractionTransportationType( - InteractionClassHandle interactionClassHandle, - TransportationType transportationType) - throws InteractionClassNotDefined, InteractionClassNotPublished, - SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.changeInteractionTransportationType( - interactionClassHandle, transportationType); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void requestAttributeValueUpdate( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleSet attributeHandles, byte[] tag) - throws ObjectInstanceNotKnown, AttributeNotDefined, - SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.requestAttributeValueUpdate( - objectInstanceHandle, attributeHandles, tag); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void requestAttributeValueUpdate( - ObjectClassHandle objectClassHandle, - AttributeHandleSet attributeHandles, - byte[] tag) - throws ObjectClassNotDefined, AttributeNotDefined, SaveInProgress, - RestoreInProgress, RTIinternalError - { - // check to see if the handles are valid - // - fdd.checkIfAttributeNotDefined(objectClassHandle, attributeHandles); - - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - WriteFuture writeFuture = rtiSession.write( - new RequestAttributeValueUpdate( - objectClassHandle, attributeHandles, tag)); - - // TODO: set timeout - // - writeFuture.join(); - - if (!writeFuture.isWritten()) - { - throw new RTIinternalError("error communicating with RTI"); - } - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void unconditionalAttributeOwnershipDivestiture( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleSet attributeHandles) - throws ObjectInstanceNotKnown, AttributeNotDefined, AttributeNotOwned, - SaveInProgress, RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.unconditionalAttributeOwnershipDivestiture( - objectInstanceHandle, attributeHandles); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void negotiatedAttributeOwnershipDivestiture( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleSet attributeHandles, byte[] tag) - throws ObjectInstanceNotKnown, AttributeNotDefined, AttributeNotOwned, - AttributeAlreadyBeingDivested, SaveInProgress, RestoreInProgress, - RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.negotiatedAttributeOwnershipDivestiture( - objectInstanceHandle, attributeHandles, tag); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void confirmDivestiture( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleSet attributeHandles, byte[] tag) - throws ObjectInstanceNotKnown, AttributeNotDefined, AttributeNotOwned, - AttributeDivestitureWasNotRequested, SaveInProgress, - RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManager.confirmDivestiture( - objectInstanceHandle, attributeHandles, tag); - } - finally - { - federateStateLock.readLock().unlock(); - } - } - - public void attributeOwnershipAcquisition( - ObjectInstanceHandle objectInstanceHandle, - AttributeHandleSet attributeHandles, byte[] tag) - throws ObjectInstanceNotKnown, ObjectClassNotPublished, AttributeNotDefined, - AttributeNotPublished, FederateOwnsAttributes, SaveInProgress, - RestoreInProgress, RTIinternalError - { - federateStateLock.readLock().lock(); - try - { - checkIfActive(); - - objectManage... [truncated message content] |