Repository: tajo Updated Branches: refs/heads/master 0d434cdba -> 845e7c35a
TAJO-2032: Change tajo.rest.service.port to be the general style in TAJO. Closes #922 Signed-off-by: Jihoon Son <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/845e7c35 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/845e7c35 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/845e7c35 Branch: refs/heads/master Commit: 845e7c35a5eb96b6c70375ee288324c0cb052226 Parents: 0d434cd Author: Byunghwa Yun <[email protected]> Authored: Thu Jan 14 23:07:15 2016 -0800 Committer: Jihoon Son <[email protected]> Committed: Thu Jan 14 23:07:47 2016 -0800 ---------------------------------------------------------------------- CHANGES | 3 +++ .../org/apache/tajo/TajoTestingCluster.java | 6 +++--- .../java/org/apache/tajo/conf/TajoConf.java | 20 ++++++++++---------- .../apache/tajo/ha/TestHAServiceHDFSImpl.java | 4 ++-- .../ws/rs/resources/TestClusterResource.java | 5 +++-- .../ws/rs/resources/TestDatabasesResource.java | 5 +++-- .../ws/rs/resources/TestFunctionsResource.java | 6 ++++-- .../tajo/ws/rs/resources/TestQueryResource.java | 6 ++++-- .../rs/resources/TestQueryResultResource.java | 5 +++-- .../ws/rs/resources/TestSessionsResource.java | 5 +++-- .../ws/rs/resources/TestTablesResource.java | 6 ++++-- .../org/apache/tajo/ws/rs/TajoRestService.java | 4 ++-- .../ws/rs/netty/NettyRestServerFactory.java | 2 +- 13 files changed, 45 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index bc12eb8..39b78d2 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,9 @@ Release 0.12.0 - unreleased IMPROVEMENT + TAJO-2032: Change tajo.rest.service.port to be the general style in TAJO. + (Byunghwa Yun via jihoon) + TAJO-1971: Replace 'for' loop with 'foreach'. (Dongkyu Hwangbo via jihoon) TAJO-2040: Decrease the default size of max request for locality. (jinho) http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java ---------------------------------------------------------------------- diff --git a/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java b/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java index c519a53..3863203 100644 --- a/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java +++ b/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java @@ -359,7 +359,7 @@ public class TajoTestingCluster { c.setVar(ConfVars.RESOURCE_TRACKER_RPC_ADDRESS, "localhost:0"); c.setVar(ConfVars.WORKER_PEER_RPC_ADDRESS, "localhost:0"); c.setVar(ConfVars.WORKER_TEMPORAL_DIR, "file://" + testBuildDir.getAbsolutePath() + "/tajo-localdir"); - c.setIntVar(ConfVars.REST_SERVICE_PORT, 0); + c.setVar(ConfVars.REST_SERVICE_ADDRESS, "localhost:0"); if (!local) { String tajoRootDir = getMiniDFSCluster().getFileSystem().getUri().toString() + "/tajo"; @@ -394,8 +394,8 @@ public class TajoTestingCluster { this.conf.setVar(ConfVars.CATALOG_ADDRESS, c.getVar(ConfVars.CATALOG_ADDRESS)); InetSocketAddress tajoRestAddress = tajoMaster.getContext().getRestServer().getBindAddress(); - - this.conf.setIntVar(ConfVars.REST_SERVICE_PORT, tajoRestAddress.getPort()); + + this.conf.setVar(ConfVars.REST_SERVICE_ADDRESS, tajoRestAddress.getHostName() + ":" + tajoRestAddress.getPort()); startTajoWorkers(numSlaves); http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java ---------------------------------------------------------------------- diff --git a/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java b/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java index 29cf9ee..ea4d936 100644 --- a/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java +++ b/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java @@ -48,7 +48,7 @@ import java.util.concurrent.TimeUnit; public class TajoConf extends Configuration { private static TimeZone SYSTEM_TIMEZONE; private static int DATE_ORDER = -1; - + private static final Map<String, ConfVars> vars = new HashMap<>(); static { @@ -121,7 +121,7 @@ public class TajoConf extends Configuration { /////////////////////////////////////////////////////////////////////////////////////// // a username for a running Tajo cluster - ROOT_DIR("tajo.rootdir", "file:///tmp/tajo-${user.name}/", + ROOT_DIR("tajo.rootdir", "file:///tmp/tajo-${user.name}/", Validators.groups(Validators.notNull(), Validators.pathUrl())), USERNAME("tajo.username", "${user.name}", Validators.javaString()), @@ -140,7 +140,7 @@ public class TajoConf extends Configuration { TAJO_MASTER_INFO_ADDRESS("tajo.master.info-http.address", "0.0.0.0:26080", Validators.networkAddr()), // Tajo Rest Service - REST_SERVICE_PORT("tajo.rest.service.port", 26880), + REST_SERVICE_ADDRESS("tajo.rest.service.address", "0.0.0.0:26880", Validators.networkAddr()), // High availability configurations TAJO_MASTER_HA_ENABLE("tajo.master.ha.enable", false, Validators.bool()), @@ -432,7 +432,7 @@ public class TajoConf extends Configuration { this.defaultBoolVal = false; this.type = VarType.STRING; } - + ConfVars(String varname, String defaultVal, Validator validator) { this(varname, defaultVal); this.validator = validator; @@ -448,7 +448,7 @@ public class TajoConf extends Configuration { this.defaultBoolVal = false; this.type = VarType.INT; } - + ConfVars(String varname, int defaultIntVal, Validator validator) { this(varname, defaultIntVal); this.validator = validator; @@ -464,7 +464,7 @@ public class TajoConf extends Configuration { this.defaultBoolVal = false; this.type = VarType.LONG; } - + ConfVars(String varname, long defaultLongVal, Validator validator) { this(varname, defaultLongVal); this.validator = validator; @@ -480,7 +480,7 @@ public class TajoConf extends Configuration { this.defaultBoolVal = false; this.type = VarType.FLOAT; } - + ConfVars(String varname, float defaultFloatVal, Validator validator) { this(varname, defaultFloatVal); this.validator = validator; @@ -496,7 +496,7 @@ public class TajoConf extends Configuration { this.defaultBoolVal = defaultBoolVal; this.type = VarType.BOOLEAN; } - + ConfVars(String varname, boolean defaultBoolVal, Validator validator) { this(varname, defaultBoolVal); this.validator = validator; @@ -847,11 +847,11 @@ public class TajoConf extends Configuration { return new Path(systemConfPathStr); } } - + /** * validateProperty function will fetch pre-defined configuration property by keyname. * If found, it will validate the supplied value with these validators. - * + * * @param name - a string containing specific key * @param value - a string containing value * @throws ConstraintViolationException http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ha/TestHAServiceHDFSImpl.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ha/TestHAServiceHDFSImpl.java b/tajo-core-tests/src/test/java/org/apache/tajo/ha/TestHAServiceHDFSImpl.java index 81eeb1f..3eeeb39 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ha/TestHAServiceHDFSImpl.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ha/TestHAServiceHDFSImpl.java @@ -107,8 +107,8 @@ public class TestHAServiceHDFSImpl { "localhost:" + NetUtils.getFreeSocketPort()); conf.setVar(TajoConf.ConfVars.TAJO_MASTER_INFO_ADDRESS, "localhost:" + NetUtils.getFreeSocketPort()); - conf.setIntVar(TajoConf.ConfVars.REST_SERVICE_PORT, - NetUtils.getFreeSocketPort()); + conf.setVar(TajoConf.ConfVars.REST_SERVICE_ADDRESS, + "localhost:" + NetUtils.getFreeSocketPort()); conf.setBoolVar(TajoConf.ConfVars.TAJO_MASTER_HA_ENABLE, true); conf.setIntVar(TajoConf.ConfVars.TAJO_MASTER_HA_MONITOR_INTERVAL, 1000); http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestClusterResource.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestClusterResource.java b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestClusterResource.java index 42671d4..52e586b 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestClusterResource.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestClusterResource.java @@ -18,6 +18,7 @@ package org.apache.tajo.ws.rs.resources; +import java.net.InetSocketAddress; import java.net.URI; import java.util.List; import java.util.Map; @@ -50,8 +51,8 @@ public class TestClusterResource extends QueryTestCaseBase { @Before public void setUp() throws Exception { - int restPort = testBase.getTestingCluster().getConfiguration().getIntVar(ConfVars.REST_SERVICE_PORT); - restServiceURI = new URI("http", null, "127.0.0.1", restPort, "/rest", null, null); + InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS); + restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); clusterURI = new URI(restServiceURI + "/cluster"); restClient = ClientBuilder.newBuilder() .register(new GsonFeature(RestTestUtils.registerTypeAdapterMap())) http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestDatabasesResource.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestDatabasesResource.java b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestDatabasesResource.java index b2afda2..6ea95f8 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestDatabasesResource.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestDatabasesResource.java @@ -18,6 +18,7 @@ package org.apache.tajo.ws.rs.resources; +import java.net.InetSocketAddress; import java.net.URI; import java.util.Collection; import java.util.Map; @@ -56,8 +57,8 @@ public class TestDatabasesResource extends QueryTestCaseBase { @Before public void setUp() throws Exception { - int restPort = testBase.getTestingCluster().getConfiguration().getIntVar(ConfVars.REST_SERVICE_PORT); - restServiceURI = new URI("http", null, "127.0.0.1", restPort, "/rest", null, null); + InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS); + restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); databasesURI = new URI(restServiceURI + "/databases"); restClient = ClientBuilder.newBuilder() .register(new GsonFeature(RestTestUtils.registerTypeAdapterMap())) http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestFunctionsResource.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestFunctionsResource.java b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestFunctionsResource.java index 0d704d9..db7b836 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestFunctionsResource.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestFunctionsResource.java @@ -32,6 +32,8 @@ import org.junit.Test; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.GenericType; + +import java.net.InetSocketAddress; import java.net.URI; import java.util.List; @@ -50,8 +52,8 @@ public class TestFunctionsResource extends QueryTestCaseBase { @Before public void setUp() throws Exception { - int restPort = testBase.getTestingCluster().getConfiguration().getIntVar(ConfVars.REST_SERVICE_PORT); - restServiceURI = new URI("http", null, "127.0.0.1", restPort, "/rest", null, null); + InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS); + restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); functionsURI = new URI(restServiceURI + "/functions"); restClient = ClientBuilder.newBuilder() .register(new GsonFeature(RestTestUtils.registerTypeAdapterMap())) http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResource.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResource.java b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResource.java index 420a0d6..7fcb640 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResource.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResource.java @@ -41,6 +41,8 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; + +import java.net.InetSocketAddress; import java.net.URI; import java.util.List; import java.util.Map; @@ -62,8 +64,8 @@ public class TestQueryResource extends QueryTestCaseBase { @Before public void setUp() throws Exception { - int restPort = testBase.getTestingCluster().getConfiguration().getIntVar(ConfVars.REST_SERVICE_PORT); - restServiceURI = new URI("http", null, "127.0.0.1", restPort, "/rest", null, null); + InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS); + restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); sessionsURI = new URI(restServiceURI + "/sessions"); queriesURI = new URI(restServiceURI + "/queries"); restClient = ClientBuilder.newBuilder() http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResultResource.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResultResource.java b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResultResource.java index 9e0d83a..331fed7 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResultResource.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestQueryResultResource.java @@ -50,6 +50,7 @@ import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.EOFException; import java.io.InputStream; +import java.net.InetSocketAddress; import java.net.URI; import java.util.ArrayList; import java.util.List; @@ -74,8 +75,8 @@ public class TestQueryResultResource extends QueryTestCaseBase { @Before public void setUp() throws Exception { - int restPort = testBase.getTestingCluster().getConfiguration().getIntVar(ConfVars.REST_SERVICE_PORT); - restServiceURI = new URI("http", null, "127.0.0.1", restPort, "/rest", null, null); + InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS); + restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); sessionsURI = new URI(restServiceURI + "/sessions"); queriesURI = new URI(restServiceURI + "/queries"); restClient = ClientBuilder.newBuilder() http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestSessionsResource.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestSessionsResource.java b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestSessionsResource.java index f939db2..83da87b 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestSessionsResource.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestSessionsResource.java @@ -18,6 +18,7 @@ package org.apache.tajo.ws.rs.resources; +import java.net.InetSocketAddress; import java.net.URI; import java.util.HashMap; import java.util.Map; @@ -56,8 +57,8 @@ public class TestSessionsResource extends QueryTestCaseBase { @Before public void setUp() throws Exception { - int restPort = testBase.getTestingCluster().getConfiguration().getIntVar(ConfVars.REST_SERVICE_PORT); - restServiceURI = new URI("http", null, "127.0.0.1", restPort, "/rest", null, null); + InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS); + restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); sessionsURI = new URI(restServiceURI + "/sessions"); restClient = ClientBuilder.newBuilder() .register(new GsonFeature(RestTestUtils.registerTypeAdapterMap())) http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java index 423e80b..9d42102 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java @@ -41,6 +41,8 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; + +import java.net.InetSocketAddress; import java.net.URI; import java.util.Collection; import java.util.List; @@ -66,8 +68,8 @@ public class TestTablesResource extends QueryTestCaseBase { @Before public void setUp() throws Exception { - int restPort = testBase.getTestingCluster().getConfiguration().getIntVar(ConfVars.REST_SERVICE_PORT); - restServiceURI = new URI("http", null, "127.0.0.1", restPort, "/rest", null, null); + InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS); + restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); tablesURI = new URI(restServiceURI + "/databases/" + defaultDatabaseName + "/tables"); queriesURI = new URI(restServiceURI + "/queries"); sessionsURI = new URI(restServiceURI + "/sessions"); http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-core/src/main/java/org/apache/tajo/ws/rs/TajoRestService.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/ws/rs/TajoRestService.java b/tajo-core/src/main/java/org/apache/tajo/ws/rs/TajoRestService.java index 5951067..293192c 100644 --- a/tajo-core/src/main/java/org/apache/tajo/ws/rs/TajoRestService.java +++ b/tajo-core/src/main/java/org/apache/tajo/ws/rs/TajoRestService.java @@ -99,8 +99,8 @@ public class TajoRestService extends CompositeService { .property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true); TajoConf tajoConf = (TajoConf) conf; - int port = TajoConf.getIntVar(tajoConf, TajoConf.ConfVars.REST_SERVICE_PORT); - URI restServiceURI = new URI("http", null, "0.0.0.0", port, "/rest", null, null); + InetSocketAddress address = tajoConf.getSocketAddrVar(TajoConf.ConfVars.REST_SERVICE_ADDRESS); + URI restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null); int workerCount = TajoConf.getIntVar(tajoConf, TajoConf.ConfVars.REST_SERVICE_RPC_SERVER_WORKER_THREAD_NUM); restServer = NettyRestServerFactory.createNettyRestServer(restServiceURI, resourceConfig, workerCount, false); http://git-wip-us.apache.org/repos/asf/tajo/blob/845e7c35/tajo-rpc/tajo-ws-rs/src/main/java/org/apache/tajo/ws/rs/netty/NettyRestServerFactory.java ---------------------------------------------------------------------- diff --git a/tajo-rpc/tajo-ws-rs/src/main/java/org/apache/tajo/ws/rs/netty/NettyRestServerFactory.java b/tajo-rpc/tajo-ws-rs/src/main/java/org/apache/tajo/ws/rs/netty/NettyRestServerFactory.java index 5d2eea1..1fcfbe5 100644 --- a/tajo-rpc/tajo-ws-rs/src/main/java/org/apache/tajo/ws/rs/netty/NettyRestServerFactory.java +++ b/tajo-rpc/tajo-ws-rs/src/main/java/org/apache/tajo/ws/rs/netty/NettyRestServerFactory.java @@ -74,7 +74,7 @@ public final class NettyRestServerFactory { handler.setRootPath(uri.getPath()); - InetSocketAddress bindAddress = new InetSocketAddress(port); + InetSocketAddress bindAddress = new InetSocketAddress(uri.getHost(), port); NettyRestServer nettyRestServer = new NettyRestServer("Tajo-REST", bindAddress, workerCount); nettyRestServer.setHandler(handler);
