From 89f5304e8e7147640da7c8a683a8d61581021411 Mon Sep 17 00:00:00 2001 From: Byunghwa Yun Date: Tue, 19 Jan 2016 16:00:41 +0900 Subject: [PATCH 1/4] TAJO-2060: Upgrade geoip-api-java library --- .../org/apache/tajo/util/TestGeoIPUtil.java | 61 +++++++++++++++++++ tajo-core/pom.xml | 6 +- 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java b/tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java new file mode 100644 index 0000000000..9733cff8ef --- /dev/null +++ b/tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tajo.util; + +import static org.junit.Assert.assertNotNull; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.zip.GZIPInputStream; + +import com.maxmind.geoip.LookupService; + +public class TestGeoIPUtil { + @Test + public void testCountryCode() throws Exception { + new GeoIPUtil(); // initialize static field. + + LookupService lookup = new LookupService(getGeoIpData().getPath(), LookupService.GEOIP_MEMORY_CACHE); + System.out.println(GeoIPUtil.class.getDeclaredField("LOG")); + Field lookupField = GeoIPUtil.class.getDeclaredField("lookup"); + lookupField.setAccessible(true); + lookupField.set(null, lookup); + assertNotNull(GeoIPUtil.getCountryCode("154.73.88.82")); + assertNotNull(GeoIPUtil.getCountryCode("154.73.89.143")); + assertNotNull(GeoIPUtil.getCountryCode("154.76.101.156")); + } + + private File getGeoIpData() throws Exception { + File tmpFile = File.createTempFile("GeoIP", ".dat"); + + try (InputStream is = new URL("http://www.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz") + .openConnection().getInputStream(); + OutputStream out = new FileOutputStream(tmpFile)) { + IOUtils.copy(new GZIPInputStream(is), out); + } + return tmpFile; + } +} diff --git a/tajo-core/pom.xml b/tajo-core/pom.xml index bea3486615..03b73bf391 100644 --- a/tajo-core/pom.xml +++ b/tajo-core/pom.xml @@ -262,9 +262,9 @@ commons-codec - org.dspace.dependencies - dspace-geoip - 1.2.3 + com.maxmind.geoip + geoip-api + 1.2.14 io.netty From 423911186143b60e4c5295f247868c31a97fbc00 Mon Sep 17 00:00:00 2001 From: Byunghwa Yun Date: Fri, 22 Jan 2016 17:27:00 +0900 Subject: [PATCH 2/4] Doesn't unit test for external library. --- .../org/apache/tajo/util/TestGeoIPUtil.java | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java b/tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java deleted file mode 100644 index 9733cff8ef..0000000000 --- a/tajo-core-tests/src/test/java/org/apache/tajo/util/TestGeoIPUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tajo.util; - -import static org.junit.Assert.assertNotNull; - -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.net.URL; -import java.util.zip.GZIPInputStream; - -import com.maxmind.geoip.LookupService; - -public class TestGeoIPUtil { - @Test - public void testCountryCode() throws Exception { - new GeoIPUtil(); // initialize static field. - - LookupService lookup = new LookupService(getGeoIpData().getPath(), LookupService.GEOIP_MEMORY_CACHE); - System.out.println(GeoIPUtil.class.getDeclaredField("LOG")); - Field lookupField = GeoIPUtil.class.getDeclaredField("lookup"); - lookupField.setAccessible(true); - lookupField.set(null, lookup); - assertNotNull(GeoIPUtil.getCountryCode("154.73.88.82")); - assertNotNull(GeoIPUtil.getCountryCode("154.73.89.143")); - assertNotNull(GeoIPUtil.getCountryCode("154.76.101.156")); - } - - private File getGeoIpData() throws Exception { - File tmpFile = File.createTempFile("GeoIP", ".dat"); - - try (InputStream is = new URL("http://www.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz") - .openConnection().getInputStream(); - OutputStream out = new FileOutputStream(tmpFile)) { - IOUtils.copy(new GZIPInputStream(is), out); - } - return tmpFile; - } -} From b638a31d6a02c037b8d3e42aea8f16ac5082fe0e Mon Sep 17 00:00:00 2001 From: Byunghwa Yun Date: Fri, 22 Jan 2016 17:29:12 +0900 Subject: [PATCH 3/4] Updates the latest version. --- tajo-core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tajo-core/pom.xml b/tajo-core/pom.xml index 03b73bf391..63322f300b 100644 --- a/tajo-core/pom.xml +++ b/tajo-core/pom.xml @@ -264,7 +264,7 @@ com.maxmind.geoip geoip-api - 1.2.14 + 1.2.15 io.netty From 4f6be0af4009a14ac28bdd009546e3f679135e3e Mon Sep 17 00:00:00 2001 From: Byunghwa Yun Date: Fri, 22 Jan 2016 17:30:54 +0900 Subject: [PATCH 4/4] geoip-api is GPL license so to change scrop to provided from default. --- tajo-core/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/tajo-core/pom.xml b/tajo-core/pom.xml index 63322f300b..f4e1b9e81b 100644 --- a/tajo-core/pom.xml +++ b/tajo-core/pom.xml @@ -265,6 +265,7 @@ com.maxmind.geoip geoip-api 1.2.15 + provided io.netty