trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [incubator-trafficcontrol] 18/36: Refactor NetworkUpdater/DeepNetworkUpdater to reduce duplication
Date Wed, 24 Jan 2018 17:23:27 GMT
This is an automated email from the ASF dual-hosted git repository.

elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit a7177480692f29c8f34c4859c6ded2b9a7ab08ff
Author: Rawlin Peters <rawlin_peters@comcast.com>
AuthorDate: Thu Nov 2 17:11:42 2017 -0600

    Refactor NetworkUpdater/DeepNetworkUpdater to reduce duplication
    
    Move specialized code into a separate method and make DeepNetworkUpdater
    extend NetworkUpdater and override the specialized method.
---
 .../core/loc/DeepNetworkUpdater.java               | 22 ++++------------------
 .../traffic_router/core/loc/NetworkUpdater.java    |  8 ++++++--
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
index b4df7b8..c978b63 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
@@ -18,7 +18,8 @@ package com.comcast.cdn.traffic_control.traffic_router.core.loc;
 import java.io.File;
 import java.io.IOException;
 
-public class DeepNetworkUpdater extends AbstractServiceUpdater {
+
+public class DeepNetworkUpdater extends NetworkUpdater {
 
 	public DeepNetworkUpdater() {
 		sourceCompressed = false;
@@ -27,23 +28,8 @@ public class DeepNetworkUpdater extends AbstractServiceUpdater {
 	}
 
 	@Override
-	public boolean loadDatabase() throws IOException {
-		final File existingDB = databasesDirectory.resolve(databaseName).toFile();
-
-		if (!existingDB.exists() || !existingDB.canRead()) {
-			return false;
-		}
-
-		return NetworkNode.generateTree(existingDB, false, true) != null;
-	}
-
-	@Override
-	public boolean verifyDatabase(final File dbFile) throws IOException {
-		if (!dbFile.exists() || !dbFile.canRead()) {
-			return false;
-		}
-
-		return NetworkNode.generateTree(dbFile, true, true) != null;
+	public NetworkNode generateTree(final File dbFile, final boolean verifyOnly) throws IOException
{
+		return NetworkNode.generateTree(dbFile, verifyOnly, true);
 	}
 
 }
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
index 92d9e05..d1dc4c5 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
@@ -35,7 +35,7 @@ public class NetworkUpdater extends AbstractServiceUpdater {
 			return false;
 		}
 
-		return NetworkNode.generateTree(existingDB, false) != null;
+		return generateTree(existingDB, false) != null;
 	}
 
 	@Override
@@ -44,7 +44,11 @@ public class NetworkUpdater extends AbstractServiceUpdater {
 			return false;
 		}
 
-		return NetworkNode.generateTree(dbFile, true) != null;
+		return generateTree(dbFile, true) != null;
+	}
+
+	public NetworkNode generateTree(final File dbFile, final boolean verifyOnly) throws IOException,
JSONException {
+		return NetworkNode.generateTree(dbFile, verifyOnly);
 	}
 
 }

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

Mime
View raw message