You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2021/06/29 19:19:31 UTC
[flink] branch master updated: [FLINK-23090] Introduce RpcSystem
abstraction
This is an automated email from the ASF dual-hosted git repository.
chesnay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new 01dc9e0 [FLINK-23090] Introduce RpcSystem abstraction
01dc9e0 is described below
commit 01dc9e087c1d9291247f3a81f39da78e5008d86f
Author: Chesnay Schepler <ch...@apache.org>
AuthorDate: Tue Jun 29 21:18:48 2021 +0200
[FLINK-23090] Introduce RpcSystem abstraction
---
flink-metrics/flink-metrics-dropwizard/pom.xml | 8 ++
.../ScheduledDropwizardReporterTest.java | 3 +-
.../DropwizardFlinkHistogramWrapperTest.java | 4 +-
flink-metrics/flink-metrics-influxdb/pom.xml | 8 ++
.../metrics/influxdb/InfluxdbReporterTest.java | 4 +-
.../apache/flink/metrics/jmx/JMXReporterTest.java | 10 +-
flink-metrics/flink-metrics-prometheus/pom.xml | 8 ++
.../PrometheusReporterTaskScopeTest.java | 4 +-
.../metrics/prometheus/PrometheusReporterTest.java | 4 +-
flink-metrics/flink-metrics-slf4j/pom.xml | 8 ++
.../flink/metrics/slf4j/Slf4jReporterTest.java | 4 +-
flink-metrics/flink-metrics-statsd/pom.xml | 8 ++
.../flink/metrics/statsd/StatsDReporterTest.java | 4 +-
.../runtime/entrypoint/ClusterEntrypoint.java | 26 ++--
.../HighAvailabilityServicesUtils.java | 11 +-
.../metrics/MetricRegistryConfiguration.java | 21 +--
.../flink/runtime/metrics/util/MetricUtils.java | 25 ++--
.../flink/runtime/minicluster/MiniCluster.java | 71 ++++++----
.../apache/flink/runtime/net/ConnectionUtils.java | 10 +-
.../org/apache/flink/runtime/rpc/RpcSystem.java | 143 +++++++++++++++++++++
.../apache/flink/runtime/rpc/RpcSystemUtils.java | 66 ++++++++++
.../org/apache/flink/runtime/rpc/RpcUtils.java | 33 +++++
.../flink/runtime/rpc/akka/AkkaBootstrapTools.java | 112 +++-------------
.../runtime/rpc/akka/AkkaRpcServiceUtils.java | 47 ++++---
.../flink/runtime/rpc/akka/AkkaRpcSystem.java | 68 ++++++++++
.../runtime/taskexecutor/TaskManagerRunner.java | 43 +++++--
.../flink/runtime/util/LeaderRetrievalUtils.java | 7 +-
.../org/apache/flink/runtime/akka/AkkaUtils.scala | 24 +---
.../runtime/entrypoint/ClusterEntrypointTest.java | 3 +-
.../HighAvailabilityServicesUtilsTest.java | 7 +-
.../ZooKeeperLeaderRetrievalTest.java | 14 +-
.../runtime/metrics/MetricRegistryImplTest.java | 20 +--
.../runtime/metrics/MetricRegistryTestUtils.java | 43 +++++++
.../metrics/groups/AbstractMetricGroupTest.java | 10 +-
.../metrics/groups/JobManagerGroupTest.java | 12 +-
.../metrics/groups/JobManagerJobGroupTest.java | 10 +-
.../groups/MetricGroupRegistrationTest.java | 6 +-
.../runtime/metrics/groups/MetricGroupTest.java | 5 +-
.../runtime/metrics/groups/OperatorGroupTest.java | 6 +-
.../metrics/groups/TaskManagerGroupTest.java | 6 +-
.../metrics/groups/TaskManagerJobGroupTest.java | 8 +-
.../metrics/groups/TaskMetricGroupTest.java | 12 +-
.../runtime/metrics/util/MetricUtilsTest.java | 11 +-
.../apache/flink/runtime/rpc/AsyncCallsTest.java | 33 ++---
.../flink/runtime/rpc/RpcConnectionTest.java | 58 ++-------
.../apache/flink/runtime/rpc/RpcEndpointTest.java | 24 +---
.../apache/flink/runtime/rpc/RpcSSLAuthITCase.java | 33 +++--
.../TaskExecutorOperatorEventHandlingTest.java | 4 +-
.../TaskManagerRunnerConfigurationTest.java | 19 ++-
.../flink/runtime/util/AddressResolutionTest.java | 8 +-
.../scala/akka/actor/RobustActorSystemTest.scala | 3 +-
.../apache/flink/runtime/akka/AkkaUtilsTest.scala | 7 +-
.../OperatorEventSendingCheckpointITCase.java | 105 +++++++++++++--
.../JobManagerHAProcessFailureRecoveryITCase.java | 4 +-
.../recovery/ProcessFailureCancelingITCase.java | 9 +-
.../flink/test/runtime/IPv6HostnamesITCase.java | 21 ++-
56 files changed, 840 insertions(+), 445 deletions(-)
diff --git a/flink-metrics/flink-metrics-dropwizard/pom.xml b/flink-metrics/flink-metrics-dropwizard/pom.xml
index cd39178..199131d 100644
--- a/flink-metrics/flink-metrics-dropwizard/pom.xml
+++ b/flink-metrics/flink-metrics-dropwizard/pom.xml
@@ -80,6 +80,14 @@ under the License.
<dependency>
<groupId>org.apache.flink</groupId>
+ <artifactId>flink-runtime_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils-junit</artifactId>
</dependency>
diff --git a/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/ScheduledDropwizardReporterTest.java b/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/ScheduledDropwizardReporterTest.java
index 553027d..07ce819 100644
--- a/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/ScheduledDropwizardReporterTest.java
+++ b/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/ScheduledDropwizardReporterTest.java
@@ -36,6 +36,7 @@ import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.JobVertexID;
import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.groups.TaskManagerJobMetricGroup;
import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
@@ -85,7 +86,7 @@ public class ScheduledDropwizardReporterTest {
configuration.setString(MetricOptions.SCOPE_DELIMITER, "_");
MetricRegistryConfiguration metricRegistryConfiguration =
- MetricRegistryConfiguration.fromConfiguration(configuration);
+ MetricRegistryTestUtils.fromConfiguration(configuration);
MetricRegistryImpl metricRegistry =
new MetricRegistryImpl(
diff --git a/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/metrics/DropwizardFlinkHistogramWrapperTest.java b/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/metrics/DropwizardFlinkHistogramWrapperTest.java
index 31a7a47..42927d1 100644
--- a/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/metrics/DropwizardFlinkHistogramWrapperTest.java
+++ b/flink-metrics/flink-metrics-dropwizard/src/test/java/org/apache/flink/dropwizard/metrics/DropwizardFlinkHistogramWrapperTest.java
@@ -23,8 +23,8 @@ import org.apache.flink.dropwizard.ScheduledDropwizardReporter;
import org.apache.flink.metrics.AbstractHistogramTest;
import org.apache.flink.metrics.MetricConfig;
import org.apache.flink.metrics.reporter.MetricReporter;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
@@ -87,7 +87,7 @@ public class DropwizardFlinkHistogramWrapperTest extends AbstractHistogramTest {
try {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
ReporterSetup.forReporter(
"test", config, new TestingReporter())));
diff --git a/flink-metrics/flink-metrics-influxdb/pom.xml b/flink-metrics/flink-metrics-influxdb/pom.xml
index e867a52..52c3929 100644
--- a/flink-metrics/flink-metrics-influxdb/pom.xml
+++ b/flink-metrics/flink-metrics-influxdb/pom.xml
@@ -72,6 +72,14 @@ under the License.
<dependency>
<groupId>org.apache.flink</groupId>
+ <artifactId>flink-runtime_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils-junit</artifactId>
</dependency>
diff --git a/flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterTest.java b/flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterTest.java
index 6e2f8b3..91b1321 100644
--- a/flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterTest.java
+++ b/flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterTest.java
@@ -22,8 +22,8 @@ import org.apache.flink.metrics.Counter;
import org.apache.flink.metrics.MetricConfig;
import org.apache.flink.metrics.reporter.MetricReporter;
import org.apache.flink.runtime.metrics.MetricRegistry;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
import org.apache.flink.util.TestLogger;
@@ -145,7 +145,7 @@ public class InfluxdbReporterTest extends TestLogger {
InfluxdbReporterOptions.CONSISTENCY.key(), consistencyLevel.name());
return new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
ReporterSetup.forReporter("test", metricConfig, new InfluxdbReporter())));
}
diff --git a/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterTest.java b/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterTest.java
index 990a753..f09683f 100644
--- a/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterTest.java
+++ b/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterTest.java
@@ -24,8 +24,8 @@ import org.apache.flink.metrics.reporter.MetricReporter;
import org.apache.flink.metrics.util.TestHistogram;
import org.apache.flink.metrics.util.TestMeter;
import org.apache.flink.runtime.management.JMXService;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.groups.FrontMetricGroup;
import org.apache.flink.runtime.metrics.groups.ReporterScopedSettings;
@@ -112,7 +112,7 @@ public class JMXReporterTest extends TestLogger {
MetricRegistryImpl reg =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Arrays.asList(reporterSetup1, reporterSetup2));
TaskManagerMetricGroup mg = new TaskManagerMetricGroup(reg, "host", "tm");
@@ -179,7 +179,7 @@ public class JMXReporterTest extends TestLogger {
MetricRegistryImpl reg =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Arrays.asList(reporterSetup1, reporterSetup2));
TaskManagerMetricGroup mg = new TaskManagerMetricGroup(reg, "host", "tm");
@@ -272,7 +272,7 @@ public class JMXReporterTest extends TestLogger {
try {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
ReporterSetup.forReporter("test", new JMXReporter(null))));
@@ -336,7 +336,7 @@ public class JMXReporterTest extends TestLogger {
try {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
ReporterSetup.forReporter("test", new JMXReporter(null))));
diff --git a/flink-metrics/flink-metrics-prometheus/pom.xml b/flink-metrics/flink-metrics-prometheus/pom.xml
index efc5bf4..31d70bb 100644
--- a/flink-metrics/flink-metrics-prometheus/pom.xml
+++ b/flink-metrics/flink-metrics-prometheus/pom.xml
@@ -91,6 +91,14 @@ under the License.
<dependency>
<groupId>org.apache.flink</groupId>
+ <artifactId>flink-runtime_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils-junit</artifactId>
</dependency>
diff --git a/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTaskScopeTest.java b/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTaskScopeTest.java
index f43b0f2..1f03b40 100644
--- a/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTaskScopeTest.java
+++ b/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTaskScopeTest.java
@@ -28,8 +28,8 @@ import org.apache.flink.metrics.util.TestHistogram;
import org.apache.flink.metrics.util.TestMeter;
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.JobVertexID;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.groups.TaskManagerJobMetricGroup;
import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
import org.apache.flink.runtime.metrics.groups.TaskMetricGroup;
@@ -113,7 +113,7 @@ public class PrometheusReporterTaskScopeTest {
public void setupReporter() {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(createReporterSetup("test1", "9400-9500")));
reporter = (PrometheusReporter) registry.getReporters().get(0);
diff --git a/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java b/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java
index 42deeb4..52bd250 100644
--- a/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java
+++ b/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java
@@ -28,8 +28,8 @@ import org.apache.flink.metrics.MetricConfig;
import org.apache.flink.metrics.SimpleCounter;
import org.apache.flink.metrics.util.TestHistogram;
import org.apache.flink.metrics.util.TestMeter;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.groups.FrontMetricGroup;
import org.apache.flink.runtime.metrics.groups.ReporterScopedSettings;
@@ -85,7 +85,7 @@ public class PrometheusReporterTest extends TestLogger {
public void setupReporter() {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
createReporterSetup("test1", portRangeProvider.next())));
metricGroup =
diff --git a/flink-metrics/flink-metrics-slf4j/pom.xml b/flink-metrics/flink-metrics-slf4j/pom.xml
index d68fe2d5..c8eec33 100644
--- a/flink-metrics/flink-metrics-slf4j/pom.xml
+++ b/flink-metrics/flink-metrics-slf4j/pom.xml
@@ -73,6 +73,14 @@ under the License.
<dependency>
<groupId>org.apache.flink</groupId>
+ <artifactId>flink-runtime_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils-junit</artifactId>
</dependency>
diff --git a/flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterTest.java b/flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterTest.java
index e526b96..50f378e 100644
--- a/flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterTest.java
+++ b/flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterTest.java
@@ -29,8 +29,8 @@ import org.apache.flink.metrics.SimpleCounter;
import org.apache.flink.metrics.util.TestHistogram;
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.JobVertexID;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
import org.apache.flink.runtime.metrics.groups.TaskMetricGroup;
@@ -75,7 +75,7 @@ public class Slf4jReporterTest extends TestLogger {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(configuration),
+ MetricRegistryTestUtils.fromConfiguration(configuration),
Collections.singletonList(
ReporterSetup.forReporter("slf4j", new Slf4jReporter())));
delimiter = registry.getDelimiter();
diff --git a/flink-metrics/flink-metrics-statsd/pom.xml b/flink-metrics/flink-metrics-statsd/pom.xml
index cb5e3f8..ecb4c8a 100644
--- a/flink-metrics/flink-metrics-statsd/pom.xml
+++ b/flink-metrics/flink-metrics-statsd/pom.xml
@@ -73,6 +73,14 @@ under the License.
<dependency>
<groupId>org.apache.flink</groupId>
+ <artifactId>flink-runtime_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils-junit</artifactId>
</dependency>
</dependencies>
diff --git a/flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterTest.java b/flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterTest.java
index caeef70..64bb864 100644
--- a/flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterTest.java
+++ b/flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterTest.java
@@ -35,8 +35,8 @@ import org.apache.flink.metrics.util.TestHistogram;
import org.apache.flink.metrics.util.TestMeter;
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.JobVertexID;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.groups.TaskManagerJobMetricGroup;
import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
@@ -89,7 +89,7 @@ public class StatsDReporterTest extends TestLogger {
MetricRegistryImpl metricRegistry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(configuration),
+ MetricRegistryTestUtils.fromConfiguration(configuration),
Collections.singletonList(
ReporterSetup.forReporter("test", new TestingStatsDReporter())));
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterEntrypoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterEntrypoint.java
index ce2a8da..cc9c210 100755
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterEntrypoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterEntrypoint.java
@@ -56,8 +56,9 @@ import org.apache.flink.runtime.resourcemanager.ResourceManager;
import org.apache.flink.runtime.rpc.AddressResolution;
import org.apache.flink.runtime.rpc.FatalErrorHandler;
import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystem;
+import org.apache.flink.runtime.rpc.RpcSystemUtils;
import org.apache.flink.runtime.rpc.RpcUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
import org.apache.flink.runtime.security.SecurityConfiguration;
import org.apache.flink.runtime.security.SecurityUtils;
import org.apache.flink.runtime.security.contexts.SecurityContext;
@@ -291,8 +292,11 @@ public abstract class ClusterEntrypoint implements AutoCloseableAsync, FatalErro
LOG.info("Initializing cluster services.");
synchronized (lock) {
+ final RpcSystem rpcSystem = RpcSystem.load();
+
commonRpcService =
- AkkaRpcServiceUtils.createRemoteRpcService(
+ RpcUtils.createRemoteRpcService(
+ rpcSystem,
configuration,
configuration.getString(JobManagerOptions.ADDRESS),
getRPCPortRange(configuration),
@@ -309,15 +313,15 @@ public abstract class ClusterEntrypoint implements AutoCloseableAsync, FatalErro
Executors.newFixedThreadPool(
ClusterEntrypointUtils.getPoolSize(configuration),
new ExecutorThreadFactory("cluster-io"));
- haServices = createHaServices(configuration, ioExecutor);
+ haServices = createHaServices(configuration, ioExecutor, rpcSystem);
blobServer = new BlobServer(configuration, haServices.createBlobStore());
blobServer.start();
heartbeatServices = createHeartbeatServices(configuration);
- metricRegistry = createMetricRegistry(configuration, pluginManager);
+ metricRegistry = createMetricRegistry(configuration, pluginManager, rpcSystem);
final RpcService metricQueryServiceRpcService =
MetricUtils.startRemoteMetricsRpcService(
- configuration, commonRpcService.getAddress());
+ configuration, commonRpcService.getAddress(), rpcSystem);
metricRegistry.startQueryService(metricQueryServiceRpcService, null);
final String hostname = RpcUtils.getHostname(commonRpcService);
@@ -350,9 +354,10 @@ public abstract class ClusterEntrypoint implements AutoCloseableAsync, FatalErro
}
protected HighAvailabilityServices createHaServices(
- Configuration configuration, Executor executor) throws Exception {
+ Configuration configuration, Executor executor, RpcSystemUtils rpcSystemUtils)
+ throws Exception {
return HighAvailabilityServicesUtils.createHighAvailabilityServices(
- configuration, executor, AddressResolution.NO_ADDRESS_RESOLUTION);
+ configuration, executor, AddressResolution.NO_ADDRESS_RESOLUTION, rpcSystemUtils);
}
protected HeartbeatServices createHeartbeatServices(Configuration configuration) {
@@ -360,9 +365,12 @@ public abstract class ClusterEntrypoint implements AutoCloseableAsync, FatalErro
}
protected MetricRegistryImpl createMetricRegistry(
- Configuration configuration, PluginManager pluginManager) {
+ Configuration configuration,
+ PluginManager pluginManager,
+ RpcSystemUtils rpcSystemUtils) {
return new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(configuration),
+ MetricRegistryConfiguration.fromConfiguration(
+ configuration, rpcSystemUtils.getMaximumMessageSizeInBytes(configuration)),
ReporterSetup.fromConfiguration(configuration, pluginManager));
}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtils.java
index 764ac7d..03ea2fe 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtils.java
@@ -38,7 +38,7 @@ import org.apache.flink.runtime.jobmanager.HighAvailabilityMode;
import org.apache.flink.runtime.resourcemanager.ResourceManager;
import org.apache.flink.runtime.rpc.AddressResolution;
import org.apache.flink.runtime.rpc.RpcServiceUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
+import org.apache.flink.runtime.rpc.RpcSystemUtils;
import org.apache.flink.runtime.util.ZooKeeperUtils;
import org.apache.flink.util.ConfigurationException;
import org.apache.flink.util.FlinkException;
@@ -83,7 +83,10 @@ public class HighAvailabilityServicesUtils {
}
public static HighAvailabilityServices createHighAvailabilityServices(
- Configuration configuration, Executor executor, AddressResolution addressResolution)
+ Configuration configuration,
+ Executor executor,
+ AddressResolution addressResolution,
+ RpcSystemUtils rpcSystemUtils)
throws Exception {
HighAvailabilityMode highAvailabilityMode = HighAvailabilityMode.fromConfig(configuration);
@@ -93,7 +96,7 @@ public class HighAvailabilityServicesUtils {
final Tuple2<String, Integer> hostnamePort = getJobManagerAddress(configuration);
final String resourceManagerRpcUrl =
- AkkaRpcServiceUtils.getRpcUrl(
+ rpcSystemUtils.getRpcUrl(
hostnamePort.f0,
hostnamePort.f1,
RpcServiceUtils.createWildcardName(
@@ -101,7 +104,7 @@ public class HighAvailabilityServicesUtils {
addressResolution,
configuration);
final String dispatcherRpcUrl =
- AkkaRpcServiceUtils.getRpcUrl(
+ rpcSystemUtils.getRpcUrl(
hostnamePort.f0,
hostnamePort.f1,
RpcServiceUtils.createWildcardName(Dispatcher.DISPATCHER_NAME),
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/MetricRegistryConfiguration.java b/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/MetricRegistryConfiguration.java
index 6ed1256..4a246aa 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/MetricRegistryConfiguration.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/MetricRegistryConfiguration.java
@@ -21,7 +21,6 @@ package org.apache.flink.runtime.metrics;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MetricOptions;
import org.apache.flink.runtime.metrics.scope.ScopeFormats;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
import org.apache.flink.util.Preconditions;
import org.slf4j.Logger;
@@ -32,8 +31,6 @@ public class MetricRegistryConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(MetricRegistryConfiguration.class);
- private static volatile MetricRegistryConfiguration defaultConfiguration;
-
// scope formats for the different components
private final ScopeFormats scopeFormats;
@@ -76,7 +73,8 @@ public class MetricRegistryConfiguration {
* @param configuration to generate the metric registry configuration from
* @return Metric registry configuration generated from the configuration
*/
- public static MetricRegistryConfiguration fromConfiguration(Configuration configuration) {
+ public static MetricRegistryConfiguration fromConfiguration(
+ Configuration configuration, long maximumFrameSize) {
ScopeFormats scopeFormats;
try {
scopeFormats = ScopeFormats.fromConfig(configuration);
@@ -93,25 +91,10 @@ public class MetricRegistryConfiguration {
delim = '.';
}
- final long maximumFrameSize = AkkaRpcServiceUtils.extractMaximumFramesize(configuration);
-
// padding to account for serialization overhead
final long messageSizeLimitPadding = 256;
return new MetricRegistryConfiguration(
scopeFormats, delim, maximumFrameSize - messageSizeLimitPadding);
}
-
- public static MetricRegistryConfiguration defaultMetricRegistryConfiguration() {
- // create the default metric registry configuration only once
- if (defaultConfiguration == null) {
- synchronized (MetricRegistryConfiguration.class) {
- if (defaultConfiguration == null) {
- defaultConfiguration = fromConfiguration(new Configuration());
- }
- }
- }
-
- return defaultConfiguration;
- }
}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/util/MetricUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/util/MetricUtils.java
index f23a6bb..69d6cbd 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/util/MetricUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/util/MetricUtils.java
@@ -35,8 +35,7 @@ import org.apache.flink.runtime.metrics.groups.JobManagerMetricGroup;
import org.apache.flink.runtime.metrics.groups.ProcessMetricGroup;
import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
import org.apache.flink.runtime.rpc.RpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaBootstrapTools;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException;
import org.apache.flink.runtime.taskexecutor.slot.TaskSlotTable;
import org.apache.flink.util.Preconditions;
@@ -190,32 +189,28 @@ public class MetricUtils {
}
public static RpcService startRemoteMetricsRpcService(
- Configuration configuration, String hostname) throws Exception {
+ Configuration configuration, String hostname, RpcSystem rpcSystem) throws Exception {
final String portRange = configuration.getString(MetricOptions.QUERY_SERVICE_PORT);
return startMetricRpcService(
- configuration,
- AkkaRpcServiceUtils.remoteServiceBuilder(configuration, hostname, portRange));
+ configuration, rpcSystem.remoteServiceBuilder(configuration, hostname, portRange));
}
- public static RpcService startLocalMetricsRpcService(Configuration configuration)
- throws Exception {
- return startMetricRpcService(
- configuration, AkkaRpcServiceUtils.localServiceBuilder(configuration));
+ public static RpcService startLocalMetricsRpcService(
+ Configuration configuration, RpcSystem rpcSystem) throws Exception {
+ return startMetricRpcService(configuration, rpcSystem.localServiceBuilder(configuration));
}
private static RpcService startMetricRpcService(
- Configuration configuration,
- AkkaRpcServiceUtils.AkkaRpcServiceBuilder rpcServiceBuilder)
+ Configuration configuration, RpcSystem.RpcServiceBuilder rpcServiceBuilder)
throws Exception {
final int threadPriority =
configuration.getInteger(MetricOptions.QUERY_SERVICE_THREAD_PRIORITY);
return rpcServiceBuilder
- .withActorSystemName(METRICS_ACTOR_SYSTEM_NAME)
- .withActorSystemExecutorConfiguration(
- new AkkaBootstrapTools.FixedThreadPoolExecutorConfiguration(
- 1, 1, threadPriority))
+ .withComponentName(METRICS_ACTOR_SYSTEM_NAME)
+ .withExecutorConfiguration(
+ new RpcSystem.FixedThreadPoolExecutorConfiguration(1, 1, threadPriority))
.createAndStart();
}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
index e11f67e..3f884c8 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
@@ -30,7 +30,6 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ConfigurationUtils;
import org.apache.flink.configuration.HighAvailabilityOptions;
import org.apache.flink.configuration.IllegalConfigurationException;
-import org.apache.flink.runtime.akka.AkkaUtils;
import org.apache.flink.runtime.blob.BlobCacheService;
import org.apache.flink.runtime.blob.BlobClient;
import org.apache.flink.runtime.blob.BlobServer;
@@ -73,8 +72,8 @@ import org.apache.flink.runtime.resourcemanager.ResourceManagerId;
import org.apache.flink.runtime.resourcemanager.StandaloneResourceManagerFactory;
import org.apache.flink.runtime.rpc.FatalErrorHandler;
import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.runtime.rpc.RpcUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
import org.apache.flink.runtime.taskexecutor.TaskExecutor;
import org.apache.flink.runtime.taskexecutor.TaskManagerRunner;
import org.apache.flink.runtime.webmonitor.retriever.LeaderRetriever;
@@ -274,8 +273,13 @@ public class MiniCluster implements AutoCloseableAsync {
try {
initializeIOFormatClasses(configuration);
+ final RpcSystem rpcSystem = RpcSystem.load();
+
LOG.info("Starting Metrics Registry");
- metricRegistry = createMetricRegistry(configuration);
+ metricRegistry =
+ createMetricRegistry(
+ configuration,
+ rpcSystem.getMaximumMessageSizeInBytes(configuration));
// bring up all the RPC services
LOG.info("Starting RPC Service(s)");
@@ -285,13 +289,13 @@ public class MiniCluster implements AutoCloseableAsync {
if (useSingleRpcService) {
// we always need the 'commonRpcService' for auxiliary calls
- commonRpcService = createLocalRpcService(configuration);
+ commonRpcService = createLocalRpcService(configuration, rpcSystem);
final CommonRpcServiceFactory commonRpcServiceFactory =
new CommonRpcServiceFactory(commonRpcService);
taskManagerRpcServiceFactory = commonRpcServiceFactory;
dispatcherResourceManagerComponentRpcServiceFactory = commonRpcServiceFactory;
metricQueryServiceRpcService =
- MetricUtils.startLocalMetricsRpcService(configuration);
+ MetricUtils.startLocalMetricsRpcService(configuration, rpcSystem);
} else {
// start a new service per component, possibly with custom bind addresses
@@ -313,21 +317,24 @@ public class MiniCluster implements AutoCloseableAsync {
configuration,
jobManagerExternalAddress,
jobManagerExternalPortRange,
- jobManagerBindAddress);
+ jobManagerBindAddress,
+ rpcSystem);
taskManagerRpcServiceFactory =
new DedicatedRpcServiceFactory(
configuration,
taskManagerExternalAddress,
taskManagerExternalPortRange,
- taskManagerBindAddress);
+ taskManagerBindAddress,
+ rpcSystem);
// we always need the 'commonRpcService' for auxiliary calls
// bind to the JobManager address with port 0
commonRpcService =
- createRemoteRpcService(configuration, jobManagerBindAddress, 0);
+ createRemoteRpcService(
+ configuration, jobManagerBindAddress, 0, rpcSystem);
metricQueryServiceRpcService =
MetricUtils.startRemoteMetricsRpcService(
- configuration, commonRpcService.getAddress());
+ configuration, commonRpcService.getAddress(), rpcSystem);
}
metricRegistry.startQueryService(metricQueryServiceRpcService, null);
@@ -893,10 +900,12 @@ public class MiniCluster implements AutoCloseableAsync {
* Factory method to create the metric registry for the mini cluster.
*
* @param config The configuration of the mini cluster
+ * @param maximumMessageSizeInBytes the maximum message size
*/
- protected MetricRegistryImpl createMetricRegistry(Configuration config) {
+ protected MetricRegistryImpl createMetricRegistry(
+ Configuration config, long maximumMessageSizeInBytes) {
return new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(config),
+ MetricRegistryConfiguration.fromConfiguration(config, maximumMessageSizeInBytes),
ReporterSetup.fromConfiguration(config, null));
}
@@ -906,15 +915,17 @@ public class MiniCluster implements AutoCloseableAsync {
* @param configuration Flink configuration.
* @param bindAddress The address to bind the RPC service to.
* @param bindPort The port range to bind the RPC service to.
+ * @param rpcSystem
* @return The instantiated RPC service
*/
protected RpcService createRemoteRpcService(
- Configuration configuration, String bindAddress, int bindPort) throws Exception {
- return AkkaRpcServiceUtils.remoteServiceBuilder(
- configuration, bindAddress, String.valueOf(bindPort))
+ Configuration configuration, String bindAddress, int bindPort, RpcSystem rpcSystem)
+ throws Exception {
+ return rpcSystem
+ .remoteServiceBuilder(configuration, bindAddress, String.valueOf(bindPort))
.withBindAddress(bindAddress)
.withBindPort(bindPort)
- .withCustomConfig(AkkaUtils.testDispatcherConfig())
+ .withExecutorConfiguration(RpcUtils.getTestForkJoinExecutorConfiguration())
.createAndStart();
}
@@ -925,18 +936,20 @@ public class MiniCluster implements AutoCloseableAsync {
* @param externalAddress The external address to access the RPC service.
* @param externalPortRange The external port range to access the RPC service.
* @param bindAddress The address to bind the RPC service to.
+ * @param rpcSystem
* @return The instantiated RPC service
*/
protected RpcService createRemoteRpcService(
Configuration configuration,
String externalAddress,
String externalPortRange,
- String bindAddress)
+ String bindAddress,
+ RpcSystem rpcSystem)
throws Exception {
- return AkkaRpcServiceUtils.remoteServiceBuilder(
- configuration, externalAddress, externalPortRange)
+ return rpcSystem
+ .remoteServiceBuilder(configuration, externalAddress, externalPortRange)
.withBindAddress(bindAddress)
- .withCustomConfig(AkkaUtils.testDispatcherConfig())
+ .withExecutorConfiguration(RpcUtils.getTestForkJoinExecutorConfiguration())
.createAndStart();
}
@@ -944,11 +957,14 @@ public class MiniCluster implements AutoCloseableAsync {
* Factory method to instantiate the local RPC service.
*
* @param configuration Flink configuration.
+ * @param rpcSystem
* @return The instantiated RPC service
*/
- protected RpcService createLocalRpcService(Configuration configuration) throws Exception {
- return AkkaRpcServiceUtils.localServiceBuilder(configuration)
- .withCustomConfig(AkkaUtils.testDispatcherConfig())
+ protected RpcService createLocalRpcService(Configuration configuration, RpcSystem rpcSystem)
+ throws Exception {
+ return rpcSystem
+ .localServiceBuilder(configuration)
+ .withExecutorConfiguration(RpcUtils.getTestForkJoinExecutorConfiguration())
.createAndStart();
}
@@ -1113,23 +1129,30 @@ public class MiniCluster implements AutoCloseableAsync {
private final String externalAddress;
private final String externalPortRange;
private final String bindAddress;
+ private final RpcSystem rpcSystem;
DedicatedRpcServiceFactory(
Configuration configuration,
String externalAddress,
String externalPortRange,
- String bindAddress) {
+ String bindAddress,
+ RpcSystem rpcSystem) {
this.configuration = configuration;
this.externalAddress = externalAddress;
this.externalPortRange = externalPortRange;
this.bindAddress = bindAddress;
+ this.rpcSystem = rpcSystem;
}
@Override
public RpcService createRpcService() throws Exception {
final RpcService rpcService =
MiniCluster.this.createRemoteRpcService(
- configuration, externalAddress, externalPortRange, bindAddress);
+ configuration,
+ externalAddress,
+ externalPortRange,
+ bindAddress,
+ rpcSystem);
synchronized (lock) {
rpcServices.add(rpcService);
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
index c4f9d28..9f61cae 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
@@ -18,9 +18,9 @@
package org.apache.flink.runtime.net;
-import org.apache.flink.runtime.akka.AkkaUtils;
import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalException;
import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener;
+import org.apache.flink.runtime.rpc.RpcSystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -367,6 +367,12 @@ public class ConnectionUtils {
private static final Duration defaultLoggingDelay = Duration.ofMillis(400);
+ private final RpcSystemUtils rpcSystemUtils;
+
+ public LeaderConnectingAddressListener(RpcSystemUtils rpcSystemUtils) {
+ this.rpcSystemUtils = rpcSystemUtils;
+ }
+
private enum LeaderRetrievalState {
NOT_RETRIEVED,
RETRIEVED,
@@ -410,7 +416,7 @@ public class ConnectionUtils {
+ "while waiting for the leader retrieval.");
}
} else if (retrievalState == LeaderRetrievalState.NEWLY_RETRIEVED) {
- targetAddress = AkkaUtils.getInetSocketAddressFromAkkaURL(akkaURL);
+ targetAddress = rpcSystemUtils.getInetSocketAddressFromRpcUrl(akkaURL);
LOG.debug(
"Retrieved new target address {} for akka URL {}.",
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java
new file mode 100644
index 0000000..96ee637
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java
@@ -0,0 +1,143 @@
+/*
+ * 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.flink.runtime.rpc;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.rpc.akka.AkkaRpcSystem;
+
+import javax.annotation.Nullable;
+
+/**
+ * This interface serves as a factory interface for RPC services, with some additional utilities
+ * that are reliant on implementation details of the RPC service.
+ */
+public interface RpcSystem extends RpcSystemUtils {
+
+ /**
+ * Returns a builder for an {@link RpcService} that is only reachable from the local machine.
+ *
+ * @param configuration Flink configuration
+ * @return rpc service builder
+ */
+ RpcServiceBuilder localServiceBuilder(Configuration configuration);
+
+ /**
+ * Returns a builder for an {@link RpcService} that is reachable from other machines.
+ *
+ * @param configuration Flink configuration
+ * @param externalAddress optional address under which the RpcService should be reachable
+ * @param externalPortRange port range from which 1 port will be chosen under which the
+ * RpcService should be reachable
+ * @return rpc service builder
+ */
+ RpcServiceBuilder remoteServiceBuilder(
+ Configuration configuration,
+ @Nullable String externalAddress,
+ String externalPortRange);
+
+ /** Builder for {@link RpcService}. */
+ interface RpcServiceBuilder {
+ RpcServiceBuilder withComponentName(String name);
+
+ RpcServiceBuilder withBindAddress(String bindAddress);
+
+ RpcServiceBuilder withBindPort(int bindPort);
+
+ RpcServiceBuilder withExecutorConfiguration(
+ FixedThreadPoolExecutorConfiguration executorConfiguration);
+
+ RpcServiceBuilder withExecutorConfiguration(
+ ForkJoinExecutorConfiguration executorConfiguration);
+
+ RpcService createAndStart() throws Exception;
+ }
+
+ /**
+ * Loads the RpcSystem.
+ *
+ * @return loaded RpcSystem
+ */
+ static RpcSystem load() {
+ return new AkkaRpcSystem();
+ }
+
+ /** Descriptor for creating a fork-join thread-pool. */
+ class ForkJoinExecutorConfiguration {
+
+ private final double parallelismFactor;
+
+ private final int minParallelism;
+
+ private final int maxParallelism;
+
+ public ForkJoinExecutorConfiguration(
+ double parallelismFactor, int minParallelism, int maxParallelism) {
+ this.parallelismFactor = parallelismFactor;
+ this.minParallelism = minParallelism;
+ this.maxParallelism = maxParallelism;
+ }
+
+ public double getParallelismFactor() {
+ return parallelismFactor;
+ }
+
+ public int getMinParallelism() {
+ return minParallelism;
+ }
+
+ public int getMaxParallelism() {
+ return maxParallelism;
+ }
+ }
+
+ /** Descriptor for creating a thread-pool with a fixed number of threads. */
+ class FixedThreadPoolExecutorConfiguration {
+
+ private final int minNumThreads;
+
+ private final int maxNumThreads;
+
+ private final int threadPriority;
+
+ public FixedThreadPoolExecutorConfiguration(
+ int minNumThreads, int maxNumThreads, int threadPriority) {
+ if (threadPriority < Thread.MIN_PRIORITY || threadPriority > Thread.MAX_PRIORITY) {
+ throw new IllegalArgumentException(
+ String.format(
+ "The thread priority must be within (%s, %s) but it was %s.",
+ Thread.MIN_PRIORITY, Thread.MAX_PRIORITY, threadPriority));
+ }
+
+ this.minNumThreads = minNumThreads;
+ this.maxNumThreads = maxNumThreads;
+ this.threadPriority = threadPriority;
+ }
+
+ public int getMinNumThreads() {
+ return minNumThreads;
+ }
+
+ public int getMaxNumThreads() {
+ return maxNumThreads;
+ }
+
+ public int getThreadPriority() {
+ return threadPriority;
+ }
+ }
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcSystemUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcSystemUtils.java
new file mode 100644
index 0000000..e4cf575
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcSystemUtils.java
@@ -0,0 +1,66 @@
+/*
+ * 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.flink.runtime.rpc;
+
+import org.apache.flink.configuration.Configuration;
+
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+
+/** Utils that are dependent on the underlying RPC implementation. */
+public interface RpcSystemUtils {
+
+ /**
+ * Constructs an RPC URL for the given parameters, that can be used to connect to the targeted
+ * RpcService.
+ *
+ * @param hostname The hostname or address where the target RPC service is listening.
+ * @param port The port where the target RPC service is listening.
+ * @param endpointName The name of the RPC endpoint.
+ * @param addressResolution Whether to try address resolution of the given hostname or not. This
+ * allows to fail fast in case that the hostname cannot be resolved.
+ * @param config The configuration from which to deduce further settings.
+ * @return The RPC URL of the specified RPC endpoint.
+ */
+ String getRpcUrl(
+ String hostname,
+ int port,
+ String endpointName,
+ AddressResolution addressResolution,
+ Configuration config)
+ throws UnknownHostException;
+
+ /**
+ * Returns an {@link InetSocketAddress} corresponding to the given RPC url.
+ *
+ * @see #getRpcUrl
+ * @param url RPC url
+ * @return inet socket address
+ * @throws Exception if the URL is invalid
+ */
+ InetSocketAddress getInetSocketAddressFromRpcUrl(String url) throws Exception;
+
+ /**
+ * Returns the maximum number of bytes that an RPC message may carry according to the given
+ * configuration. If no limit exists then {@link Long#MAX_VALUE} should be returned.
+ *
+ * @param config Flink configuration
+ * @return maximum number of bytes that an RPC message may carry
+ */
+ long getMaximumMessageSizeInBytes(Configuration config);
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcUtils.java
index 7166530..285344a 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/RpcUtils.java
@@ -19,14 +19,18 @@
package org.apache.flink.runtime.rpc;
import org.apache.flink.api.common.time.Time;
+import org.apache.flink.configuration.Configuration;
import org.apache.flink.util.AutoCloseableAsync;
import org.apache.flink.util.concurrent.FutureUtils;
+import javax.annotation.Nullable;
+
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -158,6 +162,35 @@ public class RpcUtils {
: rpcServiceAddress;
}
+ public static RpcSystem.ForkJoinExecutorConfiguration getTestForkJoinExecutorConfiguration() {
+ return new RpcSystem.ForkJoinExecutorConfiguration(1.0, 2, 4);
+ }
+
+ /**
+ * Convenient shortcut for constructing a remote RPC Service that takes care of checking for
+ * null and empty optionals.
+ *
+ * @see RpcSystem#remoteServiceBuilder(Configuration, String, String)
+ */
+ public static RpcService createRemoteRpcService(
+ RpcSystem rpcSystem,
+ Configuration configuration,
+ @Nullable String externalAddress,
+ String externalPortRange,
+ @Nullable String bindAddress,
+ @SuppressWarnings("OptionalUsedAsFieldOrParameterType") Optional<Integer> bindPort)
+ throws Exception {
+ RpcSystem.RpcServiceBuilder rpcServiceBuilder =
+ rpcSystem.remoteServiceBuilder(configuration, externalAddress, externalPortRange);
+ if (bindAddress != null) {
+ rpcServiceBuilder = rpcServiceBuilder.withBindAddress(bindAddress);
+ }
+ if (bindPort.isPresent()) {
+ rpcServiceBuilder = rpcServiceBuilder.withBindPort(bindPort.get());
+ }
+ return rpcServiceBuilder.createAndStart();
+ }
+
// We don't want this class to be instantiable
private RpcUtils() {}
}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaBootstrapTools.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaBootstrapTools.java
index 36c6920..d94b1e6 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaBootstrapTools.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaBootstrapTools.java
@@ -21,6 +21,7 @@ import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.configuration.AkkaOptions;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.util.NetUtils;
import org.apache.flink.shaded.netty4.io.netty.channel.ChannelException;
@@ -64,7 +65,8 @@ public class AkkaBootstrapTools {
NetUtils.getWildcardIPAddress(),
Optional.empty(),
logger,
- ForkJoinExecutorConfiguration.fromConfiguration(configuration),
+ AkkaUtils.getForkJoinExecutorConfig(
+ getForkJoinExecutorConfiguration(configuration)),
null);
}
@@ -94,7 +96,7 @@ public class AkkaBootstrapTools {
String bindAddress,
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") Optional<Integer> bindPort,
Logger logger,
- ActorSystemExecutorConfiguration actorSystemExecutorConfiguration,
+ Config actorSystemExecutorConfiguration,
Config customConfig)
throws Exception {
@@ -161,7 +163,7 @@ public class AkkaBootstrapTools {
String bindAddress,
int bindPort,
Logger logger,
- ActorSystemExecutorConfiguration actorSystemExecutorConfiguration,
+ Config actorSystemExecutorConfiguration,
Config customConfig)
throws Exception {
@@ -180,7 +182,7 @@ public class AkkaBootstrapTools {
configuration,
new Some<>(new Tuple2<>(externalAddress, externalPort)),
new Some<>(new Tuple2<>(bindAddress, bindPort)),
- actorSystemExecutorConfiguration.getAkkaConfig());
+ actorSystemExecutorConfiguration);
if (customConfig != null) {
akkaConfig = customConfig.withFallback(akkaConfig);
@@ -220,7 +222,7 @@ public class AkkaBootstrapTools {
Configuration configuration,
String actorSystemName,
Logger logger,
- ActorSystemExecutorConfiguration actorSystemExecutorConfiguration,
+ Config actorSystemExecutorConfiguration,
Config customConfig)
throws Exception {
@@ -232,7 +234,7 @@ public class AkkaBootstrapTools {
configuration,
scala.Option.empty(),
scala.Option.empty(),
- actorSystemExecutorConfiguration.getAkkaConfig());
+ actorSystemExecutorConfiguration);
if (customConfig != null) {
akkaConfig = customConfig.withFallback(akkaConfig);
@@ -277,92 +279,16 @@ public class AkkaBootstrapTools {
Config getAkkaConfig();
}
- /** Configuration for a fork join executor. */
- public static class ForkJoinExecutorConfiguration implements ActorSystemExecutorConfiguration {
-
- private final double parallelismFactor;
-
- private final int minParallelism;
-
- private final int maxParallelism;
-
- public ForkJoinExecutorConfiguration(
- double parallelismFactor, int minParallelism, int maxParallelism) {
- this.parallelismFactor = parallelismFactor;
- this.minParallelism = minParallelism;
- this.maxParallelism = maxParallelism;
- }
-
- public double getParallelismFactor() {
- return parallelismFactor;
- }
-
- public int getMinParallelism() {
- return minParallelism;
- }
-
- public int getMaxParallelism() {
- return maxParallelism;
- }
-
- @Override
- public Config getAkkaConfig() {
- return AkkaUtils.getForkJoinExecutorConfig(this);
- }
-
- public static ForkJoinExecutorConfiguration fromConfiguration(
- final Configuration configuration) {
- final double parallelismFactor =
- configuration.getDouble(AkkaOptions.FORK_JOIN_EXECUTOR_PARALLELISM_FACTOR);
- final int minParallelism =
- configuration.getInteger(AkkaOptions.FORK_JOIN_EXECUTOR_PARALLELISM_MIN);
- final int maxParallelism =
- configuration.getInteger(AkkaOptions.FORK_JOIN_EXECUTOR_PARALLELISM_MAX);
-
- return new ForkJoinExecutorConfiguration(
- parallelismFactor, minParallelism, maxParallelism);
- }
- }
-
- /** Configuration for a fixed thread pool executor. */
- public static class FixedThreadPoolExecutorConfiguration
- implements ActorSystemExecutorConfiguration {
-
- private final int minNumThreads;
-
- private final int maxNumThreads;
-
- private final int threadPriority;
-
- public FixedThreadPoolExecutorConfiguration(
- int minNumThreads, int maxNumThreads, int threadPriority) {
- if (threadPriority < Thread.MIN_PRIORITY || threadPriority > Thread.MAX_PRIORITY) {
- throw new IllegalArgumentException(
- String.format(
- "The thread priority must be within (%s, %s) but it was %s.",
- Thread.MIN_PRIORITY, Thread.MAX_PRIORITY, threadPriority));
- }
-
- this.minNumThreads = minNumThreads;
- this.maxNumThreads = maxNumThreads;
- this.threadPriority = threadPriority;
- }
-
- public int getMinNumThreads() {
- return minNumThreads;
- }
-
- public int getMaxNumThreads() {
- return maxNumThreads;
- }
-
- public int getThreadPriority() {
- return threadPriority;
- }
-
- @Override
- public Config getAkkaConfig() {
- return AkkaUtils.getThreadPoolExecutorConfig(this);
- }
+ public static RpcSystem.ForkJoinExecutorConfiguration getForkJoinExecutorConfiguration(
+ final Configuration configuration) {
+ final double parallelismFactor =
+ configuration.getDouble(AkkaOptions.FORK_JOIN_EXECUTOR_PARALLELISM_FACTOR);
+ final int minParallelism =
+ configuration.getInteger(AkkaOptions.FORK_JOIN_EXECUTOR_PARALLELISM_MIN);
+ final int maxParallelism =
+ configuration.getInteger(AkkaOptions.FORK_JOIN_EXECUTOR_PARALLELISM_MAX);
+
+ return new RpcSystem.ForkJoinExecutorConfiguration(
+ parallelismFactor, minParallelism, maxParallelism);
}
}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcServiceUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcServiceUtils.java
index 98e9ed6..b22d867 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcServiceUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcServiceUtils.java
@@ -24,6 +24,7 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.SecurityOptions;
import org.apache.flink.runtime.akka.AkkaUtils;
import org.apache.flink.runtime.rpc.AddressResolution;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.util.NetUtils;
import org.apache.flink.util.Preconditions;
@@ -67,7 +68,7 @@ public class AkkaRpcServiceUtils {
// RPC instantiation
// ------------------------------------------------------------------------
- public static AkkaRpcService createRemoteRpcService(
+ static AkkaRpcService createRemoteRpcService(
Configuration configuration,
@Nullable String externalAddress,
String externalPortRange,
@@ -87,7 +88,7 @@ public class AkkaRpcServiceUtils {
return akkaRpcServiceBuilder.createAndStart();
}
- public static AkkaRpcServiceBuilder remoteServiceBuilder(
+ static AkkaRpcServiceBuilder remoteServiceBuilder(
Configuration configuration,
@Nullable String externalAddress,
String externalPortRange) {
@@ -95,12 +96,12 @@ public class AkkaRpcServiceUtils {
}
@VisibleForTesting
- public static AkkaRpcServiceBuilder remoteServiceBuilder(
+ static AkkaRpcServiceBuilder remoteServiceBuilder(
Configuration configuration, @Nullable String externalAddress, int externalPort) {
return remoteServiceBuilder(configuration, externalAddress, String.valueOf(externalPort));
}
- public static AkkaRpcServiceBuilder localServiceBuilder(Configuration configuration) {
+ static AkkaRpcServiceBuilder localServiceBuilder(Configuration configuration) {
return new AkkaRpcServiceBuilder(configuration, LOG);
}
@@ -238,7 +239,7 @@ public class AkkaRpcServiceUtils {
// ------------------------------------------------------------------------
/** Builder for {@link AkkaRpcService}. */
- public static class AkkaRpcServiceBuilder {
+ static class AkkaRpcServiceBuilder implements RpcSystem.RpcServiceBuilder {
private final Configuration configuration;
private final Logger logger;
@@ -247,9 +248,7 @@ public class AkkaRpcServiceUtils {
private String actorSystemName = AkkaUtils.getFlinkActorSystemName();
- @Nullable
- private AkkaBootstrapTools.ActorSystemExecutorConfiguration
- actorSystemExecutorConfiguration = null;
+ @Nullable private Config actorSystemExecutorConfiguration = null;
@Nullable private Config customConfig = null;
private String bindAddress = NetUtils.getWildcardIPAddress();
@@ -278,28 +277,24 @@ public class AkkaRpcServiceUtils {
this.externalPortRange = null;
}
- public AkkaRpcServiceBuilder withActorSystemName(final String actorSystemName) {
+ @Override
+ public AkkaRpcServiceBuilder withComponentName(final String actorSystemName) {
this.actorSystemName = Preconditions.checkNotNull(actorSystemName);
return this;
}
- public AkkaRpcServiceBuilder withActorSystemExecutorConfiguration(
- final AkkaBootstrapTools.ActorSystemExecutorConfiguration
- actorSystemExecutorConfiguration) {
- this.actorSystemExecutorConfiguration = actorSystemExecutorConfiguration;
- return this;
- }
-
public AkkaRpcServiceBuilder withCustomConfig(final Config customConfig) {
this.customConfig = customConfig;
return this;
}
+ @Override
public AkkaRpcServiceBuilder withBindAddress(final String bindAddress) {
this.bindAddress = Preconditions.checkNotNull(bindAddress);
return this;
}
+ @Override
public AkkaRpcServiceBuilder withBindPort(int bindPort) {
Preconditions.checkArgument(
NetUtils.isValidHostPort(bindPort), "Invalid port number: " + bindPort);
@@ -307,6 +302,22 @@ public class AkkaRpcServiceUtils {
return this;
}
+ @Override
+ public RpcSystem.RpcServiceBuilder withExecutorConfiguration(
+ RpcSystem.FixedThreadPoolExecutorConfiguration executorConfiguration) {
+ this.actorSystemExecutorConfiguration =
+ AkkaUtils.getThreadPoolExecutorConfig(executorConfiguration);
+ return this;
+ }
+
+ @Override
+ public RpcSystem.RpcServiceBuilder withExecutorConfiguration(
+ RpcSystem.ForkJoinExecutorConfiguration executorConfiguration) {
+ this.actorSystemExecutorConfiguration =
+ AkkaUtils.getForkJoinExecutorConfig(executorConfiguration);
+ return this;
+ }
+
public AkkaRpcService createAndStart() throws Exception {
return createAndStart(AkkaRpcService::new);
}
@@ -316,8 +327,8 @@ public class AkkaRpcServiceUtils {
throws Exception {
if (actorSystemExecutorConfiguration == null) {
actorSystemExecutorConfiguration =
- AkkaBootstrapTools.ForkJoinExecutorConfiguration.fromConfiguration(
- configuration);
+ AkkaUtils.getForkJoinExecutorConfig(
+ AkkaBootstrapTools.getForkJoinExecutorConfiguration(configuration));
}
final ActorSystem actorSystem;
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcSystem.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcSystem.java
new file mode 100644
index 0000000..d52255d
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcSystem.java
@@ -0,0 +1,68 @@
+/*
+ * 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.flink.runtime.rpc.akka;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.rpc.AddressResolution;
+import org.apache.flink.runtime.rpc.RpcSystem;
+
+import javax.annotation.Nullable;
+
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+
+/** {@link RpcSystem} implementation based on Akka. */
+public class AkkaRpcSystem implements RpcSystem {
+
+ @Override
+ public RpcServiceBuilder localServiceBuilder(Configuration configuration) {
+ return AkkaRpcServiceUtils.localServiceBuilder(configuration);
+ }
+
+ @Override
+ public RpcServiceBuilder remoteServiceBuilder(
+ Configuration configuration,
+ @Nullable String externalAddress,
+ String externalPortRange) {
+ return AkkaRpcServiceUtils.remoteServiceBuilder(
+ configuration, externalAddress, externalPortRange);
+ }
+
+ @Override
+ public InetSocketAddress getInetSocketAddressFromRpcUrl(String url) throws Exception {
+ return AkkaUtils.getInetSocketAddressFromAkkaURL(url);
+ }
+
+ @Override
+ public String getRpcUrl(
+ String hostname,
+ int port,
+ String endpointName,
+ AddressResolution addressResolution,
+ Configuration config)
+ throws UnknownHostException {
+ return AkkaRpcServiceUtils.getRpcUrl(
+ hostname, port, endpointName, addressResolution, config);
+ }
+
+ @Override
+ public long getMaximumMessageSizeInBytes(Configuration config) {
+ return AkkaRpcServiceUtils.extractMaximumFramesize(config);
+ }
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
index 8133a4b..1a2833c 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
@@ -51,7 +51,9 @@ import org.apache.flink.runtime.metrics.util.MetricUtils;
import org.apache.flink.runtime.rpc.AddressResolution;
import org.apache.flink.runtime.rpc.FatalErrorHandler;
import org.apache.flink.runtime.rpc.RpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
+import org.apache.flink.runtime.rpc.RpcSystem;
+import org.apache.flink.runtime.rpc.RpcSystemUtils;
+import org.apache.flink.runtime.rpc.RpcUtils;
import org.apache.flink.runtime.security.SecurityConfiguration;
import org.apache.flink.runtime.security.SecurityUtils;
import org.apache.flink.runtime.taskmanager.MemoryLogger;
@@ -133,6 +135,8 @@ public class TaskManagerRunner implements FatalErrorHandler {
throws Exception {
this.configuration = checkNotNull(configuration);
+ final RpcSystem rpcSystem = RpcSystem.load();
+
timeout = Time.fromDuration(configuration.get(AkkaOptions.ASK_TIMEOUT_DURATION));
this.executor =
@@ -142,11 +146,14 @@ public class TaskManagerRunner implements FatalErrorHandler {
highAvailabilityServices =
HighAvailabilityServicesUtils.createHighAvailabilityServices(
- configuration, executor, AddressResolution.NO_ADDRESS_RESOLUTION);
+ configuration,
+ executor,
+ AddressResolution.NO_ADDRESS_RESOLUTION,
+ rpcSystem);
JMXService.startInstance(configuration.getString(JMXServerOptions.JMX_SERVER_PORT));
- rpcService = createRpcService(configuration, highAvailabilityServices);
+ rpcService = createRpcService(configuration, highAvailabilityServices, rpcSystem);
this.resourceId =
getTaskManagerResourceID(
@@ -156,11 +163,14 @@ public class TaskManagerRunner implements FatalErrorHandler {
metricRegistry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(configuration),
+ MetricRegistryConfiguration.fromConfiguration(
+ configuration,
+ rpcSystem.getMaximumMessageSizeInBytes(configuration)),
ReporterSetup.fromConfiguration(configuration, pluginManager));
final RpcService metricQueryServiceRpcService =
- MetricUtils.startRemoteMetricsRpcService(configuration, rpcService.getAddress());
+ MetricUtils.startRemoteMetricsRpcService(
+ configuration, rpcService.getAddress(), rpcSystem);
metricRegistry.startQueryService(metricQueryServiceRpcService, resourceId);
blobCacheService =
@@ -543,22 +553,27 @@ public class TaskManagerRunner implements FatalErrorHandler {
*/
@VisibleForTesting
static RpcService createRpcService(
- final Configuration configuration, final HighAvailabilityServices haServices)
+ final Configuration configuration,
+ final HighAvailabilityServices haServices,
+ final RpcSystem rpcSystem)
throws Exception {
checkNotNull(configuration);
checkNotNull(haServices);
- return AkkaRpcServiceUtils.createRemoteRpcService(
+ return RpcUtils.createRemoteRpcService(
+ rpcSystem,
configuration,
- determineTaskManagerBindAddress(configuration, haServices),
+ determineTaskManagerBindAddress(configuration, haServices, rpcSystem),
configuration.getString(TaskManagerOptions.RPC_PORT),
configuration.getString(TaskManagerOptions.BIND_HOST),
configuration.getOptional(TaskManagerOptions.RPC_BIND_PORT));
}
private static String determineTaskManagerBindAddress(
- final Configuration configuration, final HighAvailabilityServices haServices)
+ final Configuration configuration,
+ final HighAvailabilityServices haServices,
+ RpcSystemUtils rpcSystemUtils)
throws Exception {
final String configuredTaskManagerHostname =
@@ -571,19 +586,23 @@ public class TaskManagerRunner implements FatalErrorHandler {
return configuredTaskManagerHostname;
} else {
return determineTaskManagerBindAddressByConnectingToResourceManager(
- configuration, haServices);
+ configuration, haServices, rpcSystemUtils);
}
}
private static String determineTaskManagerBindAddressByConnectingToResourceManager(
- final Configuration configuration, final HighAvailabilityServices haServices)
+ final Configuration configuration,
+ final HighAvailabilityServices haServices,
+ RpcSystemUtils rpcSystemUtils)
throws LeaderRetrievalException {
final Duration lookupTimeout = configuration.get(AkkaOptions.LOOKUP_TIMEOUT_DURATION);
final InetAddress taskManagerAddress =
LeaderRetrievalUtils.findConnectingAddress(
- haServices.getResourceManagerLeaderRetriever(), lookupTimeout);
+ haServices.getResourceManagerLeaderRetriever(),
+ lookupTimeout,
+ rpcSystemUtils);
LOG.info(
"TaskManager will use hostname/address '{}' ({}) for communication.",
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/util/LeaderRetrievalUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/util/LeaderRetrievalUtils.java
index 53b7c66..c893b6f 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/util/LeaderRetrievalUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/util/LeaderRetrievalUtils.java
@@ -22,6 +22,7 @@ import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalException;
import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener;
import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService;
import org.apache.flink.runtime.net.ConnectionUtils;
+import org.apache.flink.runtime.rpc.RpcSystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,11 +73,13 @@ public class LeaderRetrievalUtils {
}
public static InetAddress findConnectingAddress(
- LeaderRetrievalService leaderRetrievalService, Duration timeout)
+ LeaderRetrievalService leaderRetrievalService,
+ Duration timeout,
+ RpcSystemUtils rpcSystemUtils)
throws LeaderRetrievalException {
ConnectionUtils.LeaderConnectingAddressListener listener =
- new ConnectionUtils.LeaderConnectingAddressListener();
+ new ConnectionUtils.LeaderConnectingAddressListener(rpcSystemUtils);
try {
leaderRetrievalService.start(listener);
diff --git a/flink-runtime/src/main/scala/org/apache/flink/runtime/akka/AkkaUtils.scala b/flink-runtime/src/main/scala/org/apache/flink/runtime/akka/AkkaUtils.scala
index 6ac3b36..1335f6d 100644
--- a/flink-runtime/src/main/scala/org/apache/flink/runtime/akka/AkkaUtils.scala
+++ b/flink-runtime/src/main/scala/org/apache/flink/runtime/akka/AkkaUtils.scala
@@ -28,7 +28,8 @@ import com.typesafe.config.{Config, ConfigFactory}
import org.apache.flink.api.common.time.Time
import org.apache.flink.configuration._
import org.apache.flink.runtime.concurrent.akka.AkkaFutureUtils
-import org.apache.flink.runtime.rpc.akka.AkkaBootstrapTools.{FixedThreadPoolExecutorConfiguration, ForkJoinExecutorConfiguration}
+import org.apache.flink.runtime.rpc.RpcSystem.{FixedThreadPoolExecutorConfiguration, ForkJoinExecutorConfiguration}
+import org.apache.flink.runtime.rpc.akka.AkkaBootstrapTools
import org.apache.flink.util.NetUtils
import org.apache.flink.util.TimeUtils
import org.apache.flink.util.concurrent.FutureUtils
@@ -191,7 +192,7 @@ object AkkaUtils {
configuration,
externalAddress,
None,
- getForkJoinExecutorConfig(ForkJoinExecutorConfiguration.fromConfiguration(configuration)))
+ getForkJoinExecutorConfig(AkkaBootstrapTools.getForkJoinExecutorConfiguration(configuration)))
}
/**
@@ -368,25 +369,6 @@ object AkkaUtils {
ConfigFactory.parseString(configString)
}
- def testDispatcherConfig: Config = {
- val config =
- s"""
- |akka {
- | actor {
- | default-dispatcher {
- | fork-join-executor {
- | parallelism-factor = 1.0
- | parallelism-min = 2
- | parallelism-max = 4
- | }
- | }
- | }
- |}
- """.stripMargin
-
- ConfigFactory.parseString(config)
- }
-
/**
* Creates a Akka config for a remote actor system listening on port on the network interface
* identified by bindAddress.
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/entrypoint/ClusterEntrypointTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/entrypoint/ClusterEntrypointTest.java
index ab12b46..cf53a68 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/entrypoint/ClusterEntrypointTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/entrypoint/ClusterEntrypointTest.java
@@ -42,6 +42,7 @@ import org.apache.flink.runtime.resourcemanager.TestingResourceManagerFactory;
import org.apache.flink.runtime.rest.SessionRestEndpointFactory;
import org.apache.flink.runtime.rpc.FatalErrorHandler;
import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystemUtils;
import org.apache.flink.runtime.testutils.TestJvmProcess;
import org.apache.flink.runtime.testutils.TestingClusterEntrypointProcess;
import org.apache.flink.runtime.util.SignalHandler;
@@ -275,7 +276,7 @@ public class ClusterEntrypointTest extends TestLogger {
@Override
protected HighAvailabilityServices createHaServices(
- Configuration configuration, Executor executor) {
+ Configuration configuration, Executor executor, RpcSystemUtils rpcSystemUtils) {
return haService;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtilsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtilsTest.java
index 6aa8b68..6d7995f 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtilsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/HighAvailabilityServicesUtilsTest.java
@@ -23,6 +23,7 @@ import org.apache.flink.configuration.HighAvailabilityOptions;
import org.apache.flink.core.fs.Path;
import org.apache.flink.runtime.jobmanager.HighAvailabilityMode;
import org.apache.flink.runtime.rpc.AddressResolution;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.util.TestLogger;
import org.apache.flink.util.concurrent.Executors;
@@ -64,7 +65,11 @@ public class HighAvailabilityServicesUtilsTest extends TestLogger {
// when
actualHaServices =
HighAvailabilityServicesUtils.createHighAvailabilityServices(
- config, executor, AddressResolution.NO_ADDRESS_RESOLUTION);
+ config,
+ executor,
+ AddressResolution.NO_ADDRESS_RESOLUTION,
+ RpcSystem.load());
+
// then
assertSame(haServices, actualHaServices);
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderRetrievalTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderRetrievalTest.java
index fe3174c..fd4f125 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderRetrievalTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderRetrievalTest.java
@@ -26,7 +26,7 @@ import org.apache.flink.runtime.highavailability.zookeeper.ZooKeeperHaServices;
import org.apache.flink.runtime.jobmaster.JobMaster;
import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService;
import org.apache.flink.runtime.rpc.AddressResolution;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.runtime.testutils.TestingUtils;
import org.apache.flink.runtime.util.LeaderRetrievalUtils;
import org.apache.flink.runtime.util.ZooKeeperUtils;
@@ -53,6 +53,8 @@ import static org.junit.Assert.assertEquals;
/** Tests for the ZooKeeper based leader election and retrieval. */
public class ZooKeeperLeaderRetrievalTest extends TestLogger {
+ private static final RpcSystem RPC_SYSTEM = RpcSystem.load();
+
private TestingServer testingServer;
private Configuration config;
@@ -112,7 +114,7 @@ public class ZooKeeperLeaderRetrievalTest extends TestLogger {
try {
String wrongAddress =
- AkkaRpcServiceUtils.getRpcUrl(
+ RPC_SYSTEM.getRpcUrl(
"1.1.1.1",
1234,
"foobar",
@@ -136,7 +138,7 @@ public class ZooKeeperLeaderRetrievalTest extends TestLogger {
new InetSocketAddress(localHost, serverSocket.getLocalPort());
String correctAddress =
- AkkaRpcServiceUtils.getRpcUrl(
+ RPC_SYSTEM.getRpcUrl(
localHost.getHostName(),
correctInetSocketAddress.getPort(),
JobMaster.JOB_MANAGER_NAME,
@@ -208,7 +210,8 @@ public class ZooKeeperLeaderRetrievalTest extends TestLogger {
highAvailabilityServices.getJobManagerLeaderRetriever(
HighAvailabilityServices.DEFAULT_JOB_ID);
InetAddress result =
- LeaderRetrievalUtils.findConnectingAddress(leaderRetrievalService, timeout);
+ LeaderRetrievalUtils.findConnectingAddress(
+ leaderRetrievalService, timeout, RPC_SYSTEM);
assertEquals(InetAddress.getLocalHost(), result);
}
@@ -231,7 +234,8 @@ public class ZooKeeperLeaderRetrievalTest extends TestLogger {
public void run() {
try {
result =
- LeaderRetrievalUtils.findConnectingAddress(leaderRetrievalService, timeout);
+ LeaderRetrievalUtils.findConnectingAddress(
+ leaderRetrievalService, timeout, RPC_SYSTEM);
} catch (Exception e) {
exception = e;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricRegistryImplTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricRegistryImplTest.java
index a067c51..30d53bd 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricRegistryImplTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricRegistryImplTest.java
@@ -69,7 +69,7 @@ public class MetricRegistryImplTest extends TestLogger {
public void testIsShutdown() throws Exception {
MetricRegistryImpl metricRegistry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
Assert.assertFalse(metricRegistry.isShutdown());
@@ -92,7 +92,7 @@ public class MetricRegistryImplTest extends TestLogger {
public void testMetricQueryServiceSetup() throws Exception {
MetricRegistryImpl metricRegistry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
Assert.assertNull(metricRegistry.getMetricQueryServiceGatewayRpcAddress());
@@ -146,7 +146,7 @@ public class MetricRegistryImplTest extends TestLogger {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
ReporterSetup.forReporter("test", config, new TestReporter3())));
@@ -187,7 +187,7 @@ public class MetricRegistryImplTest extends TestLogger {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
ReporterSetup.forReporter("test", config, new TestReporter3())),
manuallyTriggeredScheduledExecutorService);
@@ -230,7 +230,7 @@ public class MetricRegistryImplTest extends TestLogger {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Arrays.asList(
ReporterSetup.forReporter("test1", new TestReporter6()),
ReporterSetup.forReporter("test2", new TestReporter7())));
@@ -329,7 +329,7 @@ public class MetricRegistryImplTest extends TestLogger {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(config),
+ MetricRegistryTestUtils.fromConfiguration(config),
ReporterSetup.fromConfiguration(config, null));
TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "host", "id");
@@ -351,7 +351,7 @@ public class MetricRegistryImplTest extends TestLogger {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Arrays.asList(
ReporterSetup.forReporter("test1", config1, new TestReporter()),
ReporterSetup.forReporter("test2", config2, new TestReporter()),
@@ -419,7 +419,7 @@ public class MetricRegistryImplTest extends TestLogger {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(config),
+ MetricRegistryTestUtils.fromConfiguration(config),
Arrays.asList(
ReporterSetup.forReporter("test1", config1, new TestReporter8()),
ReporterSetup.forReporter("test2", config2, new TestReporter8()),
@@ -449,7 +449,7 @@ public class MetricRegistryImplTest extends TestLogger {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
final RpcService rpcService = new TestingRpcService();
@@ -492,7 +492,7 @@ public class MetricRegistryImplTest extends TestLogger {
public void testExceptionIsolation() throws Exception {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Arrays.asList(
ReporterSetup.forReporter("test1", new FailingReporter()),
ReporterSetup.forReporter("test2", new TestReporter7())));
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricRegistryTestUtils.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricRegistryTestUtils.java
new file mode 100644
index 0000000..f6503f2
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricRegistryTestUtils.java
@@ -0,0 +1,43 @@
+/*
+ * 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.flink.runtime.metrics;
+
+import org.apache.flink.configuration.Configuration;
+
+/** Test utilities for the metric registries. */
+public class MetricRegistryTestUtils {
+
+ private static volatile MetricRegistryConfiguration defaultConfiguration;
+
+ public static MetricRegistryConfiguration fromConfiguration(Configuration configuration) {
+ return MetricRegistryConfiguration.fromConfiguration(configuration, 10485760);
+ }
+
+ public static MetricRegistryConfiguration defaultMetricRegistryConfiguration() {
+ // create the default metric registry configuration only once
+ if (defaultConfiguration == null) {
+ synchronized (MetricRegistryConfiguration.class) {
+ if (defaultConfiguration == null) {
+ defaultConfiguration = fromConfiguration(new Configuration());
+ }
+ }
+ }
+
+ return defaultConfiguration;
+ }
+}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroupTest.java
index f8b7731..6b36759 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroupTest.java
@@ -28,8 +28,8 @@ import org.apache.flink.metrics.MetricConfig;
import org.apache.flink.metrics.MetricGroup;
import org.apache.flink.metrics.reporter.MetricReporter;
import org.apache.flink.runtime.metrics.MetricRegistry;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.NoOpMetricRegistry;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
@@ -61,7 +61,7 @@ public class AbstractMetricGroupTest extends TestLogger {
public void testGetAllVariables() throws Exception {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
AbstractMetricGroup group =
new AbstractMetricGroup<AbstractMetricGroup<?>>(registry, new String[0], null) {
@@ -179,7 +179,7 @@ public class AbstractMetricGroupTest extends TestLogger {
MetricRegistryImpl testRegistry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.fromConfiguration(config),
+ MetricRegistryTestUtils.fromConfiguration(config),
Arrays.asList(
ReporterSetup.forReporter(
"test1", metricConfig1, new TestReporter1()),
@@ -207,7 +207,7 @@ public class AbstractMetricGroupTest extends TestLogger {
public void testLogicalScopeCachingForMultipleReporters() throws Exception {
MetricRegistryImpl testRegistry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Arrays.asList(
ReporterSetup.forReporter("test1", new LogicalScopeReporter1()),
ReporterSetup.forReporter("test2", new LogicalScopeReporter2())));
@@ -341,7 +341,7 @@ public class AbstractMetricGroupTest extends TestLogger {
Configuration config = new Configuration();
config.setString(MetricOptions.SCOPE_NAMING_TM, "A.B.C.D");
MetricRegistryImpl testRegistry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(config));
try {
TaskManagerMetricGroup group = new TaskManagerMetricGroup(testRegistry, "host", "id");
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerGroupTest.java
index 68cb6ac..a83ba2a 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerGroupTest.java
@@ -22,8 +22,8 @@ import org.apache.flink.api.common.JobID;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MetricOptions;
import org.apache.flink.runtime.jobgraph.JobGraphBuilder;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
import org.apache.flink.runtime.metrics.util.DummyCharacterFilter;
import org.apache.flink.util.TestLogger;
@@ -45,7 +45,7 @@ public class JobManagerGroupTest extends TestLogger {
public void addAndRemoveJobs() throws Exception {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
final JobManagerMetricGroup group = new JobManagerMetricGroup(registry, "localhost");
final JobID jid1 = new JobID();
@@ -94,7 +94,7 @@ public class JobManagerGroupTest extends TestLogger {
public void testCloseClosesAll() throws Exception {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
final JobManagerMetricGroup group = new JobManagerMetricGroup(registry, "localhost");
final JobID jid1 = new JobID();
@@ -132,7 +132,7 @@ public class JobManagerGroupTest extends TestLogger {
public void testGenerateScopeDefault() throws Exception {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
JobManagerMetricGroup group = new JobManagerMetricGroup(registry, "localhost");
assertArrayEquals(new String[] {"localhost", "jobmanager"}, group.getScopeComponents());
@@ -146,7 +146,7 @@ public class JobManagerGroupTest extends TestLogger {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_JM, "constant.<host>.foo.<host>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
JobManagerMetricGroup group = new JobManagerMetricGroup(registry, "host");
@@ -161,7 +161,7 @@ public class JobManagerGroupTest extends TestLogger {
public void testCreateQueryServiceMetricInfo() {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
JobManagerMetricGroup jm = new JobManagerMetricGroup(registry, "host");
QueryScopeInfo.JobManagerQueryScopeInfo info =
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerJobGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerJobGroupTest.java
index 70b6b51..585570b 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerJobGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/JobManagerJobGroupTest.java
@@ -21,8 +21,8 @@ package org.apache.flink.runtime.metrics.groups;
import org.apache.flink.api.common.JobID;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MetricOptions;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
import org.apache.flink.runtime.metrics.util.DummyCharacterFilter;
import org.apache.flink.util.TestLogger;
@@ -39,7 +39,7 @@ public class JobManagerJobGroupTest extends TestLogger {
public void testGenerateScopeDefault() throws Exception {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
JobManagerMetricGroup tmGroup = new JobManagerMetricGroup(registry, "theHostName");
JobMetricGroup jmGroup =
@@ -60,7 +60,7 @@ public class JobManagerJobGroupTest extends TestLogger {
cfg.setString(MetricOptions.SCOPE_NAMING_JM, "abc");
cfg.setString(MetricOptions.SCOPE_NAMING_JM_JOB, "some-constant.<job_name>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
JobID jid = new JobID();
@@ -81,7 +81,7 @@ public class JobManagerJobGroupTest extends TestLogger {
cfg.setString(MetricOptions.SCOPE_NAMING_JM, "peter");
cfg.setString(MetricOptions.SCOPE_NAMING_JM_JOB, "*.some-constant.<job_id>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
JobID jid = new JobID();
@@ -102,7 +102,7 @@ public class JobManagerJobGroupTest extends TestLogger {
JobID jid = new JobID();
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
JobManagerMetricGroup jm = new JobManagerMetricGroup(registry, "host");
JobManagerJobMetricGroup jmj = new JobManagerJobMetricGroup(registry, jm, jid, "jobname");
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupRegistrationTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupRegistrationTest.java
index 1cbb722..ab0fc3d 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupRegistrationTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupRegistrationTest.java
@@ -25,8 +25,8 @@ import org.apache.flink.metrics.Histogram;
import org.apache.flink.metrics.HistogramStatistics;
import org.apache.flink.metrics.Metric;
import org.apache.flink.metrics.MetricGroup;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.ReporterSetup;
import org.apache.flink.runtime.metrics.util.TestReporter;
import org.apache.flink.util.TestLogger;
@@ -45,7 +45,7 @@ public class MetricGroupRegistrationTest extends TestLogger {
public void testMetricInstantiation() throws Exception {
MetricRegistryImpl registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration(),
Collections.singletonList(
ReporterSetup.forReporter("test", new TestReporter1())));
@@ -113,7 +113,7 @@ public class MetricGroupRegistrationTest extends TestLogger {
Configuration config = new Configuration();
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(config));
MetricGroup root = new TaskManagerMetricGroup(registry, "host", "id");
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupTest.java
index a80b835..3996d50 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/MetricGroupTest.java
@@ -30,6 +30,7 @@ import org.apache.flink.runtime.jobgraph.JobVertexID;
import org.apache.flink.runtime.metrics.MetricRegistry;
import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.NoOpMetricRegistry;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
import org.apache.flink.runtime.metrics.scope.ScopeFormat;
@@ -55,7 +56,7 @@ import static org.junit.Assert.fail;
public class MetricGroupTest extends TestLogger {
private static final MetricRegistryConfiguration defaultMetricRegistryConfiguration =
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration();
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration();
private MetricRegistryImpl registry;
@@ -245,7 +246,7 @@ public class MetricGroupTest extends TestLogger {
TestReporter.class.getName());
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(config));
try {
GenericMetricGroup root =
new GenericMetricGroup(
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/OperatorGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/OperatorGroupTest.java
index 84e612f..8585ec2 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/OperatorGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/OperatorGroupTest.java
@@ -24,8 +24,8 @@ import org.apache.flink.configuration.MetricOptions;
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.JobVertexID;
import org.apache.flink.runtime.jobgraph.OperatorID;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
import org.apache.flink.runtime.metrics.scope.ScopeFormat;
import org.apache.flink.runtime.metrics.util.DummyCharacterFilter;
@@ -50,7 +50,7 @@ public class OperatorGroupTest extends TestLogger {
public void setup() {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
}
@After
@@ -96,7 +96,7 @@ public class OperatorGroupTest extends TestLogger {
MetricOptions.SCOPE_NAMING_OPERATOR,
"<tm_id>.<job_id>.<task_id>.<operator_name>.<operator_id>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
try {
String tmID = "test-tm-id";
JobID jid = new JobID();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerGroupTest.java
index b51877d..4a94680 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerGroupTest.java
@@ -23,8 +23,8 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MetricOptions;
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.JobVertexID;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
import org.apache.flink.runtime.metrics.util.DummyCharacterFilter;
import org.apache.flink.util.AbstractID;
@@ -50,7 +50,7 @@ public class TaskManagerGroupTest extends TestLogger {
public void setup() {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
}
@After
@@ -173,7 +173,7 @@ public class TaskManagerGroupTest extends TestLogger {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_TM, "constant.<host>.foo.<host>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
TaskManagerMetricGroup group = new TaskManagerMetricGroup(registry, "host", "id");
assertArrayEquals(
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerJobGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerJobGroupTest.java
index 01eb4f7..7611581 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerJobGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskManagerJobGroupTest.java
@@ -21,8 +21,8 @@ package org.apache.flink.runtime.metrics.groups;
import org.apache.flink.api.common.JobID;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MetricOptions;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
import org.apache.flink.runtime.metrics.util.DummyCharacterFilter;
import org.apache.flink.util.TestLogger;
@@ -43,7 +43,7 @@ public class TaskManagerJobGroupTest extends TestLogger {
public void setup() {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
}
@After
@@ -75,7 +75,7 @@ public class TaskManagerJobGroupTest extends TestLogger {
cfg.setString(MetricOptions.SCOPE_NAMING_TM, "abc");
cfg.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "some-constant.<job_name>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
JobID jid = new JobID();
@@ -96,7 +96,7 @@ public class TaskManagerJobGroupTest extends TestLogger {
cfg.setString(MetricOptions.SCOPE_NAMING_TM, "peter.<tm_id>");
cfg.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "*.some-constant.<job_id>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
JobID jid = new JobID();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroupTest.java
index 5dd0e3f..05c3b69 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroupTest.java
@@ -24,8 +24,8 @@ import org.apache.flink.configuration.MetricOptions;
import org.apache.flink.metrics.Metric;
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.JobVertexID;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.metrics.dump.QueryScopeInfo;
import org.apache.flink.runtime.metrics.scope.ScopeFormat;
import org.apache.flink.runtime.metrics.util.DummyCharacterFilter;
@@ -49,7 +49,7 @@ public class TaskMetricGroupTest extends TestLogger {
public void setup() {
registry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
}
@After
@@ -94,7 +94,7 @@ public class TaskMetricGroupTest extends TestLogger {
cfg.setString(
MetricOptions.SCOPE_NAMING_TASK, "<tm_id>.<job_id>.<task_id>.<task_attempt_id>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
JobID jid = new JobID();
JobVertexID vertexId = new JobVertexID();
@@ -124,7 +124,7 @@ public class TaskMetricGroupTest extends TestLogger {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_TASK, "*.<task_attempt_id>.<subtask_index>");
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
ExecutionAttemptID executionId = new ExecutionAttemptID();
@@ -204,7 +204,7 @@ public class TaskMetricGroupTest extends TestLogger {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_OPERATOR, ScopeFormat.SCOPE_OPERATOR_NAME);
MetricRegistryImpl registry =
- new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
+ new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
TaskManagerJobMetricGroup job =
new TaskManagerJobMetricGroup(registry, tm, new JobID(), "jobname");
@@ -228,7 +228,7 @@ public class TaskMetricGroupTest extends TestLogger {
private int counter = 0;
CountingMetricRegistry(Configuration config) {
- super(MetricRegistryConfiguration.fromConfiguration(config));
+ super(MetricRegistryTestUtils.fromConfiguration(config));
}
@Override
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/util/MetricUtilsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/util/MetricUtilsTest.java
index 2f8e24f..8f387e8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/util/MetricUtilsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/util/MetricUtilsTest.java
@@ -22,12 +22,12 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MetricOptions;
import org.apache.flink.metrics.Gauge;
import org.apache.flink.metrics.MetricGroup;
-import org.apache.flink.runtime.akka.AkkaUtils;
import org.apache.flink.runtime.clusterframework.types.AllocationID;
import org.apache.flink.runtime.memory.MemoryAllocationException;
import org.apache.flink.runtime.memory.MemoryManager;
import org.apache.flink.runtime.metrics.MetricNames;
import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
import org.apache.flink.runtime.taskexecutor.TaskManagerServices;
import org.apache.flink.runtime.taskexecutor.TaskManagerServicesBuilder;
@@ -70,8 +70,8 @@ public class MetricUtilsTest extends TestLogger {
}
/**
- * Tests that the {@link MetricUtils#startRemoteMetricsRpcService(Configuration, String)}
- * respects the given {@link MetricOptions#QUERY_SERVICE_THREAD_PRIORITY}.
+ * Tests that the {@link MetricUtils#startRemoteMetricsRpcService(Configuration, String,
+ * RpcSystem)} respects the given {@link MetricOptions#QUERY_SERVICE_THREAD_PRIORITY}.
*/
@Test
public void testStartMetricActorSystemRespectsThreadPriority() throws Exception {
@@ -81,7 +81,8 @@ public class MetricUtilsTest extends TestLogger {
MetricOptions.QUERY_SERVICE_THREAD_PRIORITY, expectedThreadPriority);
final RpcService rpcService =
- MetricUtils.startRemoteMetricsRpcService(configuration, "localhost");
+ MetricUtils.startRemoteMetricsRpcService(
+ configuration, "localhost", RpcSystem.load());
assertThat(rpcService, instanceOf(AkkaRpcService.class));
final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem();
@@ -95,7 +96,7 @@ public class MetricUtilsTest extends TestLogger {
assertThat(threadPriority, is(expectedThreadPriority));
} finally {
- AkkaUtils.terminateActorSystem(actorSystem).get();
+ rpcService.stopService().get();
}
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/AsyncCallsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/AsyncCallsTest.java
index b6f7581..9597fbf 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/AsyncCallsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/AsyncCallsTest.java
@@ -19,23 +19,17 @@
package org.apache.flink.runtime.rpc;
import org.apache.flink.api.common.time.Time;
+import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.testutils.OneShotLatch;
-import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.concurrent.akka.AkkaFutureUtils;
import org.apache.flink.runtime.messages.Acknowledge;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceConfiguration;
import org.apache.flink.runtime.rpc.exceptions.FencingTokenException;
import org.apache.flink.util.ExceptionUtils;
import org.apache.flink.util.TestLogger;
-import org.apache.flink.util.concurrent.FutureUtils;
-import akka.actor.ActorSystem;
-import akka.actor.Terminated;
import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.Arrays;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -58,22 +52,19 @@ public class AsyncCallsTest extends TestLogger {
// shared test members
// ------------------------------------------------------------------------
- private static final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem();
-
private static final Time timeout = Time.seconds(10L);
- private static final AkkaRpcService akkaRpcService =
- new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
+ private static RpcService rpcService;
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ rpcService = RpcSystem.load().localServiceBuilder(new Configuration()).createAndStart();
+ }
@AfterClass
public static void shutdown()
throws InterruptedException, ExecutionException, TimeoutException {
- final CompletableFuture<Void> rpcTerminationFuture = akkaRpcService.stopService();
- final CompletableFuture<Terminated> actorSystemTerminationFuture =
- AkkaFutureUtils.toJava(actorSystem.terminate());
-
- FutureUtils.waitForAll(Arrays.asList(rpcTerminationFuture, actorSystemTerminationFuture))
- .get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
+ rpcService.stopService().get();
}
// ------------------------------------------------------------------------
@@ -95,7 +86,7 @@ public class AsyncCallsTest extends TestLogger {
final ReentrantLock lock = new ReentrantLock();
final AtomicBoolean concurrentAccess = new AtomicBoolean(false);
- RpcEndpoint rpcEndpoint = factory.create(akkaRpcService, lock, concurrentAccess);
+ RpcEndpoint rpcEndpoint = factory.create(rpcService, lock, concurrentAccess);
rpcEndpoint.start();
try {
@@ -160,7 +151,7 @@ public class AsyncCallsTest extends TestLogger {
final long delay = 10L;
- RpcEndpoint rpcEndpoint = factory.create(akkaRpcService, lock, concurrentAccess);
+ RpcEndpoint rpcEndpoint = factory.create(rpcService, lock, concurrentAccess);
rpcEndpoint.start();
try {
@@ -306,7 +297,7 @@ public class AsyncCallsTest extends TestLogger {
final OneShotLatch triggerSetNewFencingToken = new OneShotLatch();
final FencedTestEndpoint fencedTestEndpoint =
new FencedTestEndpoint(
- akkaRpcService,
+ rpcService,
initialFencingToken,
enterSetNewFencingToken,
triggerSetNewFencingToken);
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcConnectionTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcConnectionTest.java
index ebedc72..7d81ed1 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcConnectionTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcConnectionTest.java
@@ -20,29 +20,18 @@ package org.apache.flink.runtime.rpc;
import org.apache.flink.configuration.AkkaOptions;
import org.apache.flink.configuration.Configuration;
-import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.concurrent.akka.AkkaFutureUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceConfiguration;
import org.apache.flink.runtime.rpc.exceptions.RpcConnectionException;
import org.apache.flink.runtime.taskexecutor.TaskExecutorGateway;
import org.apache.flink.util.TestLogger;
-import org.apache.flink.util.concurrent.FutureUtils;
-import akka.actor.ActorSystem;
-import akka.actor.Terminated;
import org.junit.Test;
import java.time.Duration;
-import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import scala.Option;
-import scala.Tuple2;
-
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -54,23 +43,18 @@ public class RpcConnectionTest extends TestLogger {
@Test
public void testConnectFailure() throws Exception {
- ActorSystem actorSystem = null;
- RpcService rpcService = null;
- try {
- actorSystem =
- AkkaUtils.createActorSystem(
- new Configuration(),
- Option.<Tuple2<String, Object>>apply(new Tuple2<>("localhost", 0)));
-
- // we start the RPC service with a very long timeout to ensure that the test
- // can only pass if the connection problem is not recognized merely via a timeout
- Configuration configuration = new Configuration();
- configuration.set(AkkaOptions.ASK_TIMEOUT_DURATION, Duration.ofSeconds(10000000));
- rpcService =
- new AkkaRpcService(
- actorSystem,
- AkkaRpcServiceConfiguration.fromConfiguration(configuration));
+ // we start the RPC service with a very long timeout to ensure that the test
+ // can only pass if the connection problem is not recognized merely via a timeout
+ Configuration configuration = new Configuration();
+ configuration.set(AkkaOptions.ASK_TIMEOUT_DURATION, Duration.ofSeconds(10000000));
+ final RpcService rpcService =
+ RpcSystem.load()
+ .localServiceBuilder(configuration)
+ .withBindAddress("localhost")
+ .withBindPort(0)
+ .createAndStart();
+ try {
CompletableFuture<TaskExecutorGateway> future =
rpcService.connect("foo.bar.com.test.invalid", TaskExecutorGateway.class);
@@ -87,25 +71,7 @@ public class RpcConnectionTest extends TestLogger {
} catch (Throwable t) {
fail("wrong exception: " + t);
} finally {
- final CompletableFuture<Void> rpcTerminationFuture;
-
- if (rpcService != null) {
- rpcTerminationFuture = rpcService.stopService();
- } else {
- rpcTerminationFuture = CompletableFuture.completedFuture(null);
- }
-
- final CompletableFuture<Terminated> actorSystemTerminationFuture;
-
- if (actorSystem != null) {
- actorSystemTerminationFuture = AkkaFutureUtils.toJava(actorSystem.terminate());
- } else {
- actorSystemTerminationFuture = CompletableFuture.completedFuture(null);
- }
-
- FutureUtils.waitForAll(
- Arrays.asList(rpcTerminationFuture, actorSystemTerminationFuture))
- .get();
+ rpcService.stopService().get();
}
}
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcEndpointTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcEndpointTest.java
index 97dacd2..87a18f7 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcEndpointTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcEndpointTest.java
@@ -19,21 +19,14 @@
package org.apache.flink.runtime.rpc;
import org.apache.flink.api.common.time.Time;
-import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.concurrent.akka.AkkaFutureUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceConfiguration;
+import org.apache.flink.configuration.Configuration;
import org.apache.flink.util.TestLogger;
-import org.apache.flink.util.concurrent.FutureUtils;
-import akka.actor.ActorSystem;
-import akka.actor.Terminated;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.time.Duration;
-import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
@@ -52,25 +45,16 @@ import static org.junit.Assert.fail;
public class RpcEndpointTest extends TestLogger {
private static final Time TIMEOUT = Time.seconds(10L);
- private static ActorSystem actorSystem = null;
private static RpcService rpcService = null;
@BeforeClass
- public static void setup() {
- actorSystem = AkkaUtils.createDefaultActorSystem();
- rpcService =
- new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
+ public static void setup() throws Exception {
+ rpcService = RpcSystem.load().localServiceBuilder(new Configuration()).createAndStart();
}
@AfterClass
public static void teardown() throws Exception {
-
- final CompletableFuture<Void> rpcTerminationFuture = rpcService.stopService();
- final CompletableFuture<Terminated> actorSystemTerminationFuture =
- AkkaFutureUtils.toJava(actorSystem.terminate());
-
- FutureUtils.waitForAll(Arrays.asList(rpcTerminationFuture, actorSystemTerminationFuture))
- .get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
+ rpcService.stopService().get();
}
/**
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcSSLAuthITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcSSLAuthITCase.java
index 335eb60..2083faa 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcSSLAuthITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/RpcSSLAuthITCase.java
@@ -21,14 +21,10 @@ package org.apache.flink.runtime.rpc;
import org.apache.flink.configuration.AkkaOptions;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.SecurityOptions;
-import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceConfiguration;
import org.apache.flink.runtime.rpc.exceptions.RpcConnectionException;
import org.apache.flink.util.TestLogger;
import org.apache.flink.util.concurrent.FutureUtils;
-import akka.actor.ActorSystem;
import org.junit.Test;
import java.time.Duration;
@@ -57,6 +53,9 @@ public class RpcSSLAuthITCase extends TestLogger {
public void testConnectFailure() throws Exception {
final Configuration baseConfig = new Configuration();
baseConfig.setString(AkkaOptions.TCP_TIMEOUT, "1 s");
+ // we start the RPC service with a very long timeout to ensure that the test
+ // can only pass if the connection problem is not recognized merely via a timeout
+ baseConfig.set(AkkaOptions.ASK_TIMEOUT_DURATION, Duration.ofSeconds(10000000));
// !!! This config has KEY_STORE_FILE / TRUST_STORE_FILE !!!
Configuration sslConfig1 = new Configuration(baseConfig);
@@ -80,28 +79,26 @@ public class RpcSSLAuthITCase extends TestLogger {
sslConfig2.setString(SecurityOptions.SSL_INTERNAL_TRUSTSTORE_PASSWORD, "password");
sslConfig2.setString(SecurityOptions.SSL_ALGORITHMS, "TLS_RSA_WITH_AES_128_CBC_SHA");
- ActorSystem actorSystem1 = null;
- ActorSystem actorSystem2 = null;
RpcService rpcService1 = null;
RpcService rpcService2 = null;
try {
- actorSystem1 = AkkaUtils.createActorSystem(sslConfig1, "localhost", 0);
- actorSystem2 = AkkaUtils.createActorSystem(sslConfig2, "localhost", 0);
-
// to test whether the test is still good:
// - create actorSystem2 with sslConfig1 (same as actorSystem1) and see that both can
// connect
// - set 'require-mutual-authentication = off' in the AkkaUtils ssl config section
-
- // we start the RPC service with a very long timeout to ensure that the test
- // can only pass if the connection problem is not recognized merely via a timeout
- Configuration configuration = new Configuration();
- configuration.set(AkkaOptions.ASK_TIMEOUT_DURATION, Duration.ofSeconds(10000000));
- AkkaRpcServiceConfiguration akkaRpcServiceConfig =
- AkkaRpcServiceConfiguration.fromConfiguration(configuration);
- rpcService1 = new AkkaRpcService(actorSystem1, akkaRpcServiceConfig);
- rpcService2 = new AkkaRpcService(actorSystem2, akkaRpcServiceConfig);
+ rpcService1 =
+ RpcSystem.load()
+ .localServiceBuilder(sslConfig1)
+ .withBindAddress("localhost")
+ .withBindPort(0)
+ .createAndStart();
+ rpcService2 =
+ RpcSystem.load()
+ .localServiceBuilder(sslConfig2)
+ .withBindAddress("localhost")
+ .withBindPort(0)
+ .createAndStart();
TestEndpoint endpoint = new TestEndpoint(rpcService1);
endpoint.start();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorOperatorEventHandlingTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorOperatorEventHandlingTest.java
index f5c1029..16deaaa 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorOperatorEventHandlingTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorOperatorEventHandlingTest.java
@@ -31,8 +31,8 @@ import org.apache.flink.runtime.jobgraph.OperatorID;
import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
import org.apache.flink.runtime.jobmaster.JobMasterId;
import org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
import org.apache.flink.runtime.metrics.MetricRegistryImpl;
+import org.apache.flink.runtime.metrics.MetricRegistryTestUtils;
import org.apache.flink.runtime.operators.coordination.OperatorEvent;
import org.apache.flink.runtime.operators.coordination.TestOperatorEvent;
import org.apache.flink.runtime.rpc.TestingRpcService;
@@ -68,7 +68,7 @@ public class TaskExecutorOperatorEventHandlingTest extends TestLogger {
rpcService = new TestingRpcService();
metricRegistry =
new MetricRegistryImpl(
- MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+ MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
metricRegistry.startQueryService(rpcService, new ResourceID("mqs"));
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunnerConfigurationTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunnerConfigurationTest.java
index 75ea99d..41076a9 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunnerConfigurationTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunnerConfigurationTest.java
@@ -31,6 +31,7 @@ import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
import org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils;
import org.apache.flink.runtime.rpc.AddressResolution;
import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.util.IOUtils;
import org.apache.flink.util.TestLogger;
import org.apache.flink.util.concurrent.Executors;
@@ -74,6 +75,8 @@ import static org.junit.Assume.assumeNoException;
@NotThreadSafe
public class TaskManagerRunnerConfigurationTest extends TestLogger {
+ private static final RpcSystem RPC_SYSTEM = RpcSystem.load();
+
private static final int TEST_TIMEOUT_SECONDS = 10;
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -90,7 +93,8 @@ public class TaskManagerRunnerConfigurationTest extends TestLogger {
RpcService taskManagerRpcService = null;
try {
taskManagerRpcService =
- TaskManagerRunner.createRpcService(config, highAvailabilityServices);
+ TaskManagerRunner.createRpcService(
+ config, highAvailabilityServices, RPC_SYSTEM);
assertThat(taskManagerRpcService.getPort(), is(greaterThanOrEqualTo(0)));
assertThat(taskManagerRpcService.getAddress(), is(equalTo(taskmanagerHost)));
@@ -109,7 +113,8 @@ public class TaskManagerRunnerConfigurationTest extends TestLogger {
RpcService taskManagerRpcService = null;
try {
taskManagerRpcService =
- TaskManagerRunner.createRpcService(config, highAvailabilityServices);
+ TaskManagerRunner.createRpcService(
+ config, highAvailabilityServices, RPC_SYSTEM);
assertThat(taskManagerRpcService.getAddress(), not(isEmptyOrNullString()));
} finally {
maybeCloseRpcService(taskManagerRpcService);
@@ -130,7 +135,8 @@ public class TaskManagerRunnerConfigurationTest extends TestLogger {
RpcService taskManagerRpcService = null;
try {
taskManagerRpcService =
- TaskManagerRunner.createRpcService(config, highAvailabilityServices);
+ TaskManagerRunner.createRpcService(
+ config, highAvailabilityServices, RPC_SYSTEM);
assertThat(taskManagerRpcService.getAddress(), is(ipAddress()));
} finally {
maybeCloseRpcService(taskManagerRpcService);
@@ -151,7 +157,7 @@ public class TaskManagerRunnerConfigurationTest extends TestLogger {
createHighAvailabilityServices(config);
try {
- TaskManagerRunner.createRpcService(config, highAvailabilityServices);
+ TaskManagerRunner.createRpcService(config, highAvailabilityServices, RPC_SYSTEM);
fail("Should fail because -1 is not a valid port range");
} catch (final IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("Invalid port range definition: -1"));
@@ -237,7 +243,10 @@ public class TaskManagerRunnerConfigurationTest extends TestLogger {
private HighAvailabilityServices createHighAvailabilityServices(final Configuration config)
throws Exception {
return HighAvailabilityServicesUtils.createHighAvailabilityServices(
- config, Executors.directExecutor(), AddressResolution.NO_ADDRESS_RESOLUTION);
+ config,
+ Executors.directExecutor(),
+ AddressResolution.NO_ADDRESS_RESOLUTION,
+ RpcSystem.load());
}
private static ServerSocket openServerSocket() {
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/util/AddressResolutionTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/util/AddressResolutionTest.java
index e5fbbed..53680fa 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/util/AddressResolutionTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/util/AddressResolutionTest.java
@@ -20,7 +20,7 @@ package org.apache.flink.runtime.util;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.rpc.AddressResolution;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.util.TestLogger;
import org.junit.BeforeClass;
@@ -35,6 +35,8 @@ import static org.junit.Assume.assumeTrue;
/** Unit tests for respecting {@link AddressResolution}. */
public class AddressResolutionTest extends TestLogger {
+ private static final RpcSystem RPC_SYSTEM = RpcSystem.load();
+
private static final String ENDPOINT_NAME = "endpoint";
private static final String NON_EXISTING_HOSTNAME = "foo.bar.com.invalid";
private static final int PORT = 17234;
@@ -63,7 +65,7 @@ public class AddressResolutionTest extends TestLogger {
@Test
public void testNoAddressResolution() throws UnknownHostException {
- AkkaRpcServiceUtils.getRpcUrl(
+ RPC_SYSTEM.getRpcUrl(
NON_EXISTING_HOSTNAME,
PORT,
ENDPOINT_NAME,
@@ -74,7 +76,7 @@ public class AddressResolutionTest extends TestLogger {
@Test
public void testTryAddressResolution() {
try {
- AkkaRpcServiceUtils.getRpcUrl(
+ RPC_SYSTEM.getRpcUrl(
NON_EXISTING_HOSTNAME,
PORT,
ENDPOINT_NAME,
diff --git a/flink-runtime/src/test/scala/akka/actor/RobustActorSystemTest.scala b/flink-runtime/src/test/scala/akka/actor/RobustActorSystemTest.scala
index 33a6da4..025c8fd 100644
--- a/flink-runtime/src/test/scala/akka/actor/RobustActorSystemTest.scala
+++ b/flink-runtime/src/test/scala/akka/actor/RobustActorSystemTest.scala
@@ -19,6 +19,7 @@
package akka.actor
import org.apache.flink.runtime.akka.AkkaUtils
+import org.apache.flink.runtime.rpc.RpcUtils
import org.apache.flink.util.concurrent.TestingUncaughtExceptionHandler
import org.junit.{After, Before, Test}
import org.scalatest.Matchers
@@ -36,7 +37,7 @@ class RobustActorSystemTest extends JUnitSuite with Matchers {
testingUncaughtExceptionHandler = new TestingUncaughtExceptionHandler
robustActorSystem = RobustActorSystem.create(
"testSystem",
- AkkaUtils.testDispatcherConfig,
+ AkkaUtils.getForkJoinExecutorConfig(RpcUtils.getTestForkJoinExecutorConfiguration),
testingUncaughtExceptionHandler)
}
diff --git a/flink-runtime/src/test/scala/org/apache/flink/runtime/akka/AkkaUtilsTest.scala b/flink-runtime/src/test/scala/org/apache/flink/runtime/akka/AkkaUtilsTest.scala
index 92e1c35..206cdd4 100644
--- a/flink-runtime/src/test/scala/org/apache/flink/runtime/akka/AkkaUtilsTest.scala
+++ b/flink-runtime/src/test/scala/org/apache/flink/runtime/akka/AkkaUtilsTest.scala
@@ -22,7 +22,7 @@ import java.net.{InetAddress, InetSocketAddress}
import java.util.Collections
import org.apache.flink.configuration.{AkkaOptions, Configuration, IllegalConfigurationException, SecurityOptions}
import org.apache.flink.runtime.rpc.AddressResolution
-import org.apache.flink.runtime.rpc.akka.AkkaBootstrapTools.FixedThreadPoolExecutorConfiguration
+import org.apache.flink.runtime.rpc.RpcSystem
import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils
import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils.AkkaProtocol
import org.apache.flink.util.NetUtils
@@ -175,8 +175,9 @@ class AkkaUtilsTest
"localhost",
1234,
AkkaUtils.getThreadPoolExecutorConfig(
- new FixedThreadPoolExecutorConfiguration(minThreads, maxThreads, threadPriority)
- ))
+ new RpcSystem.FixedThreadPoolExecutorConfiguration(
+ minThreads, maxThreads, threadPriority))
+ )
akkaConfig.getString("akka.actor.default-dispatcher.executor") should
equal("thread-pool-executor")
diff --git a/flink-tests/src/test/java/org/apache/flink/runtime/operators/coordination/OperatorEventSendingCheckpointITCase.java b/flink-tests/src/test/java/org/apache/flink/runtime/operators/coordination/OperatorEventSendingCheckpointITCase.java
index e510a83..e31336c 100644
--- a/flink-tests/src/test/java/org/apache/flink/runtime/operators/coordination/OperatorEventSendingCheckpointITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/runtime/operators/coordination/OperatorEventSendingCheckpointITCase.java
@@ -31,18 +31,19 @@ import org.apache.flink.api.connector.source.lib.util.IteratorSourceReader;
import org.apache.flink.api.connector.source.lib.util.IteratorSourceSplit;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.io.InputStatus;
-import org.apache.flink.runtime.akka.AkkaUtils;
import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
import org.apache.flink.runtime.jobgraph.OperatorID;
import org.apache.flink.runtime.messages.Acknowledge;
import org.apache.flink.runtime.minicluster.MiniCluster;
import org.apache.flink.runtime.minicluster.MiniClusterConfiguration;
import org.apache.flink.runtime.minicluster.RpcServiceSharing;
+import org.apache.flink.runtime.rpc.FencedRpcGateway;
+import org.apache.flink.runtime.rpc.RpcEndpoint;
import org.apache.flink.runtime.rpc.RpcGateway;
+import org.apache.flink.runtime.rpc.RpcServer;
import org.apache.flink.runtime.rpc.RpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceConfiguration;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
+import org.apache.flink.runtime.rpc.RpcSystem;
+import org.apache.flink.runtime.rpc.RpcUtils;
import org.apache.flink.runtime.source.event.AddSplitEvent;
import org.apache.flink.runtime.source.event.NoMoreSplitsEvent;
import org.apache.flink.runtime.taskexecutor.TaskExecutorGateway;
@@ -53,15 +54,16 @@ import org.apache.flink.streaming.util.TestStreamEnvironment;
import org.apache.flink.util.SerializedValue;
import org.apache.flink.util.TestLogger;
import org.apache.flink.util.concurrent.FutureUtils;
+import org.apache.flink.util.concurrent.ScheduledExecutor;
import org.apache.flink.util.function.TriFunction;
-import akka.actor.ActorSystem;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import javax.annotation.Nullable;
+import java.io.Serializable;
import java.time.Duration;
import java.util.ArrayDeque;
import java.util.Collection;
@@ -69,7 +71,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.Set;
+import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -450,19 +455,87 @@ public class OperatorEventSendingCheckpointITCase extends TestLogger {
}
}
- private static class InterceptingRpcService extends AkkaRpcService {
+ private static class InterceptingRpcService implements RpcService {
- public InterceptingRpcService(
- ActorSystem actorSystem, AkkaRpcServiceConfiguration configuration) {
- super(actorSystem, configuration);
+ private final RpcService rpcService;
+
+ public InterceptingRpcService(RpcService rpcService) {
+ this.rpcService = rpcService;
+ }
+
+ @Override
+ public String getAddress() {
+ return rpcService.getAddress();
+ }
+
+ @Override
+ public int getPort() {
+ return rpcService.getPort();
}
@Override
public <C extends RpcGateway> CompletableFuture<C> connect(String address, Class<C> clazz) {
- final CompletableFuture<C> future = super.connect(address, clazz);
+ final CompletableFuture<C> future = rpcService.connect(address, clazz);
return clazz == TaskExecutorGateway.class ? decorateTmGateway(future) : future;
}
+ @Override
+ public <F extends Serializable, C extends FencedRpcGateway<F>> CompletableFuture<C> connect(
+ String address, F fencingToken, Class<C> clazz) {
+ return rpcService.connect(address, fencingToken, clazz);
+ }
+
+ @Override
+ public <C extends RpcEndpoint & RpcGateway> RpcServer startServer(C rpcEndpoint) {
+ return rpcService.startServer(rpcEndpoint);
+ }
+
+ @Override
+ public <F extends Serializable> RpcServer fenceRpcServer(
+ RpcServer rpcServer, F fencingToken) {
+ return rpcService.fenceRpcServer(rpcServer, fencingToken);
+ }
+
+ @Override
+ public void stopServer(RpcServer selfGateway) {
+ rpcService.stopServer(selfGateway);
+ }
+
+ @Override
+ public CompletableFuture<Void> stopService() {
+ return rpcService.stopService();
+ }
+
+ @Override
+ public CompletableFuture<Void> getTerminationFuture() {
+ return rpcService.getTerminationFuture();
+ }
+
+ @Override
+ public Executor getExecutor() {
+ return rpcService.getExecutor();
+ }
+
+ @Override
+ public ScheduledExecutor getScheduledExecutor() {
+ return rpcService.getScheduledExecutor();
+ }
+
+ @Override
+ public ScheduledFuture<?> scheduleRunnable(Runnable runnable, long delay, TimeUnit unit) {
+ return rpcService.scheduleRunnable(runnable, delay, unit);
+ }
+
+ @Override
+ public void execute(Runnable runnable) {
+ rpcService.execute(runnable);
+ }
+
+ @Override
+ public <T> CompletableFuture<T> execute(Callable<T> callable) {
+ return rpcService.execute(callable);
+ }
+
@SuppressWarnings("unchecked")
private <C extends RpcGateway> CompletableFuture<C> decorateTmGateway(
CompletableFuture<C> future) {
@@ -499,12 +572,16 @@ public class OperatorEventSendingCheckpointITCase extends TestLogger {
}
@Override
- protected RpcService createLocalRpcService(Configuration configuration) throws Exception {
+ protected RpcService createLocalRpcService(Configuration configuration, RpcSystem rpcSystem)
+ throws Exception {
localRpcCreated = true;
- return AkkaRpcServiceUtils.localServiceBuilder(configuration)
- .withCustomConfig(AkkaUtils.testDispatcherConfig())
- .createAndStart(InterceptingRpcService::new);
+ return new InterceptingRpcService(
+ rpcSystem
+ .localServiceBuilder(configuration)
+ .withExecutorConfiguration(
+ RpcUtils.getTestForkJoinExecutorConfiguration())
+ .createAndStart());
}
}
}
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java
index 26fb2f1..fb3acc7 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java
@@ -41,8 +41,8 @@ import org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils;
import org.apache.flink.runtime.leaderelection.TestingListener;
import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService;
import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.runtime.rpc.RpcUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
import org.apache.flink.runtime.taskexecutor.TaskExecutorResourceUtils;
import org.apache.flink.runtime.taskexecutor.TaskManagerRunner;
import org.apache.flink.runtime.testutils.DispatcherProcess;
@@ -272,7 +272,7 @@ public class JobManagerHAProcessFailureRecoveryITCase extends TestLogger {
TaskExecutorResourceUtils.adjustForLocalExecution(config);
final RpcService rpcService =
- AkkaRpcServiceUtils.remoteServiceBuilder(config, "localhost", 0).createAndStart();
+ RpcSystem.load().remoteServiceBuilder(config, "localhost", "0").createAndStart();
try {
final Deadline deadline = Deadline.fromNow(TEST_TIMEOUT);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java
index 578a75b..3fb6780 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java
@@ -44,8 +44,8 @@ import org.apache.flink.runtime.metrics.NoOpMetricRegistry;
import org.apache.flink.runtime.resourcemanager.StandaloneResourceManagerFactory;
import org.apache.flink.runtime.rpc.AddressResolution;
import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.runtime.rpc.RpcUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils;
import org.apache.flink.runtime.testutils.TestingUtils;
import org.apache.flink.runtime.util.BlobServerResource;
import org.apache.flink.runtime.util.TestingFatalErrorHandler;
@@ -115,7 +115,7 @@ public class ProcessFailureCancelingITCase extends TestLogger {
config.setInteger(RestOptions.PORT, 0);
final RpcService rpcService =
- AkkaRpcServiceUtils.remoteServiceBuilder(config, "localhost", 0).createAndStart();
+ RpcSystem.load().remoteServiceBuilder(config, "localhost", "0").createAndStart();
final int jobManagerPort = rpcService.getPort();
config.setInteger(JobManagerOptions.PORT, jobManagerPort);
@@ -127,7 +127,10 @@ public class ProcessFailureCancelingITCase extends TestLogger {
final ScheduledExecutorService ioExecutor = TestingUtils.defaultExecutor();
final HighAvailabilityServices haServices =
HighAvailabilityServicesUtils.createHighAvailabilityServices(
- config, ioExecutor, AddressResolution.NO_ADDRESS_RESOLUTION);
+ config,
+ ioExecutor,
+ AddressResolution.NO_ADDRESS_RESOLUTION,
+ RpcSystem.load());
final AtomicReference<Throwable> programException = new AtomicReference<>();
diff --git a/flink-tests/src/test/java/org/apache/flink/test/runtime/IPv6HostnamesITCase.java b/flink-tests/src/test/java/org/apache/flink/test/runtime/IPv6HostnamesITCase.java
index 9916faf..93af2fa 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/runtime/IPv6HostnamesITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/runtime/IPv6HostnamesITCase.java
@@ -26,7 +26,8 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.configuration.MemorySize;
import org.apache.flink.configuration.TaskManagerOptions;
-import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcSystem;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.test.testdata.WordCountData;
import org.apache.flink.test.util.MiniClusterWithClientResource;
@@ -35,7 +36,6 @@ import org.apache.flink.util.Collector;
import org.apache.flink.util.NetUtils;
import org.apache.flink.util.TestLogger;
-import akka.actor.ActorSystem;
import org.junit.AssumptionViolatedException;
import org.junit.Rule;
import org.junit.Test;
@@ -49,8 +49,6 @@ import java.net.ServerSocket;
import java.util.Enumeration;
import java.util.List;
-import scala.Some;
-
import static org.junit.Assert.fail;
/** Test proper handling of IPv6 address literals in URLs. */
@@ -149,13 +147,14 @@ public class IPv6HostnamesITCase extends TestLogger {
// test whether Akka's netty can bind to the address
log.info("Testing whether Akka can use " + addr);
int port = NetUtils.getAvailablePort();
- ActorSystem as =
- AkkaUtils.createActorSystem(
- new Configuration(),
- new Some<scala.Tuple2<String, Object>>(
- new scala.Tuple2<String, Object>(
- addr.getHostAddress(), port)));
- as.terminate();
+
+ final RpcService rpcService =
+ RpcSystem.load()
+ .localServiceBuilder(new Configuration())
+ .withBindAddress(addr.getHostAddress())
+ .withBindPort(port)
+ .createAndStart();
+ rpcService.stopService().get();
log.info("Using address " + addr);
return (Inet6Address) addr;