You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2015/04/15 14:22:47 UTC
svn commit: r1673740 [2/2] - in /uima/sandbox/uima-ducc/trunk:
uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/
uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/
uima-ducc-container/src/main/java/org/apache...
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler01.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler01.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler01.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler01.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.junit.Test;
+
+public class TestMessageHandler01 extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ // single node:pid:tid
+
+ @Test
+ public void test_01() {
+ try {
+ setUp();
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(1,1,1);
+ ThreadInfo ti = tif.getRandom();
+ String node = ti.getNodeName();
+ int pid = ti.getPid();
+ int tid = ti.getTid();
+ int casNo = 1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,node,pid,tid,casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ while(metaCas != null) {
+ transAck(messageHandler,trans,casNo);
+ transEnd(messageHandler,trans,casNo);
+ casNo++;
+ metaCasPrevious = metaCas;
+ trans = transGet(messageHandler,node,pid,tid,casNo);
+ metaCas = trans.getMetaCas();
+ }
+ assertTrue(metaCasPrevious.getSystemKey().equals("100"));
+ asExpected("CASes processed count == 100");
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ assertTrue(oi.getWorkItemCrFetches() == 100);
+ asExpected("CASes fetched count == 100");
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler01.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler01.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02a.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02a.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02a.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02a.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.junit.Test;
+
+public class TestMessageHandler02a extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ // multiple node:pid:tid
+
+ @Test
+ public void test_02a() {
+ try {
+ if(skipAll) {
+ return;
+ }
+ //
+ setUp();
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(2,2,2);
+ ThreadInfo ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ int casNo = 1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ assertTrue(metaCas != null);
+ while(metaCas != null) {
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ if(metaCas.getSystemKey().equals("100")) {
+ assertTrue(!oi.isWorkItemCrPending());
+ }
+ else {
+ assertTrue(oi.isWorkItemCrPending());
+ }
+ transAck(messageHandler,trans,casNo);
+ transEnd(messageHandler,trans,casNo);
+ casNo++;
+ metaCasPrevious = metaCas;
+ assertTrue(metaCasPrevious != null);
+ ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ metaCas = trans.getMetaCas();
+ }
+ assertTrue(metaCasPrevious.getSystemKey().equals("100"));
+ asExpected("CASes processed count == 100");
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ assertTrue(oi.getWorkItemCrFetches() == 100);
+ asExpected("CASes fetched count == 100");
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02a.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02a.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02b.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02b.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02b.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02b.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.mh.iface.IWorkItemInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.junit.Test;
+
+public class TestMessageHandler02b extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ // multiple node:pid:tid
+
+ @Test
+ public void test_02b() {
+ try {
+ if(skipAll) {
+ return;
+ }
+ //
+ setUp();
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ enforce = false;
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(200,10,1);
+ ThreadInfo ti = tif.getUnique();
+ debug("random:"+ti.toKey());
+ int casNo = 1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ assertTrue(metaCas != null);
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ while(oi.getWorkItemCrFetches() < 100) {
+ if(metaCas != null) {
+ transAck(messageHandler,trans,casNo);
+ //transEnd(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ casNo++;
+ metaCasPrevious = metaCas;
+ assertTrue(metaCasPrevious != null);
+ }
+ ti = tif.getUnique();
+ debug("random:"+ti.toKey());
+ trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ metaCas = trans.getMetaCas();
+ oi = messageHandler.handleGetOperatingInfo();
+ ArrayList<IWorkItemInfo> list = oi.getActiveWorkItemInfo();
+ debug("list:"+list.size());
+ debug("worker-threads:"+jd.getRemoteWorkerThreadMap().size());
+ }
+ assertTrue(oi.getWorkItemCrFetches() == 100);
+ asExpected("CASes fetched count == 100");
+ ArrayList<IWorkItemInfo> list = oi.getActiveWorkItemInfo();
+ assertTrue(list.size() == 100);
+ asExpected("Operating count == 100");
+ enforce = true;
+ }
+ catch(Exception e) {
+ enforce = true;
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02b.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler02b.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler03.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler03.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler03.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler03.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Random;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.mh.iface.IProcessInfo;
+import org.apache.uima.ducc.container.jd.mh.impl.ProcessInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.junit.Test;
+
+public class TestMessageHandler03 extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ // multiple node:pid:tid with preemptions
+
+ @Test
+ public void test_03() {
+ try {
+ if(skipAll) {
+ return;
+ }
+ //
+ setUp();
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(2,2,2);
+ ThreadInfo ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ int casNo = -1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ assertTrue(metaCas != null);
+ while(metaCas != null) {
+ randomPreemptTest03(messageHandler,ti);
+ transAck(messageHandler,trans,casNo);
+ randomPreemptTest03(messageHandler,ti);
+ try {
+ Thread.sleep(20);
+ }
+ catch(Exception e) {
+ }
+ messageHandler.handleGetOperatingInfo();
+ transEnd(messageHandler,trans,casNo);
+ randomPreemptTest03(messageHandler,ti);
+ casNo--;
+ metaCasPrevious = metaCas;
+ assertTrue(metaCasPrevious != null);
+ ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ metaCas = trans.getMetaCas();
+ }
+ assertTrue(metaCasPrevious.getSystemKey().equals("100"));
+ asExpected("CASes processed count == 100");
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ assertTrue(oi.getWorkItemCrFetches() == 100);
+ asExpected("CASes fetched count == 100");
+ assertTrue(oi.getWorkItemPreemptions() > 0);
+ asExpected("CASes preempted count == "+oi.getWorkItemPreemptions());
+ try {
+ Thread.sleep(50);
+ }
+ catch(Exception e) {
+ }
+ messageHandler.handleGetOperatingInfo();
+ long tod = oi.getWorkItemTodMostRecentStart();
+ assertTrue(tod >= 0);
+ asExpected("Most Recent Start > 0, value="+tod);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ private long seedTest03 = 3;
+ private Random randomTest03 = new Random(seedTest03);
+ private long pctTest03 = 15;
+
+ private void randomPreemptTest03(MessageHandler messageHandler, ThreadInfo ti) {
+ int n = randomTest03.nextInt(100);
+ if(n < pctTest03) {
+ IProcessInfo processInfo = new ProcessInfo(ti.getNodeName(),null,""+ti.getPid(),ti.getPid());
+ messageHandler.handleProcessPreempt(processInfo);
+ }
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler03.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler03.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler04.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler04.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler04.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler04.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Random;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.apache.uima.ducc.user.error.iface.Transformer;
+import org.junit.Test;
+
+public class TestMessageHandler04 extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ // multiple node:pid:tid with errors
+
+ @Test
+ public void test_04() {
+ try {
+ if(skipAll) {
+ return;
+ }
+ //
+ setUp();
+ //
+ System.setProperty(FlagsHelper.Name.JobId.pname(), "40");
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ String key = "ducc.process.log.dir";
+ String value = directory;
+ System.setProperty(key, value);
+ //
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(2,2,2);
+ ThreadInfo ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ int casNo = -1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ assertTrue(metaCas != null);
+ int inject = 0;
+ int index = 0;
+
+ while(metaCas != null) {
+ index++;
+ System.out.println("index:"+index);
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ System.out.println("kill:"+oi.isKillJob());
+ transAck(messageHandler,trans,casNo);
+ if(randomErrorTest04()) {
+ Exception e = new RuntimeException("injected error test #04");
+ Object serializedException = Transformer.serialize(e);
+ metaCas.setUserSpaceException(serializedException);
+ inject++;
+ }
+ transEnd(messageHandler,trans,casNo);
+ IOperatingInfo oi2 = messageHandler.handleGetOperatingInfo();
+ System.out.println("kill2:"+oi2.isKillJob());
+ casNo--;
+ metaCasPrevious = metaCas;
+ assertTrue(metaCasPrevious != null);
+ ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ metaCas = trans.getMetaCas();
+ }
+ //assertTrue(metaCasPrevious.getSystemKey().equals("100"));
+ //asExpected("CASes processed count == 100");
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ //assertTrue(oi.getWorkItemCrFetches() == 100);
+ //asExpected("CASes fetched count == 100");
+ long endSuccess = oi.getWorkItemEndSuccesses();
+ long endFailure = oi.getWorkItemEndFailures();
+ debug("injected errors: "+inject);
+ debug("end success: "+endSuccess);
+ debug("end failure: "+endFailure);
+ assertTrue(endFailure == expectedErrorsTest04);
+ asExpected("CASes error count == "+expectedErrorsTest04);
+ boolean killJob = oi.isKillJob();
+ if(endFailure >= 15) {
+ assertTrue(killJob == true);
+ }
+ else {
+ assertTrue(killJob == false);
+ }
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ private long seedTest04 = 4;
+ private Random randomTest04 = new Random(seedTest04);
+ private long pctTest04 = 15;
+
+ private long expectedErrorsTest04 = 16;
+
+ private boolean randomErrorTest04() {
+ boolean retVal = false;
+ int n = randomTest04.nextInt(100);
+ if(n < pctTest04) {
+ retVal = true;
+ }
+ return retVal;
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler04.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler04.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05a.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05a.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05a.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05a.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Random;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.apache.uima.ducc.user.error.iface.Transformer;
+import org.junit.Test;
+
+public class TestMessageHandler05a extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ // multiple node:pid:tid with errors
+
+ @Test
+ public void test_05a() {
+ try {
+ if(skipAll) {
+ return;
+ }
+ //
+ setUp();
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ String key = "ducc.process.log.dir";
+ String value = directory;
+ System.setProperty(key, value);
+ //
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(2,2,2);
+ ThreadInfo ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ int casNo = -1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ assertTrue(metaCas != null);
+ int inject = 0;
+ while(metaCas != null) {
+ transAck(messageHandler,trans,casNo);
+ if(randomErrorTest05()) {
+ Throwable exception = new RuntimeException("injected error test #05");
+ Object serializedException = Transformer.serialize(exception);
+ metaCas.setUserSpaceException(serializedException);
+ inject++;
+ }
+ transEnd(messageHandler,trans,casNo);
+ casNo--;
+ metaCasPrevious = metaCas;
+ assertTrue(metaCasPrevious != null);
+ ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ metaCas = trans.getMetaCas();
+ }
+ assertTrue(metaCasPrevious.getSystemKey().equals("100"));
+ asExpected("CASes processed count == 100");
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ assertTrue(oi.getWorkItemCrFetches() == 100);
+ asExpected("CASes fetched count == 100");
+ long endSuccess = oi.getWorkItemEndSuccesses();
+ long endFailure = oi.getWorkItemEndFailures();
+ debug("injected errors: "+inject);
+ debug("end success: "+endSuccess);
+ debug("end failure: "+endFailure);
+ System.out.println(endFailure);
+ assertTrue(endFailure == expectedErrorsTest05a);
+ asExpected("CASes error count == "+expectedErrorsTest05a);
+ assertTrue(endSuccess+endFailure == 100);
+ asExpected("CASes failure+success count == 100");
+ boolean killJob = oi.isKillJob();
+ assertTrue(killJob == false);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ private long seedTest05 = 5;
+ private Random randomTest05 = new Random(seedTest05);
+ private long pctTest05 = 5;
+
+ private long expectedErrorsTest05a = 7;
+
+ private boolean randomErrorTest05() {
+ boolean retVal = false;
+ int n = randomTest05.nextInt(100);
+ if(n < pctTest05) {
+ retVal = true;
+ }
+ return retVal;
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05a.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05a.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05b.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05b.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05b.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05b.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Random;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.apache.uima.ducc.user.error.iface.Transformer;
+import org.junit.Test;
+
+public class TestMessageHandler05b extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ @Test
+ public void test_05b() {
+ try {
+ if(skipAll) {
+ return;
+ }
+ //
+ setUp();
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ String key = "ducc.process.log.dir";
+ String value = directory;
+ System.setProperty(key, value);
+ //
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ //
+ String ehcp = "KillJobLimit="+2;
+ System.setProperty(FlagsHelper.Name.UserErrorHandlerCfg.pname(), ehcp);
+ //
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(2,2,2);
+ ThreadInfo ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ int casNo = -1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ assertTrue(metaCas != null);
+ int inject = 0;
+ while(metaCas != null) {
+ transAck(messageHandler,trans,casNo);
+ if(randomErrorTest05()) {
+ Exception e = new RuntimeException("injected error test #05");
+ Object serializedException = Transformer.serialize(e);
+ metaCas.setUserSpaceException(serializedException);
+ inject++;
+ }
+ transEnd(messageHandler,trans,casNo);
+ casNo--;
+ metaCasPrevious = metaCas;
+ assertTrue(metaCasPrevious != null);
+ ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ metaCas = trans.getMetaCas();
+ }
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ long endSuccess = oi.getWorkItemEndSuccesses();
+ long endFailure = oi.getWorkItemEndFailures();
+ debug("injected errors: "+inject);
+ debug("end success: "+endSuccess);
+ debug("end failure: "+endFailure);
+ assertTrue(endFailure == expectedErrorsTest05b);
+ asExpected("CASes error count == "+expectedErrorsTest05b);
+ boolean killJob = oi.isKillJob();
+ assertTrue(killJob == true);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ private long seedTest05 = 52;
+ private Random randomTest05 = new Random(seedTest05);
+ private long pctTest05 = 20;
+
+ private long expectedErrorsTest05b = 16;
+
+ private boolean randomErrorTest05() {
+ boolean retVal = false;
+ int n = randomTest05.nextInt(100);
+ if(n < pctTest05) {
+ retVal = true;
+ }
+ return retVal;
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05b.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler05b.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler06.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler06.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler06.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler06.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.messagehandler;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Random;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.blacklist.JobProcessBlacklist;
+import org.apache.uima.ducc.container.jd.mh.MessageHandler;
+import org.apache.uima.ducc.container.jd.mh.iface.IOperatingInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfo;
+import org.apache.uima.ducc.container.jd.test.helper.ThreadInfoFactory;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCasTransaction;
+import org.apache.uima.ducc.user.error.iface.Transformer;
+import org.junit.Test;
+
+public class TestMessageHandler06 extends TestMessageHandler {
+
+ protected JobDriver jd;
+
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ JobProcessBlacklist.getInstance().disable();
+ }
+
+ // multiple node:pid:tid with errors & retrys
+
+ @Test
+ public void test_06() {
+ try {
+ if(skipAll) {
+ return;
+ }
+ //
+ setUp();
+ //
+ File working = mkWorkingDir();
+ String directory = working.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JobDirectory.pname(), directory);
+ //
+ String key = "ducc.process.log.dir";
+ String value = directory;
+ System.setProperty(key, value);
+ //
+ URL urlXml = null;
+ File file = null;
+ String path = null;
+ //
+ urlXml = this.getClass().getResource("/CR100.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), path);
+ //
+ urlXml = this.getClass().getResource("/DDSleepDescriptor.xml");
+ file = new File(urlXml.getFile());
+ path = file.getAbsolutePath();
+ System.setProperty(FlagsHelper.Name.JpDd.pname(), path);
+ //
+ String userClasspath = Utilities.getInstance().getUserCP();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+ //
+ String eh = "org.apache.uima.ducc.user.jd.test.helper.TestJdContainerErrorHandlerRandomRetry";
+ System.setProperty(FlagsHelper.Name.UserErrorHandlerClassname.pname(), eh);
+ //
+ int size = jd.getRemoteWorkerThreadMap().size();
+ debug("map size:"+size);
+ MessageHandler messageHandler = new MessageHandler();
+ ThreadInfoFactory tif = new ThreadInfoFactory(2,2,2);
+ ThreadInfo ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ int casNo = -1;
+ IMetaCas metaCasPrevious = null;
+ MetaCasTransaction trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ IMetaCas metaCas = trans.getMetaCas();
+ assertTrue(metaCas != null);
+ int inject = 0;
+ int index = 0;
+ while(metaCas != null) {
+ index++;
+
+ transAck(messageHandler,trans,casNo);
+ if(randomErrorTest06()) {
+ Exception e = new RuntimeException("injected error test #06");
+ Object serializedException = Transformer.serialize(e);
+ metaCas.setUserSpaceException(serializedException);
+ inject++;
+ }
+ System.out.println("index:"+index+" "+"error:"+inject);
+ transEnd(messageHandler,trans,casNo);
+ casNo--;
+ metaCasPrevious = metaCas;
+ assertTrue(metaCasPrevious != null);
+ ti = tif.getRandom();
+ debug("random:"+ti.toKey());
+ trans = transGet(messageHandler,ti.getNodeName(),ti.getPid(),ti.getTid(),casNo);
+ metaCas = trans.getMetaCas();
+ }
+ assertTrue(metaCasPrevious.getSystemKey().equals("100"));
+ asExpected("CASes processed count == 100");
+ IOperatingInfo oi = messageHandler.handleGetOperatingInfo();
+ assertTrue(oi.getWorkItemCrFetches() == 100);
+ asExpected("CASes fetched count == 100");
+ long endSuccess = oi.getWorkItemEndSuccesses();
+ long endFailure = oi.getWorkItemEndFailures();
+ long endRetry = oi.getWorkItemEndRetrys();
+ debug("injected errors: "+inject);
+ debug("end success: "+endSuccess);
+ debug("end failure: "+endFailure);
+ debug("end retry: "+endRetry);
+ assertTrue(endSuccess+endFailure == 100);
+ asExpected("CASes failure+success count == 100");
+ assertTrue(endRetry > 0);
+ asExpected("CASes retry count == "+endRetry);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ private long seedTest06 = 6;
+ private Random randomTest06 = new Random(seedTest06);
+ private long pctTest06 = 10;
+
+ private boolean randomErrorTest06() {
+ boolean retVal = false;
+ int n = randomTest06.nextInt(100);
+ if(n < pctTest06) {
+ retVal = true;
+ }
+ return retVal;
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler06.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/messagehandler/TestMessageHandler06.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/fsm/TestWiFsm.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/fsm/TestWiFsm.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/fsm/TestWiFsm.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/fsm/TestWiFsm.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.wi.fsm;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import org.apache.uima.ducc.common.container.FlagsHelper;
+import org.apache.uima.ducc.container.common.fsm.Action;
+import org.apache.uima.ducc.container.common.fsm.Event;
+import org.apache.uima.ducc.container.common.fsm.Fsm;
+import org.apache.uima.ducc.container.common.fsm.State;
+import org.apache.uima.ducc.container.common.fsm.StateEventKey;
+import org.apache.uima.ducc.container.common.fsm.iface.IAction;
+import org.apache.uima.ducc.container.common.fsm.iface.IEvent;
+import org.apache.uima.ducc.container.common.fsm.iface.IFsm;
+import org.apache.uima.ducc.container.common.fsm.iface.IFsmBuilder;
+import org.apache.uima.ducc.container.common.fsm.iface.IState;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.fsm.wi.WiFsm;
+import org.apache.uima.ducc.container.jd.test.TestBase;
+import org.apache.uima.ducc.container.jd.test.helper.Utilities;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestWiFsm extends TestBase {
+
+ protected JobDriver jd;
+
+ @Before
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getInstance();
+ }
+
+ @Test
+ public void test_01() {
+ try {
+ IState s0 = new State("a");
+ IState s1 = new State("a");
+ IState s2 = new State("b");
+ assertTrue(s0.equals(s1));
+ asExpected("State "+s0.getName()+" == "+s1.getName());
+ assertTrue(!s0.equals(s2));
+ asExpected("State "+s0.getName()+" != "+s2.getName());
+ assertTrue(!s1.equals(s2));
+ asExpected("State "+s1.getName()+" != "+s2.getName());
+ try {
+ new State(null);
+ fail("expected Exception");
+ }
+ catch(Exception e) {
+ asExpected(e);
+ }
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ @Test
+ public void test_02() {
+ try {
+ IEvent e0 = new Event("c");
+ IEvent e1 = new Event("c");
+ IEvent e2 = new Event("d");
+ assertTrue(e0.equals(e1));
+ asExpected("Event "+e0.getName()+" == "+e1.getName());
+ assertTrue(!e0.equals(e2));
+ asExpected("Event "+e0.getName()+" != "+e2.getName());
+ assertTrue(!e1.equals(e2));
+ asExpected("Event "+e1.getName()+" != "+e2.getName());
+ try {
+ new Event(null);
+ fail("expected Exception");
+ }
+ catch(Exception e) {
+ asExpected(e);
+ }
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ @Test
+ public void test_03() {
+ try {
+ IState s0 = new State("a");
+ IState s1 = new State("b");
+ IEvent e0 = new Event("c");
+ IEvent e1 = new Event("d");
+ StateEventKey se00A = new StateEventKey(s0, e0);
+ StateEventKey se00B = new StateEventKey(s0, e0);
+ assertTrue(se00A.equals(se00B));
+ StateEventKey se00 = new StateEventKey(s0, e0);
+ StateEventKey se01 = new StateEventKey(s0, e1);
+ StateEventKey se10 = new StateEventKey(s1, e0);
+ StateEventKey se11 = new StateEventKey(s1, e1);
+ assertTrue(!se00.equals(se01));
+ assertTrue(!se00.equals(se10));
+ assertTrue(!se00.equals(se11));
+ assertTrue(!se01.equals(se10));
+ assertTrue(!se01.equals(se11));
+ assertTrue(!se10.equals(se11));
+ try {
+ new StateEventKey(null, e0);;
+ fail("expected Exception");
+ }
+ catch(Exception e) {
+ asExpected(e);
+ }
+ try {
+ new StateEventKey(s0, null);;
+ fail("expected Exception");
+ }
+ catch(Exception e) {
+ asExpected(e);
+ }
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ @Test
+ public void test_04() {
+ try {
+ IState s1 = new State("s1");
+ IState s2 = new State("s2");
+ IEvent e1 = new Event("e1");
+ IEvent e2 = new Event("e2");
+ IAction a0 = new Action();
+ IFsmBuilder fsmBuilder = new Fsm();
+ IFsm fsm = fsmBuilder;
+ debug("s1:"+s1.getName());
+ debug("s2:"+s2.getName());
+ debug("e1:"+e1.getName());
+ debug("e2:"+e2.getName());
+ fsmBuilder.addInitial(s1, e1, a0, s1);
+ fsmBuilder.add(s1, e2, a0, s2);
+ assertTrue(fsm.getStateCurrent().getName().equals(s1.getName()));
+ asExpected("state == "+s1.getName());
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ private void initUserClasspath() {
+ String userClasspath = Utilities.getInstance().getUserCP();
+ String[] classpathParts = userClasspath.split(File.pathSeparator);
+ StringBuffer sb = new StringBuffer();
+ for(int i=0; i<classpathParts.length; i++) {
+ String jar = classpathParts[i];
+ debug(i+" use: "+jar);
+ sb.append(jar);
+ sb.append(File.pathSeparator);
+ }
+ String userPartialClasspath = sb.toString();
+ System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userPartialClasspath);
+ }
+
+ @Test
+ public void test_05() {
+ try {
+ initUserClasspath();
+ WiFsm wiFsm = new WiFsm();
+ Object actionData = null;
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ asExpected("state == "+WiFsm.Start.getName());
+ wiFsm.transition(WiFsm.Get_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Get_Pending.getName()));
+ asExpected("state == "+WiFsm.Get_Pending.getName());
+ wiFsm.transition(WiFsm.CAS_Available, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.CAS_Send.getName()));
+ asExpected("state == "+WiFsm.CAS_Send.getName());
+ wiFsm.transition(WiFsm.Ack_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.CAS_Active.getName()));
+ asExpected("state == "+WiFsm.CAS_Active.getName());
+ wiFsm.transition(WiFsm.End_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ asExpected("state == "+WiFsm.Start.getName());
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+ @Test
+ public void test_06() {
+ try {
+ initUserClasspath();
+ WiFsm wiFsm = new WiFsm();
+ Object actionData = null;
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ asExpected("state == "+WiFsm.Start.getName());
+ wiFsm.transition(WiFsm.Process_Preempt, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ //
+ wiFsm.transition(WiFsm.Get_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Get_Pending.getName()));
+ wiFsm.transition(WiFsm.Process_Preempt, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ //
+ wiFsm.transition(WiFsm.Get_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Get_Pending.getName()));
+ asExpected("state == "+WiFsm.Get_Pending.getName());
+ wiFsm.transition(WiFsm.CAS_Available, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.CAS_Send.getName()));
+ asExpected("state == "+WiFsm.CAS_Send.getName());
+ wiFsm.transition(WiFsm.Process_Preempt, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ //
+ wiFsm.transition(WiFsm.Get_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Get_Pending.getName()));
+ asExpected("state == "+WiFsm.Get_Pending.getName());
+ wiFsm.transition(WiFsm.CAS_Available, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.CAS_Send.getName()));
+ asExpected("state == "+WiFsm.CAS_Send.getName());
+ wiFsm.transition(WiFsm.Ack_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.CAS_Active.getName()));
+ asExpected("state == "+WiFsm.CAS_Active.getName());
+ wiFsm.transition(WiFsm.Process_Preempt, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ //
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ asExpected("state == "+WiFsm.Start.getName());
+ wiFsm.transition(WiFsm.Get_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Get_Pending.getName()));
+ asExpected("state == "+WiFsm.Get_Pending.getName());
+ wiFsm.transition(WiFsm.CAS_Available, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.CAS_Send.getName()));
+ asExpected("state == "+WiFsm.CAS_Send.getName());
+ wiFsm.transition(WiFsm.Ack_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.CAS_Active.getName()));
+ asExpected("state == "+WiFsm.CAS_Active.getName());
+ wiFsm.transition(WiFsm.End_Request, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ asExpected("state == "+WiFsm.Start.getName());
+ wiFsm.transition(WiFsm.Process_Preempt, actionData);
+ assertTrue(wiFsm.getStateCurrent().getName().equals(WiFsm.Start.getName()));
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/fsm/TestWiFsm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/fsm/TestWiFsm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/statefile/TestWiStateFile.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/statefile/TestWiStateFile.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/statefile/TestWiStateFile.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/statefile/TestWiStateFile.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.wi.statefile;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import org.apache.uima.ducc.common.jd.files.workitem.IWorkItemStateKeeper;
+import org.apache.uima.ducc.common.jd.files.workitem.IWorkItemStateReader;
+import org.apache.uima.ducc.common.jd.files.workitem.WorkItemStateKeeper;
+import org.apache.uima.ducc.common.jd.files.workitem.WorkItemStateReader;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.test.TestBase;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestWiStateFile extends TestBase {
+
+ protected JobDriver jd;
+
+ @Before
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getInstance();
+ }
+
+ @Test
+ public void test_01() {
+ try {
+ File working = mkWorkingDir();
+ String component = "JD.test";
+ String directory = working.getAbsolutePath();
+ debug(directory);
+ IWorkItemStateKeeper wisk = new WorkItemStateKeeper(component, directory);
+ //
+ // int seqNo, String wiId, String node, String pid, String tid
+ //
+ wisk.start(0, "u.0", "n.0", "p.0", "t.0");
+ //
+ wisk.start(1, "u.1", "n.1", "p.1", "t.1");
+ wisk.queued(1);
+ //
+ wisk.start(2, "u.2", "n.2", "p.2", "t.2");
+ wisk.queued(2);
+ wisk.operating(2);
+ //
+ wisk.start(3, "u.3", "n.3", "p.3", "t.3");
+ wisk.queued(3);
+ wisk.operating(3);
+ wisk.ended(3);
+ //
+ wisk.start(4, "u.4", "n.4", "p.4", "t.4");
+ wisk.queued(4);
+ wisk.operating(4);
+ wisk.error(4);
+ //
+ wisk.start(5, "u.5", "n.5", "p.5", "t.5");
+ wisk.queued(5);
+ wisk.operating(5);
+ wisk.retry(5);
+ //
+ wisk.persist();
+ //
+ String user = "self";
+ long version = 1;
+ IWorkItemStateReader wisr = new WorkItemStateReader(component, directory, user, version);
+ int size = wisr.getMap().size();
+ debug("size="+size);
+ assertTrue(size > 0);
+ //
+ wisk.zip();
+ //
+ wisr = new WorkItemStateReader(component, directory, user, version);
+ size = wisr.getMap().size();
+ assertTrue(size > 0);
+ //
+ delete(working);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/statefile/TestWiStateFile.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/statefile/TestWiStateFile.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/tracker/TestWiTracker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/tracker/TestWiTracker.java?rev=1673740&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/tracker/TestWiTracker.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/tracker/TestWiTracker.java Wed Apr 15 12:22:46 2015
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.container.jd.test.wi.tracker;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Random;
+
+import org.apache.uima.ducc.container.common.fsm.iface.IFsm;
+import org.apache.uima.ducc.container.jd.JobDriver;
+import org.apache.uima.ducc.container.jd.JobDriverException;
+import org.apache.uima.ducc.container.jd.mh.RemoteWorkerThread;
+import org.apache.uima.ducc.container.jd.mh.iface.remote.IRemoteWorkerThread;
+import org.apache.uima.ducc.container.jd.test.TestBase;
+import org.apache.uima.ducc.container.jd.wi.IWorkItem;
+import org.apache.uima.ducc.container.jd.wi.WiTracker;
+import org.apache.uima.ducc.container.jd.wi.WorkItem;
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+import org.apache.uima.ducc.container.net.impl.MetaCas;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestWiTracker extends TestBase {
+
+ private static Random random = new Random();
+
+ protected JobDriver jd;
+
+ @Before
+ public void setUp() throws JobDriverException {
+ initialize();
+ jd = JobDriver.getNewInstance();
+ }
+
+ private IFsm getFsm() {
+ IFsm fsm = null;
+ return fsm;
+ }
+
+ private IMetaCas getMetaCas(int seqNo) {
+ IMetaCas metaCas = null;
+ String text = ""+seqNo;
+ Object cas = null;
+ metaCas = new MetaCas(seqNo, text, cas);
+ return metaCas;
+ }
+
+ private IWorkItem getWi(int seqNo) {
+ IWorkItem wi = null;
+ IMetaCas metaCas = getMetaCas(seqNo);
+ IFsm fsm = getFsm();
+ wi = new WorkItem(metaCas, fsm);
+ return wi;
+ }
+
+ private IRemoteWorkerThread getRemoteWorkerThread() {
+ IRemoteWorkerThread rwt = null;
+ int node = random.nextInt(900)+100;
+ String nodeName = "node:"+node;
+ String nodeAddress = "address:"+node;
+ int pid = random.nextInt(30000)+10000;
+ String pidName = "pid:"+pid;
+ int tid = random.nextInt(90)+10;
+ rwt = new RemoteWorkerThread(nodeName, nodeAddress, pidName, pid, tid);
+ return rwt;
+ }
+
+ @Test
+ public void test() {
+
+ WiTracker tracker = WiTracker.getInstance();
+ int seqNo = 1;
+ //
+ IRemoteWorkerThread rwt01A = getRemoteWorkerThread();
+ IWorkItem wi01A = tracker.assign(rwt01A);
+ IMetaCas metaCas = getMetaCas(1);
+ wi01A.setMetaCas(metaCas);
+ //
+ assertTrue(tracker.getSize() == 1);
+ //
+ IRemoteWorkerThread rwt01B = rwt01A;
+ tracker.assign(rwt01B);
+ //
+ assertTrue(tracker.getSize() == 1);
+ //
+ seqNo = 2;
+ IWorkItem wi02A = getWi(seqNo);
+ IRemoteWorkerThread rwt02A = getRemoteWorkerThread();
+ tracker.assign(rwt02A);
+ wi02A.setMetaCas(metaCas);
+ //
+ assertTrue(tracker.getSize() == 2);
+ //
+ IRemoteWorkerThread rwt02B = rwt02A;
+ tracker.assign(rwt02B);
+ //
+ assertTrue(tracker.getSize() == 2);
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/tracker/TestWiTracker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/wi/tracker/TestWiTracker.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverComponent.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverComponent.java?rev=1673740&r1=1673739&r2=1673740&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverComponent.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jd/JobDriverComponent.java Wed Apr 15 12:22:46 2015
@@ -95,7 +95,6 @@ implements IJobDriverComponent {
private void createInstance() {
String location = "createInstance";
try {
- JobDriver.createInstance();
int total = JobDriver.getInstance().getCasManager().getCasManagerStats().getCrTotal();
logger.info(location, jobid, "total: "+total);
}