-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-2034. Async RATIS pipeline creation and destroy through heartbeat commands #29
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 all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd870a8
HDDS-2034. Async RATIS pipeline creation and destroy through datanode…
ChenSammi 5b6b3ba
Fix checkstyle and code improvement
ChenSammi a422bd3
update per comments
ChenSammi 34072a2
move exit safe mode wait from safe mode manager to mini ozone cluster
ChenSammi 0af319c
fix unit test TestSCMPipelineManager.java
ChenSammi 0daca86
move pipeline create to scm safe mode manager
ChenSammi 4e51d9c
remove RATIS ONE factor pipeline from HealthyPipelineSafeModeRule
ChenSammi caf93b0
fix failed integraton test
ChenSammi 3545f83
fix issue caused by rebase
ChenSammi 93a8da7
fix checkstyle and ut
ChenSammi 4a46f9f
update per comment
ChenSammi 2a358b8
TestBlockManager
ChenSammi 86deabf
Fix issues caused by rebase
ChenSammi 29298cc
remove unused import
ChenSammi 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
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
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
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
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
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
120 changes: 120 additions & 0 deletions
120
...adoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.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,120 @@ | ||
| /** | ||
| * 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.ozone.container.common.statemachine.commandhandler; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.apache.hadoop.hdds.protocol.proto. | ||
| StorageContainerDatanodeProtocolProtos.ClosePipelineCommandProto; | ||
| import org.apache.hadoop.hdds.protocol.proto. | ||
| StorageContainerDatanodeProtocolProtos.SCMCommandProto; | ||
| import org.apache.hadoop.ozone.container.common.statemachine | ||
| .SCMConnectionManager; | ||
| import org.apache.hadoop.ozone.container.common.statemachine.StateContext; | ||
| import org.apache.hadoop.ozone.container.common.transport.server | ||
| .XceiverServerSpi; | ||
| import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer; | ||
| import org.apache.hadoop.ozone.protocol.commands.ClosePipelineCommand; | ||
| import org.apache.hadoop.ozone.protocol.commands.SCMCommand; | ||
| import org.apache.hadoop.util.Time; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.atomic.AtomicLong; | ||
|
|
||
| /** | ||
| * Handler for close pipeline command received from SCM. | ||
| */ | ||
| public class ClosePipelineCommandHandler implements CommandHandler { | ||
|
|
||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(ClosePipelineCommandHandler.class); | ||
|
|
||
| private AtomicLong invocationCount = new AtomicLong(0); | ||
| private long totalTime; | ||
|
|
||
| /** | ||
| * Constructs a closePipelineCommand handler. | ||
| */ | ||
| public ClosePipelineCommandHandler() { | ||
| } | ||
|
|
||
| /** | ||
| * Handles a given SCM command. | ||
| * | ||
| * @param command - SCM Command | ||
| * @param ozoneContainer - Ozone Container. | ||
| * @param context - Current Context. | ||
| * @param connectionManager - The SCMs that we are talking to. | ||
| */ | ||
| @Override | ||
| public void handle(SCMCommand command, OzoneContainer ozoneContainer, | ||
| StateContext context, SCMConnectionManager connectionManager) { | ||
| invocationCount.incrementAndGet(); | ||
| final long startTime = Time.monotonicNow(); | ||
| final DatanodeDetails dn = context.getParent().getDatanodeDetails(); | ||
| final ClosePipelineCommandProto closeCommand = | ||
| ((ClosePipelineCommand)command).getProto(); | ||
| final HddsProtos.PipelineID pipelineID = closeCommand.getPipelineID(); | ||
|
|
||
| try { | ||
| XceiverServerSpi server = ozoneContainer.getWriteChannel(); | ||
| server.removeGroup(pipelineID); | ||
| LOG.info("Close Pipeline #{} command on datanode #{}.", pipelineID, | ||
| dn.getUuidString()); | ||
| } catch (IOException e) { | ||
| LOG.error("Can't close pipeline #{}", pipelineID, e); | ||
| } finally { | ||
| long endTime = Time.monotonicNow(); | ||
| totalTime += endTime - startTime; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns the command type that this command handler handles. | ||
| * | ||
| * @return Type | ||
| */ | ||
| @Override | ||
| public SCMCommandProto.Type getCommandType() { | ||
| return SCMCommandProto.Type.closePipelineCommand; | ||
| } | ||
|
|
||
| /** | ||
| * Returns number of times this handler has been invoked. | ||
| * | ||
| * @return int | ||
| */ | ||
| @Override | ||
| public int getInvocationCount() { | ||
| return (int)invocationCount.get(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the average time this function takes to run. | ||
| * | ||
| * @return long | ||
| */ | ||
| @Override | ||
| public long getAverageRunTime() { | ||
| if (invocationCount.get() > 0) { | ||
| return totalTime / invocationCount.get(); | ||
| } | ||
| return 0; | ||
| } | ||
| } |
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
Oops, something went wrong.
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.