protected MUX firstAvailableMUX (long maxWait) { do { for (MUX m : mux) if (isUsable(m)) return m; ISOUtil.sleep (1000); } while (System.currentTimeMillis() < maxWait); return null; } protected MUX nextAvailableMUX (int mnumber, long maxWait) {
protected MUX nextAvailableMUX (int mnumber, long maxWait) { do { for (int i=0; i<mux.length; i++) { int j = (mnumber+i) % mux.length; if (isUsable(mux[j])) return mux[j]; msgno.incrementAndGet(); } ISOUtil.sleep (1000); } while (System.currentTimeMillis() < maxWait); return null; } private String[] toStringArray (String s) {
public void run() { ISOUtil.sleep(500); } }
protected boolean isConnected (MUX mux) { if (mux.isConnected()) return true; long timeout = System.currentTimeMillis() + waitTimeout; while (System.currentTimeMillis() < timeout) { if (mux.isConnected()) return true; ISOUtil.sleep (500); } return false; } }
public void run () { while (running()) { waitUntilStartTime(); if (running()) { Thread taskThread = new Thread(task); taskThread.setDaemon (true); taskThread.start(); ISOUtil.sleep (1000); } } } public Date getWhen() {
public void run() { ISOUtil.sleep (1000); txnmgr.queue (ctx); // re-inject paused transaction } }.start();
public void run() { ISOUtil.sleep(1000L); sp.out("KA", Boolean.TRUE); } }.start();
public void run() { ISOUtil.sleep (1000L); sp.out ("KA", Boolean.TRUE); } }.start();
public void run() { ISOUtil.sleep (1000L); sp.out ("KA", Boolean.TRUE); } }.start();
@Override public void run() { Thread.currentThread().setName (getName()+"-retry-task"); while (running()) { for (Serializable context; (context = (Serializable)psp.rdp (RETRY_QUEUE)) != null;) { iisp.out (queue, context, retryTimeout); psp.inp (RETRY_QUEUE); } ISOUtil.sleep(retryInterval); } } }
public void run() { ISOUtil.sleep (250L); int active = server.getActiveConnections(); meter.setConnected(active > 0); try { meter.setPositiveCounter( ISOUtil.zeropad(Integer.toString(active), 6) ); } catch (ISOException e) { } meter.repaint(); } };
@Test public void testRetry() throws IOException { Q2 q2 = new Q2("build/resources/test/org/jpos/util/dirpoll_retry/deploy"); q2.start(); ISOUtil.sleep(5000L); createTestFile("build/resources/test/org/jpos/util/dirpoll_retry/request/REQ1", "RETRYME"); ISOUtil.sleep(5000L); q2.stop(); ISOUtil.sleep(2000L); assertTrue("Can't read request", new File("build/resources/test/org/jpos/util/dirpoll_retry/request/REQ1").canRead()); } public static class RetryTest implements DirPoll.Processor {
@Test public void testSleep() throws Throwable { ISOUtil.sleep(100L); assertTrue("Test completed without Exception", true); }
@Test public void testSleepThrowsIllegalArgumentException() throws Throwable { try { ISOUtil.sleep(-30L); fail("Expected IllegalArgumentException to be thrown"); } catch (IllegalArgumentException ex) { assertEquals("ex.getMessage()", "timeout value is negative", ex.getMessage()); } }
@Test public void testRunNames() throws Throwable { ThreadPool threadPool = new ThreadPool(1, 2); threadPool.execute(new TestTask()); ISOUtil.sleep(20); threadPool.execute(new TestTask()); ISOUtil.sleep(20); Thread[] tl = new Thread[threadPool.activeCount()]; threadPool.enumerate(tl); for (Thread t :tl ) assertThat(t.getName(), new Matches("ThreadPool.PooledThread-\\d+-(running|idle)")); }
@Test public void testRun1() throws Throwable { ThreadPool threadPool = new ThreadPool(1, 100); ISOUtil.sleep(50); threadPool.execute(new TestTask()); ISOUtil.sleep(50); assertEquals("threadPool.getJobCount()", 1, threadPool.getJobCount()); assertEquals("threadPool.getPoolSize()", 1, threadPool.getPoolSize()); assertEquals("threadPool.getMaxPoolSize()", 100, threadPool.getMaxPoolSize()); ISOUtil.sleep(500); assertEquals("threadPool.getJobCount()", 1, threadPool.getJobCount()); assertEquals("threadPool.getPoolSize()", 1, threadPool.getPoolSize()); }
private long nextAsync(long id, long delay) { SeqNoManager mgr = new SeqNoManager(new DB()); long l = mgr.next("sync", id, 60000L, 60000L, 999999L); ISOUtil.sleep(delay); mgr.release("sync", id); return l; } private void reset() {
@BeforeClass public static void setUp() { RestAssured.baseURI = APITest.BASE_URL; RestAssured.requestSpecification = new RequestSpecBuilder().build().contentType(MediaType.APPLICATION_JSON); sp = SpaceFactory.getSpace(); if (sp.rdp ("JPOSEE:STARTED") == null) { System.setProperty("user.name", "admin"); q2 = new Q2(); q2.start(); } ISOUtil.sleep(5000); }
@Test public void testRun3() throws Throwable { ThreadPool threadPool = new ThreadPool(1, 2); threadPool.execute(new TestTask()); ISOUtil.sleep(20); threadPool.execute(new TestTask()); ISOUtil.sleep(20); assertEquals("threadPool.getJobCount()", 2, threadPool.getJobCount()); assertEquals("threadPool.getPoolSize()", 2, threadPool.getPoolSize()); assertEquals("threadPool.getMaxPoolSize()", 2, threadPool.getMaxPoolSize()); }
private long next(long delay) { try (DB db = new DB()) { SeqNoManager mgr = new SeqNoManager(db); db.open(); db.beginTransaction(); long l = mgr.next("sync", 999999L); ISOUtil.sleep(delay); db.commit(); return l; } }