Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <[email protected]>
  • Loading branch information
garyschulte committed Aug 30, 2023
1 parent 8274fe3 commit aa31df6
Showing 1 changed file with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

import static java.util.stream.Collectors.toUnmodifiableSet;

import com.google.common.base.Splitter;
import com.google.common.collect.Streams;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.plugin.services.metrics.OperationTimer;
Expand All @@ -34,7 +31,6 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -44,7 +40,10 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.common.base.Splitter;
import com.google.common.collect.Streams;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.tuweni.bytes.Bytes;
import org.rocksdb.BlockBasedTableConfig;
import org.rocksdb.BloomFilter;
import org.rocksdb.ColumnFamilyDescriptor;
Expand Down Expand Up @@ -165,18 +164,14 @@ public RocksDBColumnarKeyValueStorage(
txOptions = new TransactionDBOptions();
columnHandles = new ArrayList<>(columnDescriptors.size());
} catch (RocksDBException e) {
List<SegmentIdentifier> knownSegments = Streams.concat(
defaultSegments.stream(),
ignorableSegments.stream())
.distinct()
.toList();
List<SegmentIdentifier> knownSegments =
Streams.concat(defaultSegments.stream(), ignorableSegments.stream()).distinct().toList();
throw parseRocksDBException(e, knownSegments);
}
}

private static StorageException parseRocksDBException(
final RocksDBException ex,
final List<SegmentIdentifier> knownSegments) {
final RocksDBException ex, final List<SegmentIdentifier> knownSegments) {
String message = ex.getMessage();

// parse out unprintable segment names for a more useful exception:
Expand All @@ -185,20 +180,23 @@ private static StorageException parseRocksDBException(
String substring = message.substring(message.indexOf(": ") + 2);

List<String> unHandledSegments = new ArrayList<>();
Splitter.on(", ").splitToStream(substring)
.forEach(part -> {
byte[] bytes = part.getBytes(StandardCharsets.UTF_8);
unHandledSegments.add(
knownSegments.stream().filter(seg -> Arrays.equals(seg.getId(), bytes))
.findFirst()
.map(SegmentIdentifier::getName)
.orElse("unknown segment:{" + Bytes.of(bytes).toHexString() + "}"));

});
Splitter.on(", ")
.splitToStream(substring)
.forEach(
part -> {
byte[] bytes = part.getBytes(StandardCharsets.UTF_8);
unHandledSegments.add(
knownSegments.stream()
.filter(seg -> Arrays.equals(seg.getId(), bytes))
.findFirst()
.map(SegmentIdentifier::getName)
.orElse("unknown segment:{" + Bytes.of(bytes).toHexString() + "}"));
});

return new StorageException(
"RocksDBException: Unhandled column families: [" +
unHandledSegments.stream().collect(Collectors.joining(", ")) + "]");
"RocksDBException: Unhandled column families: ["
+ unHandledSegments.stream().collect(Collectors.joining(", "))
+ "]");
} else {
return new StorageException(ex);
}
Expand Down

0 comments on commit aa31df6

Please sign in to comment.