Skip to content

Commit

Permalink
Remove MapWriter.append (#2919)
Browse files Browse the repository at this point in the history
Undocumented and called in only 2 places. Since MapWriter is implemented by a great many things, we should be conservative adding methods there. append() is kind of clever but I think it's outside the scope of what MapWriter should be.
  • Loading branch information
dsmiley authored Dec 28, 2024
1 parent 02cdf9e commit d9461e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
20 changes: 11 additions & 9 deletions solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1702,16 +1702,18 @@ public void publish(
}
if (core != null && core.getDirectoryFactory().isSharedStorage()) {
if (core.getDirectoryFactory().isSharedStorage()) {
// append additional entries to 'm'
MapWriter original = m;
m =
m.append(
props -> {
props.put(ZkStateReader.SHARED_STORAGE_PROP, "true");
props.put("dataDir", core.getDataDir());
UpdateLog ulog = core.getUpdateHandler().getUpdateLog();
if (ulog != null) {
props.put("ulogDir", ulog.getUlogDir());
}
});
props -> {
original.writeMap(props);
props.put(ZkStateReader.SHARED_STORAGE_PROP, "true");
props.put("dataDir", core.getDataDir());
UpdateLog ulog = core.getUpdateHandler().getUpdateLog();
if (ulog != null) {
props.put("ulogDir", ulog.getUlogDir());
}
};
}
}
} catch (SolrCoreInitializationException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import org.apache.solr.cloud.api.collections.CollectionHandlingUtils;
import org.apache.solr.common.MapWriter;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionAdminParams;
import org.apache.solr.common.params.CommonAdminParams;
Expand Down Expand Up @@ -73,8 +74,9 @@ public void testContainsTaskWithRequestId() throws Exception {
String watchID = tq.createResponseNode();
String requestId2 = "baz";

// append async then submit
tq.createRequestNode(
Utils.toJSON(props.append(ew -> ew.put(CommonAdminParams.ASYNC, requestId2))), watchID);
Utils.toJSON(new ZkNodeProps(props).plus(CommonAdminParams.ASYNC, requestId2)), watchID);

// Set a SolrResponse as the response node by removing the QueueEvent, as done in
// OverseerTaskProcessor
Expand Down
7 changes: 5 additions & 2 deletions solr/solrj/src/java/org/apache/solr/common/MapWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
*/
public interface MapWriter extends MapSerializable, NavigableObject, JSONWriter.Writable {

/** Writes this object's entries out to {@code ew}. */
void writeMap(EntryWriter ew) throws IOException;

default String jsonStr() {
return Utils.toJSONString(this);
}
Expand All @@ -42,6 +45,7 @@ default Map<String, Object> toMap(Map<String, Object> map) {
return Utils.convertToMap(this, map);
}

/** For implementing Noggit {@link org.noggit.JSONWriter.Writable}. */
@Override
default void write(JSONWriter writer) {
writer.startObject();
Expand Down Expand Up @@ -70,8 +74,7 @@ public MapWriter.EntryWriter put(CharSequence k, Object v) {
writer.endObject();
}

void writeMap(EntryWriter ew) throws IOException;

@Deprecated
default MapWriter append(MapWriter another) {
MapWriter m = this;
return ew -> {
Expand Down

0 comments on commit d9461e2

Please sign in to comment.