Search in sources :

Example 1 with ConnectionPool

use of org.eclipse.persistence.sessions.server.ConnectionPool in project eclipselink by eclipse-ee4j.

the class Server method login.

public void login() {
    this.serverSession.login();
    ConnectionPool cp = this.serverSession.getConnectionPool("default");
    try {
        // close off one of the connections.  This part of the test sees if our reconnect on the fly works.
        cp.getConnectionsAvailable().get(0).getConnection().close();
    } catch (java.sql.SQLException e) {
        e.printStackTrace(System.out);
    }
}
Also used : ConnectionPool(org.eclipse.persistence.sessions.server.ConnectionPool)

Example 2 with ConnectionPool

use of org.eclipse.persistence.sessions.server.ConnectionPool in project eclipselink by eclipse-ee4j.

the class Server1 method login.

public void login() {
    this.serverSession.login();
    ConnectionPool cp = this.serverSession.getConnectionPool("default");
    try {
        // close off one of the connections.  This part of the test sees if our reconnect on the fly works.
        cp.getConnectionsAvailable().get(0).getConnection().close();
    } catch (java.sql.SQLException e) {
        e.printStackTrace(System.out);
    }
}
Also used : ConnectionPool(org.eclipse.persistence.sessions.server.ConnectionPool)

Example 3 with ConnectionPool

use of org.eclipse.persistence.sessions.server.ConnectionPool in project eclipselink by eclipse-ee4j.

the class ClientServerTest method verify.

@Override
public void verify() {
    try {
        int counter = 0;
        ConnectionPool pool = server.serverSession.getConnectionPools().get("default");
        List<Accessor> connections = pool.getConnectionsAvailable();
        for (Iterator<Accessor> iterator = connections.iterator(); iterator.hasNext(); ) {
            if (iterator.next().isConnected()) {
                counter = counter + 1;
            }
        }
        if (counter < minimumConnections) {
            throw new TestErrorException("too many connections are disconnected!!");
        }
        if (counter > minimumConnections) {
            throw new TestErrorException("not enough connections are disconected!!");
        }
        if (connections.size() < minimumConnections) {
            throw new TestErrorException("too many connections are released!!");
        }
        if (connections.size() > minimumConnections) {
            throw new TestErrorException("not enough connections are released!!");
        }
    } catch (Exception ex) {
        if ((ex instanceof ValidationException) && (((ValidationException) ex).getErrorCode() == 7090)) {
        }
    }
}
Also used : ConnectionPool(org.eclipse.persistence.sessions.server.ConnectionPool) ValidationException(org.eclipse.persistence.exceptions.ValidationException) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) DatabaseAccessor(org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor) Accessor(org.eclipse.persistence.internal.databaseaccess.Accessor) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) ValidationException(org.eclipse.persistence.exceptions.ValidationException)

Example 4 with ConnectionPool

use of org.eclipse.persistence.sessions.server.ConnectionPool in project eclipselink by eclipse-ee4j.

the class RuntimeServices method getAvailableConnectionPools.

/**
 *     This method will return the available Connection pools within this Server Session
 * @return java.util.List the available pools.
 */
public List getAvailableConnectionPools() {
    Vector list = null;
    if (ClassConstants.ServerSession_Class.isAssignableFrom(getSession().getClass())) {
        Map<String, ConnectionPool> pools = ((ServerSession) getSession()).getConnectionPools();
        list = new Vector(pools.size());
        Iterator<String> poolNames = pools.keySet().iterator();
        while (poolNames.hasNext()) {
            list.add(poolNames.next());
        }
    } else {
        list = new Vector();
    }
    return list;
}
Also used : ConnectionPool(org.eclipse.persistence.sessions.server.ConnectionPool) ServerSession(org.eclipse.persistence.sessions.server.ServerSession) Vector(java.util.Vector)

Example 5 with ConnectionPool

use of org.eclipse.persistence.sessions.server.ConnectionPool in project eclipselink by eclipse-ee4j.

the class RuntimeServices method updatePoolSize.

/**
 *     This method allows the client to set the pool size for a particular pool, based on the pool name
 * @param poolName the name of the pool to be updated.
 * @param maxSize the new maximum number of connections
 * @param minSize the new minimum number of connections
 */
public void updatePoolSize(String poolName, int maxSize, int minSize) {
    if (ClassConstants.ServerSession_Class.isAssignableFrom(getSession().getClass())) {
        ConnectionPool connectionPool = ((ServerSession) getSession()).getConnectionPool(poolName);
        if (connectionPool != null) {
            connectionPool.setMaxNumberOfConnections(maxSize);
            connectionPool.setMinNumberOfConnections(minSize);
        }
    }
}
Also used : ConnectionPool(org.eclipse.persistence.sessions.server.ConnectionPool) ServerSession(org.eclipse.persistence.sessions.server.ServerSession)

Aggregations

ConnectionPool (org.eclipse.persistence.sessions.server.ConnectionPool)19 ServerSession (org.eclipse.persistence.sessions.server.ServerSession)10 ReadConnectionPool (org.eclipse.persistence.sessions.server.ReadConnectionPool)7 HashMap (java.util.HashMap)6 Map (java.util.Map)5 EntityManager (jakarta.persistence.EntityManager)4 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)4 JpaEntityManagerFactory (org.eclipse.persistence.jpa.JpaEntityManagerFactory)4 ExternalConnectionPool (org.eclipse.persistence.sessions.server.ExternalConnectionPool)4 Accessor (org.eclipse.persistence.internal.databaseaccess.Accessor)3 EntityManagerFactoryProvider.getConfigPropertyAsString (org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.getConfigPropertyAsString)3 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)2 Vector (java.util.Vector)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 ValidationException (org.eclipse.persistence.exceptions.ValidationException)2 IdentityMap (org.eclipse.persistence.internal.identitymaps.IdentityMap)2 SessionBroker (org.eclipse.persistence.sessions.broker.SessionBroker)2 Employee (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_2.Employee)2 OptimisticLockException (jakarta.persistence.OptimisticLockException)1 PersistenceException (jakarta.persistence.PersistenceException)1