Skip to content

Persist allocation ID with shard state metadata on nodes #14831

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

Merged
merged 1 commit into from
Nov 23, 2015

Conversation

ywelsch
Copy link
Contributor

@ywelsch ywelsch commented Nov 18, 2015

Implements first step of #14739

@@ -148,12 +156,52 @@ public String toString() {

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject("allocation_id");
builder.field("id", id);
builder.startObject(ALLOCATION_ID_OBJECT_KEY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the same static Fields we use in other places?

    static final class Fields {
        static final XContentBuilderString _INDEX = new XContentBuilderString("_index");
        static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
        static final XContentBuilderString _ID = new XContentBuilderString("_id");
        static final XContentBuilderString _VERSION = new XContentBuilderString("_version");
        static final XContentBuilderString FOUND = new XContentBuilderString("found");
        static final XContentBuilderString FIELDS = new XContentBuilderString("fields");
    }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh can we please not add this useless class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we do in all other classes. If you don't like it, fine, but can you say why so we'll stop doing it in other places?

@bleskes
Copy link
Contributor

bleskes commented Nov 19, 2015

left some minor comments.

}
builder.endObject();
return builder;
}

public static AllocationId fromXContent(XContentParser parser) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use DocumentParser.java for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how DocumentParser helps here. Extra class Fields with XContentBuilderString does not help here as we match exact string names in fromXContent method (Fields is only used in cases where there is only toXContent). I implemented it in exactly the same way as it's done for ShardStateMetaData ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on using static strings - I didn't realize that the XContentStrings things are not usable when parsing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a new method and should not copy old clumsy ways of implementing things. AFAIK DocumentParser is perfect for this and less error prone

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I meant org.elasticsearch.common.xcontent.ObjectParser all the time my fault

@ywelsch
Copy link
Contributor Author

ywelsch commented Nov 23, 2015

pushed new changes.

@@ -100,6 +111,8 @@ public void toXContent(XContentBuilder builder, ShardStateMetaData shardStateMet
builder.field(VERSION_KEY, shardStateMetaData.version);
builder.field(PRIMARY_KEY, shardStateMetaData.primary);
builder.field(INDEX_UUID_KEY, shardStateMetaData.indexUUID);
builder.field(ALLOCATION_ID_KEY);
shardStateMetaData.allocationId.toXContent(builder, ToXContent.EMPTY_PARAMS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use field(String name, ToXContent xContent)?

@bleskes
Copy link
Contributor

bleskes commented Nov 23, 2015

LGTM. Left one minor comment.

@ywelsch ywelsch force-pushed the feature/persist-allocid-shardstate branch from 8f62b87 to fccad13 Compare November 23, 2015 16:44
ywelsch pushed a commit that referenced this pull request Nov 23, 2015
…tate

Persist allocation ID with shard state metadata on nodes
@ywelsch ywelsch merged commit 7d32c88 into elastic:master Nov 23, 2015
ywelsch pushed a commit that referenced this pull request Nov 23, 2015
…llocation id

Such a write can happen when upgrading shard state metadata using the MultiDataPathUpgrader

Relates to #14831
@s1monw
Copy link
Contributor

s1monw commented Nov 24, 2015

IMO this was merged too early. I left some more comments on the relevant places

@lcawl lcawl added :Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. and removed :Allocation labels Feb 13, 2018
@clintongormley clintongormley added :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) and removed :Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >enhancement v5.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants