@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); } }
@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 Date getNextShrinkDate() { return new Date(MonotonicClock.currentTimeMillis() + TimeUnit.SECONDS.toMillis(bean.getMaxIdleTime())); }
public Date getNextShrinkDate() { return new Date(MonotonicClock.currentTimeMillis() + bean.getMaxIdleTime() * 1000); }
public Date getNextShrinkDate() { return new Date(MonotonicClock.currentTimeMillis() + TimeUnit.SECONDS.toMillis(bean.getMaxIdleTime())); }
public Date getNextShrinkDate() { return new Date(MonotonicClock.currentTimeMillis() + bean.getMaxIdleTime() * 1000); }
/** * Create a new transaction log ready to be stored. * @param status record type * @param gtrid global transaction id * @param uniqueNames unique names of XA data sources used in this transaction */ public TransactionLogRecord(int status, Uid gtrid, Set<String> uniqueNames) { this.status = status; this.time = MonotonicClock.currentTimeMillis(); this.sequenceNumber = sequenceGenerator.incrementAndGet(); this.gtrid = gtrid; this.uniqueNames = new TreeSet<String>(uniqueNames); this.endRecord = TransactionLogAppender.END_RECORD; this.headerLength = RECORD_HEADER_LENGTH; refresh(); }
/** * Create a new transaction log ready to be stored. * @param status record type * @param gtrid global transaction id * @param uniqueNames unique names of XA data sources used in this transaction */ public TransactionLogRecord(int status, Uid gtrid, Set<String> uniqueNames) { this.status = status; this.time = MonotonicClock.currentTimeMillis(); this.sequenceNumber = sequenceGenerator.incrementAndGet(); this.gtrid = gtrid; this.uniqueNames = new TreeSet<String>(uniqueNames); this.endRecord = TransactionLogAppender.END_RECORD; this.headerLength = RECORD_HEADER_LENGTH; refresh(); }
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); }
public synchronized void shrink() throws Exception { if (log.isDebugEnabled()) log.debug("shrinking " + this); List<XAStatefulHolder> toRemoveXaStatefulHolders = new ArrayList<XAStatefulHolder>(); long now = MonotonicClock.currentTimeMillis(); for (XAStatefulHolder xaStatefulHolder : objects) { if (xaStatefulHolder.getState() != XAStatefulHolder.STATE_IN_POOL) continue; long expirationTime = (xaStatefulHolder.getLastReleaseDate().getTime() + (bean.getMaxIdleTime() * 1000)); if (log.isDebugEnabled()) log.debug("checking if connection can be closed: " + xaStatefulHolder + " - closing time: " + expirationTime + ", now time: " + now); if (expirationTime <= now) { try { xaStatefulHolder.close(); } catch (Exception ex) { log.warn("error closing " + xaStatefulHolder, ex); } toRemoveXaStatefulHolders.add(xaStatefulHolder); } } // for if (log.isDebugEnabled()) log.debug("closed " + toRemoveXaStatefulHolders.size() + " idle connection(s)"); objects.removeAll(toRemoveXaStatefulHolders); growUntilMinPoolSize(); if (log.isDebugEnabled()) log.debug("shrunk " + this); }
/** * 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); }