Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate MapWriter.append #2919

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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
Loading