-
Notifications
You must be signed in to change notification settings - Fork 625
HDDS-3142. Create isolated enviornment for OM to test it without SCM. #656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
977f740
HDDS-3142. Fake scm implementation for OM tests
elek df30045
Merge remote-tracking branch 'origin/master' into HDDS-3142
elek 38ea07c
bumping rocksdb version
elek 2663871
do not cache index and filter blocks
elek 163f400
address reviews / typo fixes
elek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,34 @@ | ||
| #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. | ||
|
|
||
| RULE mock scm block client | ||
| CLASS org.apache.hadoop.hdds.scm.protocolPB.ScmBlockLocationProtocolClientSideTranslatorPB | ||
| METHOD submitRequest | ||
| AT ENTRY | ||
| BIND client:org.apache.hadoop.hdds.scm.protocolPB.ScmBlockLocationProtocolClientSideTranslatorPB = $0; | ||
| result:org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos$SCMBlockLocationResponse = org.apache.hadoop.hdds.freon.FakeScmBlockLocationProtocolClient.submitRequest($1); | ||
| IF true | ||
| DO return result; | ||
| ENDRULE | ||
|
|
||
| RULE mock scm container client | ||
| CLASS org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB | ||
| METHOD submitRpcRequest | ||
| AT ENTRY | ||
| BIND client:org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB = $0; | ||
| result:org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos$ScmContainerLocationResponse = org.apache.hadoop.hdds.freon.FakeScmContainerLocationProtocolClient.submitRequest($1); | ||
| IF true | ||
| DO return result; | ||
| ENDRULE |
92 changes: 92 additions & 0 deletions
92
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/freon/FakeClusterTopology.java
This file contains hidden or 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,92 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.freon; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Random; | ||
| import java.util.UUID; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.DatanodeDetailsProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.Pipeline; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.Port; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType; | ||
| import org.apache.hadoop.hdds.scm.pipeline.PipelineID; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Class to store pre-generated topology information for load-tests. | ||
| */ | ||
| public class FakeClusterTopology { | ||
|
|
||
| private static final Logger LOGGER = | ||
| LoggerFactory.getLogger(FakeClusterTopology.class); | ||
|
|
||
| public static final FakeClusterTopology INSTANCE = new FakeClusterTopology(); | ||
|
|
||
| private List<DatanodeDetailsProto> datanodes = new ArrayList<>(); | ||
|
|
||
| private List<Pipeline> piplines = new ArrayList<>(); | ||
|
|
||
| private Random random = new Random(); | ||
|
|
||
| public FakeClusterTopology() { | ||
| try { | ||
| for (int i = 0; i < 9; i++) { | ||
| datanodes.add(createDatanode(i)); | ||
| if ((i + 1) % 3 == 0) { | ||
| piplines.add(Pipeline.newBuilder() | ||
| .setId(PipelineID.randomId().getProtobuf()) | ||
| .setFactor(ReplicationFactor.THREE) | ||
| .setType(ReplicationType.RATIS) | ||
| .addMembers(getDatanode(i - 2)) | ||
| .addMembers(getDatanode(i - 1)) | ||
| .addMembers(getDatanode(i)) | ||
| .build()); | ||
| } | ||
| } | ||
| } catch (Exception ex) { | ||
| LOGGER.error("Can't initialize FakeClusterTopology", ex); | ||
| } | ||
| } | ||
|
|
||
| private DatanodeDetailsProto createDatanode(int index) { | ||
| return DatanodeDetailsProto.newBuilder() | ||
| .setUuid(UUID.randomUUID().toString()) | ||
| .setHostName("localhost") | ||
| .setIpAddress("127.0.0.1") | ||
| .addPorts( | ||
| Port.newBuilder().setName("RATIS").setValue(1234)) | ||
| .build(); | ||
| } | ||
|
|
||
| public DatanodeDetailsProto getDatanode(int i) { | ||
| return datanodes.get(i); | ||
| } | ||
|
|
||
| public Pipeline getRandomPipeline() { | ||
| return piplines.get(random.nextInt(piplines.size())); | ||
| } | ||
|
|
||
| public List<DatanodeDetailsProto> getAllDatanodes() { | ||
| return datanodes; | ||
| } | ||
| } | ||
100 changes: 100 additions & 0 deletions
100
...common/src/main/java/org/apache/hadoop/hdds/freon/FakeScmBlockLocationProtocolClient.java
This file contains hidden or 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,100 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.freon; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.atomic.AtomicLong; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ContainerBlockID; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.GetScmInfoResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.AllocateBlockResponse; | ||
| import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.AllocateScmBlockResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.AllocateScmBlockResponseProto.Builder; | ||
| import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationRequest; | ||
| import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationResponse; | ||
| import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.Status; | ||
| import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.Type; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Fake SCM client to return a simulated block location. | ||
| */ | ||
| public final class FakeScmBlockLocationProtocolClient { | ||
|
|
||
| private static final Logger LOGGER = | ||
| LoggerFactory.getLogger(FakeScmBlockLocationProtocolClient.class); | ||
|
|
||
| public static final int BLOCK_PER_COUNTER = 1000; | ||
|
elek marked this conversation as resolved.
Outdated
|
||
|
|
||
| private static AtomicLong counter = new AtomicLong(); | ||
|
|
||
| private FakeScmBlockLocationProtocolClient() { | ||
| } | ||
|
|
||
| public static SCMBlockLocationResponse submitRequest( | ||
| SCMBlockLocationRequest req) | ||
| throws IOException { | ||
| try { | ||
| if (req.getCmdType() == Type.GetScmInfo) { | ||
| return SCMBlockLocationResponse.newBuilder() | ||
| .setCmdType(req.getCmdType()) | ||
| .setStatus(Status.OK) | ||
| .setSuccess(true) | ||
| .setGetScmInfoResponse( | ||
| GetScmInfoResponseProto.newBuilder() | ||
| .setScmId("scm-id") | ||
| .setClusterId("cluster-id") | ||
| .build() | ||
| ) | ||
| .build(); | ||
| } else if (req.getCmdType() == Type.AllocateScmBlock) { | ||
| Builder allocateBlockResponse = | ||
| AllocateScmBlockResponseProto.newBuilder(); | ||
| for (int i = 0; | ||
| i < req.getAllocateScmBlockRequest().getNumBlocks(); i++) { | ||
| long seq = counter.incrementAndGet(); | ||
|
|
||
| allocateBlockResponse.addBlocks(AllocateBlockResponse.newBuilder() | ||
| .setPipeline(FakeClusterTopology.INSTANCE.getRandomPipeline()) | ||
| .setContainerBlockID(ContainerBlockID.newBuilder() | ||
| .setContainerID(seq / BLOCK_PER_COUNTER) | ||
| .setLocalID(seq)) | ||
| ); | ||
| } | ||
| return SCMBlockLocationResponse.newBuilder() | ||
| .setCmdType(req.getCmdType()) | ||
| .setStatus(Status.OK) | ||
| .setSuccess(true) | ||
| .setAllocateScmBlockResponse( | ||
| allocateBlockResponse | ||
| ) | ||
| .build(); | ||
| } else { | ||
| throw new IllegalArgumentException( | ||
| "Unsupported request. Fake answer is not implemented for " + req | ||
| .getCmdType()); | ||
| } | ||
| } catch (Exception ex) { | ||
| LOGGER.error("Error on creating fake SCM response", ex); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| } | ||
80 changes: 80 additions & 0 deletions
80
...on/src/main/java/org/apache/hadoop/hdds/freon/FakeScmContainerLocationProtocolClient.java
This file contains hidden or 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,80 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.freon; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.DatanodeDetailsProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.Node; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.NodeQueryResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.NodeQueryResponseProto.Builder; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationRequest; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse.Status; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.Type; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Fake SCM client to return a simulated block location. | ||
| */ | ||
| public final class FakeScmContainerLocationProtocolClient { | ||
|
|
||
| private static final Logger LOGGER = | ||
| LoggerFactory.getLogger(FakeScmContainerLocationProtocolClient.class); | ||
|
|
||
| private FakeScmContainerLocationProtocolClient() { | ||
| } | ||
|
|
||
| public static ScmContainerLocationResponse submitRequest( | ||
| ScmContainerLocationRequest req) | ||
| throws IOException { | ||
| try { | ||
| if (req.getCmdType() == Type.QueryNode) { | ||
| Builder builder = NodeQueryResponseProto.newBuilder() | ||
| .addDatanodes(Node.newBuilder() | ||
| .setNodeID(FakeClusterTopology.INSTANCE.getDatanode(1)) | ||
| .addNodeStates(NodeState.HEALTHY) | ||
| .build()); | ||
|
elek marked this conversation as resolved.
Outdated
|
||
| for (DatanodeDetailsProto datanode : FakeClusterTopology.INSTANCE | ||
| .getAllDatanodes()) { | ||
| builder.addDatanodes(Node.newBuilder() | ||
| .setNodeID(datanode) | ||
| .addNodeStates(NodeState.HEALTHY) | ||
| .build()); | ||
| } | ||
|
|
||
| return ScmContainerLocationResponse.newBuilder() | ||
| .setCmdType(Type.QueryNode) | ||
| .setStatus(Status.OK) | ||
| .setNodeQueryResponse(builder.build()) | ||
| .build(); | ||
| } else { | ||
| throw new IllegalArgumentException( | ||
| "Unsupported request. Fake answer is not implemented for " + req | ||
| .getCmdType()); | ||
| } | ||
| } catch (Exception ex) { | ||
| LOGGER.error("Error on creating fake SCM response", ex); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| } | ||
24 changes: 24 additions & 0 deletions
24
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/freon/package-info.java
This file contains hidden or 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,24 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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. | ||
| * <p> | ||
| * Freon related helper classes used for load testing. | ||
| */ | ||
|
|
||
| /** | ||
| * Freon related helper classes used for load testing. | ||
| */ | ||
| package org.apache.hadoop.hdds.freon; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.