Skip to content

Commit

Permalink
Merge branch '3.8' of https://github.com/JumpMind/symmetric-ds.git in…
Browse files Browse the repository at this point in the history
…to 3.8
  • Loading branch information
jumpmind-josh committed Feb 8, 2017
2 parents 8132ccd + 05fac50 commit 97ed77b
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ public class AndroidJobManager implements IJobManager {
protected long lastFileSyncTrackerTime = System.currentTimeMillis();

protected long lastFileSyncPushTime = System.currentTimeMillis();

protected boolean started = false;

public AndroidJobManager(ISymmetricEngine engine) {
this.engine = engine;
}

@Override
public boolean isStarted() {
return started;
}

public List<IJob> getJobs() {
List<IJob> jobs = new ArrayList<IJob>(1);
Expand All @@ -76,12 +83,14 @@ public void startJobs() {
job = new Job();
job.start();
}
started = true;
}

public void stopJobs() {
if (job != null) {
job.stop();
}
started = false;
}

public IJob getJob(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class JobManager implements IJobManager {

private ThreadPoolTaskScheduler taskScheduler;

private boolean started = false;

public JobManager(ISymmetricEngine engine) {

this.taskScheduler = new ThreadPoolTaskScheduler();
Expand Down Expand Up @@ -67,6 +69,11 @@ public JobManager(ISymmetricEngine engine) {
this.jobs.add(new MonitorJob(engine, taskScheduler));
this.jobs.add(new ReportStatusJob(engine, taskScheduler));
}

@Override
public boolean isStarted() {
return started;
}

@Override
public IJob getJob(String name) {
Expand All @@ -91,6 +98,7 @@ public synchronized void startJobs() {
log.info("Job {} not configured for auto start", job.getName());
}
}
started = true;
}

@Override
Expand All @@ -108,6 +116,7 @@ public synchronized void stopJobs() {
job.stop();
}
Thread.interrupted();
started = false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ public interface IJobManager {

public IJob getJob(String name);

public boolean isStarted();

}
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void syncEnded(DataContext context, List<IncomingBatch> batchesProcessed,

if (context.get(CTX_KEY_RESTART_JOBMANAGER_NEEDED) != null) {
IJobManager jobManager = engine.getJobManager();
if (jobManager != null) {
if (jobManager != null && jobManager.isStarted()) {
log.info("About to restart jobs because a new schedule came through the data loader");
jobManager.stopJobs();
jobManager.startJobs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public Node findNode(String id, boolean useCache) {
}
return nodeCache.get(id);
} else {
return findAllNodesAsMap().get(id);
return findNode(id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public String readSqlStatement() {
sql.setLength(0);
}
} else {
checkStatementEndsIndex = sql.length()-1;
checkStatementEndsIndex = sql.length();
}
line = readLine();
} while (line != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@

import org.junit.Test;

@SuppressWarnings("resource")
public class SqlScriptReaderTest {

@Test
public void testReadScript2() throws Exception {
SqlScriptReader reader = new SqlScriptReader(new InputStreamReader(getClass().getResourceAsStream("/test-script-2.sql")));
int count = 0;
while (reader.readSqlStatement() != null) {
count++;
}
assertEquals(36, count);
}

@Test
public void testReadScript() throws Exception {
public void testReadScript1() throws Exception {
SqlScriptReader reader = new SqlScriptReader(new InputStreamReader(getClass().getResourceAsStream("/test-script-1.sql")));

String nextStatement = reader.readSqlStatement();
Expand Down
Loading

0 comments on commit 97ed77b

Please sign in to comment.