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

Rename TracingStorageFixture #2355

Merged
merged 3 commits into from
Oct 31, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
/**
* Data source configuration.
*/
@Getter
@RequiredArgsConstructor
@Getter
public final class DataSourceConfiguration implements TracingStorageConfiguration<DataSource> {

private static final String GETTER_PREFIX = "get";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.apache.shardingsphere.elasticjob.kernel.tracing.api.TracingConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobEvent;
import org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobExecutionEvent;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCaller;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.TestTracingListener;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixture;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.listener.TestTracingListener;
import org.apache.shardingsphere.elasticjob.test.util.ReflectionUtils;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
Expand All @@ -42,7 +42,7 @@
class JobTracingEventBusTest {

@Mock
private JobEventCaller jobEventCaller;
private TracingStorageFixture tracingStorage;

@Mock
private EventBus eventBus;
Expand All @@ -57,11 +57,11 @@ void assertRegisterFailure() {

@Test
void assertPost() {
jobTracingEventBus = new JobTracingEventBus(new TracingConfiguration<>("TEST", jobEventCaller));
jobTracingEventBus = new JobTracingEventBus(new TracingConfiguration<>("TEST", tracingStorage));
assertTrue((Boolean) ReflectionUtils.getFieldValue(jobTracingEventBus, "isRegistered"));
jobTracingEventBus.post(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0));
Awaitility.await().pollDelay(100L, TimeUnit.MILLISECONDS).until(TestTracingListener::isExecutionEventCalled);
verify(jobEventCaller).call();
verify(tracingStorage).call();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture;
package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.elasticjob.kernel.tracing.api.TracingStorageConfiguration;

/**
* {@link TracingStorageConfiguration} for {@link JobEventCaller}.
*/
@RequiredArgsConstructor
public final class JobEventCallerConfiguration implements TracingStorageConfiguration<JobEventCaller> {

private final JobEventCaller jobEventCaller;
@Getter
public final class TracingStorageConfigurationFixture implements TracingStorageConfiguration<TracingStorageFixture> {

@Override
public JobEventCaller getStorage() {
return jobEventCaller;
}
private final TracingStorageFixture storage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture;
package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config;

public interface JobEventCaller {
public interface TracingStorageFixture {

/**
* Execute call.
* Call.
*/
void call();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture;
package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config;

import org.apache.shardingsphere.elasticjob.kernel.tracing.api.TracingStorageConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.storage.TracingStorageConverter;

/**
* {@link TracingStorageConverter} for {@link JobEventCaller}.
*/
public final class JobEventCallerConverter implements TracingStorageConverter<JobEventCaller> {
public final class TracingStorageFixtureConverter implements TracingStorageConverter<TracingStorageFixture> {

@Override
public TracingStorageConfiguration<JobEventCaller> convertObjectToConfiguration(final JobEventCaller storage) {
return new JobEventCallerConfiguration(storage);
public TracingStorageConfiguration<TracingStorageFixture> convertObjectToConfiguration(final TracingStorageFixture storage) {
return new TracingStorageConfigurationFixture(storage);
}

@Override
public Class<JobEventCaller> storageType() {
return JobEventCaller.class;
public Class<TracingStorageFixture> storageType() {
return TracingStorageFixture.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture;
package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.listener;

import org.apache.shardingsphere.elasticjob.kernel.tracing.listener.TracingListenerConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.listener.TracingListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture;
package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.listener;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixture;
import org.apache.shardingsphere.elasticjob.kernel.tracing.listener.TracingListener;
import org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobExecutionEvent;
import org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobStatusTraceEvent;
Expand All @@ -29,17 +30,17 @@ public final class TestTracingListener implements TracingListener {
@Getter
private static volatile boolean executionEventCalled;

private final JobEventCaller jobEventCaller;
private final TracingStorageFixture tracingStorageFixture;

@Override
public void listen(final JobExecutionEvent jobExecutionEvent) {
jobEventCaller.call();
tracingStorageFixture.call();
executionEventCalled = true;
}

@Override
public void listen(final JobStatusTraceEvent jobStatusTraceEvent) {
jobEventCaller.call();
tracingStorageFixture.call();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture;
package org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.listener;

import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixture;
import org.apache.shardingsphere.elasticjob.kernel.tracing.listener.TracingListenerConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.listener.TracingListener;

public final class TestTracingListenerConfiguration implements TracingListenerConfiguration<JobEventCaller> {
public final class TestTracingListenerConfiguration implements TracingListenerConfiguration<TracingStorageFixture> {

@Override
public TracingListener createTracingListener(final JobEventCaller storage) {
public TracingListener createTracingListener(final TracingStorageFixture storage) {
return new TestTracingListener(storage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.shardingsphere.elasticjob.kernel.tracing.storage;

import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCaller;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixture;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -27,7 +27,7 @@ class TracingStorageConverterFactoryTest {

@Test
void assertConverterExists() {
assertTrue(TracingStorageConverterFactory.findConverter(JobEventCaller.class).isPresent());
assertTrue(TracingStorageConverterFactory.findConverter(TracingStorageFixture.class).isPresent());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.elasticjob.kernel.tracing.api.TracingStorageConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCaller;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCallerConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixture;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageConfigurationFixture;

/**
* YAML JobEventCaller configuration.
*/
@Getter
@Setter
public final class YamlJobEventCallerConfiguration implements YamlTracingStorageConfiguration<JobEventCaller> {
public final class YamlJobEventCallerConfiguration implements YamlTracingStorageConfiguration<TracingStorageFixture> {

private static final long serialVersionUID = -3152825887223378472L;

private JobEventCaller jobEventCaller;
private TracingStorageFixture tracingStorageFixture;

@Override
public TracingStorageConfiguration<JobEventCaller> toConfiguration() {
return new JobEventCallerConfiguration(jobEventCaller);
public TracingStorageConfiguration<TracingStorageFixture> toConfiguration() {
return new TracingStorageConfigurationFixture(tracingStorageFixture);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@

import org.apache.shardingsphere.elasticjob.kernel.infra.yaml.config.YamlConfigurationConverter;
import org.apache.shardingsphere.elasticjob.kernel.tracing.api.TracingStorageConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCaller;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCallerConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixture;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageConfigurationFixture;

/**
* YAML JobEventCaller configuration converter.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public final class YamlJobEventCallerConfigurationConverter implements YamlConfigurationConverter<TracingStorageConfiguration<JobEventCaller>, YamlTracingStorageConfiguration<JobEventCaller>> {
public final class YamlJobEventCallerConfigurationConverter
implements
YamlConfigurationConverter<TracingStorageConfiguration<TracingStorageFixture>, YamlTracingStorageConfiguration<TracingStorageFixture>> {

@Override
public YamlTracingStorageConfiguration<JobEventCaller> convertToYamlConfiguration(final TracingStorageConfiguration<JobEventCaller> data) {
public YamlTracingStorageConfiguration<TracingStorageFixture> convertToYamlConfiguration(final TracingStorageConfiguration<TracingStorageFixture> data) {
YamlJobEventCallerConfiguration result = new YamlJobEventCallerConfiguration();
result.setJobEventCaller(data.getStorage());
result.setTracingStorageFixture(data.getStorage());
return result;
}

@Override
public Class getType() {
return JobEventCallerConfiguration.class;
return TracingStorageConfigurationFixture.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.shardingsphere.elasticjob.kernel.tracing.yaml;

import org.apache.shardingsphere.elasticjob.kernel.tracing.api.TracingConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCaller;
import org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixture;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
Expand All @@ -30,15 +30,15 @@ class YamlTracingConfigurationConverterTest {

@Test
void assertConvertTracingConfiguration() {
JobEventCaller expectedStorage = () -> {
TracingStorageFixture expectedStorage = () -> {
};
TracingConfiguration<JobEventCaller> tracingConfig = new TracingConfiguration<>("TEST", expectedStorage);
YamlTracingConfigurationConverter<JobEventCaller> converter = new YamlTracingConfigurationConverter<>();
YamlTracingConfiguration<JobEventCaller> actual = converter.convertToYamlConfiguration(tracingConfig);
TracingConfiguration<TracingStorageFixture> tracingConfig = new TracingConfiguration<>("TEST", expectedStorage);
YamlTracingConfigurationConverter<TracingStorageFixture> converter = new YamlTracingConfigurationConverter<>();
YamlTracingConfiguration<TracingStorageFixture> actual = converter.convertToYamlConfiguration(tracingConfig);
assertThat(actual.getType(), is("TEST"));
assertNotNull(actual.getTracingStorageConfiguration());
assertTrue(actual.getTracingStorageConfiguration() instanceof YamlJobEventCallerConfiguration);
YamlJobEventCallerConfiguration result = (YamlJobEventCallerConfiguration) actual.getTracingStorageConfiguration();
assertThat(result.getJobEventCaller(), is(expectedStorage));
assertThat(result.getTracingStorageFixture(), is(expectedStorage));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# limitations under the License.
#

org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.TestTracingListenerConfiguration
org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.TestTracingFailureConfiguration
org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.listener.TestTracingListenerConfiguration
org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.listener.TestTracingFailureConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.JobEventCallerConverter
org.apache.shardingsphere.elasticjob.kernel.tracing.fixture.config.TracingStorageFixtureConverter