Skip to content

Commit cf5c743

Browse files
authored
Merge branch 'apache:master' into HDDS-11463
2 parents 416198a + 1d42e20 commit cf5c743

File tree

337 files changed

+10590
-2546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+10590
-2546
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ jobs:
167167
with:
168168
path: |
169169
~/.pnpm-store
170-
**/node_modules
171170
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
172171
restore-keys: |
173172
${{ runner.os }}-pnpm-
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
RULE Change container state to STATE_PLACEHOLDER
17+
CLASS org.apache.hadoop.ozone.container.common.impl.ContainerData
18+
METHOD getState
19+
AT ENTRY
20+
IF TRUE
21+
DO
22+
traceln("BYTEMAN RULE: Overriding getState() to return STATE_PLACEHOLDER state");
23+
return org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos$ContainerDataProto$State.valueOf("STATE_PLACEHOLDER")
24+
ENDRULE

hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientMetrics.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,19 @@ public class XceiverClientMetrics implements MetricsSource {
5151
private EnumMap<ContainerProtos.Type, MutableCounterLong> pendingOpsArray;
5252
private EnumMap<ContainerProtos.Type, MutableCounterLong> opsArray;
5353
private EnumMap<ContainerProtos.Type, PerformanceMetrics> containerOpsLatency;
54+
55+
// TODO: https://issues.apache.org/jira/browse/HDDS-13555
56+
@SuppressWarnings("PMD.SingularField")
5457
private MetricsRegistry registry;
55-
private OzoneConfiguration conf = new OzoneConfiguration();
56-
private int[] intervals = conf.getInts(OzoneConfigKeys
57-
.OZONE_XCEIVER_CLIENT_METRICS_PERCENTILES_INTERVALS_SECONDS_KEY);
5858

5959
public XceiverClientMetrics() {
6060
init();
6161
}
6262

6363
public void init() {
64+
OzoneConfiguration conf = new OzoneConfiguration();
65+
int[] intervals = conf.getInts(OzoneConfigKeys.OZONE_XCEIVER_CLIENT_METRICS_PERCENTILES_INTERVALS_SECONDS_KEY);
66+
6467
this.registry = new MetricsRegistry(SOURCE_NAME);
6568

6669
this.pendingOpsArray = new EnumMap<>(ContainerProtos.Type.class);

hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ public class BlockDataStreamOutput implements ByteBufferStreamOutput {
125125
private final List<DatanodeDetails> failedServers;
126126
private final Checksum checksum;
127127

128-
//number of buffers used before doing a flush/putBlock.
129-
private int flushPeriod;
130128
private final Token<? extends TokenIdentifier> token;
131129
private final String tokenString;
132130
private final DataStreamOutput out;
@@ -172,8 +170,9 @@ public BlockDataStreamOutput(
172170
// Alternatively, stream setup can be delayed till the first chunk write.
173171
this.out = setupStream(pipeline);
174172
this.bufferList = bufferList;
175-
flushPeriod = (int) (config.getStreamBufferFlushSize() / config
176-
.getStreamBufferSize());
173+
174+
//number of buffers used before doing a flush/putBlock.
175+
int flushPeriod = (int) (config.getStreamBufferFlushSize() / config.getStreamBufferSize());
177176

178177
Preconditions
179178
.checkArgument(

hadoop-hdds/common/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
<groupId>com.google.protobuf</groupId>
5656
<artifactId>protobuf-java</artifactId>
5757
</dependency>
58-
<dependency>
59-
<groupId>commons-collections</groupId>
60-
<artifactId>commons-collections</artifactId>
61-
</dependency>
6258
<dependency>
6359
<groupId>commons-io</groupId>
6460
<artifactId>commons-io</artifactId>
@@ -92,6 +88,10 @@
9288
<groupId>jakarta.xml.bind</groupId>
9389
<artifactId>jakarta.xml.bind-api</artifactId>
9490
</dependency>
91+
<dependency>
92+
<groupId>org.apache.commons</groupId>
93+
<artifactId>commons-collections4</artifactId>
94+
</dependency>
9595
<dependency>
9696
<groupId>org.apache.commons</groupId>
9797
<artifactId>commons-lang3</artifactId>

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/StringUtils.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,30 @@ public static String bytes2String(byte[] bytes) {
9797
public static byte[] string2Bytes(String str) {
9898
return str.getBytes(UTF8);
9999
}
100+
101+
public static String getLexicographicallyLowerString(String val) {
102+
if (val == null || val.isEmpty()) {
103+
throw new IllegalArgumentException("Input string must not be null or empty");
104+
}
105+
char[] charVal = val.toCharArray();
106+
int lastIdx = charVal.length - 1;
107+
if (charVal[lastIdx] == Character.MIN_VALUE) {
108+
throw new IllegalArgumentException("Cannot decrement character below Character.MIN_VALUE");
109+
}
110+
charVal[lastIdx] -= 1;
111+
return String.valueOf(charVal);
112+
}
113+
114+
public static String getLexicographicallyHigherString(String val) {
115+
if (val == null || val.isEmpty()) {
116+
throw new IllegalArgumentException("Input string must not be null or empty");
117+
}
118+
char[] charVal = val.toCharArray();
119+
int lastIdx = charVal.length - 1;
120+
if (charVal[lastIdx] == Character.MAX_VALUE) {
121+
throw new IllegalArgumentException("Cannot increment character above Character.MAX_VALUE");
122+
}
123+
charVal[lastIdx] += 1;
124+
return String.valueOf(charVal);
125+
}
100126
}

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@ public static void transferRatisLeadership(ConfigurationSource conf,
544544
+ group.getPeers().stream().map(RaftPeer::getId)
545545
.collect(Collectors.toList()) + ".");
546546
}
547+
if (!group.getPeer(targetPeerId).getStartupRole().equals(RaftProtos.RaftPeerRole.FOLLOWER)) {
548+
throw new IOException("Target " + targetPeerId + " not in FOLLOWER role. "
549+
+ group.getPeers().stream()
550+
.map(p -> p.getId() + ":" + p.getStartupRole())
551+
.collect(Collectors.toList()) + ".");
552+
}
547553

548554
LOG.info("Start transferring leadership to {}", targetPeerId);
549555
try (RaftClient client = newRaftClient(SupportedRpcType.GRPC, null,
@@ -566,13 +572,19 @@ null, group, createRetryPolicy(conf), tlsConfig, conf)) {
566572
RaftClientReply setConf = null;
567573
try {
568574
// Set priority
569-
final List<RaftPeer> peersWithNewPriorities = group.getPeers().stream()
575+
final List<RaftPeer> followerWithNewPriorities = group.getPeers().stream()
576+
.filter(peer -> peer.getStartupRole().equals(RaftProtos.RaftPeerRole.FOLLOWER))
577+
.map(peer -> newRaftPeer(peer, targetPeerId))
578+
.collect(Collectors.toList());
579+
final List<RaftPeer> listenerWithNewPriorities = group.getPeers().stream()
580+
.filter(peer -> peer.getStartupRole().equals(RaftProtos.RaftPeerRole.LISTENER))
570581
.map(peer -> newRaftPeer(peer, targetPeerId))
571582
.collect(Collectors.toList());
572583
// Set new configuration
573-
setConf = client.admin().setConfiguration(peersWithNewPriorities);
584+
setConf = client.admin().setConfiguration(followerWithNewPriorities, listenerWithNewPriorities);
574585
if (setConf.isSuccess()) {
575-
LOG.info("Successfully set priority: {}", peersWithNewPriorities);
586+
LOG.info("Successfully set priority: Follower: {}, Listener: {}", followerWithNewPriorities,
587+
listenerWithNewPriorities);
576588
} else {
577589
throw new IOException("Failed to set priority.",
578590
setConf.getException());
@@ -598,13 +610,19 @@ null, group, createRetryPolicy(conf), tlsConfig, conf)) {
598610
}
599611

600612
private static void resetPriorities(RaftGroup original, RaftClient client) {
601-
final List<RaftPeer> resetPeers = original.getPeers().stream()
613+
final List<RaftPeer> resetFollower = original.getPeers().stream()
614+
.filter(peer -> peer.getStartupRole().equals(RaftProtos.RaftPeerRole.FOLLOWER))
615+
.map(originalPeer -> RaftPeer.newBuilder(originalPeer)
616+
.setPriority(NEUTRAL_PRIORITY).build())
617+
.collect(Collectors.toList());
618+
final List<RaftPeer> resetListener = original.getPeers().stream()
619+
.filter(peer -> peer.getStartupRole().equals(RaftProtos.RaftPeerRole.LISTENER))
602620
.map(originalPeer -> RaftPeer.newBuilder(originalPeer)
603621
.setPriority(NEUTRAL_PRIORITY).build())
604622
.collect(Collectors.toList());
605-
LOG.info("Resetting Raft peers priorities to {}", resetPeers);
623+
LOG.info("Resetting Raft peers priorities to Follower: {}, Listener: {}", resetFollower, resetListener);
606624
try {
607-
RaftClientReply reply = client.admin().setConfiguration(resetPeers);
625+
RaftClientReply reply = client.admin().setConfiguration(resetFollower, resetListener);
608626
if (reply.isSuccess()) {
609627
LOG.info("Successfully reset priorities: {}", original);
610628
} else {

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerReplicaInfo.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@
1717

1818
package org.apache.hadoop.hdds.scm.container;
1919

20-
import static org.apache.hadoop.hdds.HddsUtils.checksumToString;
21-
22-
import com.fasterxml.jackson.core.JsonGenerator;
23-
import com.fasterxml.jackson.databind.JsonSerializer;
24-
import com.fasterxml.jackson.databind.SerializerProvider;
2520
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
26-
import java.io.IOException;
2721
import java.util.UUID;
2822
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
2923
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
24+
import org.apache.hadoop.hdds.server.JsonUtils;
3025

3126
/**
3227
* Class which stores ContainerReplica details on the client.
@@ -41,7 +36,7 @@ public final class ContainerReplicaInfo {
4136
private long keyCount;
4237
private long bytesUsed;
4338
private int replicaIndex = -1;
44-
@JsonSerialize(using = LongToHexJsonSerializer.class)
39+
@JsonSerialize(using = JsonUtils.ChecksumSerializer.class)
4540
private long dataChecksum;
4641

4742
public static ContainerReplicaInfo fromProto(
@@ -100,13 +95,6 @@ public long getDataChecksum() {
10095
return dataChecksum;
10196
}
10297

103-
private static class LongToHexJsonSerializer extends JsonSerializer<Long> {
104-
@Override
105-
public void serialize(Long value, JsonGenerator gen, SerializerProvider provider) throws IOException {
106-
gen.writeString(checksumToString(value));
107-
}
108-
}
109-
11098
/**
11199
* Builder for ContainerReplicaInfo class.
112100
*/

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/net/NetUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Collection;
2222
import java.util.Iterator;
2323
import java.util.List;
24-
import org.apache.commons.collections.CollectionUtils;
24+
import org.apache.commons.collections4.CollectionUtils;
2525
import org.apache.commons.lang3.StringUtils;
2626
import org.slf4j.Logger;
2727
import org.slf4j.LoggerFactory;

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/net/NetworkTopologyImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import java.util.concurrent.locks.ReadWriteLock;
3737
import java.util.concurrent.locks.ReentrantReadWriteLock;
3838
import java.util.function.Consumer;
39-
import org.apache.commons.collections.CollectionUtils;
39+
import org.apache.commons.collections4.CollectionUtils;
4040
import org.apache.hadoop.hdds.conf.ConfigurationSource;
4141
import org.slf4j.Logger;
4242
import org.slf4j.LoggerFactory;

0 commit comments

Comments
 (0)