use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class XceiverServerRatis method triggerPipelineClose.
private void triggerPipelineClose(RaftGroupId groupId, String detail, ClosePipelineInfo.Reason reasonCode, boolean triggerHB) {
PipelineID pipelineID = PipelineID.valueOf(groupId.getUuid());
ClosePipelineInfo.Builder closePipelineInfo = ClosePipelineInfo.newBuilder().setPipelineID(pipelineID.getProtobuf()).setReason(reasonCode).setDetailedReason(detail);
PipelineAction action = PipelineAction.newBuilder().setClosePipeline(closePipelineInfo).setAction(PipelineAction.Action.CLOSE).build();
context.addPipelineActionIfAbsent(action);
// wait for the next HB timeout or right away?
if (triggerHB) {
context.getParent().triggerHeartbeat();
}
LOG.error("pipeline Action {} on pipeline {}.Reason : {}", action.getAction(), pipelineID, action.getClosePipeline().getDetailedReason());
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class XceiverServerRatis method getPipelineIds.
@VisibleForTesting
public List<PipelineID> getPipelineIds() {
Iterable<RaftGroupId> gids = server.getGroupIds();
List<PipelineID> pipelineIDs = new ArrayList<>();
for (RaftGroupId groupId : gids) {
pipelineIDs.add(PipelineID.valueOf(groupId.getUuid()));
LOG.info("pipeline id {}", PipelineID.valueOf(groupId.getUuid()));
}
return pipelineIDs;
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class ClosePipelineCommandHandler method handle.
/**
* 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();
ClosePipelineCommand closePipelineCommand = (ClosePipelineCommand) command;
final PipelineID pipelineID = closePipelineCommand.getPipelineID();
final HddsProtos.PipelineID pipelineIdProto = pipelineID.getProtobuf();
try {
XceiverServerSpi server = ozoneContainer.getWriteChannel();
if (server.isExist(pipelineIdProto)) {
server.removeGroup(pipelineIdProto);
LOG.info("Close Pipeline {} command on datanode {}.", pipelineID, dn.getUuidString());
} else {
LOG.debug("Ignoring close pipeline command for pipeline {} " + "as it does not exist", pipelineID);
}
} catch (IOException e) {
LOG.error("Can't close pipeline {}", pipelineID, e);
} finally {
long endTime = Time.monotonicNow();
totalTime += endTime - startTime;
}
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class TestFreonWithPipelineDestroy method destroyPipeline.
private void destroyPipeline() throws Exception {
XceiverServerSpi server = cluster.getHddsDatanodes().get(0).getDatanodeStateMachine().getContainer().getWriteChannel();
StorageContainerDatanodeProtocolProtos.PipelineReport report = server.getPipelineReport().get(0);
PipelineID id = PipelineID.getFromProtobuf(report.getPipelineID());
PipelineManager pipelineManager = cluster.getStorageContainerManager().getPipelineManager();
Pipeline pipeline = pipelineManager.getPipeline(id);
pipelineManager.closePipeline(pipeline, false);
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class SCMNodeManager method getPeerList.
@Override
public Collection<DatanodeDetails> getPeerList(DatanodeDetails dn) {
HashSet<DatanodeDetails> dns = new HashSet<>();
Preconditions.checkNotNull(dn);
Set<PipelineID> pipelines = nodeStateManager.getPipelineByDnID(dn.getUuid());
PipelineManager pipelineManager = scmContext.getScm().getPipelineManager();
if (!pipelines.isEmpty()) {
pipelines.forEach(id -> {
try {
Pipeline pipeline = pipelineManager.getPipeline(id);
List<DatanodeDetails> peers = pipeline.getNodes();
dns.addAll(peers);
} catch (PipelineNotFoundException pnfe) {
// ignore the pipeline not found exception here
}
});
}
// renove self node from the set
dns.remove(dn);
return dns;
}
Aggregations