Skip to content

Commit

Permalink
Merge branch 'apache:master' into HDDS-11243
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 authored Aug 29, 2024
2 parents 1b204ed + 47564bb commit 7fc7745
Show file tree
Hide file tree
Showing 133 changed files with 3,015 additions and 2,255 deletions.
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<extension>
<groupId>com.gradle</groupId>
<artifactId>develocity-maven-extension</artifactId>
<version>1.21.5</version>
<version>1.22</version>
</extension>
<extension>
<groupId>com.gradle</groupId>
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Apache Ozone
Copyright 2022 The Apache Software Foundation
Copyright 2024 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Expand Down
98 changes: 98 additions & 0 deletions dev-support/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed 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. See accompanying LICENSE file.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ozone-main</artifactId>
<groupId>org.apache.ozone</groupId>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ozone-dev-support</artifactId>
<description>Helper module for sharing resources among projects</description>
<name>Apache Ozone Dev Support</name>

<properties>
<failIfNoTests>false</failIfNoTests>
</properties>
<build>
<resources>
<resource>
<directory>${project.build.directory}/extra-resources</directory>
<targetPath>META-INF</targetPath>
<includes>
<include>LICENSE.txt</include>
<include>NOTICE.txt</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!-- copy L&N files to target/extra-resources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/extra-resources</outputDirectory>
<resources>
<resource>
<directory>../</directory>
<includes>
<include>LICENSE.txt</include>
<include>NOTICE.txt</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- add entries for L&N files to remote-resources.xml in jar file -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<resourcesDirectory>${project.build.outputDirectory}</resourcesDirectory>
<includes>
<include>META-INF/LICENSE.txt</include>
<include>META-INF/NOTICE.txt</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.scm;

import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
import org.apache.ratis.protocol.ClientId;
import org.apache.ratis.protocol.RaftClientReply;

/**
* Client side error injector allowing simulating receiving errors from server side.
*/
@FunctionalInterface
public interface ErrorInjector {
RaftClientReply getResponse(ContainerProtos.ContainerCommandRequestProto request, ClientId id, Pipeline pipeline);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
* Factory for XceiverClientSpi implementations. Client instances are not cached.
*/
public class XceiverClientCreator implements XceiverClientFactory {
private static ErrorInjector errorInjector;

public static void enableErrorInjection(ErrorInjector injector) {
errorInjector = injector;
}

private final ConfigurationSource conf;
private final boolean topologyAwareRead;
private final ClientTrustManager trustManager;
Expand Down Expand Up @@ -60,7 +66,7 @@ protected XceiverClientSpi newClient(Pipeline pipeline) throws IOException {
XceiverClientSpi client;
switch (pipeline.getType()) {
case RATIS:
client = XceiverClientRatis.newXceiverClientRatis(pipeline, conf, trustManager);
client = XceiverClientRatis.newXceiverClientRatis(pipeline, conf, trustManager, errorInjector);
break;
case STAND_ALONE:
client = new XceiverClientGrpc(pipeline, conf, trustManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
public class XceiverClientManager extends XceiverClientCreator {
private static final Logger LOG =
LoggerFactory.getLogger(XceiverClientManager.class);

private final Cache<String, XceiverClientSpi> clientCache;
private final CacheMetrics cacheMetrics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ public final class XceiverClientRatis extends XceiverClientSpi {
public static XceiverClientRatis newXceiverClientRatis(
org.apache.hadoop.hdds.scm.pipeline.Pipeline pipeline,
ConfigurationSource ozoneConf) {
return newXceiverClientRatis(pipeline, ozoneConf, null);
return newXceiverClientRatis(pipeline, ozoneConf, null, null);
}

public static XceiverClientRatis newXceiverClientRatis(
org.apache.hadoop.hdds.scm.pipeline.Pipeline pipeline,
ConfigurationSource ozoneConf, ClientTrustManager trustManager) {
ConfigurationSource ozoneConf, ClientTrustManager trustManager, ErrorInjector errorInjector) {
final String rpcType = ozoneConf
.get(ScmConfigKeys.HDDS_CONTAINER_RATIS_RPC_TYPE_KEY,
ScmConfigKeys.HDDS_CONTAINER_RATIS_RPC_TYPE_DEFAULT);
Expand All @@ -93,7 +93,7 @@ public static XceiverClientRatis newXceiverClientRatis(
SecurityConfig(ozoneConf), trustManager);
return new XceiverClientRatis(pipeline,
SupportedRpcType.valueOfIgnoreCase(rpcType),
retryPolicy, tlsConfig, ozoneConf);
retryPolicy, tlsConfig, ozoneConf, errorInjector);
}

private final Pipeline pipeline;
Expand All @@ -110,13 +110,14 @@ public static XceiverClientRatis newXceiverClientRatis(
= XceiverClientManager.getXceiverClientMetrics();
private final RaftProtos.ReplicationLevel watchType;
private final int majority;
private final ErrorInjector errorInjector;

/**
* Constructs a client.
*/
private XceiverClientRatis(Pipeline pipeline, RpcType rpcType,
RetryPolicy retryPolicy, GrpcTlsConfig tlsConfig,
ConfigurationSource configuration) {
ConfigurationSource configuration, ErrorInjector errorInjector) {
super();
this.pipeline = pipeline;
this.majority = (pipeline.getReplicationConfig().getRequiredNodes() / 2) + 1;
Expand All @@ -142,6 +143,7 @@ private XceiverClientRatis(Pipeline pipeline, RpcType rpcType,
LOG.trace("new XceiverClientRatis for pipeline " + pipeline.getId(),
new Throwable("TRACE"));
}
this.errorInjector = errorInjector;
}

private long updateCommitInfosMap(RaftClientReply reply, RaftProtos.ReplicationLevel level) {
Expand Down Expand Up @@ -248,6 +250,12 @@ public ConcurrentMap<UUID, Long> getCommitInfoMap() {

private CompletableFuture<RaftClientReply> sendRequestAsync(
ContainerCommandRequestProto request) {
if (errorInjector != null) {
RaftClientReply response = errorInjector.getResponse(request, getClient().getId(), pipeline);
if (response != null) {
return CompletableFuture.completedFuture(response);
}
}
return TracingUtil.executeInNewSpan(
"XceiverClientRatis." + request.getCmdType().name(),
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ XceiverClientReply watchOnLastIndex() throws IOException {
*
* @param commitIndex log index to watch for
* @return minimum commit index replicated to all nodes
* @throws IOException IOException in case watch gets timed out
*/
CompletableFuture<XceiverClientReply> watchForCommitAsync(long commitIndex) {
final MemoizedSupplier<CompletableFuture<XceiverClientReply>> supplier
Expand Down
Loading

0 comments on commit 7fc7745

Please sign in to comment.