Skip to content

Commit f294d96

Browse files
committed
HDDS-14932. Support optional Recon startup in ozone local
1 parent 4314efb commit f294d96

12 files changed

Lines changed: 493 additions & 22 deletions

File tree

hadoop-hdds/docs/content/tools/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Client commands:
4444
* **sh** - Primary command line interface for ozone to manage volumes/buckets/keys.
4545
* **fs** - Runs a command on ozone file system (similar to `hdfs dfs`)
4646
* **local** - Runs a single-node local Ozone cluster (SCM, OM, datanodes,
47-
and optional S3 Gateway) in one process for development.
47+
and optional S3 Gateway and Recon) in one process for development.
4848
* **version** - Prints the version of Ozone and HDDS.
4949

5050

hadoop-ozone/integration-test-recon/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@
180180
<artifactId>ozone-reconcodegen</artifactId>
181181
<scope>test</scope>
182182
</dependency>
183+
<dependency>
184+
<groupId>org.apache.ozone</groupId>
185+
<artifactId>ozone-tools</artifactId>
186+
<scope>test</scope>
187+
</dependency>
183188
<dependency>
184189
<groupId>org.apache.ratis</groupId>
185190
<artifactId>ratis-common</artifactId>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.hadoop.ozone.local;
19+
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
21+
22+
import java.net.HttpURLConnection;
23+
import java.net.URL;
24+
import java.nio.file.Path;
25+
import java.time.Duration;
26+
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
27+
import org.junit.jupiter.api.Test;
28+
import org.junit.jupiter.api.io.TempDir;
29+
30+
/**
31+
* Integration tests for Recon in the {@code ozone local} runtime.
32+
*/
33+
class TestLocalOzoneRecon {
34+
35+
@TempDir
36+
private Path tempDir;
37+
38+
@Test
39+
void reconServesRequestsWhenEnabled() throws Exception {
40+
LocalOzoneClusterConfig config = LocalOzoneClusterConfig.builder(
41+
tempDir.resolve("local-ozone-recon"))
42+
.setS3gEnabled(false)
43+
.setReconEnabled(true)
44+
.setStartupTimeout(Duration.ofMinutes(2))
45+
.build();
46+
47+
try (LocalOzoneCluster cluster = new LocalOzoneCluster(config, new OzoneConfiguration())) {
48+
cluster.start();
49+
50+
assertTrue(cluster.getReconPort() > 0);
51+
assertHttpEndpointResponds(cluster.getReconEndpoint());
52+
}
53+
}
54+
55+
private static void assertHttpEndpointResponds(String endpoint) throws Exception {
56+
HttpURLConnection connection = (HttpURLConnection) new URL(endpoint).openConnection();
57+
try {
58+
connection.setConnectTimeout(1_000);
59+
connection.setReadTimeout(1_000);
60+
// Any HTTP response proves Recon is serving requests.
61+
assertTrue(connection.getResponseCode() > 0, endpoint);
62+
} finally {
63+
connection.disconnect();
64+
}
65+
}
66+
}

hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ConfigurationProvider.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.hadoop.ozone.recon;
1919

20-
import com.google.common.annotations.VisibleForTesting;
2120
import com.google.inject.Provider;
2221
import org.apache.hadoop.conf.Configuration;
2322
import org.apache.hadoop.conf.Configuration.DeprecationDelta;
@@ -50,16 +49,14 @@ private static void addDeprecations() {
5049
});
5150
}
5251

53-
@VisibleForTesting
5452
public static void setConfiguration(OzoneConfiguration conf) {
55-
// Nullity check is used in case the configuration was already set
56-
// in the MiniOzoneCluster
53+
// Nullity check is used in case the configuration was already set by a
54+
// same-JVM launcher (MiniOzoneCluster or ozone local)
5755
if (configuration == null) {
5856
ConfigurationProvider.configuration = conf;
5957
}
6058
}
6159

62-
@VisibleForTesting
6360
public static void resetConfiguration() {
6461
configuration = null;
6562
}

hadoop-ozone/tools/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
<groupId>org.apache.ozone</groupId>
8383
<artifactId>ozone-manager</artifactId>
8484
</dependency>
85+
<dependency>
86+
<groupId>org.apache.ozone</groupId>
87+
<artifactId>ozone-recon</artifactId>
88+
</dependency>
8589
<dependency>
8690
<groupId>org.apache.ozone</groupId>
8791
<artifactId>ozone-s3gateway</artifactId>

0 commit comments

Comments
 (0)