-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Annotations to support config/counters documentation/validation (#1593)
* [Java] initial work * [Java] add basic aeron counter annotation/validation * [Java] appease checkstyle * [Java] add aeron-client tasks, annotate more elements * [Java] more driver annotations * [JAVA] switch flow control group tag to long instead of string * [Java] refactor to use xml instead of json as intermediate data format * [Java] use native java object serialization instead of xml * [Java] store Objects as Serializable * [Java] store defaults as Strings * [Java] remove unused import * [Java] allow c default validation to be skipped * [Java] driver c validation complete * [Java] refactor Grep object to avoid leaving a stream open * [Java] add config to refactored processor, update AeronCounters * [Java] add config annotation to cluster * [Java] add config annotation to archive * [Java] fix duplicate config ids * [Java] allow processors to be disabled via system property * [Java] address CodeQL issues
- Loading branch information
Showing
39 changed files
with
3,586 additions
and
16 deletions.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
aeron-annotations/src/main/java/io/aeron/config/Config.java
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 |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* 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, ElementType.TYPE}) | ||
@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 ""; | ||
|
||
/** | ||
* @return specify a string that acts as a stand-in for the default value when generating documentation | ||
*/ | ||
String defaultValueString() 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; | ||
} |
80 changes: 80 additions & 0 deletions
80
aeron-annotations/src/main/java/io/aeron/config/ConfigInfo.java
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* 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 String defaultValueString; | ||
|
||
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; | ||
} |
Oops, something went wrong.