stream.writeLong( efh.getDuration() ); stream.writeBoolean( efh.isExpired() ); stream.writeLong( efh.getActivationsCount() );
public void execute(InternalWorkingMemory workingMemory) { if ( this.factHandle.isValid() ) { EventFactHandle eventHandle = (EventFactHandle) factHandle; if ( eventHandle.hasPendingActions() ) { workingMemory.queueWorkingMemoryAction( this ); return; } // if the fact is still in the working memory (since it may have been previously retracted already final PropagationContext context = new PropagationContextImpl( workingMemory.getNextPropagationIdCounter(), PropagationContext.EXPIRATION, null, null, this.factHandle ); eventHandle.setExpired( true ); this.node.retractObject( factHandle, context, workingMemory ); context.evaluateActionQueue( workingMemory ); // if no activations for this expired event if ( eventHandle.getActivationsCount() == 0 ) { // remove it from the object store and clean up resources eventHandle.getEntryPoint().retract( factHandle ); } context.evaluateActionQueue( workingMemory ); } }
private static ProtobufMessages.FactHandle writeFactHandle(MarshallerWriteContext context, ObjectMarshallingStrategyStore objectMarshallingStrategyStore, InternalFactHandle handle) throws IOException { ProtobufMessages.FactHandle.Builder _handle = ProtobufMessages.FactHandle.newBuilder(); _handle.setType(getHandleType(handle)); _handle.setId(handle.getId()); _handle.setRecency(handle.getRecency()); _handle.setEntryPoint( handle.getEntryPoint().getEntryPointId() ); if (_handle.getType() == ProtobufMessages.FactHandle.HandleType.EVENT) { // is event EventFactHandle efh = (EventFactHandle) handle; _handle.setTimestamp(efh.getStartTimestamp()); _handle.setDuration(efh.getDuration()); _handle.setIsExpired(efh.isExpired()); _handle.setActivationsCount(efh.getActivationsCount()); } Object object = handle.getObject(); if (object != null) { ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(object); Integer index = context.getStrategyIndex(strategy); _handle.setStrategyIndex(index.intValue()); _handle.setObject(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, object))); } return _handle.build(); }