You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by mo...@apache.org on 2016/08/24 20:49:39 UTC
reef git commit: [REEF-1540] Release 0.15.1
Repository: reef
Updated Branches:
refs/heads/branch-0.15.1 226b67a20 -> 4c2c044e7
[REEF-1540] Release 0.15.1
Backport the following fixes from master to branch-0.15.1:
* [REEF-1539] Fix memory leak in InteropUtil.cpp
* [REEF-1528] Refactor dependency between yarn runtime and reef-webserver projects
* [REEF-1529] Fixing reef-webserver for multi runtime
Pull Request: Closes #1106
Project: http://git-wip-us.apache.org/repos/asf/reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/4c2c044e
Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/4c2c044e
Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/4c2c044e
Branch: refs/heads/branch-0.15.1
Commit: 4c2c044e7a84a9d0a9a757766cb7021827b5defd
Parents: 226b67a
Author: pchung13 <me...@patrickchung.net>
Authored: Tue Aug 23 10:18:35 2016 -0700
Committer: Sergiy Matusevych <mo...@apache.org>
Committed: Wed Aug 24 12:34:59 2016 -0700
----------------------------------------------------------------------
lang/cs/Org.Apache.REEF.Bridge/InteropUtil.cpp | 1 +
.../common/driver/EvaluatorRequestorImpl.java | 3 +-
.../reef/runtime/multi/driver/RuntimesHost.java | 17 ++-
lang/java/reef-runtime-yarn/pom.xml | 10 ++
.../yarn/driver/DefaultTrackingURLProvider.java | 33 ------
.../yarn/driver/HttpTrackingURLProvider.java | 72 ++++++++++++
.../yarn/driver/TrackingURLProvider.java | 2 +-
.../runtime/yarn/driver/TestTrackingUri.java | 116 +++++++++++++++++++
.../driver/YarnResourceRequestHandlerTest.java | 33 +++---
lang/java/reef-webserver/pom.xml | 5 -
.../webserver/HttpHandlerConfiguration.java | 2 -
.../org/apache/reef/webserver/HttpServer.java | 3 +
.../reef/webserver/HttpTrackingURLProvider.java | 67 -----------
.../reef/webserver/NoOpHttpServerImpl.java | 49 ++++++++
.../apache/reef/webserver/TestTrackingUri.java | 114 ------------------
15 files changed, 286 insertions(+), 241 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/cs/Org.Apache.REEF.Bridge/InteropUtil.cpp
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Bridge/InteropUtil.cpp b/lang/cs/Org.Apache.REEF.Bridge/InteropUtil.cpp
index 66e1a01..b7dd871 100644
--- a/lang/cs/Org.Apache.REEF.Bridge/InteropUtil.cpp
+++ b/lang/cs/Org.Apache.REEF.Bridge/InteropUtil.cpp
@@ -101,6 +101,7 @@ array<byte>^ ManagedByteArrayFromJavaByteArray(
for (int i = 0; i < len; i++) {
managedByteArray[i] = bytes[i];
}
+ env->ReleaseByteArrayElements(javaByteArray, (jbyte*)bytes, JNI_ABORT);
return managedByteArray;
}
return nullptr;
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImpl.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImpl.java b/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImpl.java
index 58f5a8a..b2faf98 100644
--- a/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImpl.java
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImpl.java
@@ -47,6 +47,7 @@ public final class EvaluatorRequestorImpl implements EvaluatorRequestor {
/**
* @param resourceCatalog
* @param resourceRequestHandler
+ * @param loggingScopeFactory
*/
@Inject
public EvaluatorRequestorImpl(final ResourceCatalog resourceCatalog,
@@ -98,7 +99,7 @@ public final class EvaluatorRequestorImpl implements EvaluatorRequestor {
relaxLocality = false;
}
- try (LoggingScope ls = loggingScopeFactory.evaluatorSubmit(req.getNumber())) {
+ try (LoggingScope ls = this.loggingScopeFactory.evaluatorSubmit(req.getNumber())) {
final ResourceRequestEvent request = ResourceRequestEventImpl
.newBuilder()
.setResourceCount(req.getNumber())
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-runtime-multi/src/main/java/org/apache/reef/runtime/multi/driver/RuntimesHost.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-multi/src/main/java/org/apache/reef/runtime/multi/driver/RuntimesHost.java b/lang/java/reef-runtime-multi/src/main/java/org/apache/reef/runtime/multi/driver/RuntimesHost.java
index bfbc037..62646d2 100644
--- a/lang/java/reef-runtime-multi/src/main/java/org/apache/reef/runtime/multi/driver/RuntimesHost.java
+++ b/lang/java/reef-runtime-multi/src/main/java/org/apache/reef/runtime/multi/driver/RuntimesHost.java
@@ -40,16 +40,20 @@ import org.apache.reef.tang.formats.AvroConfigurationSerializer;
import org.apache.reef.wake.EventHandler;
import org.apache.reef.wake.time.runtime.event.RuntimeStart;
import org.apache.reef.wake.time.runtime.event.RuntimeStop;
+import org.apache.reef.webserver.HttpServer;
import javax.inject.Inject;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* Hosts the actual runtime implementations and delegates invocations to them.
*/
final class RuntimesHost {
+ private static final Logger LOG = Logger.getLogger(RuntimesHost.class.getName());
private final AvroMultiRuntimeDefinition runtimeDefinition;
private final Injector originalInjector;
private final String defaultRuntimeName;
@@ -127,12 +131,23 @@ final class RuntimesHost {
runtimeInjector.bindVolatileParameter(
RuntimeParameters.RuntimeStatusHandler.class,
runtimeStatusEventHandler);
+ HttpServer httpServer = null;
+ try {
+ httpServer = this.originalInjector.getInstance(HttpServer.class);
+ } catch (final InjectionException e) {
+ LOG.log(Level.INFO, "Http Server is not configured for the runtime", e);
+ }
+
+ if (httpServer != null) {
+ runtimeInjector.bindVolatileInstance(HttpServer.class, httpServer);
+ LOG.log(Level.INFO, "Binding http server for the runtime implementation");
+ }
}
/**
* Retrieves requested runtime, if requested name is empty a default runtime will be used.
* @param requestedRuntimeName the requested runtime name
- * @return
+ * @return The runtime
*/
private Runtime getRuntime(final String requestedRuntimeName) {
String runtimeName = requestedRuntimeName;
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-runtime-yarn/pom.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-yarn/pom.xml b/lang/java/reef-runtime-yarn/pom.xml
index 8f3e933..556d784 100644
--- a/lang/java/reef-runtime-yarn/pom.xml
+++ b/lang/java/reef-runtime-yarn/pom.xml
@@ -42,6 +42,11 @@ under the License.
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>reef-webserver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>reef-utils-hadoop</artifactId>
<version>${project.version}</version>
</dependency>
@@ -65,6 +70,11 @@ under the License.
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/DefaultTrackingURLProvider.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/DefaultTrackingURLProvider.java b/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/DefaultTrackingURLProvider.java
deleted file mode 100644
index af2442a..0000000
--- a/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/DefaultTrackingURLProvider.java
+++ /dev/null
@@ -1,33 +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.reef.runtime.yarn.driver;
-
-import javax.inject.Inject;
-
-final class DefaultTrackingURLProvider implements TrackingURLProvider {
-
- @Inject
- DefaultTrackingURLProvider() {
- }
-
- @Override
- public String getTrackingUrl() {
- return "";
- }
-}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/HttpTrackingURLProvider.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/HttpTrackingURLProvider.java b/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/HttpTrackingURLProvider.java
new file mode 100644
index 0000000..d7829bb
--- /dev/null
+++ b/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/HttpTrackingURLProvider.java
@@ -0,0 +1,72 @@
+/*
+ * 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.reef.runtime.yarn.driver;
+
+import org.apache.reef.webserver.NoOpHttpServerImpl;
+import org.apache.reef.webserver.HttpServer;
+
+import javax.inject.Inject;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Http TrackingURLProvider.
+ */
+public final class HttpTrackingURLProvider implements TrackingURLProvider {
+ /**
+ * Standard Java logger.
+ */
+ private static final Logger LOG = Logger.getLogger(HttpTrackingURLProvider.class.getName());
+
+ /**
+ * HttpServer.
+ */
+ private final HttpServer httpServer;
+
+ /**
+ * Constructor of HttpTrackingURLProvider.
+ *
+ * @param httpServer
+ */
+ @Inject
+ public HttpTrackingURLProvider(final HttpServer httpServer) {
+ this.httpServer = httpServer instanceof NoOpHttpServerImpl ? null : httpServer;
+ }
+
+ /**
+ * get tracking URI.
+ *
+ * @return
+ */
+ @Override
+ public String getTrackingUrl() {
+ if (this.httpServer == null) {
+ return "";
+ }
+
+ try {
+ return InetAddress.getLocalHost().getHostAddress() + ":" + httpServer.getPort();
+ } catch (final UnknownHostException e) {
+ LOG.log(Level.WARNING, "Cannot get host address.", e);
+ throw new RuntimeException("Cannot get host address.", e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/TrackingURLProvider.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/TrackingURLProvider.java b/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/TrackingURLProvider.java
index 068abd6..47d1e40 100644
--- a/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/TrackingURLProvider.java
+++ b/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/TrackingURLProvider.java
@@ -23,7 +23,7 @@ import org.apache.reef.tang.annotations.DefaultImplementation;
/**
* Implement this interface to set the tracking URL reported to YARN.
*/
-@DefaultImplementation(DefaultTrackingURLProvider.class)
+@DefaultImplementation(HttpTrackingURLProvider.class)
public interface TrackingURLProvider {
String getTrackingUrl();
}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/TestTrackingUri.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/TestTrackingUri.java b/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/TestTrackingUri.java
new file mode 100644
index 0000000..c97c02c
--- /dev/null
+++ b/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/TestTrackingUri.java
@@ -0,0 +1,116 @@
+/*
+ * 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.reef.runtime.yarn.driver;
+
+import org.apache.reef.tang.Injector;
+import org.apache.reef.tang.JavaConfigurationBuilder;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.wake.remote.ports.parameters.TcpPortRangeBegin;
+import org.apache.reef.webserver.HttpHandlerConfiguration;
+import org.apache.reef.webserver.HttpServer;
+import org.apache.reef.webserver.HttpServerImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.net.UnknownHostException;
+
+/**
+ * Tracking Uri test.
+ */
+public class TestTrackingUri {
+ /**
+ * Get Default Tracking URI.
+ *
+ * @throws InjectionException
+ * @throws UnknownHostException
+ */
+ @Test
+ public void testDefaultTrackingUri() throws InjectionException, UnknownHostException {
+ final String uri = Tang.Factory.getTang().newInjector().getInstance(TrackingURLProvider.class).getTrackingUrl();
+ Assert.assertEquals(uri, "");
+ }
+
+ /**
+ * Get Tracking URI with specified port number and HttpTrackingURLProvider.
+ *
+ * @throws InjectionException
+ * @throws UnknownHostException
+ * @throws BindException
+ */
+ @Test
+ public void testHttpTrackingUri() throws InjectionException, UnknownHostException, BindException {
+ final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder()
+ .bindNamedParameter(TcpPortRangeBegin.class, "8888")
+ .bindImplementation(TrackingURLProvider.class, HttpTrackingURLProvider.class)
+ .bindImplementation(HttpServer.class, HttpServerImpl.class);
+
+ final Injector injector = Tang.Factory.getTang().newInjector(cb.build());
+ final String uri = injector.getInstance(TrackingURLProvider.class).getTrackingUrl();
+ final int port = injector.getInstance(HttpServer.class).getPort();
+ verifyUri(uri, port);
+ }
+
+ /**
+ * Get Tracking URI with HttpTrackingURLProvider and defualt port number.
+ *
+ * @throws InjectionException
+ * @throws UnknownHostException
+ * @throws BindException
+ */
+ @Test
+ public void testHttpTrackingUriDefaultPort() throws InjectionException, UnknownHostException, BindException {
+ final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder()
+ .bindImplementation(HttpServer.class, HttpServerImpl.class)
+ .bindImplementation(TrackingURLProvider.class, HttpTrackingURLProvider.class);
+
+ final Injector injector = Tang.Factory.getTang().newInjector(cb.build());
+ final String uri = injector.getInstance(TrackingURLProvider.class).getTrackingUrl();
+ final int port = injector.getInstance(HttpServer.class).getPort();
+ verifyUri(uri, port);
+ }
+
+ /**
+ * Http Tracking URI using default binding test.
+ *
+ * @throws InjectionException
+ * @throws UnknownHostException
+ * @throws BindException
+ */
+ @Test
+ public void testHttpTrackingUriDefaultBinding() throws InjectionException, UnknownHostException, BindException {
+ final Injector injector = Tang.Factory.getTang().newInjector(HttpHandlerConfiguration.CONF.build());
+ final String uri = injector.getInstance(TrackingURLProvider.class).getTrackingUrl();
+ final int port = injector.getInstance(HttpServer.class).getPort();
+ verifyUri(uri, port);
+ }
+
+ /**
+ * Verify if URI is correct.
+ *
+ * @param uri
+ * @param port
+ */
+ private void verifyUri(final String uri, final int port) {
+ final String[] parts = uri.split(":");
+ Assert.assertTrue(parts.length == 2);
+ Assert.assertEquals(port, Integer.parseInt(parts[1]));
+ }
+}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/YarnResourceRequestHandlerTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/YarnResourceRequestHandlerTest.java b/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/YarnResourceRequestHandlerTest.java
index 66a8b16..a7a9d59 100644
--- a/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/YarnResourceRequestHandlerTest.java
+++ b/lang/java/reef-runtime-yarn/src/main/test/java/org/apache/reef/runtime/yarn/driver/YarnResourceRequestHandlerTest.java
@@ -23,6 +23,9 @@ import org.apache.reef.driver.evaluator.EvaluatorRequest;
import org.apache.reef.driver.evaluator.EvaluatorRequestor;
import org.apache.reef.runtime.common.driver.EvaluatorRequestorImpl;
import org.apache.hadoop.yarn.client.api.AMRMClient;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.util.logging.LoggingScopeFactory;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
@@ -35,7 +38,6 @@ public final class YarnResourceRequestHandlerTest {
private final MockContainerRequestHandler containerRequestHandler = new MockContainerRequestHandler();
private final YarnResourceRequestHandler resourceRequestHandler = new YarnResourceRequestHandler(containerRequestHandler, applicationMasterRegistration);
private final ResourceCatalog resourceCatalog = Mockito.mock(ResourceCatalog.class);
- private final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, resourceRequestHandler);
private class MockContainerRequestHandler implements YarnContainerRequestHandler {
private AMRMClient.ContainerRequest[] requests;
@@ -54,7 +56,10 @@ public final class YarnResourceRequestHandlerTest {
* Tests whether the amount of memory is transferred correctly.
*/
@Test
- public void testDifferentMemory() {
+ public void testDifferentMemory() throws InjectionException {
+ final LoggingScopeFactory loggingScopeFactory = Tang.Factory.getTang().newInjector().getInstance(LoggingScopeFactory.class);
+ final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, resourceRequestHandler, loggingScopeFactory);
+
final EvaluatorRequest requestOne = EvaluatorRequest.newBuilder()
.setNumber(1)
.setMemory(64)
@@ -65,31 +70,30 @@ public final class YarnResourceRequestHandlerTest {
.setMemory(128)
.setNumberOfCores(2)
.build();
- {
+
evaluatorRequestor.submit(requestOne);
Assert.assertEquals("Request in REEF and YARN form should have the same amount of memory",
requestOne.getMegaBytes(),
containerRequestHandler.getRequests()[0].getCapability().getMemory()
);
- }
- {
+
evaluatorRequestor.submit(requestTwo);
Assert.assertEquals("Request in REEF and YARN form should have the same amount of memory",
requestTwo.getMegaBytes(),
containerRequestHandler.getRequests()[0].getCapability().getMemory()
);
- }
- {
+
evaluatorRequestor.submit(requestOne);
Assert.assertNotEquals("Request in REEF and YARN form should have the same amount of memory",
requestTwo.getMegaBytes(),
containerRequestHandler.getRequests()[0].getCapability().getMemory()
);
- }
}
@Test
- public void testEvaluatorCount() {
+ public void testEvaluatorCount() throws InjectionException {
+ final LoggingScopeFactory loggingScopeFactory = Tang.Factory.getTang().newInjector().getInstance(LoggingScopeFactory.class);
+ final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, resourceRequestHandler, loggingScopeFactory);
final EvaluatorRequest requestOne = EvaluatorRequest.newBuilder()
.setNumber(1)
.setMemory(64)
@@ -100,28 +104,23 @@ public final class YarnResourceRequestHandlerTest {
.setMemory(128)
.setNumberOfCores(2)
.build();
- {
+
evaluatorRequestor.submit(requestOne);
Assert.assertEquals("Request in REEF and YARN form should have the same number of Evaluators",
requestOne.getNumber(),
containerRequestHandler.getRequests().length
);
- }
- {
+
evaluatorRequestor.submit(requestTwo);
Assert.assertEquals("Request in REEF and YARN form should have the same number of Evaluators",
requestTwo.getNumber(),
containerRequestHandler.getRequests().length
);
- }
- {
+
evaluatorRequestor.submit(requestTwo);
Assert.assertNotEquals("Request in REEF and YARN form should have the same number of Evaluators",
requestOne.getNumber(),
containerRequestHandler.getRequests().length
);
- }
}
-
-
}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-webserver/pom.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-webserver/pom.xml b/lang/java/reef-webserver/pom.xml
index be554cb..1809494 100644
--- a/lang/java/reef-webserver/pom.xml
+++ b/lang/java/reef-webserver/pom.xml
@@ -107,11 +107,6 @@ under the License.
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>reef-runtime-yarn</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>reef-common</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpHandlerConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpHandlerConfiguration.java b/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpHandlerConfiguration.java
index 778e202..7c72681 100644
--- a/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpHandlerConfiguration.java
+++ b/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpHandlerConfiguration.java
@@ -18,7 +18,6 @@
*/
package org.apache.reef.webserver;
-import org.apache.reef.runtime.yarn.driver.TrackingURLProvider;
import org.apache.reef.tang.formats.ConfigurationModule;
import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
import org.apache.reef.tang.formats.OptionalParameter;
@@ -38,6 +37,5 @@ public final class HttpHandlerConfiguration extends ConfigurationModuleBuilder {
*/
public static final ConfigurationModule CONF = new HttpHandlerConfiguration().merge(HttpRuntimeConfiguration.CONF)
.bindSetEntry(HttpEventHandlers.class, HTTP_HANDLERS)
- .bindImplementation(TrackingURLProvider.class, HttpTrackingURLProvider.class)
.build();
}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpServer.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpServer.java b/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpServer.java
index d49d774..43c3e8f 100644
--- a/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpServer.java
+++ b/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpServer.java
@@ -18,9 +18,12 @@
*/
package org.apache.reef.webserver;
+import org.apache.reef.tang.annotations.DefaultImplementation;
+
/**
* HttpServer interface.
*/
+@DefaultImplementation(NoOpHttpServerImpl.class)
public interface HttpServer {
/**
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpTrackingURLProvider.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpTrackingURLProvider.java b/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpTrackingURLProvider.java
deleted file mode 100644
index 2835421..0000000
--- a/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/HttpTrackingURLProvider.java
+++ /dev/null
@@ -1,67 +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.reef.webserver;
-
-import org.apache.reef.runtime.yarn.driver.TrackingURLProvider;
-
-import javax.inject.Inject;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Http TrackingURLProvider.
- */
-public final class HttpTrackingURLProvider implements TrackingURLProvider {
- /**
- * Standard Java logger.
- */
- private static final Logger LOG = Logger.getLogger(HttpTrackingURLProvider.class.getName());
-
- /**
- * HttpServer.
- */
- private final HttpServer httpServer;
-
- /**
- * Constructor of HttpTrackingURLProvider.
- *
- * @param httpServer
- */
- @Inject
- public HttpTrackingURLProvider(final HttpServer httpServer) {
- this.httpServer = httpServer;
- }
-
- /**
- * get tracking URI.
- *
- * @return
- */
- @Override
- public String getTrackingUrl() {
- try {
- return InetAddress.getLocalHost().getHostAddress() + ":" + httpServer.getPort();
- } catch (final UnknownHostException e) {
- LOG.log(Level.WARNING, "Cannot get host address.", e);
- throw new RuntimeException("Cannot get host address.", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/NoOpHttpServerImpl.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/NoOpHttpServerImpl.java b/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/NoOpHttpServerImpl.java
new file mode 100644
index 0000000..9958b73
--- /dev/null
+++ b/lang/java/reef-webserver/src/main/java/org/apache/reef/webserver/NoOpHttpServerImpl.java
@@ -0,0 +1,49 @@
+/*
+ * 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.reef.webserver;
+
+import javax.inject.Inject;
+
+/**
+ * Empty implementation for the HttpServer.
+ * It has no functionality and serves only as an injectable placeholder.
+ */
+public final class NoOpHttpServerImpl implements HttpServer {
+ @Inject
+ NoOpHttpServerImpl() {
+ }
+
+ @Override
+ public void start() throws Exception {
+ }
+
+ @Override
+ public void stop() throws Exception {
+ }
+
+ @Override
+ public int getPort() {
+ return 0;
+ }
+
+ @Override
+ public void addHttpHandler(final HttpHandler httpHandler) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/reef/blob/4c2c044e/lang/java/reef-webserver/src/test/java/org/apache/reef/webserver/TestTrackingUri.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-webserver/src/test/java/org/apache/reef/webserver/TestTrackingUri.java b/lang/java/reef-webserver/src/test/java/org/apache/reef/webserver/TestTrackingUri.java
deleted file mode 100644
index a2ac62e..0000000
--- a/lang/java/reef-webserver/src/test/java/org/apache/reef/webserver/TestTrackingUri.java
+++ /dev/null
@@ -1,114 +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.reef.webserver;
-
-import org.apache.reef.runtime.yarn.driver.TrackingURLProvider;
-import org.apache.reef.tang.Injector;
-import org.apache.reef.tang.JavaConfigurationBuilder;
-import org.apache.reef.tang.Tang;
-import org.apache.reef.tang.exceptions.BindException;
-import org.apache.reef.tang.exceptions.InjectionException;
-import org.apache.reef.wake.remote.ports.parameters.TcpPortRangeBegin;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.net.UnknownHostException;
-
-/**
- * Tracking Uri test.
- */
-public class TestTrackingUri {
- /**
- * Get Default Tracking URI.
- *
- * @throws InjectionException
- * @throws UnknownHostException
- */
- @Test
- public void testDefaultTrackingUri() throws InjectionException, UnknownHostException {
- final String uri = Tang.Factory.getTang().newInjector().getInstance(TrackingURLProvider.class).getTrackingUrl();
- Assert.assertEquals(uri, "");
- }
-
- /**
- * Get Tracking URI with specified port number and HttpTrackingURLProvider.
- *
- * @throws InjectionException
- * @throws UnknownHostException
- * @throws BindException
- */
- @Test
- public void testHttpTrackingUri() throws InjectionException, UnknownHostException, BindException {
- final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder()
- .bindNamedParameter(TcpPortRangeBegin.class, "8888")
- .bindImplementation(TrackingURLProvider.class, HttpTrackingURLProvider.class)
- .bindImplementation(HttpServer.class, HttpServerImpl.class);
-
- final Injector injector = Tang.Factory.getTang().newInjector(cb.build());
- final String uri = injector.getInstance(TrackingURLProvider.class).getTrackingUrl();
- final int port = injector.getInstance(HttpServer.class).getPort();
- verifyUri(uri, port);
- }
-
- /**
- * Get Tracking URI with HttpTrackingURLProvider and defualt port number.
- *
- * @throws InjectionException
- * @throws UnknownHostException
- * @throws BindException
- */
- @Test
- public void testHttpTrackingUriDefaultPort() throws InjectionException, UnknownHostException, BindException {
- final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder()
- .bindImplementation(HttpServer.class, HttpServerImpl.class)
- .bindImplementation(TrackingURLProvider.class, HttpTrackingURLProvider.class);
-
- final Injector injector = Tang.Factory.getTang().newInjector(cb.build());
- final String uri = injector.getInstance(TrackingURLProvider.class).getTrackingUrl();
- final int port = injector.getInstance(HttpServer.class).getPort();
- verifyUri(uri, port);
- }
-
- /**
- * Http Tracking URI using default binding test.
- *
- * @throws InjectionException
- * @throws UnknownHostException
- * @throws BindException
- */
- @Test
- public void testHttpTrackingUriDefaultBinding() throws InjectionException, UnknownHostException, BindException {
- final Injector injector = Tang.Factory.getTang().newInjector(HttpHandlerConfiguration.CONF.build());
- final String uri = injector.getInstance(TrackingURLProvider.class).getTrackingUrl();
- final int port = injector.getInstance(HttpServer.class).getPort();
- verifyUri(uri, port);
- }
-
- /**
- * Verify if URI is correct.
- *
- * @param uri
- * @param port
- */
- private void verifyUri(final String uri, final int port) {
- final String[] parts = uri.split(":");
- Assert.assertTrue(parts.length == 2);
- Assert.assertEquals(port, Integer.parseInt(parts[1]));
- }
-}