Skip to content

Commit fb851c9

Browse files
committed
HDDS-1232. Recon Container DB service definition. Contributed by Aravindan Vijayan.
1 parent 373705f commit fb851c9

File tree

22 files changed

+785
-24
lines changed

22 files changed

+785
-24
lines changed

hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/LevelDBStoreIterator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ public void seekToFirst() {
6161
public void seekToLast() {
6262
levelDBIterator.seekToLast();
6363
}
64+
65+
@Override
66+
public void prefixSeek(byte[] prefix) {
67+
levelDBIterator.seek(prefix);
68+
}
6469
}

hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/MetaStoreIterator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ public interface MetaStoreIterator<T> extends Iterator<T> {
3636
*/
3737
void seekToLast();
3838

39+
/**
40+
* seek with prefix.
41+
*/
42+
void prefixSeek(byte[] prefix);
43+
3944
}

hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/RocksDBStoreIterator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,9 @@ public void seekToLast() {
6363
rocksDBIterator.seekToLast();
6464
}
6565

66+
@Override
67+
public void prefixSeek(byte[] prefix) {
68+
rocksDBIterator.seek(prefix);
69+
}
70+
6671
}

hadoop-hdds/common/src/main/resources/ozone-default.xml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,4 +2144,98 @@
21442144
milliseconds.
21452145
</description>
21462146
</property>
2147+
<property>
2148+
<name>ozone.recon.http.enabled</name>
2149+
<value>true</value>
2150+
<tag>RECON, MANAGEMENT</tag>
2151+
<description>
2152+
Property to enable or disable Recon web user interface.
2153+
</description>
2154+
</property>
2155+
<property>
2156+
<name>ozone.recon.http-address</name>
2157+
<value>0.0.0.0:9888</value>
2158+
<tag>RECON, MANAGEMENT</tag>
2159+
<description>
2160+
The address and the base port where the Recon web UI will listen on.
2161+
2162+
If the port is 0, then the server will start on a free port. However, it
2163+
is best to specify a well-known port, so it is easy to connect and see
2164+
the Recon management UI.
2165+
</description>
2166+
</property>
2167+
<property>
2168+
<name>ozone.recon.http-bind-host</name>
2169+
<value>0.0.0.0</value>
2170+
<tag>RECON, MANAGEMENT</tag>
2171+
<description>
2172+
The actual address the Recon server will bind to. If this optional
2173+
the address is set, it overrides only the hostname portion of
2174+
ozone.recon.http-address.
2175+
</description>
2176+
</property>
2177+
<property>
2178+
<name>ozone.recon.https-bind-host</name>
2179+
<value>0.0.0.0</value>
2180+
<tag>RECON, MANAGEMENT, SECURITY</tag>
2181+
<description>
2182+
The actual address the Recon web server will bind to using HTTPS.
2183+
If this optional address is set, it overrides only the hostname portion of
2184+
ozone.recon.https-address.
2185+
</description>
2186+
</property>
2187+
<property>
2188+
<name>ozone.recon.https-address</name>
2189+
<value>0.0.0.0:9889</value>
2190+
<tag>RECON, MANAGEMENT, SECURITY</tag>
2191+
<description>
2192+
The address and the base port where the Recon web UI will listen
2193+
on using HTTPS. If the port is 0 then the server will start on a free
2194+
port.
2195+
</description>
2196+
</property>
2197+
<property>
2198+
<name>ozone.recon.keytab.file</name>
2199+
<value/>
2200+
<tag>RECON, SECURITY</tag>
2201+
<description>
2202+
The keytab file for Kerberos authentication in Recon.
2203+
</description>
2204+
</property>
2205+
<property>
2206+
<name>ozone.recon.authentication.kerberos.principal</name>
2207+
<value/>
2208+
<tag>RECON</tag>
2209+
<description>The server principal used by Ozone Recon server. This is
2210+
typically set to HTTP/[email protected] The SPNEGO server principal
2211+
begins with the prefix HTTP/ by convention.
2212+
</description>
2213+
</property>
2214+
<property>
2215+
<name>ozone.recon.container.db.cache.size.mb</name>
2216+
<value>128</value>
2217+
<tag>RECON, PERFORMANCE</tag>
2218+
<description>
2219+
The size of Recon DB cache in MB that used for caching files.
2220+
This value is set to an abnormally low value in the default configuration.
2221+
That is to make unit testing easy. Generally, this value should be set to
2222+
something like 16GB or more, if you intend to use Recon at scale.
2223+
2224+
A large value for this key allows a proportionally larger amount of Recon
2225+
container DB to be cached in memory. This makes Recon Container-Key
2226+
operations faster.
2227+
</description>
2228+
</property>
2229+
<property>
2230+
<name>ozone.recon.db.dirs</name>
2231+
<value/>
2232+
<tag>OZONE, RECON, STORAGE, PERFORMANCE</tag>
2233+
<description>
2234+
Directory where the Recon Server stores its metadata. This should
2235+
be specified as a single directory. If the directory does not
2236+
exist then the Recon will attempt to create it.
2237+
If undefined, then the Recon will log a warning and fallback to
2238+
ozone.metadata.dirs.
2239+
</description>
2240+
</property>
21472241
</configuration>

