Configurable map polling
This commit is contained in:
parent
93c2d676d0
commit
c058cc57ef
2 changed files with 23 additions and 18 deletions
|
@ -39,11 +39,14 @@ public class OsmParser extends MapCreatorBase {
|
|||
int rawBlobCount = 0;
|
||||
|
||||
long bytesRead = 0L;
|
||||
Boolean avoidMapPolling = Boolean.getBoolean("avoidMapPolling");
|
||||
|
||||
// wait for file to become available
|
||||
while (!mapFile.exists()) {
|
||||
System.out.println("--- waiting for " + mapFile + " to become available");
|
||||
Thread.sleep(10000);
|
||||
if (!avoidMapPolling) {
|
||||
// wait for file to become available
|
||||
while (!mapFile.exists()) {
|
||||
System.out.println("--- waiting for " + mapFile + " to become available");
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
long currentSize = mapFile.length();
|
||||
|
@ -53,18 +56,20 @@ public class OsmParser extends MapCreatorBase {
|
|||
|
||||
|
||||
for (; ; ) {
|
||||
// continue reading if either more then a 100 MB unread, or the current-size is known for more then 2 Minutes
|
||||
while (currentSize - bytesRead < 100000000L) {
|
||||
long newSize = mapFile.length();
|
||||
if (newSize != currentSize) {
|
||||
currentSize = newSize;
|
||||
currentSizeTime = System.currentTimeMillis();
|
||||
} else if (System.currentTimeMillis() - currentSizeTime > 120000) {
|
||||
break;
|
||||
}
|
||||
if (currentSize - bytesRead < 100000000L) {
|
||||
System.out.println("--- waiting for more data, currentSize=" + currentSize + " bytesRead=" + bytesRead);
|
||||
Thread.sleep(10000);
|
||||
if (!avoidMapPolling) {
|
||||
// continue reading if either more then a 100 MB unread, or the current-size is known for more than 2 Minutes
|
||||
while (currentSize - bytesRead < 100000000L) {
|
||||
long newSize = mapFile.length();
|
||||
if (newSize != currentSize) {
|
||||
currentSize = newSize;
|
||||
currentSizeTime = System.currentTimeMillis();
|
||||
} else if (System.currentTimeMillis() - currentSizeTime > 120000) {
|
||||
break;
|
||||
}
|
||||
if (currentSize - bytesRead < 100000000L) {
|
||||
System.out.println("--- waiting for more data, currentSize=" + currentSize + " bytesRead=" + bytesRead);
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package btools.mapcreator;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
public class MapcreatorTest {
|
||||
@Ignore("Fails with PBF parser")
|
||||
@Test
|
||||
public void mapcreatorTest() throws Exception {
|
||||
System.setProperty("avoidMapPolling", "true");
|
||||
|
||||
URL mapurl = this.getClass().getResource("/dreieich.pbf");
|
||||
Assert.assertNotNull("test-osm-map dreieich.pbf not found", mapurl);
|
||||
File mapFile = new File(mapurl.getFile());
|
||||
|
|
Loading…
Reference in a new issue