public void write( MarshallerWriteContext context ) throws IOException { context.writeShort( WorkingMemoryAction.PropagateAction ); context.write( node.getId() ); }
public void write(MarshallerWriteContext context) throws IOException { context.writeShort( WorkingMemoryAction.WorkingMemoryReteAssertAction ); context.writeInt( this.factHandle.getId() ); context.writeBoolean( this.removeLogical ); context.writeBoolean( this.updateEqualsMap ); if ( this.ruleOrigin != null ) { context.writeBoolean( true ); context.writeUTF( ruleOrigin.getPackage() ); context.writeUTF( ruleOrigin.getName() ); } else { context.writeBoolean( false ); } if ( this.leftTuple != null ) { context.writeBoolean( true ); context.writeInt( context.terminalTupleMap.get( this.leftTuple ) ); } else { context.writeBoolean( false ); } }
public void write(MarshallerWriteContext context) throws IOException { context.writeShort( WorkingMemoryAction.LogicalRetractCallback ); context.writeInt( this.handle.getId() ); context.writeLong( this.context.getPropagationNumber() ); context.writeInt( context.terminalTupleMap.get( this.activation.getTuple() ) ); }
public void write(MarshallerWriteContext context) throws IOException { context.writeShort( WorkingMemoryAction.DeactivateCallback ); context.writeUTF( ruleFlowGroup.getName() ); }
public void marshall(final OutputStream stream, final StatefulKnowledgeSession ksession, final long clockTime) throws IOException { MarshallerWriteContext context = new MarshallerWriteContext( stream, (InternalRuleBase) ((InternalKnowledgeBase) kbase).getRuleBase(), (InternalWorkingMemory) ((StatefulKnowledgeSessionImpl) ksession).session, RuleBaseNodes.getNodeMap( (InternalRuleBase) ((InternalKnowledgeBase) kbase).getRuleBase() ), this.strategyStore, this.marshallingConfig.isMarshallProcessInstances(), this.marshallingConfig.isMarshallWorkItems(), ksession.getEnvironment() ); context.clockTime = clockTime; ProtobufOutputMarshaller.writeSession( context ); context.close(); }
public void write(MarshallerWriteContext context) throws IOException { context.writeShort( WorkingMemoryAction.WorkingMemoryReteExpireAction ); context.writeInt( this.factHandle.getId() ); context.writeInt( this.node.getId() ); }
public static void writeTimers(Collection<TimerJobInstance> timers, MarshallerWriteContext outCtx) throws IOException { List<TimerJobInstance> sortedTimers = new ArrayList<TimerJobInstance>( timers ); Collections.sort( sortedTimers, new Comparator<TimerJobInstance>() { public int compare(TimerJobInstance o1, TimerJobInstance o2) { return (int) (o1.getJobHandle().getId() - o2.getJobHandle().getId()); } } ); for ( TimerJobInstance timer : sortedTimers ) { outCtx.writeShort( PersisterEnums.DEFAULT_TIMER ); JobContext jctx = ((SelfRemovalJobContext)timer.getJobContext()).getJobContext(); TimersOutputMarshaller writer = outCtx.writersByClass.get( jctx.getClass() ); writer.write( jctx, outCtx ); } outCtx.writeShort( PersisterEnums.END ); }
public static void writeToStreamWithHeader( MarshallerWriteContext context, Message payload ) throws IOException { ProtobufMessages.Header.Builder _header = ProtobufMessages.Header.newBuilder(); // need to automate this version numbering somehow _header.setVersion( ProtobufMessages.Version.newBuilder() .setVersionMajor( 5 ) .setVersionMinor( 4 ) .setVersionRevision( 0 ) .build() ); writeStrategiesIndex( context, _header ); byte[] buff = payload.toByteArray(); sign( _header, buff ); _header.setPayload( ByteString.copyFrom( buff ) ); // LoggerFactory.getLogger(PersisterHelper.class).trace("============================================================================================================="); // LoggerFactory.getLogger(PersisterHelper.class).trace(payload); context.stream.write( _header.build().toByteArray() ); }
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(); }
boolean isOpen = node.isOpenQuery(); context.writeBoolean( isOpen ); if ( isOpen ) { InternalFactHandle factHandle = (InternalFactHandle) leftTuple.getObject(); context.writeBoolean( true ); RightTuple rightTuple = (RightTuple) leftTuple.getObject();
public void marshall(final OutputStream stream, final StatefulKnowledgeSession ksession, final long clockTime) throws IOException { MarshallerWriteContext context = new MarshallerWriteContext( stream, (InternalRuleBase) ((InternalKnowledgeBase) kbase).getRuleBase(), (InternalWorkingMemory) ((StatefulKnowledgeSessionImpl) ksession).session, RuleBaseNodes.getNodeMap( (InternalRuleBase) ((InternalKnowledgeBase) kbase).getRuleBase() ), this.strategyStore, this.marshallingConfig.isMarshallProcessInstances(), this.marshallingConfig.isMarshallWorkItems(), ksession.getEnvironment() ); context.clockTime = clockTime; OutputMarshaller.writeSession( context ); context.close(); }
public void write(MarshallerWriteContext outputCtx) throws IOException { outputCtx.writeShort( WorkingMemoryAction.WorkingMemoryBehahviourRetract ); // write out SlidingTimeWindowContext SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) context; EventFactHandle handle = slCtx.getQueue().peek(); outputCtx.writeInt( handle.getId() ); }
public static void writeActionQueue(MarshallerWriteContext context) throws IOException { ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm; WorkingMemoryAction[] queue = wm.getActionQueue().toArray( new WorkingMemoryAction[wm.getActionQueue().size()] ); for ( int i = queue.length - 1; i >= 0; i-- ) { context.writeShort( PersisterEnums.WORKING_MEMORY_ACTION ); queue[i].write( context ); } context.writeShort( PersisterEnums.END ); }
public static void writeTrigger(Trigger trigger, MarshallerWriteContext outCtx) throws IOException { if ( trigger instanceof CronTrigger ) { outCtx.writeShort( PersisterEnums.CRON_TRIGGER ); outCtx.writeLong( cronTrigger.getStartTime().getTime() ); if ( cronTrigger.getEndTime() != null ) { outCtx.writeBoolean( true ); outCtx.writeLong( cronTrigger.getEndTime().getTime() ); } else { outCtx.writeBoolean( false ); outCtx.writeInt( cronTrigger.getRepeatLimit() ); outCtx.writeInt( cronTrigger.getRepeatCount() ); outCtx.writeUTF( cronTrigger.getCronEx().getCronExpression() ); if ( cronTrigger.getNextFireTime() != null ) { outCtx.writeBoolean( true ); outCtx.writeLong( cronTrigger.getNextFireTime().getTime() ); } else { outCtx.writeBoolean( false ); outCtx.writeObject( cronTrigger.getCalendarNames() ); } else if ( trigger instanceof IntervalTrigger ) { outCtx.writeShort( PersisterEnums.INT_TRIGGER ); outCtx.writeLong( intTrigger.getStartTime().getTime() ); if ( intTrigger.getEndTime() != null ) { outCtx.writeBoolean( true ); outCtx.writeLong( intTrigger.getEndTime().getTime() ); } else { outCtx.writeBoolean( false );
ByteArrayOutputStream stream = new ByteArrayOutputStream(); context = new MarshallerWriteContext(stream, null, null, null, objectMarshallingStrategyStore, env); Variable marshallVariable = null; if (o instanceof Map) { marshallVariable); context.close();
public void write(JobContext jobCtx, MarshallerWriteContext outputCtx) throws IOException { outputCtx.writeShort( PersisterEnums.BEHAVIOR_TIMER ); // BehaviorJob, no state BehaviorJobContext bjobCtx = ( BehaviorJobContext ) jobCtx; // write out SlidingTimeWindowContext SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) bjobCtx.behaviorContext; EventFactHandle handle = slCtx.getQueue().peek(); outputCtx.writeInt( handle.getId() ); // BetaNode node = (BetaNode) handle.getRightTupleSink(); // outputCtx.writeInt( node.getId() ); // // Behavior[] behaviors = node.getBehaviors(); // int i = 0; // for ( ; i < behaviors.length; i++ ) { // if ( behaviors[i] == bjobCtx.behavior ) { // break; // } // } // outputCtx.writeInt( i ); }
DefaultAgenda agenda = (DefaultAgenda) wm.getAgenda(); context.writeInt( agenda.getDormantActivations() ); context.writeInt( agenda.getActiveActivations() ); context.writeShort( PersisterEnums.AGENDA_GROUP ); context.writeUTF( group.getName() ); context.writeBoolean( group.isActive() ); context.writeShort( PersisterEnums.END ); context.writeShort( PersisterEnums.AGENDA_GROUP ); context.writeUTF( group.getName() ); context.writeShort( PersisterEnums.END ); context.writeShort( PersisterEnums.RULE_FLOW_GROUP ); context.writeUTF( group.getName() ); context.writeBoolean( group.isActive() ); context.writeBoolean( group.isAutoDeactivate() ); Map<Long, String> nodeInstances = group.getNodeInstances(); context.writeInt( nodeInstances.size() ); for ( Map.Entry<Long, String> entry : nodeInstances.entrySet() ) { context.writeLong( entry.getKey() ); context.writeUTF( entry.getValue() ); context.writeShort( PersisterEnums.END );
public void write(JobContext jobCtx, MarshallerWriteContext outputCtx) throws IOException { outputCtx.writeShort( PersisterEnums.ACTIVATION_TIMER ); ActivationTimerJobContext ajobCtx = ( ActivationTimerJobContext ) jobCtx; int leftTupleId = outputCtx.terminalTupleMap.get( ajobCtx.getScheduledAgendaItem().getTuple() ); outputCtx.writeInt( leftTupleId ); OutputMarshaller.writeTrigger(ajobCtx.getTrigger(), outputCtx); }
public void write(JobContext jobCtx, MarshallerWriteContext outputCtx) throws IOException { outputCtx.writeShort( PersisterEnums.EXPIRE_TIMER ); // ExpireJob, no state ExpireJobContext ejobCtx = (ExpireJobContext) jobCtx; WorkingMemoryReteExpireAction expireAction = ejobCtx.getExpireAction(); outputCtx.writeInt( expireAction.getFactHandle().getId() ); outputCtx.writeUTF( expireAction.getNode().getEntryPoint().getEntryPointId() ); outputCtx.writeUTF( ((ClassObjectType) expireAction.getNode().getObjectType()).getClassType().getName() ); DefaultJobHandle jobHandle = (DefaultJobHandle) ejobCtx.getJobHandle(); PointInTimeTrigger trigger = (PointInTimeTrigger) jobHandle.getTimerJobInstance().getTrigger(); outputCtx.writeLong( trigger.hasNextFireTime().getTime() ); }
public static void writeBehaviours(WindowNode windowNode, MarshallerWriteContext outCtx) throws IOException { Behavior[] behaviors = windowNode.getBehaviors(); WindowMemory memory = (WindowMemory) outCtx.wm.getNodeMemory( windowNode ); Object[] behaviorContexts = ( Object[] ) memory.behaviorContext; for ( int i = 0; i < behaviors.length; i++ ) { if ( windowNode.getBehaviors()[i] instanceof SlidingTimeWindow) { outCtx.writeShort( PersisterEnums.SLIDING_TIME_WIN ); outCtx.writeInt( i ); writeSlidingTimeWindowBehaviour( ( SlidingTimeWindow) windowNode.getBehaviors()[i], ( SlidingTimeWindowContext ) behaviorContexts[i], outCtx); } else if ( windowNode.getBehaviors()[i] instanceof SlidingLengthWindow) { outCtx.writeShort( PersisterEnums.SLIDING_LENGTH_WIN ); outCtx.writeInt( i ); writeSlidingLengthWindowBehaviour( ( SlidingLengthWindow) windowNode.getBehaviors()[i], ( SlidingLengthWindowContext ) behaviorContexts[i], outCtx); } } outCtx.writeShort( PersisterEnums.END ); }