Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private static void writeBlockSet(Set<ClusterBlock> blocks, StreamOutput out) th
public static ClusterBlocks readFrom(StreamInput in) throws IOException {
if (in.getTransportVersion().onOrAfter(TransportVersions.MULTI_PROJECT)) {
final Set<ClusterBlock> global = readBlockSet(in);
final Map<ProjectId, ProjectBlocks> projectBlocksMap = in.readImmutableMap(ProjectId::new, ProjectBlocks::readFrom);
final Map<ProjectId, ProjectBlocks> projectBlocksMap = in.readImmutableMap(ProjectId::readFrom, ProjectBlocks::readFrom);
if (global.isEmpty()
&& noProjectOrDefaultProjectOnly(projectBlocksMap)
&& projectBlocksMap.getOrDefault(Metadata.DEFAULT_PROJECT_ID, ProjectBlocks.EMPTY).indices().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ public static Metadata readFrom(StreamInput in) throws IOException {
builder.put(ReservedStateMetadata.readFrom(in));
}

builder.projectMetadata(in.readMap(ProjectId::new, ProjectMetadata::readFrom));
builder.projectMetadata(in.readMap(ProjectId::readFrom, ProjectMetadata::readFrom));
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public record ProjectId(String id) implements Writeable, ToXContent {

public static final Reader<ProjectId> READER = ProjectId::new;
public static final Reader<ProjectId> READER = ProjectId::readFrom;
private static final int MAX_LENGTH = 128;

public ProjectId {
Expand Down Expand Up @@ -53,8 +53,9 @@ private static boolean isValidIdChar(char c) {
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || c == '-';
}

public ProjectId(StreamInput in) throws IOException {
this(in.readString());
public static ProjectId readFrom(StreamInput in) throws IOException {
final var id = in.readString();
return Metadata.DEFAULT_PROJECT_ID.id.equals(id) ? Metadata.DEFAULT_PROJECT_ID : new ProjectId(id);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params p) {
}

public static ProjectMetadata readFrom(StreamInput in) throws IOException {
ProjectId id = new ProjectId(in);
ProjectId id = ProjectId.readFrom(in);
Builder builder = builder(id);
Function<String, MappingMetadata> mappingLookup;
Map<String, MappingMetadata> mappingMetadataMap = in.readMapValues(MappingMetadata::new, MappingMetadata::getSha256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static Diff<GlobalRoutingTable> readDiffFrom(StreamInput in) throws IOExc
}

public static GlobalRoutingTable readFrom(StreamInput in) throws IOException {
final var table = in.readImmutableOpenMap(ProjectId::new, RoutingTable::readFrom);
final var table = in.readImmutableOpenMap(ProjectId::readFrom, RoutingTable::readFrom);
return new GlobalRoutingTable(table);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected AbstractAllocateAllocationCommand(StreamInput in) throws IOException {
shardId = in.readVInt();
node = in.readString();
if (in.getTransportVersion().onOrAfter(TransportVersions.MULTI_PROJECT)) {
projectId = new ProjectId(in);
projectId = ProjectId.readFrom(in);
} else {
projectId = Metadata.DEFAULT_PROJECT_ID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public CancelAllocationCommand(StreamInput in) throws IOException {
node = in.readString();
allowPrimary = in.readBoolean();
if (in.getTransportVersion().onOrAfter(TransportVersions.MULTI_PROJECT)) {
projectId = new ProjectId(in);
projectId = ProjectId.readFrom(in);
} else {
projectId = Metadata.DEFAULT_PROJECT_ID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public MoveAllocationCommand(StreamInput in) throws IOException {
fromNode = in.readString();
toNode = in.readString();
if (in.getTransportVersion().onOrAfter(TransportVersions.MULTI_PROJECT)) {
projectId = new ProjectId(in);
projectId = ProjectId.readFrom(in);
} else {
projectId = Metadata.DEFAULT_PROJECT_ID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public Request(TimeValue masterNodeTimeout, TimeValue ackTimeout, ProjectId proj

public Request(StreamInput in) throws IOException {
super(in);
this.projectId = new ProjectId(in);
this.projectId = ProjectId.readFrom(in);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public Request(TimeValue masterNodeTimeout, TimeValue ackTimeout, ProjectId proj

public Request(StreamInput in) throws IOException {
super(in);
this.projectId = new ProjectId(in);
this.projectId = ProjectId.readFrom(in);
}

@Override
Expand Down