20 import java.util.Properties;
21 import java.util.concurrent.ExecutorService;
22 import java.util.concurrent.Executors;
23 import java.util.concurrent.TimeUnit;
25 import junit.framework.TestCase;
27 import testsuite.clusterj.model.Employee;
29 import com.mysql.clusterj.ClusterJHelper;
30 import com.mysql.clusterj.Session;
31 import com.mysql.clusterj.SessionFactory;
39 public static void main(
String[] args) {
56 ExecutorService pool = Executors.newFixedThreadPool(4);
58 Manager.createClusterJSession();
63 for (
int i = 0;
i < 4; ++
i) {
65 pool.submit(
new Runnable() {
68 Session session = Manager.getSessionFactory().getSession();
73 entity.setName(
"Employee " +
id);
84 pool.awaitTermination(5, TimeUnit.SECONDS);
85 }
catch (InterruptedException e) {
86 fail(
"Interrupted pool.awaitTermination");
91 private static void insert(
int number) {
92 Session session = Manager.getSessionFactory().getSession();
109 createClusterJSession();
113 static void createClusterJSession() {
115 properties.
put(
"com.mysql.clusterj.connectstring",
"localhost:9311");
116 properties.
put(
"com.mysql.clusterj.database",
"test");
117 sessionfactory = ClusterJHelper.getSessionFactory(properties);
122 public static SessionFactory getSessionFactory() {
123 return sessionfactory;