-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
HLRC XPack Protocol clean up: Licence, Misc #34469
Merged
vladimirdolzhenko
merged 12 commits into
elastic:master
from
vladimirdolzhenko:hlrc_xprotocol_cleanup_1
Oct 19, 2018
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7d3f9d6
HLRC XPack Protocol clean up: Licence, Misc
b7b8f8d
package typo (extra space)
1931084
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_1
c5e6c9d
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_1
32872b4
inline ParseField as it's used in one place
7e778d7
fill the gaps for LicensingIT
3a7f138
move protocol-test to another PR
dab4d55
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
9e236d4
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_1
7afecce
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
a12a507
moved ProtocolUtils from protocol to client
85eb8f5
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,11 @@ | |
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.protocol.xpack.license; | ||
package org.elasticsearch.client.license; | ||
|
||
import org.elasticsearch.action.support.master.AcknowledgedResponse; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.collect.Tuple; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.common.xcontent.XContentParseException; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
import org.elasticsearch.protocol.xpack.common.ProtocolUtils; | ||
|
@@ -42,7 +37,9 @@ | |
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg; | ||
|
||
public class PutLicenseResponse extends AcknowledgedResponse { | ||
public final class PutLicenseResponse { | ||
|
||
private static final ParseField ACKNOWLEDGED = new ParseField("acknowledged"); | ||
|
||
private static final ConstructingObjectParser<PutLicenseResponse, Void> PARSER = new ConstructingObjectParser<>( | ||
"put_license_response", true, (a, v) -> { | ||
|
@@ -58,7 +55,7 @@ public class PutLicenseResponse extends AcknowledgedResponse { | |
}); | ||
|
||
static { | ||
PARSER.declareBoolean(constructorArg(), new ParseField("acknowledged")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i actually dont mind having these defined here if we dont use them anywhere else. |
||
PARSER.declareBoolean(constructorArg(), ACKNOWLEDGED); | ||
PARSER.declareString(constructorArg(), new ParseField("license_status")); | ||
PARSER.declareObject(optionalConstructorArg(), (parser, v) -> { | ||
Map<String, String[]> acknowledgeMessages = new HashMap<>(); | ||
|
@@ -97,6 +94,7 @@ public class PutLicenseResponse extends AcknowledgedResponse { | |
new ParseField("acknowledge")); | ||
} | ||
|
||
private boolean acknowledged; | ||
private LicensesStatus status; | ||
private Map<String, String[]> acknowledgeMessages; | ||
private String acknowledgeHeader; | ||
|
@@ -110,12 +108,16 @@ public PutLicenseResponse(boolean acknowledged, LicensesStatus status) { | |
|
||
public PutLicenseResponse(boolean acknowledged, LicensesStatus status, String acknowledgeHeader, | ||
Map<String, String[]> acknowledgeMessages) { | ||
super(acknowledged); | ||
this.acknowledged = acknowledged; | ||
this.status = status; | ||
this.acknowledgeHeader = acknowledgeHeader; | ||
this.acknowledgeMessages = acknowledgeMessages; | ||
} | ||
|
||
public boolean isAcknowledged() { | ||
return acknowledged; | ||
} | ||
|
||
public LicensesStatus status() { | ||
return status; | ||
} | ||
|
@@ -128,62 +130,6 @@ public String acknowledgeHeader() { | |
return acknowledgeHeader; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
status = LicensesStatus.fromId(in.readVInt()); | ||
acknowledgeHeader = in.readOptionalString(); | ||
int size = in.readVInt(); | ||
Map<String, String[]> acknowledgeMessages = new HashMap<>(size); | ||
for (int i = 0; i < size; i++) { | ||
String feature = in.readString(); | ||
int nMessages = in.readVInt(); | ||
String[] messages = new String[nMessages]; | ||
for (int j = 0; j < nMessages; j++) { | ||
messages[j] = in.readString(); | ||
} | ||
acknowledgeMessages.put(feature, messages); | ||
} | ||
this.acknowledgeMessages = acknowledgeMessages; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeVInt(status.id()); | ||
out.writeOptionalString(acknowledgeHeader); | ||
out.writeVInt(acknowledgeMessages.size()); | ||
for (Map.Entry<String, String[]> entry : acknowledgeMessages.entrySet()) { | ||
out.writeString(entry.getKey()); | ||
out.writeVInt(entry.getValue().length); | ||
for (String message : entry.getValue()) { | ||
out.writeString(message); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void addCustomFields(XContentBuilder builder, Params params) throws IOException { | ||
builder.field("license_status", status.toString()); | ||
if (!acknowledgeMessages.isEmpty()) { | ||
builder.startObject("acknowledge"); | ||
builder.field("message", acknowledgeHeader); | ||
for (Map.Entry<String, String[]> entry : acknowledgeMessages.entrySet()) { | ||
builder.startArray(entry.getKey()); | ||
for (String message : entry.getValue()) { | ||
builder.value(message); | ||
} | ||
builder.endArray(); | ||
} | ||
builder.endObject(); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Strings.toString(this, true, true); | ||
} | ||
|
||
public static PutLicenseResponse fromXContent(XContentParser parser) throws IOException { | ||
return PARSER.parse(parser, null); | ||
} | ||
|
@@ -205,5 +151,4 @@ public int hashCode() { | |
return Objects.hash(super.hashCode(), status, ProtocolUtils.hashCode(acknowledgeMessages), acknowledgeHeader); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lolwut... thanks for nothing, git.