@Override public void stateChanged(JdbcPooledConnection source, State oldState, State newState) { if (newState == State.IN_POOL) { lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } else if (oldState == State.IN_POOL && newState == State.ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } else if (oldState == State.NOT_ACCESSIBLE && newState == State.ACCESSIBLE) { TransactionContextHelper.recycle(this); } }
@Override public void stateChanged(JdbcPooledConnection source, State oldState, State newState) { if (newState == State.IN_POOL) { lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } else if (oldState == State.IN_POOL && newState == State.ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } else if (oldState == State.NOT_ACCESSIBLE && newState == State.ACCESSIBLE) { TransactionContextHelper.recycle(this); } }
public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("requeued JMS connection of " + poolingConnectionFactory); lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_IN_POOL && newState == STATE_ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } if (newState == STATE_CLOSED) { ManagementRegistrar.unregister(jmxName); } }
public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("requeued JDBC connection of " + poolingDataSource); lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_IN_POOL && newState == STATE_ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_NOT_ACCESSIBLE && newState == STATE_ACCESSIBLE) { TransactionContextHelper.recycle(this); } }
public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("requeued JDBC connection of " + poolingDataSource); lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_IN_POOL && newState == STATE_ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_NOT_ACCESSIBLE && newState == STATE_ACCESSIBLE) { TransactionContextHelper.recycle(this); } }
@Override public void stateChanged(JmsPooledConnection source, State oldState, State newState) { if (newState == State.IN_POOL) { if (log.isDebugEnabled()) { log.debug("requeued JMS connection of " + poolingConnectionFactory); } lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == State.IN_POOL && newState == State.ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } if (newState == State.CLOSED) { ManagementRegistrar.unregister(jmxName); } }
public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("requeued JMS connection of " + poolingConnectionFactory); lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_IN_POOL && newState == STATE_ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } if (newState == STATE_CLOSED) { ManagementRegistrar.unregister(jmxName); } }
public Date getNextShrinkDate() { return new Date(MonotonicClock.currentTimeMillis() + TimeUnit.SECONDS.toMillis(bean.getMaxIdleTime())); }
public Date getNextShrinkDate() { return new Date(MonotonicClock.currentTimeMillis() + bean.getMaxIdleTime() * 1000); }
public void setActive(int timeout) throws IllegalStateException, SystemException { if (status != Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction has already started"); setStatus(Status.STATUS_ACTIVE); this.startDate = new Date(MonotonicClock.currentTimeMillis()); this.timeoutDate = new Date(MonotonicClock.currentTimeMillis() + (timeout * 1000L)); if (TransactionManagerServices.getConfiguration().isDebugZeroResourceTransaction()) { this.activationStackTrace = new StackTrace(); } taskScheduler.scheduleTransactionTimeout(this, timeoutDate); }
public void setActive(int timeout) throws IllegalStateException, SystemException { if (status != Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction has already started"); setStatus(Status.STATUS_ACTIVE); this.startDate = new Date(MonotonicClock.currentTimeMillis()); this.timeoutDate = new Date(MonotonicClock.currentTimeMillis() + (timeout * 1000L)); if (TransactionManagerServices.getConfiguration().isDebugZeroResourceTransaction()) { this.activationStackTrace = new StackTrace(); } taskScheduler.scheduleTransactionTimeout(this, timeoutDate); }
public void setActive(int timeout) throws IllegalStateException, SystemException { if (status != Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction has already started"); setStatus(Status.STATUS_ACTIVE); this.startDate = new Date(MonotonicClock.currentTimeMillis()); this.timeoutDate = new Date(MonotonicClock.currentTimeMillis() + (timeout * 1000L)); if (TransactionManagerServices.getConfiguration().isDebugZeroResourceTransaction()) { this.activationStackTrace = new StackTrace(); } taskScheduler.scheduleTransactionTimeout(this, timeoutDate); }
public void setActive(int timeout) throws IllegalStateException, SystemException { if (status != Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction has already started"); setStatus(Status.STATUS_ACTIVE); this.startDate = new Date(MonotonicClock.currentTimeMillis()); this.timeoutDate = new Date(MonotonicClock.currentTimeMillis() + (timeout * 1000L)); if (TransactionManagerServices.getConfiguration().isDebugZeroResourceTransaction()) { this.activationStackTrace = new StackTrace(); } taskScheduler.scheduleTransactionTimeout(this, timeoutDate); }
/** * Generate a UID, globally unique. This method relies on the configured serverId for network uniqueness. * @return the generated UID. */ public static Uid generateUid() { byte[] timestamp = Encoder.longToBytes(MonotonicClock.currentTimeMillis()); byte[] sequence = Encoder.intToBytes(sequenceGenerator.incrementAndGet()); byte[] serverId = TransactionManagerServices.getConfiguration().buildServerIdArray(); int uidLength = serverId.length + timestamp.length + sequence.length; byte[] uidArray = new byte[uidLength]; System.arraycopy(serverId, 0, uidArray, 0, serverId.length); System.arraycopy(timestamp, 0, uidArray, serverId.length, timestamp.length); System.arraycopy(sequence, 0, uidArray, serverId.length + timestamp.length, sequence.length); return new Uid(uidArray); }
public void testPrecision() throws Exception { for (int i = 0; i < 100; i++) { long monoTime = MonotonicClock.currentTimeMillis(); long wallTime = System.currentTimeMillis(); assertTrue("iteration #" + i + " wall time: " + wallTime + ", mono time: " + monoTime, Math.abs(wallTime - monoTime) < 5L); Thread.sleep(10); } }
public void testPrecision() throws Exception { for (int i = 0; i < 100; i++) { long monoTime = MonotonicClock.currentTimeMillis(); long wallTime = System.currentTimeMillis(); assertTrue("iteration #" + i + " wall time: " + wallTime + ", mono time: " + monoTime, Math.abs(wallTime - monoTime) < 5L); Thread.sleep(10); } }
public void testTaskOrdering() throws Exception { List<SimpleTask> result = Collections.synchronizedList(new ArrayList<SimpleTask>()); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 100), ts, 0, result)); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 200), ts, 1, result)); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 300), ts, 2, result)); ts.join(1000); assertEquals(0, result.get(0).getObject()); assertEquals(1, result.get(1).getObject()); assertEquals(2, result.get(2).getObject()); }
public void testTaskOrdering() throws Exception { List<SimpleTask> result = Collections.synchronizedList(new ArrayList<SimpleTask>()); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 100), ts, 0, result)); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 200), ts, 1, result)); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 300), ts, 2, result)); ts.join(1000); assertEquals(0, result.get(0).getObject()); assertEquals(1, result.get(1).getObject()); assertEquals(2, result.get(2).getObject()); }
public void testIdenticalScheduleTimestamp() throws Exception { List<SimpleTask> result = Collections.synchronizedList(new ArrayList<SimpleTask>()); long firstTimestamp = MonotonicClock.currentTimeMillis(); long secondTimestamp = MonotonicClock.currentTimeMillis() + 200; ts.addTask(new SimpleTask(new Date(firstTimestamp), ts, 0, result)); ts.addTask(new SimpleTask(new Date(secondTimestamp), ts, 1, result)); ts.addTask(new SimpleTask(new Date(secondTimestamp), ts, 2, result)); assertEquals("Three tasks were created. All 3 (even identical timestamps) should be queued", 3, ts.countTasksQueued()); ts.join(1000); }
public void testIdenticalScheduleTimestamp() throws Exception { List<SimpleTask> result = Collections.synchronizedList(new ArrayList<SimpleTask>()); long firstTimestamp = MonotonicClock.currentTimeMillis(); long secondTimestamp = MonotonicClock.currentTimeMillis() + 200; ts.addTask(new SimpleTask(new Date(firstTimestamp), ts, 0, result)); ts.addTask(new SimpleTask(new Date(secondTimestamp), ts, 1, result)); ts.addTask(new SimpleTask(new Date(secondTimestamp), ts, 2, result)); assertEquals("Three tasks were created. All 3 (even identical timestamps) should be queued", 3, ts.countTasksQueued()); ts.join(1000); }