forked from apache/ozone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDDS-11650. ContainerId list to track all containers created in a dat…
…anode (#4) * HDDS-11650. ContainerId list to track all containers created in a datanode Change-Id: I94fd413a2d778ac5d86a7da5126cf3d1cac8113a * HDDS-11650. Fix test cases Change-Id: I22654091edbd3a11c585aa95ca2b554eba0f9d95 * HDDS-11650. Add comments Change-Id: Icaa5ae0b29ec0ffccf5914bec0fd6ed6ae117219 * HDDS-11650. Fix tests Change-Id: I995fc25b93f16aa859eeb8f0418aa774e3719330 * HDDS-11650. Remove from rocskdb Change-Id: Ibeadc9330185f699e4cf1d9c1c8631d1af52683e * HDDS-11650. Fix checkstyle Change-Id: I5ac6a685a49e79be5ea43717294dd649383433f2 * HDDS-11650. Fix Issues Change-Id: I18f48f9d97b0cc16a3c97a3137ee01ebda4fcbec * HDDS-11650. Fix checkstyle & rat Change-Id: I16cec52ea1c2853c80ee9a6e3279a23408d05651 * HDDS-11650. Fix checkstyle & rat Change-Id: Icf779e2bff8ace1721b529e3c89edbe9effa9989 * HDDS-11650. Fix tests failures Change-Id: I485646e86105a8a1bab6b638262669fc5f92d94d * HDDS-11650. Fix tests failures Change-Id: I03ab7dd188ae39248ca889f40b9490eb2870579f * HDDS-11650. Fix MasterVolumeMetaStore cache Change-Id: I82647ef09edc6fd9432652d911bf2ff4bccf25a5 * HDDS-11650. Fix MasterVolumeMetaStore cache Change-Id: I73091fc280dea5ad447b9df8bb0a1877d8f1ff35 * HDDS-11650. Fix MasterVolumeMetaStore cache Change-Id: Ife63a4ab2a69869cce9d1c407bfdeba2540d2482 * HDDS-11650. Fix acceptance tests Change-Id: Ic9fe75b9efe885080e3ad440f132eb0100c41a17 * HDDS-11650. Fix acceptance tests Change-Id: I5a8e092d8fb751a2ca69256740df59edd59b9b95 * HDDS-11650. Add an integration test to test dn restarts with missing containers Change-Id: Ic67537ed852920d8945430665e22eeddc7350d6e * HDDS-11650. Address review comments Change-Id: Icf8b45e0c2de6d353f3f880c441de7d7a6138009 * HDDS-11650. Address review comments Change-Id: I7ead428f7ff82968a0f1e5058bbf65f3b807bdb9 * HDDS-11650. Reduce number of files changed Change-Id: I4476c42d2c8c11af64fc5808eafcecc9046bd2e8 * HDDS-11650. Fix checkstyle Change-Id: I33f2a74daa2812d227e985b1a0738bc0be99e6e7
- Loading branch information
1 parent
79ca956
commit d9bff79
Showing
47 changed files
with
1,270 additions
and
307 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/Proto2EnumCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* 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.hadoop.hdds.utils.db; | ||
|
||
import org.apache.ratis.thirdparty.com.google.protobuf.ProtocolMessageEnum; | ||
import jakarta.annotation.Nonnull; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.ConcurrentMap; | ||
|
||
/** | ||
* Codecs to serialize/deserialize Protobuf v2 enums. | ||
*/ | ||
public final class Proto2EnumCodec<M extends ProtocolMessageEnum> | ||
implements Codec<M> { | ||
private static final ConcurrentMap<Class<? extends ProtocolMessageEnum>, | ||
Codec<? extends ProtocolMessageEnum>> CODECS | ||
= new ConcurrentHashMap<>(); | ||
private static final IntegerCodec INTEGER_CODEC = IntegerCodec.get(); | ||
|
||
/** | ||
* @return the {@link Codec} for the given class. | ||
*/ | ||
public static <T extends ProtocolMessageEnum> Codec<T> get(T t) { | ||
final Codec<?> codec = CODECS.computeIfAbsent(t.getClass(), | ||
key -> new Proto2EnumCodec<>(t)); | ||
return (Codec<T>) codec; | ||
} | ||
|
||
private final Class<M> clazz; | ||
|
||
private Proto2EnumCodec(M m) { | ||
this.clazz = (Class<M>) m.getClass(); | ||
} | ||
|
||
@Override | ||
public Class<M> getTypeClass() { | ||
return clazz; | ||
} | ||
|
||
@Override | ||
public boolean supportCodecBuffer() { | ||
return INTEGER_CODEC.supportCodecBuffer(); | ||
} | ||
|
||
@Override | ||
public CodecBuffer toCodecBuffer(@Nonnull M value, | ||
CodecBuffer.Allocator allocator) throws IOException { | ||
return INTEGER_CODEC.toCodecBuffer(value.getNumber(), allocator); | ||
} | ||
|
||
private M parseFrom(Integer value) throws IOException { | ||
try { | ||
return (M) this.clazz.getDeclaredMethod("forNumber", int.class).invoke(null, value); | ||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { | ||
throw new IOException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public M fromCodecBuffer(@Nonnull CodecBuffer buffer) | ||
throws IOException { | ||
return parseFrom(INTEGER_CODEC.fromCodecBuffer(buffer)); | ||
} | ||
|
||
@Override | ||
public byte[] toPersistedFormat(M value) { | ||
return INTEGER_CODEC.toPersistedFormat(value.getNumber()); | ||
} | ||
|
||
@Override | ||
public M fromPersistedFormat(byte[] bytes) throws IOException { | ||
return parseFrom(INTEGER_CODEC.fromPersistedFormat(bytes)); | ||
} | ||
|
||
@Override | ||
public M copyObject(M message) { | ||
// proto messages are immutable | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...rvice/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/BaseDBHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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.hadoop.ozone.container.common.interfaces; | ||
|
||
import org.apache.hadoop.ozone.container.metadata.AbstractStore; | ||
|
||
import java.io.Closeable; | ||
|
||
/** | ||
* DB handle abstract class. | ||
*/ | ||
public abstract class BaseDBHandle<STORE extends AbstractStore> implements Closeable { | ||
|
||
private final STORE store; | ||
private final String containerDBPath; | ||
|
||
public BaseDBHandle(STORE store, String containerDBPath) { | ||
this.store = store; | ||
this.containerDBPath = containerDBPath; | ||
} | ||
|
||
public STORE getStore() { | ||
return this.store; | ||
} | ||
|
||
public String getContainerDBPath() { | ||
return this.containerDBPath; | ||
} | ||
|
||
public boolean cleanup() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DBHandle{" + | ||
"containerDBPath='" + containerDBPath + '\'' + | ||
", store=" + store + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.