public void testReloadStates() throws Exception { File soupsDir = new File(CompatibilityTest.class.getClassLoader().getResource("soups").getFile()); for (File soupState : soupsDir.listFiles( new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith("soup"); } })) { ExecutionQueueImpl soup = new ExecutionQueueImpl(CoreBpelTest.class.getClassLoader()); soup.read(new FileInputStream(soupState)); JacobVPU vpu = new JacobVPU(soup); CoreBpelTest instance = new CoreBpelTest(); vpu.registerExtension(OdeRTInstanceContext.class, instance); instance._completedOk = false; instance._terminate = false; instance._fault = null; for (int i = 0; i < 1000 && !instance._completedOk && instance._fault == null && !instance._terminate; ++i) vpu.execute(); } }
public RuntimeInstanceImpl(RuntimeImpl runtime, ExecutionQueueImpl soup) { _runtime = runtime; _vpu = new JacobVPU(); _vpu.registerExtension(OdeRTInstanceContext.class, this); if (soup == null) { _soup = new ExecutionQueueImpl(getClass().getClassLoader()); _soup.setGlobalData(new OutstandingRequestManager()); } else { _soup = soup; } _soup.setReplacementMap(_runtime._replacementMap); _vpu.setContext(_soup); }
public void testReloadProcess() throws Exception { File soupsDir = new File(CompatibilityTest.class.getClassLoader().getResource("soups").getFile()); for (File soupState : soupsDir.listFiles( new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith("sa"); } })) { ExecutionQueueImpl soup = new ExecutionQueueImpl(CoreBpelTest.class.getClassLoader()); Serializer ser = new Serializer( CompatibilityTest.class.getClassLoader().getResourceAsStream("TestActivityFlow.cbp")); soup.setReplacementMap(new ReplacementMapImpl((OProcess) ser.readPModel())); soup.read(new FileInputStream(soupState)); // JacobVPU vpu = new JacobVPU(soup); // CoreBpelTest instance = new CoreBpelTest(); // vpu.registerExtension(OdeRTInstanceContext.class, instance); // // instance._completedOk = false; // instance._terminate = false; // instance._fault = null; // // int i = 0; // try { // for (i = 0; i < 100000 && !instance._completedOk && instance._fault == null && // !instance._terminate; ++i) { // vpu.execute(); // } // } catch (Exception npe) { // npe.printStackTrace(); // } // System.out.println("=> " + i); } }
@Override public void run() { // Remember all running PickReceive activities Set<OActivity> pickReceives = new HashSet<OActivity>(); ActivityEventHandler evtHandler = ActivityEventHandler.getInstance(); List<Running_Activity> activities = evtHandler.getRunningActivities(); // Loop through all running activities for (Running_Activity run_Act : activities) { // Check if the activity belongs to our process instance if (run_Act.getProcessID().equals(getBpelRuntimeContext().getPid())) { // Get the activity over its xpath OActivity act = ReexecutionHandler.getActivity( run_Act.getXPath(), getBpelRuntimeContext().getBpelProcess().getOProcess()); if (act != null) { if (act instanceof OPickReceive) { pickReceives.add(act); } } } } if (!pickReceives.isEmpty()) { ExecutionQueueImpl soup = (ExecutionQueueImpl) getBpelRuntimeContext().getVPU()._executionQueue; /* * Check the IMAManager for conflicting PickResponseChannels: */ // Query the PickResponseChannels of all PICK's over the // execution queue // index list Set<PickResponseChannel> pickResponseChannels = new HashSet<PickResponseChannel>(); if (!soup.getIndex().keySet().isEmpty()) { LinkedList<IndexedObject> list = null; Iterator<Object> keys = soup.getIndex().keySet().iterator(); while (keys.hasNext()) { Key key = (Key) keys.next(); if (key.getType().getClass() == OPickReceive.class) { if (pickReceives.contains(key.getType())) { list = soup.getIndex().get(key); } else { list = null; } } if (list != null) { Iterator<IndexedObject> iter = list.iterator(); while (iter.hasNext()) { IndexedObject obj = iter.next(); if (obj instanceof PICK) { pickResponseChannels.add(((PICK) obj).getPickResponseChannel()); } } } } } for (PickResponseChannel channel : pickResponseChannels) { String channelStr = channel.export(); // Remove the PickResponseChannel from the // IMAManager, if it is registered if (getBpelRuntimeContext().isIMAChannelRegistered(channelStr)) { getBpelRuntimeContext().cancelOutstandingRequests(channelStr); // Delete the corresponding outdated MessageRoute String correlatorStr = ChannelRegistry.getRegistry() .getPickResponseChannelCorrelator(getBpelRuntimeContext().getPid(), channelStr); ProcessDAO process = getBpelRuntimeContext().getBpelProcess().getProcessDAO(); CorrelatorDAO correlator = process.getCorrelator(correlatorStr); correlator.removeRoutes( channelStr, process.getInstance(getBpelRuntimeContext().getPid())); } } } instance(_iterationRunnable); }
/* (non-Javadoc) * @see org.apache.ode.bpel.engine.rapi.OdeInternalInstance#saveState() */ public Object saveState(OutputStream bos) throws IOException { if (bos != null) _soup.write(bos); return _soup; }
private OutstandingRequestManager getORM() { return (OutstandingRequestManager) _soup.getGlobalData(); }