You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2015/10/20 09:32:29 UTC

[2/2] ignite git commit: IGNITE-1710 update employee, car with random values

IGNITE-1710 update employee, car with random values


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a2e00c28
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a2e00c28
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a2e00c28

Branch: refs/heads/ignite-843-rc1
Commit: a2e00c28ca56b3faca7449333c03342bb007d20f
Parents: f234578
Author: Andrey <an...@gridgain.com>
Authored: Tue Oct 20 14:32:47 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Oct 20 14:32:47 2015 +0700

----------------------------------------------------------------------
 .../agent/testdrive/AgentSqlTestDrive.java      | 119 +++++++++----------
 1 file changed, 55 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a2e00c28/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
index 9b71178..d9fe0d2 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
@@ -96,9 +96,6 @@ public class AgentSqlTestDrive {
     /** Counter for threads in pool. */
     private static final AtomicInteger THREAD_CNT = new AtomicInteger(0);
 
-    /** */
-    private static ScheduledExecutorService cachePool;
-
     /**
      * Configure cacheEmployee.
      *
@@ -399,70 +396,64 @@ public class AgentSqlTestDrive {
 
         populateCacheCar(ignite, CAR_CACHE_NAME);
 
-        if (cachePool != null)
-            cachePool.shutdownNow();
-
-        cachePool = newScheduledThreadPool(2, "test-drive-sql-load-cache-tasks");
-
-        if (cachePool != null) {
-            cachePool.scheduleWithFixedDelay(new Runnable() {
-                @Override public void run() {
-                    try {
-                        IgniteCache<EmployeeKey, Employee> cache = ignite.cache(EMPLOYEE_CACHE_NAME);
-
-                        if (cache != null)
-                            for (int i = 0; i < n; i++) {
-                                Integer employeeId = rnd.nextInt(EMPL_CNT);
-
-                                Integer mgrId = (i == 0 || rnd.nextBoolean()) ? null : rnd.nextInt(employeeId);
-
-                                double r = rnd.nextDouble();
-
-                                cache.put(new EmployeeKey(employeeId),
-                                    new Employee(employeeId, "first name " + (i + 1), "last name " + (i + 1),
-                                        "email " + (i + 1), "phone number " + (i + 1),
-                                        new java.sql.Date((long)(r * diff)), "job " + (i + 1),
-                                        round(r * 5000, 2) , mgrId, rnd.nextInt(DEP_CNT)));
-
-                                if (rnd.nextBoolean())
-                                    cache.remove(new EmployeeKey(rnd.nextInt(EMPL_CNT)));
-                            }
-                    }
-                    catch (IllegalStateException ignored) {
-                    }
-                    catch (Throwable e) {
-                        if (!e.getMessage().contains("cache is stopped"))
-                            ignite.log().error("Cache write task execution error", e);
-                    }
+        ScheduledExecutorService cachePool = newScheduledThreadPool(2, "test-drive-sql-load-cache-tasks");
+
+        cachePool.scheduleWithFixedDelay(new Runnable() {
+            @Override public void run() {
+                try {
+                    IgniteCache<EmployeeKey, Employee> cache = ignite.cache(EMPLOYEE_CACHE_NAME);
+
+                    if (cache != null)
+                        for (int i = 0; i < n; i++) {
+                            Integer employeeId = rnd.nextInt(EMPL_CNT);
+
+                            Integer mgrId = (i == 0 || rnd.nextBoolean()) ? null : rnd.nextInt(employeeId);
+
+                            double r = rnd.nextDouble();
+
+                            cache.put(new EmployeeKey(employeeId),
+                                new Employee(employeeId, "first name " + (i + 1), "last name " + (i + 1),
+                                    "email " + (i + 1), "phone number " + (i + 1),
+                                    new java.sql.Date((long)(r * diff)), "job " + (i + 1),
+                                    round(r * 5000, 2), mgrId, rnd.nextInt(DEP_CNT)));
+
+                            if (rnd.nextBoolean())
+                                cache.remove(new EmployeeKey(rnd.nextInt(EMPL_CNT)));
+                        }
                 }
-            }, 10, 3, TimeUnit.SECONDS);
-
-            cachePool.scheduleWithFixedDelay(new Runnable() {
-                @Override public void run() {
-                    try {
-                        IgniteCache<CarKey, Car> cache = ignite.cache(CAR_CACHE_NAME);
-
-                        if (cache != null)
-                            for (int i = 0; i < n; i++) {
-                                Integer carId = rnd.nextInt(CAR_CNT);
-
-                                cache.put(new CarKey(carId), new Car(carId, rnd.nextInt(PARK_CNT), "Car " + (i + 1)));
-
-                                if (rnd.nextBoolean())
-                                    cache.remove(new CarKey(rnd.nextInt(CAR_CNT)));
-                            }
-                    }
-                    catch (IllegalStateException ignored) {
-                    }
-                    catch (Throwable e) {
-                        if (!e.getMessage().contains("cache is stopped"))
-                            ignite.log().error("Cache write task execution error", e);
-                    }
+                catch (IllegalStateException ignored) {
                 }
-            }, 10, 3, TimeUnit.SECONDS);
-        }
-    }
+                catch (Throwable e) {
+                    if (!e.getMessage().contains("cache is stopped"))
+                        ignite.log().error("Cache write task execution error", e);
+                }
+            }
+        }, 10, 3, TimeUnit.SECONDS);
+
+        cachePool.scheduleWithFixedDelay(new Runnable() {
+            @Override public void run() {
+                try {
+                    IgniteCache<CarKey, Car> cache = ignite.cache(CAR_CACHE_NAME);
+
+                    if (cache != null)
+                        for (int i = 0; i < n; i++) {
+                            Integer carId = rnd.nextInt(CAR_CNT);
+
+                            cache.put(new CarKey(carId), new Car(carId, rnd.nextInt(PARK_CNT), "Car " + (i + 1)));
 
+                            if (rnd.nextBoolean())
+                                cache.remove(new CarKey(rnd.nextInt(CAR_CNT)));
+                        }
+                }
+                catch (IllegalStateException ignored) {
+                }
+                catch (Throwable e) {
+                    if (!e.getMessage().contains("cache is stopped"))
+                        ignite.log().error("Cache write task execution error", e);
+                }
+            }
+        }, 10, 3, TimeUnit.SECONDS);
+    }
 
     /**
      * Start ignite node with cacheEmployee and populate it with data.