Skip to content
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
6 changes: 3 additions & 3 deletions agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ ShardingSphere-Agent module provides an observable framework for ShardingSphere,
### Logging

The logging plugin uses to record logs of ShardingSphere.
Supports for File.
Support for File.

### Metrics

The metrics plugin uses to collect and expose monitoring metrics.
Supports for prometheus.
Support for prometheus.

### Tracing

The tracing plugin uses to obtain the link trace information of SQL parsing and SQL execution.
Supports for OpenTelemetry.
Support for OpenTelemetry.

## How To Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void assertAdviceCatchException() {
assertDoesNotThrow(() -> executor.advice(new SimpleTargetAdviceObject(), new Object[]{new LinkedList<>()}));
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
void assertIntercept() {
Builder<?> builder = mock(Builder.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void assertAdviceWhenAfterThrows() throws ReflectiveOperationException {
assertThat(queue, is(Arrays.asList("first before foo", "second before bar", "origin call")));
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
void assertIntercept() {
Builder<?> builder = mock(Builder.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AgentBuilderFactoryTest {
@BeforeAll
static void setup() {
ByteBuddyAgent.install();
AdvisorConfiguration advisorConfig = createAdvisorConfiguration(TARGET_CLASS_NAME);
AdvisorConfiguration advisorConfig = createAdvisorConfiguration();
Map<String, AdvisorConfiguration> advisorConfigs = Collections.singletonMap(advisorConfig.getTargetClassName(), advisorConfig);
AgentBuilder agentBuilder = AgentBuilderFactory.create(Collections.emptyMap(), Collections.emptyList(), advisorConfigs, true);
agent = agentBuilder.installOnByteBuddyAgent();
Expand All @@ -62,8 +62,8 @@ static void setup() {
.getLoaded();
}

private static AdvisorConfiguration createAdvisorConfiguration(final String targetClassName) {
AdvisorConfiguration result = new AdvisorConfiguration(targetClassName);
private static AdvisorConfiguration createAdvisorConfiguration() {
AdvisorConfiguration result = new AdvisorConfiguration(TARGET_CLASS_NAME);
result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.isConstructor().and(ElementMatchers.takesArguments(1)), FooAdvice.class.getName(), "FIXTURE"));
result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.isConstructor().and(ElementMatchers.takesArguments(1)), BarAdvice.class.getName(), "FIXTURE"));
result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("call"), FooAdvice.class.getName(), "FIXTURE"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class YamlPluginConfigurationLoaderTest {
@Test
void assertLoad(@TempDir final Path tempDir) throws IOException {
Path yamlFile = tempDir.resolve("agent.yaml");
String yamlContent = ""
+ "plugins:\n"
String yamlContent = "plugins:\n"
+ " logging:\n"
+ " FILE:\n"
+ " host: localhost\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.file.Files;
import java.util.LinkedHashMap;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -102,9 +101,7 @@ void assertSwapWithNullLoggingPlugins() {
@Test
void assertSwapWithNullPluginConfigurationValue() {
YamlPluginCategoryConfiguration yamlPluginCategoryConfig = new YamlPluginCategoryConfiguration();
Map<String, YamlPluginConfiguration> logging = new LinkedHashMap<>();
logging.put("log_fixture", null);
yamlPluginCategoryConfig.setLogging(logging);
yamlPluginCategoryConfig.setLogging(Collections.singletonMap("log_fixture", null));
YamlAgentConfiguration yamlAgentConfig = new YamlAgentConfiguration();
yamlAgentConfig.setPlugins(yamlPluginCategoryConfig);
Map<String, PluginConfiguration> actual = YamlPluginsConfigurationSwapper.swap(yamlAgentConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import org.apache.shardingsphere.agent.api.PluginConfiguration;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

class PluginConfigurationValidatorTest {

@Test
void assertValidateHostAndPortSuccess() {
PluginConfigurationValidator.validateHostAndPort("foo_type", new PluginConfiguration("localhost", 8080, "pwd", null));
assertDoesNotThrow(() -> PluginConfigurationValidator.validateHostAndPort("foo_type", new PluginConfiguration("localhost", 8080, "pwd", null)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void assertObserveWithoutBuckets() throws ReflectiveOperationException {
MetricCollectorType.HISTOGRAM, "foo_help", Collections.emptyList(), Collections.emptyMap()));
collector.observe(1D);
Histogram histogram = (Histogram) Plugins.getMemberAccessor().get(PrometheusMetricsHistogramCollector.class.getDeclaredField("histogram"), collector);
assertThat(histogram.collect().get(0).samples.stream().filter(sample -> sample.name.endsWith("_count")).findFirst().get().value, is(1D));
assertThat(histogram.collect().get(0).samples.stream().filter(sample -> sample.name.endsWith("_count")).findFirst().map(optional -> optional.value).orElse(0D), is(1D));
}

@Test
Expand Down
5 changes: 0 additions & 5 deletions src/resources/idea/inspections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
<inspection_tool class="DoubleLiteralMayBeFloatLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DuplicateExpressions" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="DuplicatedBeanNamesInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="DynamicRegexReplaceableByCompiledPattern" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="EmptyClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignorableAnnotations">
<value />
Expand Down Expand Up @@ -215,7 +214,6 @@
<inspection_tool class="GroovyUnsynchronizedMethodOverridesSynchronizedMethod" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="GroovyUnusedAssignment" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="GroovyUnusedIncOrDec" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="HardcodedLineSeparators" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="HasPlatformType" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="HashCodeUsesNonFinalVariable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="HtmlExtraClosingTag" enabled="false" level="WARNING" enabled_by_default="false" />
Expand All @@ -242,9 +240,6 @@
<inspection_tool class="InjectionValueTypeInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="InnerClassReferencedViaSubclass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="InstanceofCatchParameter" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="InstanceofChain" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreInstanceofOnLibraryClasses" value="false" />
</inspection_tool>
<inspection_tool class="InstanceofThis" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="IntLiteralMayBeLongLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="IntroduceWhenSubject" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
Expand Down
Loading