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

Add support for high level Kafka consumer mode #7504

Merged
merged 19 commits into from
Mar 11, 2020
Merged
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public Map<String, Map<String, Object>> asList() {
config.put("is_optional", f.isOptional().equals(ConfigurationField.Optional.OPTIONAL));
config.put("attributes", f.getAttributes());
config.put("additional_info", f.getAdditionalInformation());
config.put("position", f.getPosition());

configs.put(f.getName(), config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ public abstract class AbstractConfigurationField implements ConfigurationField {
protected final String humanName;
protected final String description;
protected final ConfigurationField.Optional optional;
protected int position;

public AbstractConfigurationField(String field_type, String name, String humanName, String description, ConfigurationField.Optional optional1) {
this.field_type = field_type;
this.name = name;
this.humanName = humanName;
this.description = description;
this.optional = optional1;
this.position = DEFAULT_POSITION;
}
public AbstractConfigurationField(String field_type, String name, String humanName, String description, ConfigurationField.Optional optional1, int position) {
this(field_type, name, humanName,description,optional1);
this.position = position;
}

@Override
Expand Down Expand Up @@ -69,4 +75,9 @@ public List<String> getAttributes() {
public Map<String, Map<String, String>> getAdditionalInformation() {
return Collections.emptyMap();
}

@Override
public int getPosition() {
return position;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public BooleanField(String name, String humanName, boolean defaultValue, String
super(FIELD_TYPE, name, humanName, description, Optional.OPTIONAL);
this.defaultValue = defaultValue;
}
public BooleanField(String name, String humanName, boolean defaultValue, String description, int position) {
super(FIELD_TYPE, name, humanName, description, Optional.OPTIONAL, position);
this.defaultValue = defaultValue;
}

@Override
public Object getDefaultValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.util.Map;

public interface ConfigurationField {
int DEFAULT_POSITION = 100; // corresponds to ConfigurationForm.jsx
int PLACE_AT_END_POSITION = 200;

enum Optional {
OPTIONAL,
NOT_OPTIONAL
Expand All @@ -42,4 +45,8 @@ enum Optional {
List<String> getAttributes();

Map<String, Map<String, String>> getAdditionalInformation();

default int getPosition() {
return DEFAULT_POSITION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ public TextField(String name, String humanName, String defaultValue, String desc
}
}
}
public TextField(String name, String humanName, String defaultValue, String description, Optional isOptional, int position, Attribute... attrs) {
super(FIELD_TYPE, name, humanName, description, isOptional, position);
this.defaultValue = defaultValue;
this.attributes = Lists.newArrayList();
if (attrs != null) {
for (Attribute attribute : attrs) {
this.attributes.add(attribute.toString().toLowerCase(Locale.ENGLISH));
}
}
}

@Override
public Object getDefaultValue() {
Expand Down
1 change: 1 addition & 0 deletions graylog2-server/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<!-- Silence Kafka log chatter -->
<Logger name="kafka.log.Log" level="warn"/>
<Logger name="kafka.log.OffsetIndex" level="warn"/>
<Logger name="org.apache.kafka.clients.consumer.ConsumerConfig" level="warn"/>
<!-- Silence useless session validation messages -->
<Logger name="org.apache.shiro.session.mgt.AbstractValidatingSessionManager" level="warn"/>
<Root level="warn">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ class ConfigurationForm extends React.Component {
};
};

_sortByOptionality = (x1, x2) => {
_sortByPosOrOptionality = (x1, x2) => {
const { configFields } = this.state;
let diff = configFields[x1.name].is_optional - configFields[x2.name].is_optional;
const DEFAULT_POSITION = 100; // corresponds to ConfigurationField.java
const x1pos = configFields[x1.name].position || DEFAULT_POSITION;
const x2pos = configFields[x2.name].position || DEFAULT_POSITION;

let diff = x1pos - x2pos;
if (!diff) {
diff = configFields[x1.name].is_optional - configFields[x2.name].is_optional;
}

if (!diff) {
// Sort equal fields stably
Expand Down Expand Up @@ -163,7 +170,7 @@ class ConfigurationForm extends React.Component {
const { configFields } = this.state;
const configFieldKeys = $.map(configFields, (field, name) => name)
.map((name, pos) => ({ name: name, pos: pos }))
.sort(this._sortByOptionality);
.sort(this._sortByPosOrOptionality);

const renderedConfigFields = configFieldKeys.map((key) => {
const configField = this._renderConfigField(configFields[key.name], key.name, shouldAutoFocus);
Expand Down