use of org.eclipse.persistence.sessions.server.Server in project eclipselink by eclipse-ee4j.
the class UnitOfWorkPartitionedIsolatedAlwaysTestModel method buildServerSession.
/**
* Simulate a database cluster by having multiple pools to the same database.
*/
@Override
public Server buildServerSession() {
Server server = getSession().getProject().clone().createServerSession(1, 3);
server.addConnectionPool("node2", getSession().getLogin(), 1, 3);
server.addConnectionPool("node3", getSession().getLogin(), 1, 3);
server.setSessionLog(getSession().getSessionLog());
server.setPartitioningPolicy(new RoundRobinPartitioningPolicy("default", "node2", "node3"));
server.login();
return server;
}
use of org.eclipse.persistence.sessions.server.Server in project eclipselink by eclipse-ee4j.
the class UnitOfWorkPartitionedTestModel method buildServerSession.
/**
* Simulate a database cluster by having multiple pools to the same database.
*/
@Override
public Server buildServerSession() {
Server server = getSession().getProject().clone().createServerSession(1, 3);
server.addConnectionPool("node2", getSession().getLogin(), 1, 3);
server.addConnectionPool("node3", getSession().getLogin(), 1, 3);
server.setSessionLog(getSession().getSessionLog());
server.setPartitioningPolicy(new RoundRobinPartitioningPolicy("default", "node2", "node3"));
server.login();
return server;
}
use of org.eclipse.persistence.sessions.server.Server in project eclipselink by eclipse-ee4j.
the class ConcurrentReadFetchJoinWithUOWLocksTest method test.
@Override
public void test() {
Server server = this.getServerSession();
UnitOfWork uow = server.acquireUnitOfWork();
ConcurrentLargeProject clonedProject = (ConcurrentLargeProject) uow.registerObject(project);
clonedProject.getLocation().setPostalCode("K1P 1A4");
ConcurrentPerson clonedPerson = (ConcurrentPerson) uow.registerObject(person);
clonedPerson.setHobby(clonedProject);
uow.writeChanges();
Thread thread1 = new Thread(new ProjectReader(server.acquireClientSession(), project.getId()));
ConcurrentProject.RUNNING_TEST = ConcurrentProject.READ_WITH_UOW_LOCKS_TESTS;
// start reading Project, and have the thread wait while building DTF mappings
thread1.start();
try {
// wait a token amount to be sure that thread1 isn't starved before getting deferred lock on Project.
thread1.join(1000);
} catch (InterruptedException ex) {
}
// start uow commit, which will get locks on Person+Address, commit, then merge.
// merge should get a deferred lock on Project.
Thread thread2 = new Thread(new UOWCommit(uow));
thread2.start();
// releases.
try {
thread1.join(20000);
if (thread1.isAlive()) {
try {
thread1.interrupt();
thread2.interrupt();
} catch (Exception e) {
}
deadlockDetected = true;
}
} catch (InterruptedException ex) {
}
}
use of org.eclipse.persistence.sessions.server.Server in project eclipselink by eclipse-ee4j.
the class NoSQLSessionTest method testServerSession.
/**
* Test {@link Server} session creation and login.
*/
@Test
public void testServerSession() throws Exception {
final Server session = SessionHelper.createServerSession(NoSQLTestSuite.project);
session.logout();
}
use of org.eclipse.persistence.sessions.server.Server in project eclipselink by eclipse-ee4j.
the class JUnitJPQLSimpleTestSuite method conformResultsInUnitOfWorkTest.
public void conformResultsInUnitOfWorkTest() {
ReadObjectQuery readObjectQuery = new ReadObjectQuery();
readObjectQuery.setReferenceClass(Employee.class);
readObjectQuery.setEJBQLString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.id = ?1");
readObjectQuery.conformResultsInUnitOfWork();
readObjectQuery.addArgument("1", Integer.class);
// ServerSession next
Server serverSession = getServerSession().getProject().createServerSession();
serverSession.setSessionLog(getServerSession().getSessionLog());
serverSession.login();
UnitOfWork unitOfWork = serverSession.acquireUnitOfWork();
Employee newEmployee = new Employee();
newEmployee.setId(9000);
unitOfWork.registerObject(newEmployee);
Vector testV = new Vector();
testV.addElement(9000);
Employee result = (Employee) unitOfWork.executeQuery(readObjectQuery, testV);
Assert.assertTrue("Conform Results In Unit of Work using ServerSession failed", comparer.compareObjects(result, newEmployee));
serverSession.logout();
}
Aggregations