diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-22 00:31:00 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-22 00:32:28 +0100 |
commit | c8c863ce36f57954369a0b4a15e6c5e720f03f87 (patch) | |
tree | 2e49e11db5be949571642ceca947bb7b2178c777 | |
parent | 012b0864e95e120ea57433ab0e719cc6011c7647 (diff) | |
download | esper-testing-c8c863ce36f57954369a0b4a15e6c5e720f03f87.tar.gz esper-testing-c8c863ce36f57954369a0b4a15e6c5e720f03f87.tar.bz2 esper-testing-c8c863ce36f57954369a0b4a15e6c5e720f03f87.tar.xz esper-testing-c8c863ce36f57954369a0b4a15e6c5e720f03f87.zip |
o Moving stuff to utils package.
24 files changed, 36 insertions, 284 deletions
@@ -176,7 +176,7 @@ </program> <program> <name>jenkins-build-poller</name> - <mainClass>io.trygvis.esper.testing.core.JenkinsBuildPoller</mainClass> + <mainClass>io.trygvis.esper.testing.core.jenkins.JenkinsBuildPoller</mainClass> </program> </programs> </configuration> diff --git a/src/main/java/io/trygvis/esper/testing/Daos.java b/src/main/java/io/trygvis/esper/testing/Daos.java index 5ddb75b..967dae4 100644 --- a/src/main/java/io/trygvis/esper/testing/Daos.java +++ b/src/main/java/io/trygvis/esper/testing/Daos.java @@ -1,6 +1,6 @@ package io.trygvis.esper.testing; -import io.trygvis.esper.testing.core.*; +import io.trygvis.esper.testing.core.db.*; import io.trygvis.esper.testing.gitorious.*; import io.trygvis.esper.testing.jenkins.*; diff --git a/src/main/java/io/trygvis/esper/testing/Util.java b/src/main/java/io/trygvis/esper/testing/Util.java index 4e1bf93..c33e64c 100644 --- a/src/main/java/io/trygvis/esper/testing/Util.java +++ b/src/main/java/io/trygvis/esper/testing/Util.java @@ -4,7 +4,7 @@ import fj.*; import fj.data.*; import static fj.data.Option.*; -import io.trygvis.esper.testing.sql.*; +import io.trygvis.esper.testing.util.sql.*; import org.jdom2.*; import org.joda.time.*; diff --git a/src/main/java/io/trygvis/esper/testing/core/TablePoller.java b/src/main/java/io/trygvis/esper/testing/core/TablePoller.java index c21b5ae..062f5e7 100644 --- a/src/main/java/io/trygvis/esper/testing/core/TablePoller.java +++ b/src/main/java/io/trygvis/esper/testing/core/TablePoller.java @@ -1,14 +1,14 @@ package io.trygvis.esper.testing.core; import fj.data.*; -import io.trygvis.esper.testing.sql.*; +import io.trygvis.esper.testing.util.sql.*; import org.slf4j.*; import javax.sql.*; import java.sql.*; -import static io.trygvis.esper.testing.sql.ResultSetF.*; -import static io.trygvis.esper.testing.sql.SqlOption.*; +import static io.trygvis.esper.testing.util.sql.ResultSetF.*; +import static io.trygvis.esper.testing.util.sql.SqlOption.*; import static java.lang.System.*; public class TablePoller<A> { diff --git a/src/main/java/io/trygvis/esper/testing/core/BuildDto.java b/src/main/java/io/trygvis/esper/testing/core/db/BuildDto.java index 37de1b3..5cc6b0a 100644 --- a/src/main/java/io/trygvis/esper/testing/core/BuildDto.java +++ b/src/main/java/io/trygvis/esper/testing/core/db/BuildDto.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.core; +package io.trygvis.esper.testing.core.db; import io.trygvis.esper.testing.*; import org.joda.time.*; diff --git a/src/main/java/io/trygvis/esper/testing/core/CoreDao.java b/src/main/java/io/trygvis/esper/testing/core/db/CoreDao.java index a010dad..5eab2c9 100644 --- a/src/main/java/io/trygvis/esper/testing/core/CoreDao.java +++ b/src/main/java/io/trygvis/esper/testing/core/db/CoreDao.java @@ -1,13 +1,13 @@ -package io.trygvis.esper.testing.core; +package io.trygvis.esper.testing.core.db; import io.trygvis.esper.testing.*; -import io.trygvis.esper.testing.sql.*; +import io.trygvis.esper.testing.util.sql.*; import org.joda.time.*; import java.sql.*; import java.util.*; -import static io.trygvis.esper.testing.sql.SqlOption.*; +import static io.trygvis.esper.testing.util.sql.SqlOption.*; import static java.lang.System.*; public class CoreDao { diff --git a/src/main/java/io/trygvis/esper/testing/core/PersonDto.java b/src/main/java/io/trygvis/esper/testing/core/db/PersonDto.java index 33355a3..c643fc7 100644 --- a/src/main/java/io/trygvis/esper/testing/core/PersonDto.java +++ b/src/main/java/io/trygvis/esper/testing/core/db/PersonDto.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.core; +package io.trygvis.esper.testing.core.db; import io.trygvis.esper.testing.*; import org.joda.time.*; diff --git a/src/main/java/io/trygvis/esper/testing/core/JenkinsBuildPoller.java b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java index cb9157c..90a4ef4 100644 --- a/src/main/java/io/trygvis/esper/testing/core/JenkinsBuildPoller.java +++ b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java @@ -1,9 +1,11 @@ -package io.trygvis.esper.testing.core; +package io.trygvis.esper.testing.core.jenkins; import com.jolbox.bonecp.*; import io.trygvis.esper.testing.*; +import io.trygvis.esper.testing.core.*; +import io.trygvis.esper.testing.core.db.*; import io.trygvis.esper.testing.jenkins.*; -import io.trygvis.esper.testing.sql.*; +import io.trygvis.esper.testing.util.sql.*; import org.slf4j.*; import java.sql.*; diff --git a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java index 295f6a6..1429f83 100644 --- a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java +++ b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java @@ -4,11 +4,11 @@ import com.jolbox.bonecp.*; import fj.data.Option; import static fj.data.Option.*; import io.trygvis.esper.testing.*; -import io.trygvis.esper.testing.object.ActorRef; -import io.trygvis.esper.testing.object.ObjectFactory; -import io.trygvis.esper.testing.object.ObjectManager; -import io.trygvis.esper.testing.object.ObjectUtil; -import io.trygvis.esper.testing.object.TransactionalActor; +import io.trygvis.esper.testing.util.object.ActorRef; +import io.trygvis.esper.testing.util.object.ObjectFactory; +import io.trygvis.esper.testing.util.object.ObjectManager; +import io.trygvis.esper.testing.util.object.ObjectUtil; +import io.trygvis.esper.testing.util.object.TransactionalActor; import io.trygvis.esper.testing.util.*; import static java.lang.System.*; diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java index 7f52bd0..a31c6a0 100644 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java @@ -1,7 +1,7 @@ package io.trygvis.esper.testing.jenkins; import fj.data.*; -import io.trygvis.esper.testing.sql.*; +import io.trygvis.esper.testing.util.sql.*; import org.joda.time.*; import java.net.*; @@ -11,7 +11,7 @@ import java.util.List; import static fj.data.Option.*; import static io.trygvis.esper.testing.Util.toUuidArray; -import static io.trygvis.esper.testing.sql.SqlOption.fromRs; +import static io.trygvis.esper.testing.util.sql.SqlOption.fromRs; import static java.lang.System.*; public class JenkinsDao { diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java index e30dca7..3a688eb 100644 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java @@ -2,7 +2,7 @@ package io.trygvis.esper.testing.jenkins; import com.jolbox.bonecp.*; import io.trygvis.esper.testing.*; -import io.trygvis.esper.testing.object.*; +import io.trygvis.esper.testing.util.object.*; import io.trygvis.esper.testing.util.*; import org.apache.abdera.*; import org.codehaus.httpcache4j.cache.*; @@ -12,7 +12,7 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; -import static io.trygvis.esper.testing.object.ObjectUtil.*; +import static io.trygvis.esper.testing.util.object.ObjectUtil.*; import static java.lang.Thread.*; public class JenkinsImporter { diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java index 8f04faf..cf95c4e 100644 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java @@ -1,8 +1,8 @@ package io.trygvis.esper.testing.jenkins; import fj.data.*; -import io.trygvis.esper.testing.object.*; -import io.trygvis.esper.testing.sql.*; +import io.trygvis.esper.testing.util.object.*; +import io.trygvis.esper.testing.util.sql.*; import org.slf4j.*; import java.net.*; diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerOld.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerOld.java index cfd9939..9f48191 100644 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerOld.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerOld.java @@ -5,7 +5,7 @@ import fj.data.*; import static fj.data.Option.*; import static io.trygvis.esper.testing.jenkins.JenkinsClient.apiXml; -import io.trygvis.esper.testing.object.*; +import io.trygvis.esper.testing.util.object.*; import org.joda.time.*; import java.io.*; diff --git a/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java b/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java index 3bf93c4..4042108 100644 --- a/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java +++ b/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java @@ -3,7 +3,7 @@ package io.trygvis.esper.testing.nexus; import com.jolbox.bonecp.*; import fj.data.*; import io.trygvis.esper.testing.*; -import io.trygvis.esper.testing.object.*; +import io.trygvis.esper.testing.util.object.*; import io.trygvis.esper.testing.util.*; import static java.lang.Thread.*; import static java.util.regex.Pattern.quote; diff --git a/src/main/java/io/trygvis/esper/testing/task/TaskDao.java b/src/main/java/io/trygvis/esper/testing/task/TaskDao.java deleted file mode 100644 index 242eb2a..0000000 --- a/src/main/java/io/trygvis/esper/testing/task/TaskDao.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.trygvis.esper.testing.task; - -import java.sql.*; -import java.util.*; - -public class TaskDao { - private final Connection c; - private final String table; - - public TaskDao(Connection c, String table) { - this.c = c; - this.table = table; - } - - public List<String> findTasks() throws SQLException { - try (PreparedStatement s = c.prepareStatement("SELECT task_id FROM ? FOR UPDATE")) { - s.setString(1, table); - ResultSet rs = s.executeQuery(); - List<String> list = new ArrayList<>(); - while(rs.next()) { - list.add(rs.getString(1)); - } - return list; - } - } -} diff --git a/src/main/java/io/trygvis/esper/testing/task/TaskManager.java b/src/main/java/io/trygvis/esper/testing/task/TaskManager.java deleted file mode 100644 index e4daba5..0000000 --- a/src/main/java/io/trygvis/esper/testing/task/TaskManager.java +++ /dev/null @@ -1,224 +0,0 @@ -package io.trygvis.esper.testing.task; - -import com.jolbox.bonecp.*; -import org.slf4j.*; -import org.slf4j.helpers.*; - -import java.sql.*; -import java.util.*; -import java.util.concurrent.*; - -public class TaskManager<T> { - public final String table; - public final TaskExecutorFactory taskExecutorFactory; - public final Executor executor; - public final BoneCP boneCP; - - private final Set<String> inProgress = new HashSet<>(); - - public TaskManager(String table, TaskExecutorFactory taskExecutorFactory, Executor executor, BoneCP boneCP) { - this.table = table; - this.taskExecutorFactory = taskExecutorFactory; - this.executor = executor; - this.boneCP = boneCP; - - Thread thread = new Thread(new Runnable() { - public void run() { - TaskManager.this.run(); - } - }); - thread.start(); - } - - private void run() { - while (true) { - try { - try (Connection c = boneCP.getConnection()) { - singleRun(c); - } - } catch (SQLException e) { - e.printStackTrace(System.out); - } - } - } - - private void singleRun(Connection c) throws SQLException { - TaskDao taskDao = new TaskDao(c, table); - - List<String> ids = taskDao.findTasks(); - - System.out.println("Found " + ids.size() + " new tasks."); - - synchronized (inProgress) { - System.out.println("Have " + inProgress.size() + " tasks in progress already"); - ids.removeAll(inProgress); - - List<Runnable> runnables = new ArrayList<>(ids.size()); - - for (final String id : ids) { - System.out.println("Scheduling " + id); - - final TaskExecutor executor = taskExecutorFactory.create(); - runnables.add(new Runnable() { - public void run() { - System.out.println("Executing " + id); - try { - try (Connection c2 = boneCP.getConnection()) { - SqlLogger logger = new SqlLogger(); - executor.execute(id, c2, logger); - // TODO: insert log statements - System.out.println("Executing " + id); - c2.commit(); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - synchronized (inProgress) { - inProgress.remove(id); - } - } - } - }); - inProgress.add(id); - } - for (Runnable runnable : runnables) { - executor.execute(runnable); - } - } - } - - /** - * See MessageFormatter - */ - private static class SqlLogger extends MarkerIgnoringBase { - - public boolean isTraceEnabled() { - throw new RuntimeException("Not implemented"); - } - - public void trace(String msg) { - throw new RuntimeException("Not implemented"); - } - - public void trace(String format, Object arg) { - throw new RuntimeException("Not implemented"); - } - - public void trace(String format, Object arg1, Object arg2) { - throw new RuntimeException("Not implemented"); - } - - public void trace(String format, Object[] argArray) { - throw new RuntimeException("Not implemented"); - } - - public void trace(String msg, Throwable t) { - throw new RuntimeException("Not implemented"); - } - - public boolean isDebugEnabled() { - throw new RuntimeException("Not implemented"); - } - - public void debug(String msg) { - throw new RuntimeException("Not implemented"); - } - - public void debug(String format, Object arg) { - throw new RuntimeException("Not implemented"); - } - - public void debug(String format, Object arg1, Object arg2) { - throw new RuntimeException("Not implemented"); - } - - public void debug(String format, Object[] argArray) { - throw new RuntimeException("Not implemented"); - } - - public void debug(String msg, Throwable t) { - throw new RuntimeException("Not implemented"); - } - - public boolean isInfoEnabled() { - throw new RuntimeException("Not implemented"); - } - - public void info(String msg) { - throw new RuntimeException("Not implemented"); - } - - public void info(String format, Object arg) { - throw new RuntimeException("Not implemented"); - } - - public void info(String format, Object arg1, Object arg2) { - throw new RuntimeException("Not implemented"); - } - - public void info(String format, Object[] argArray) { - throw new RuntimeException("Not implemented"); - } - - public void info(String msg, Throwable t) { - throw new RuntimeException("Not implemented"); - } - - public boolean isWarnEnabled() { - throw new RuntimeException("Not implemented"); - } - - public void warn(String msg) { - throw new RuntimeException("Not implemented"); - } - - public void warn(String format, Object arg) { - throw new RuntimeException("Not implemented"); - } - - public void warn(String format, Object[] argArray) { - throw new RuntimeException("Not implemented"); - } - - public void warn(String format, Object arg1, Object arg2) { - throw new RuntimeException("Not implemented"); - } - - public void warn(String msg, Throwable t) { - throw new RuntimeException("Not implemented"); - } - - public boolean isErrorEnabled() { - throw new RuntimeException("Not implemented"); - } - - public void error(String msg) { - throw new RuntimeException("Not implemented"); - } - - public void error(String format, Object arg) { - throw new RuntimeException("Not implemented"); - } - - public void error(String format, Object arg1, Object arg2) { - throw new RuntimeException("Not implemented"); - } - - public void error(String format, Object[] argArray) { - throw new RuntimeException("Not implemented"); - } - - public void error(String msg, Throwable t) { - throw new RuntimeException("Not implemented"); - } - } -} - -interface TaskExecutorFactory { - TaskExecutor create(); -} - -interface TaskExecutor { - void execute(String id, Connection c, Logger logger) - throws SQLException; -} diff --git a/src/main/java/io/trygvis/esper/testing/object/ActorRef.java b/src/main/java/io/trygvis/esper/testing/util/object/ActorRef.java index bc64da3..49986e6 100644 --- a/src/main/java/io/trygvis/esper/testing/object/ActorRef.java +++ b/src/main/java/io/trygvis/esper/testing/util/object/ActorRef.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.object; +package io.trygvis.esper.testing.util.object; import java.io.*; diff --git a/src/main/java/io/trygvis/esper/testing/object/ObjectFactory.java b/src/main/java/io/trygvis/esper/testing/util/object/ObjectFactory.java index 8e7d4b0..ea53a46 100644 --- a/src/main/java/io/trygvis/esper/testing/object/ObjectFactory.java +++ b/src/main/java/io/trygvis/esper/testing/util/object/ObjectFactory.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.object; +package io.trygvis.esper.testing.util.object; import java.io.*; diff --git a/src/main/java/io/trygvis/esper/testing/object/ObjectManager.java b/src/main/java/io/trygvis/esper/testing/util/object/ObjectManager.java index a4fbc60..5b9d740 100644 --- a/src/main/java/io/trygvis/esper/testing/object/ObjectManager.java +++ b/src/main/java/io/trygvis/esper/testing/util/object/ObjectManager.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.object; +package io.trygvis.esper.testing.util.object; import org.slf4j.*; diff --git a/src/main/java/io/trygvis/esper/testing/object/ObjectUtil.java b/src/main/java/io/trygvis/esper/testing/util/object/ObjectUtil.java index 0e9912b..143a181 100644 --- a/src/main/java/io/trygvis/esper/testing/object/ObjectUtil.java +++ b/src/main/java/io/trygvis/esper/testing/util/object/ObjectUtil.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.object; +package io.trygvis.esper.testing.util.object; import org.slf4j.*; diff --git a/src/main/java/io/trygvis/esper/testing/object/TransactionalActor.java b/src/main/java/io/trygvis/esper/testing/util/object/TransactionalActor.java index 4d3cdce..0799695 100644 --- a/src/main/java/io/trygvis/esper/testing/object/TransactionalActor.java +++ b/src/main/java/io/trygvis/esper/testing/util/object/TransactionalActor.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.object; +package io.trygvis.esper.testing.util.object; import java.sql.*; diff --git a/src/main/java/io/trygvis/esper/testing/sql/ResultSetF.java b/src/main/java/io/trygvis/esper/testing/util/sql/ResultSetF.java index e5a9e4e..9e42242 100644 --- a/src/main/java/io/trygvis/esper/testing/sql/ResultSetF.java +++ b/src/main/java/io/trygvis/esper/testing/util/sql/ResultSetF.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.sql; +package io.trygvis.esper.testing.util.sql; import java.sql.*; diff --git a/src/main/java/io/trygvis/esper/testing/sql/SqlF.java b/src/main/java/io/trygvis/esper/testing/util/sql/SqlF.java index fb05e4c..e4e8197 100644 --- a/src/main/java/io/trygvis/esper/testing/sql/SqlF.java +++ b/src/main/java/io/trygvis/esper/testing/util/sql/SqlF.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.sql; +package io.trygvis.esper.testing.util.sql; import java.sql.*; diff --git a/src/main/java/io/trygvis/esper/testing/sql/SqlOption.java b/src/main/java/io/trygvis/esper/testing/util/sql/SqlOption.java index 288735a..286a872 100644 --- a/src/main/java/io/trygvis/esper/testing/sql/SqlOption.java +++ b/src/main/java/io/trygvis/esper/testing/util/sql/SqlOption.java @@ -1,4 +1,4 @@ -package io.trygvis.esper.testing.sql; +package io.trygvis.esper.testing.util.sql; import java.sql.*; |