diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/DataLoaderService.java b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/DataLoaderService.java index 2692d67c33..6757632b74 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/DataLoaderService.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/DataLoaderService.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.ConnectException; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -112,6 +113,8 @@ protected List loadDataAndReturnBatches( } } catch (ConnectException ex) { logger.warn(ErrorConstants.COULD_NOT_CONNECT_TO_TRANSPORT); + } catch (UnknownHostException ex) { + logger.warn(ErrorConstants.COULD_NOT_CONNECT_TO_TRANSPORT + " Unknown host name of " + ex.getMessage()); } catch (RegistrationNotOpenException ex) { logger.warn("Registration attempt failed. Registration was not open for the node."); } catch (Exception e) { diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PullService.java b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PullService.java index 930723310b..ce7c0949fd 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PullService.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PullService.java @@ -33,7 +33,7 @@ import org.jumpmind.symmetric.service.IPullService; public class PullService implements IPullService { - + private static final Log logger = LogFactory.getLog(PullService.class); private INodeService nodeService; @@ -41,18 +41,20 @@ public class PullService implements IPullService { private IDataLoaderService dataLoaderService; public void pullData() { - logger.info("Pull requested"); List nodes = nodeService.findNodesToPull(); - for (Node node : nodes) { - try { - dataLoaderService.loadData(node, nodeService.findIdentity()); - } catch (ConnectException ex) { - logger.warn(ErrorConstants.COULD_NOT_CONNECT_TO_TRANSPORT); - } catch (IOException e) { - logger.error(e, e); + if (nodes != null && nodes.size() > 0) { + logger.info("Pull requested"); + for (Node node : nodes) { + try { + dataLoaderService.loadData(node, nodeService.findIdentity()); + } catch (ConnectException ex) { + logger.warn(ErrorConstants.COULD_NOT_CONNECT_TO_TRANSPORT); + } catch (IOException e) { + logger.error(e, e); + } } + logger.info("Pull completed"); } - logger.info("Pull completed"); } public void setNodeService(INodeService nodeService) { diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PurgeService.java b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PurgeService.java index 7fd4d37874..cc7e51d3f0 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PurgeService.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PurgeService.java @@ -56,7 +56,7 @@ public class PurgeService extends AbstractService implements IPurgeService { private int retentionInMinutes = 7200; public void purge() { - logger.info("The symmetric purge process is about to run."); + logger.info("The purge process is about to run."); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MINUTE, -retentionInMinutes); for (String sql : purgeSql) { diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PushService.java b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PushService.java index 53bff6ef7a..ffab431f65 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PushService.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/PushService.java @@ -54,14 +54,14 @@ public void setExtractor(IDataExtractorService extractor) { } public void pushData() { - info("Push requested"); List nodes = nodeService.findNodesToPushTo(); - if (nodes != null) { + if (nodes != null && nodes.size() > 0) { + info("Push requested"); for (Node node : nodes) { pushToNode(node); } - } - info("Push request completed"); + info("Push request completed"); + } } class ParameterParser { diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/transport/http/HttpTransportManager.java b/symmetric/src/main/java/org/jumpmind/symmetric/transport/http/HttpTransportManager.java index adaf6d8dab..8a3b13a0b0 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/transport/http/HttpTransportManager.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/transport/http/HttpTransportManager.java @@ -43,8 +43,6 @@ /** * Allow remote communication to nodes, in order to push data, pull data, and send messages. - * - * @author elong */ public class HttpTransportManager extends AbstractTransportManager implements ITransportManager { diff --git a/symmetric/src/test/java/org/jumpmind/symmetric/service/impl/DataLoaderServiceTest.java b/symmetric/src/test/java/org/jumpmind/symmetric/service/impl/DataLoaderServiceTest.java index 59a4c5130b..ea7aeda325 100644 --- a/symmetric/src/test/java/org/jumpmind/symmetric/service/impl/DataLoaderServiceTest.java +++ b/symmetric/src/test/java/org/jumpmind/symmetric/service/impl/DataLoaderServiceTest.java @@ -26,13 +26,16 @@ import java.util.List; import org.apache.commons.lang.ArrayUtils; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; import org.jumpmind.symmetric.common.Constants; import org.jumpmind.symmetric.common.TestConstants; import org.jumpmind.symmetric.common.csv.CsvConstants; import org.jumpmind.symmetric.load.AbstractDataLoaderTest; -import org.jumpmind.symmetric.model.Node; +import org.jumpmind.symmetric.load.csv.CsvLoader; import org.jumpmind.symmetric.model.IncomingBatch; import org.jumpmind.symmetric.model.IncomingBatchHistory; +import org.jumpmind.symmetric.model.Node; import org.jumpmind.symmetric.service.IDataLoaderService; import org.jumpmind.symmetric.service.IIncomingBatchService; import org.jumpmind.symmetric.transport.internal.InternalIncomingTransport; @@ -53,11 +56,16 @@ public class DataLoaderServiceTest extends AbstractDataLoaderTest { protected Node client; + protected void turnOffLoggingForTest() { + Logger.getLogger(DataLoaderService.class).setLevel(Level.OFF); + Logger.getLogger(CsvLoader.class).setLevel(Level.OFF); + } + @BeforeTest(groups = "continuous") protected void setUp() { + turnOffLoggingForTest(); dataLoaderService = (IDataLoaderService) getBeanFactory().getBean(Constants.DATALOADER_SERVICE); - incomingBatchService = (IIncomingBatchService) getBeanFactory().getBean( - Constants.INCOMING_BATCH_SERVICE); + incomingBatchService = (IIncomingBatchService) getBeanFactory().getBean(Constants.INCOMING_BATCH_SERVICE); transportManager = new MockTransportManager(); dataLoaderService.setTransportManager(transportManager); client = new Node(); @@ -154,8 +162,8 @@ public void testSkippingResentBatch() throws Exception { @Test(groups = "continuous") public void testErrorWhileSkip() throws Exception { - String[] values = { getNextId(), "string2", "string not null2", "char2", "char not null2", - "2007-01-02", "2007-02-03 04:05:06.0", "0", "47", "67.89" }; + String[] values = { getNextId(), "string2", "string not null2", "char2", "char not null2", "2007-01-02", + "2007-02-03 04:05:06.0", "0", "47", "67.89" }; testSimple(CsvConstants.INSERT, values, values); Assert.assertEquals(findIncomingBatchStatus(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID), @@ -189,8 +197,8 @@ public void testErrorWhileSkip() throws Exception { @Test(groups = "continuous") public void testErrorWhileParsing() throws Exception { - String[] values = { getNextId(), "should not reach database", "string not null", "char", - "char not null", "2007-01-02", "2007-02-03 04:05:06.0", "0", "47", "67.89" }; + String[] values = { getNextId(), "should not reach database", "string not null", "char", "char not null", + "2007-01-02", "2007-02-03 04:05:06.0", "0", "47", "67.89" }; ByteArrayOutputStream out = new ByteArrayOutputStream(); CsvWriter writer = getWriter(out); @@ -215,8 +223,8 @@ public void testErrorWhileParsing() throws Exception { @Test(groups = "continuous") public void testErrorThenSuccessBatch() throws Exception { String[] values = { getNextId(), "This string is too large and will cause the statement to fail", - "string not null2", "char2", "char not null2", "2007-01-02", "2007-02-03 04:05:06.0", "0", - "47", "67.89" }; + "string not null2", "char2", "char not null2", "2007-01-02", "2007-02-03 04:05:06.0", "0", "47", + "67.89" }; getNextBatchId(); int retries = 3; for (int i = 0; i < retries; i++) { @@ -249,11 +257,11 @@ public void testErrorThenSuccessBatch() throws Exception { @Test(groups = "continuous") public void testMultipleBatch() throws Exception { - String[] values = { getNextId(), "string", "string not null2", "char2", "char not null2", - "2007-01-02", "2007-02-03 04:05:06.0", "0", "47", "67.89" }; + String[] values = { getNextId(), "string", "string not null2", "char2", "char not null2", "2007-01-02", + "2007-02-03 04:05:06.0", "0", "47", "67.89" }; String[] values2 = { getNextId(), "This string is too large and will cause the statement to fail", - "string not null2", "char2", "char not null2", "2007-01-02", "2007-02-03 04:05:06.0", "0", - "47", "67.89" }; + "string not null2", "char2", "char not null2", "2007-01-02", "2007-02-03 04:05:06.0", "0", "47", + "67.89" }; ByteArrayOutputStream out = new ByteArrayOutputStream(); CsvWriter writer = getWriter(out); diff --git a/symmetric/src/test/resources/log4j.xml b/symmetric/src/test/resources/log4j.xml index fdd922abb5..643e064118 100644 --- a/symmetric/src/test/resources/log4j.xml +++ b/symmetric/src/test/resources/log4j.xml @@ -17,14 +17,6 @@ - - - - - - - -