private static ProtobufMessages.KnowledgeSession loadAndParseSession(MarshallerReaderContext context) throws IOException, ClassNotFoundException { ExtensionRegistry registry = PersisterHelper.buildRegistry( context, processMarshaller ); ProtobufMessages.Header _header = PersisterHelper.readFromStreamWithHeaderPreloaded(context, registry); return ProtobufMessages.KnowledgeSession.parseFrom( _header.getPayload(), registry ); }
public static void writeSession(MarshallerWriteContext context) throws IOException { ProtobufMessages.KnowledgeSession _session = serializeSession(context); PersisterHelper.writeToStreamWithHeader(context, _session); }
public Object unmarshal(Context context, ObjectInputStream is, byte[] object, ClassLoader classloader) throws IOException, ClassNotFoundException { SerializablePlaceholderStrategyContext ctx = (SerializablePlaceholderStrategyContext)context; return ctx.data.get( PersisterHelper.byteArrayToInt( object ) ); }
private static ProtobufMessages.Header loadStrategiesCheckSignature(MarshallerReaderContext context, ProtobufMessages.Header _header) throws ClassNotFoundException, IOException { loadStrategiesIndex( context, _header ); byte[] sessionbuff = _header.getPayload().toByteArray(); // should we check version as well here? checkSignature( _header, sessionbuff ); return _header; }
private static void readActivations(MarshallerReaderContext context, List<ProtobufMessages.Activation> _list) { for ( ProtobufMessages.Activation _activation : _list ) { context.filter.getDormantActivationsMap().put( PersisterHelper.createActivationKey( _activation.getPackageName(), _activation.getRuleName(), _activation.getTuple() ), _activation ); } }
public static ProtobufMessages.Activation createActivation(final String packageName, final String ruleName, final LeftTuple tuple) { return ProtobufMessages.Activation.newBuilder() .setPackageName( packageName ) .setRuleName( ruleName ) .setTuple( createTuple( tuple ) ) .build(); }
Map<TupleKey, ProtobufMessages.FactHandle> map = new HashMap<TupleKey, ProtobufMessages.FactHandle>(); for( ProtobufMessages.NodeMemory.AccumulateNodeMemory.AccumulateContext _ctx : _node.getAccumulate().getContextList() ) { map.put( PersisterHelper.createTupleKey( _ctx.getTuple() ), _ctx.getResultHandle() ); Map<TupleKey, ProtobufMessages.FactHandle> map = new HashMap<TupleKey, ProtobufMessages.FactHandle>(); for( ProtobufMessages.NodeMemory.RIANodeMemory.RIAContext _ctx : _node.getRia().getContextList() ) { map.put( PersisterHelper.createTupleKey( _ctx.getTuple() ), _ctx.getResultHandle() ); for( ProtobufMessages.NodeMemory.FromNodeMemory.FromContext _ctx : _node.getFrom().getContextList() ) { map.put( PersisterHelper.createTupleKey( _ctx.getTuple() ), new LinkedList<ProtobufMessages.FactHandle>( _ctx.getHandleList() ) ); map.put( PersisterHelper.createTupleKey( _ctx.getTuple() ), new QueryElementContext( _ctx ) );
public static ProtobufInputMarshaller.ActivationKey createActivationKey(final String pkgName, final String ruleName, final ProtobufMessages.Tuple _tuple) { int[] tuple = createTupleArray( _tuple ); return new ProtobufInputMarshaller.ActivationKey( pkgName, ruleName, tuple ); }
public ProtobufMessages.ActionQueue.Action serialize(MarshallerWriteContext context) { LogicalRetract _retract = ProtobufMessages.ActionQueue.LogicalRetract.newBuilder() .setHandleId( this.handle.getId() ) .setActivation( PersisterHelper.createActivation( this.activation.getRule().getPackageName(), this.activation.getRule().getName(), this.activation.getTuple() ) ) .build(); return ProtobufMessages.ActionQueue.Action.newBuilder() .setType( ProtobufMessages.ActionQueue.ActionType.LOGICAL_RETRACT ) .setLogicalRetract( _retract ) .build(); }
public boolean accept(Activation activation, PropagationContext context, InternalWorkingMemory workingMemory, RuleTerminalNode rtn) { ActivationKey key = PersisterHelper.createActivationKey( rtn.getRule().getPackageName(), rtn.getRule().getName(), activation.getTuple() ); // add the tuple to the cache for correlation this.tuplesCache.put( key, activation.getTuple() ); // check if there was an active activation for it return !this.dormantActivations.containsKey( key ); }
@SuppressWarnings("unchecked") private static ProtobufMessages.NodeMemory writeFromNodeMemory(final int nodeId, final Memory memory) { FromMemory fromMemory = (FromMemory) memory; if (fromMemory.betaMemory.getLeftTupleMemory().size() > 0) { ProtobufMessages.NodeMemory.FromNodeMemory.Builder _from = ProtobufMessages.NodeMemory.FromNodeMemory.newBuilder(); final org.drools.core.util.Iterator tupleIter = fromMemory.betaMemory.getLeftTupleMemory().iterator(); for (LeftTuple leftTuple = (LeftTuple) tupleIter.next(); leftTuple != null; leftTuple = (LeftTuple) tupleIter.next()) { Map<Object, RightTuple> matches = (Map<Object, RightTuple>) leftTuple.getObject(); ProtobufMessages.NodeMemory.FromNodeMemory.FromContext.Builder _context = ProtobufMessages.NodeMemory.FromNodeMemory.FromContext.newBuilder() .setTuple(PersisterHelper.createTuple(leftTuple)); for (RightTuple rightTuple : matches.values()) { FactHandle _handle = ProtobufMessages.FactHandle.newBuilder() .setId(rightTuple.getFactHandle().getId()) .setRecency(rightTuple.getFactHandle().getRecency()) .build(); _context.addHandle(_handle); } _from.addContext(_context.build()); } return ProtobufMessages.NodeMemory.newBuilder() .setNodeId(nodeId) .setNodeType(ProtobufMessages.NodeMemory.NodeType.FROM) .setFrom(_from.build()) .build(); } return null; }
@SuppressWarnings("unchecked") private QueryElementFactHandle createQueryResultHandle(PropagationContext context, InternalWorkingMemory workingMemory, Object[] objects) { QueryElementFactHandle handle = null; ProtobufMessages.FactHandle _handle = null; if( context.getReaderContext() != null ) { Map<TupleKey, QueryElementContext> map = (Map<TupleKey, QueryElementContext>) context.getReaderContext().nodeMemories.get( node.getId() ); if( map != null ) { QueryElementContext _context = map.get( PersisterHelper.createTupleKey( leftTuple ) ); if( _context != null ) { _handle = _context.results.removeFirst(); } } } if( _handle != null ) { // create a handle with the given id handle = new QueryElementFactHandle( objects, _handle.getId(), _handle.getRecency() ); } else { handle = new QueryElementFactHandle( objects, workingMemory.getFactHandleFactory().getAtomicId().incrementAndGet(), workingMemory.getFactHandleFactory().getAtomicRecency().incrementAndGet() ); } return handle; }
public static ProtobufInputMarshaller.TupleKey createTupleKey(final ProtobufMessages.Tuple _tuple) { return new ProtobufInputMarshaller.TupleKey( createTupleArray( _tuple ) ); }
public Timer serialize(JobContext jobCtx, MarshallerWriteContext outputCtx) { ActivationTimerJobContext ajobCtx = ( ActivationTimerJobContext ) jobCtx; return ProtobufMessages.Timers.Timer.newBuilder() .setType( ProtobufMessages.Timers.TimerType.ACTIVATION ) .setActivation( ProtobufMessages.Timers.ActivationTimer.newBuilder() .setActivation( PersisterHelper.createActivation( ajobCtx.getScheduledAgendaItem().getRule().getPackageName(), ajobCtx.getScheduledAgendaItem().getRule().getName(), ajobCtx.getScheduledAgendaItem().getTuple() ) ) .setTrigger( ProtobufOutputMarshaller.writeTrigger(ajobCtx.getTrigger(), outputCtx) ) .build() ) .build(); } }
context.classLoader = ContentMarshallerHelper.class.getClassLoader(); ExtensionRegistry registry = PersisterHelper.buildRegistry(context, null); Header _header = PersisterHelper.readFromStreamWithHeaderPreloaded(context, registry); Variable parseFrom = JBPMMessages.Variable.parseFrom(_header.getPayload(), registry); Object value = ProtobufProcessMarshaller.unmarshallVariableValue(context, parseFrom);
o); PersisterHelper.writeToStreamWithHeader( context, marshallVariable);
public WorkingMemoryReteAssertAction(MarshallerReaderContext context, Action _action) { Assert _assert = _action.getAssert(); this.factHandle = context.handles.get( _assert.getHandleId() ); this.removeLogical = _assert.getRemoveLogical(); this.updateEqualsMap = _assert.getUpdateEqualsMap(); if ( _assert.hasTuple() ) { String pkgName = _assert.getOriginPkgName(); String ruleName = _assert.getOriginRuleName(); Package pkg = context.ruleBase.getPackage( pkgName ); this.ruleOrigin = pkg.getRule( ruleName ); this.leftTuple = context.filter.getTuplesCache().get( PersisterHelper.createActivationKey( pkgName, ruleName, _assert.getTuple() ) ); } }
private static ProtobufMessages.NodeMemory writeRIANodeMemory(final int nodeId, final Memory memory) { // for RIA nodes, we need to store the ID of the created handles RIAMemory mem = (RIAMemory) memory; if (!mem.memory.isEmpty()) { ProtobufMessages.NodeMemory.RIANodeMemory.Builder _ria = ProtobufMessages.NodeMemory.RIANodeMemory.newBuilder(); final org.drools.core.util.Iterator it = mem.memory.iterator(); // iterates over all propagated handles and assert them to the new sink for (ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next()) { LeftTuple leftTuple = (LeftTuple) entry.getKey(); InternalFactHandle handle = (InternalFactHandle) entry.getValue(); FactHandle _handle = ProtobufMessages.FactHandle.newBuilder() .setId(handle.getId()) .setRecency(handle.getRecency()) .build(); _ria.addContext(ProtobufMessages.NodeMemory.RIANodeMemory.RIAContext.newBuilder() .setTuple(PersisterHelper.createTuple(leftTuple)) .setResultHandle(_handle) .build()); } return ProtobufMessages.NodeMemory.newBuilder() .setNodeId(nodeId) .setNodeType(ProtobufMessages.NodeMemory.NodeType.RIA) .setRia(_ria.build()) .build(); } return null; }
Map<ProtobufInputMarshaller.TupleKey, List<ProtobufMessages.FactHandle>> map = (Map<ProtobufInputMarshaller.TupleKey, List<ProtobufMessages.FactHandle>>) context.getReaderContext().nodeMemories.get( getId() ); if( map != null ) { TupleKey key = PersisterHelper.createTupleKey( leftTuple ); List<FactHandle> list = map.get( key ); if( list != null && ! list.isEmpty() ) {
public static ProtobufInputMarshaller.ActivationKey createActivationKey(final String pkgName, final String ruleName, final LeftTuple leftTuple) { int[] tuple = createTupleArray( leftTuple ); return new ProtobufInputMarshaller.ActivationKey( pkgName, ruleName, tuple ); }