hadoop-hdds/common/src/test/java/org/apache/hadoop/utils/TestMetadataStore.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,58 @@ public void testIterator() throws Exception {
163163

164164
}
165165

166+
167+
@Test
168+
public void testIteratorPrefixSeek() throws Exception {
169+
Configuration conf = new OzoneConfiguration();
170+
conf.set(OzoneConfigKeys.OZONE_METADATA_STORE_IMPL, storeImpl);
171+
File dbDir = GenericTestUtils.getRandomizedTestDir();
172+
MetadataStore dbStore = MetadataStoreBuilder.newBuilder()
173+
.setConf(conf)
174+
.setCreateIfMissing(true)
175+
.setDbFile(dbDir)
176+
.build();
177+
178+
for (int i = 0; i < 5; i++) {
179+
dbStore.put(getBytes("a" + i), getBytes("a-value" + i));
180+
}
181+
182+
for (int i = 0; i < 5; i++) {
183+
dbStore.put(getBytes("b" + i), getBytes("b-value" + i));
184+
}
185+
186+
for (int i = 0; i < 5; i++) {
187+
dbStore.put(getBytes("c" + i), getBytes("c-value" + i));
188+
}
189+
190+
for (int i = 5; i < 10; i++) {
191+
dbStore.put(getBytes("b" + i), getBytes("b-value" + i));
192+
}
193+
194+
for (int i = 5; i < 10; i++) {
195+
dbStore.put(getBytes("a" + i), getBytes("a-value" + i));
196+
}
197+
198+
199+
MetaStoreIterator<KeyValue> metaStoreIterator = dbStore.iterator();
200+
metaStoreIterator.prefixSeek(getBytes("b"));
201+
int i = 0;
202+
while (metaStoreIterator.hasNext()) {
203+
KeyValue val = metaStoreIterator.next();
204+
String key = getString(val.getKey());
205+
if (key.startsWith("b")) {
206+
assertEquals("b-value" + i, getString(val.getValue()));
207+
} else {
208+
break;
209+
}
210+
i++;
211+
}
212+
assertTrue(i == 10);
213+
dbStore.close();
214+
dbStore.destroy();
215+
FileUtils.deleteDirectory(dbDir);
216+
}
217+
166218
@Test
167219
public void testMetaStoreConfigDifferentFromType() throws IOException {
168220

hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServerUtils.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,29 @@ public static void releaseConnection(HttpRequestBase request) {
125125
* @return
126126
*/
127127
public static File getScmDbDir(Configuration conf) {
128-
final Collection<String> metadirs = conf.getTrimmedStringCollection(
129-
ScmConfigKeys.OZONE_SCM_DB_DIRS);
128+
129+
File metadataDir = getDirWithFallBackToOzoneMetadata(conf, ScmConfigKeys
130+
.OZONE_SCM_DB_DIRS, "SCM");
131+
if (metadataDir != null) {
132+
return metadataDir;
133+
}
134+
135+
LOG.warn("{} is not configured. We recommend adding this setting. " +
136+
"Falling back to {} instead.",
137+
ScmConfigKeys.OZONE_SCM_DB_DIRS, HddsConfigKeys.OZONE_METADATA_DIRS);
138+
return getOzoneMetaDirPath(conf);
139+
}
140+
141+
public static File getDirWithFallBackToOzoneMetadata(Configuration conf,
142+
String key,
143+
String componentName) {
144+
final Collection<String> metadirs = conf.getTrimmedStringCollection(key);
130145

131146
if (metadirs.size() > 1) {
132147
throw new IllegalArgumentException(
133-
"Bad config setting " + ScmConfigKeys.OZONE_SCM_DB_DIRS +
134-
". SCM does not support multiple metadata dirs currently");
148+
"Bad config setting " + key +
149+
". " + componentName +
150+
" does not support multiple metadata dirs currently");
135151
}
136152

137153
if (metadirs.size() == 1) {
@@ -143,11 +159,7 @@ public static File getScmDbDir(Configuration conf) {
143159
}
144160
return dbDirPath;
145161
}
146-
147-
LOG.warn("{} is not configured. We recommend adding this setting. " +
148-
"Falling back to {} instead.",
149-
ScmConfigKeys.OZONE_SCM_DB_DIRS, HddsConfigKeys.OZONE_METADATA_DIRS);
150-
return getOzoneMetaDirPath(conf);
162+
return null;
151163
}
152164

153165
/**

hadoop-ozone/dist/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@
103103
<classifier>classpath</classifier>
104104
<destFileName>hadoop-ozone-datanode.classpath</destFileName>
105105
</artifactItem>
106+
<artifactItem>
107+
<groupId>org.apache.hadoop</groupId>
108+
<artifactId>hadoop-ozone-recon</artifactId>
109+
<version>${ozone.version}</version>
110+
<classifier>classpath</classifier>
111+
<destFileName>hadoop-ozone-recon.classpath</destFileName>
112+
</artifactItem>
106113
</artifactItems>
107114
</configuration>
108115
</execution>

hadoop-ozone/integration-test/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
5252
<groupId>org.apache.hadoop</groupId>
5353
<artifactId>hadoop-ozone-s3gateway</artifactId>
5454
</dependency>
55+
<dependency>
56+
<groupId>org.apache.hadoop</groupId>
57+
<artifactId>hadoop-ozone-recon</artifactId>
58+
</dependency>
5559
<dependency>
5660
<groupId>org.apache.hadoop</groupId>
5761
<artifactId>hadoop-ozone-client</artifactId>

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestOzoneConfigurationFields.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.hadoop.hdds.HddsConfigKeys;
2222
import org.apache.hadoop.ozone.om.OMConfigKeys;
2323
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
24+
import org.apache.hadoop.ozone.recon.ReconServerConfigKeys;
2425
import org.apache.hadoop.ozone.s3.S3GatewayConfigKeys;
2526

2627
/**
@@ -34,6 +35,7 @@ public void initializeMemberVariables() {
3435
configurationClasses =
3536
new Class[] {OzoneConfigKeys.class, ScmConfigKeys.class,
3637
OMConfigKeys.class, HddsConfigKeys.class,
38+
ReconServerConfigKeys.class,
3739
S3GatewayConfigKeys.class};
3840
errorIfMissingConfigProps = true;
3941
errorIfMissingXmlProps = true;

hadoop-ozone/ozone-recon/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</parent>
2323
<name>Apache Hadoop Ozone Recon</name>
2424
<modelVersion>4.0.0</modelVersion>
25-
<artifactId>ozone-recon</artifactId>
25+
<artifactId>hadoop-ozone-recon</artifactId>
2626
<dependencies>
2727
<dependency>
2828
<groupId>org.apache.hadoop</groupId>
@@ -50,5 +50,16 @@
5050
<artifactId>guice-assistedinject</artifactId>
5151
<version>4.1.0</version>
5252
</dependency>
53+
<dependency>
54+
<groupId>junit</groupId>
55+
<artifactId>junit</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.mockito</groupId>
60+
<artifactId>mockito-all</artifactId>
61+
<version>1.10.19</version>
62+
<scope>test</scope>
63+
</dependency>
5364
</dependencies>
5465
</project>

0 commit comments

Comments
 (0)