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

Annotations to support config/counters documentation/validation #1593

Merged
merged 25 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b6f2e4c
[Java] initial work
nbradac Apr 23, 2024
36a6000
Merge branch 'master' into config_doc_gen
nbradac Apr 23, 2024
9023ddf
[Java] add basic aeron counter annotation/validation
nbradac Apr 29, 2024
6bc0e9f
Merge branch 'master' into config_doc_gen
nbradac Apr 29, 2024
149c608
[Java] appease checkstyle
nbradac Apr 30, 2024
ecd220e
[Java] add aeron-client tasks, annotate more elements
nbradac May 7, 2024
4ab6cca
Merge branch 'master' into config_doc_gen
nbradac May 7, 2024
ea4a3cb
[Java] more driver annotations
nbradac May 8, 2024
3014078
[JAVA] switch flow control group tag to long instead of string
nbradac May 8, 2024
17f9a99
[Java] refactor to use xml instead of json as intermediate data format
nbradac May 8, 2024
214fefb
[Java] use native java object serialization instead of xml
nbradac May 9, 2024
50b110d
[Java] store Objects as Serializable
nbradac May 9, 2024
454f9a8
[Java] store defaults as Strings
nbradac May 9, 2024
f2239cd
[Java] remove unused import
nbradac May 9, 2024
90d4a01
[Java] allow c default validation to be skipped
nbradac May 9, 2024
4d4425c
[Java] driver c validation complete
nbradac May 10, 2024
fbee032
[Java] refactor Grep object to avoid leaving a stream open
nbradac May 10, 2024
7502c0a
[Java] add config to refactored processor, update AeronCounters
nbradac May 15, 2024
f4c4091
[Java] add config annotation to cluster
nbradac May 16, 2024
e618608
[Java] add config annotation to archive
nbradac May 17, 2024
4a498eb
[Java] fix duplicate config ids
nbradac May 21, 2024
1dd3f28
Merge branch 'master' into config_doc_gen
nbradac May 21, 2024
af23a71
Merge branch 'master' into config_doc_gen
nbradac May 29, 2024
dfb3032
[Java] allow processors to be disabled via system property
nbradac Jun 3, 2024
8b55509
[Java] address CodeQL issues
nbradac Jun 4, 2024
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
133 changes: 133 additions & 0 deletions aeron-annotations/src/main/java/io/aeron/config/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Copyright 2014-2024 Real Logic Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.aeron.config;

import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;

/**
* Annotation to indicate this is a config option
*/
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.SOURCE)
public @interface Config
{
/**
* Type is used to indicate whether the annotation is marking a property name or a default value
*/
enum Type
{
UNDEFINED, PROPERTY_NAME, DEFAULT
}

/**
* @return what type of field is being annotated
*/
Type configType() default Type.UNDEFINED;

/**
* @return the unique id that ties together all the usages of the annotation across fields/methods
*/
String id() default "";

/**
* @return the uri parameter (if any) associated with this option
*/
String uriParam() default "";

/**
* @return whether or not this config option exists in the C code
*/
boolean existsInC() default true;

/**
* @return the expected C #define name that will be set with the env variable name for this option
*/
String expectedCEnvVarFieldName() default "";

/**
* @return the expected C env variable name for this option
*/
String expectedCEnvVar() default "";

/**
* @return the expected C #define name that will be set with the default value for this option
*/
String expectedCDefaultFieldName() default "";

/**
* @return the expected C default value for this option
*/
String expectedCDefault() default "";

/**
* @return whether to skip validation of the default in C
*/
boolean skipCDefaultValidation() default false;

/**
* @return what's the type of default (string, int, etc...)
*/
DefaultType defaultType() default DefaultType.UNDEFINED;

/**
* @return specify the default boolean, if defaultType is BOOLEAN
*/
boolean defaultBoolean() default false;

/**
* @return specify the default int, if defaultType is INT
*/
int defaultInt() default 0;

/**
* @return specify the default long, if defaultType is LONG
*/
long defaultLong() default 0;

/**
* @return specify the default double, if defaultType is DOUBLE
*/
double defaultDouble() default 0.0;

/**
* @return specify the default string, if defaultType is STRING
*/
String defaultString() default "";

/**
* Used to indicate whether or not the default value is a time value
*/
enum IsTimeValue
{
UNDEFINED, TRUE, FALSE
}

/**
* @return whether or not the default value is a time value
*/
IsTimeValue isTimeValue() default IsTimeValue.UNDEFINED;

/**
* @return the time unit if the default value is a time value of some sort
*/
TimeUnit timeUnit() default TimeUnit.NANOSECONDS;

/**
* @return whether or not this config option has a 'context'
*/
boolean hasContext() default true;
}
78 changes: 78 additions & 0 deletions aeron-annotations/src/main/java/io/aeron/config/ConfigInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2014-2024 Real Logic Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.aeron.config;

import java.io.Serializable;
import java.util.concurrent.TimeUnit;

/**
* A handy class for storing data that gets serialized into json
*/
public class ConfigInfo implements Serializable
{
private static final long serialVersionUID = 6600224566064248728L;

public final String id;
public final ExpectedConfig expectations;

/**
* @param id the unique identifier for this block o' config information
*/
public ConfigInfo(final String id)
{
this.id = id;
expectations = new ExpectedConfig();
}

public boolean foundPropertyName = false;
public boolean foundDefault = false;

public String propertyNameDescription;

public String propertyNameFieldName;

public String propertyNameClassName;

public String propertyName;

public String defaultDescription;

public String defaultFieldName;

public String defaultClassName;

public String defaultValue;

public DefaultType defaultValueType = DefaultType.UNDEFINED;

public String overrideDefaultValue;

public DefaultType overrideDefaultValueType = DefaultType.UNDEFINED;

public String uriParam;

public boolean hasContext = true;

public String context;

public String contextDescription;

public Boolean isTimeValue;

public TimeUnit timeUnit;

public boolean deprecated = false;
}
Loading