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

[X-Pack] Beats centralized management: security role + licensing #30520

Merged
merged 22 commits into from
Jul 10, 2018
Merged
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
Prev Previous commit
Next Next commit
Refactoring: extract common code into method
  • Loading branch information
ycombinator committed Jul 9, 2018
commit ee45e0313e63d5d139d32abe064a445c2af26dc9
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ private static String[] sqlAcknowledgementMessages(OperationMode currentMode, Op
return Strings.EMPTY_ARRAY;
}

private boolean isBasic() {
// status is volatile, so a local variable is used for a consistent view
Status localStatus = status;
return localStatus.mode == OperationMode.BASIC;
}

/** A wrapper for the license mode and state, to allow atomically swapping. */
private static class Status {

Expand Down Expand Up @@ -519,20 +525,7 @@ public boolean isRollupAllowed() {
*/
public boolean isLogstashAllowed() {
Status localStatus = status;

if (localStatus.active == false) {
return false;
}

switch (localStatus.mode) {
case TRIAL:
case GOLD:
case PLATINUM:
case STANDARD:
return true;
default:
return false;
}
return localStatus.active && !isBasic();
}

/**
Expand All @@ -541,20 +534,8 @@ public boolean isLogstashAllowed() {
*/
public boolean isBeatsAllowed() {
Copy link
Member

Choose a reason for hiding this comment

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

Given that the ingest team owns, I wonder if this should instead be isIngestAllowed and simply replace isLogstashAllowed? They share the same license requirements, so it seems reasonable to me that they shouldn't dupe their code too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally I feel like the code should reflect the products/features and not organization structure, as much as possible. So I'd like to keep this as-is.

I'd be okay with refactoring the duplicate code in the two methods into a helper method like isNotBasic or something like that. What do you think of that?

Copy link
Member

Choose a reason for hiding this comment

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

I'd be happy with an isNotBasic method.

Status localStatus = status;
return localStatus.active && !isBasic();

if (localStatus.active == false) {
return false;
}

switch (localStatus.mode) {
case TRIAL:
case GOLD:
case PLATINUM:
case STANDARD:
return true;
default:
return false;
}
}

/**
Expand Down