Skip to content

Commit

Permalink
style: just rename SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Lambert-Rao committed Mar 15, 2024
1 parent a2a67e9 commit 559da54
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client;
package org.apache.eventmesh.dashboard.console.function.SDK;

public abstract class AbstractSDKOperation<T> implements SDKOperation<T> {

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

package org.apache.eventmesh.dashboard.console.function.client;
package org.apache.eventmesh.dashboard.console.function.SDK;

import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.client.operation.NacosConfigSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.operation.NacosNamingSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.operation.NacosSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.operation.RedisSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.operation.RocketMQProduceSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.operation.RocketMQPushConsumerSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.operation.RocketMQRemotingSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.NacosConfigSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.NacosNamingSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.NacosSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RedisSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RocketMQProduceSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RocketMQPushConsumerSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.operation.RocketMQRemotingSDKOperation;

import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
Expand All @@ -49,39 +49,39 @@ public static SDKManager getInstance() {
/**
* inner key is the unique key of a client, such as (ip + port) they are defined in CreateClientConfig
*
* @see CreateClientConfig#getUniqueKey()
* @see CreateSDKConfig#getUniqueKey()
*/

private final Map<ClientTypeEnum, Map<String, Object>> clientMap = new ConcurrentHashMap<>();
private final Map<SDKTypeEnum, Map<String, Object>> clientMap = new ConcurrentHashMap<>();

private final Map<ClientTypeEnum, SDKOperation<?>> clientCreateOperationMap = new ConcurrentHashMap<>();
private final Map<SDKTypeEnum, SDKOperation<?>> clientCreateOperationMap = new ConcurrentHashMap<>();

// register all client create operation
{
for (ClientTypeEnum clientTypeEnum : ClientTypeEnum.values()) {
for (SDKTypeEnum clientTypeEnum : SDKTypeEnum.values()) {
clientMap.put(clientTypeEnum, new ConcurrentHashMap<>());
}

clientCreateOperationMap.put(ClientTypeEnum.STORAGE_REDIS, new RedisSDKOperation());
clientCreateOperationMap.put(SDKTypeEnum.STORAGE_REDIS, new RedisSDKOperation());

clientCreateOperationMap.put(ClientTypeEnum.STORAGE_ROCKETMQ_REMOTING, new RocketMQRemotingSDKOperation());
clientCreateOperationMap.put(ClientTypeEnum.STORAGE_ROCKETMQ_PRODUCER, new RocketMQProduceSDKOperation());
clientCreateOperationMap.put(ClientTypeEnum.STORAGE_ROCKETMQ_CONSUMER, new RocketMQPushConsumerSDKOperation());
clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, new RocketMQRemotingSDKOperation());
clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_PRODUCER, new RocketMQProduceSDKOperation());
clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_CONSUMER, new RocketMQPushConsumerSDKOperation());

clientCreateOperationMap.put(ClientTypeEnum.CENTER_NACOS, new NacosSDKOperation());
clientCreateOperationMap.put(ClientTypeEnum.CENTER_NACOS_CONFIG, new NacosConfigSDKOperation());
clientCreateOperationMap.put(ClientTypeEnum.CENTER_NACOS_NAMING, new NacosNamingSDKOperation());
clientCreateOperationMap.put(SDKTypeEnum.META_NACOS, new NacosSDKOperation());
clientCreateOperationMap.put(SDKTypeEnum.META_NACOS_CONFIG, new NacosConfigSDKOperation());
clientCreateOperationMap.put(SDKTypeEnum.META_NACOS_NAMING, new NacosNamingSDKOperation());

}

private SDKManager() {
}

public <T> SimpleEntry<String, T> createClient(ClientTypeEnum clientTypeEnum, CreateClientConfig config) {
public <T> SimpleEntry<String, T> createClient(SDKTypeEnum clientTypeEnum, CreateSDKConfig config) {
return createClient(clientTypeEnum, config.getUniqueKey(), config);
}

public <T> SimpleEntry<String, T> createClient(ClientTypeEnum clientTypeEnum, String uniqueKey, CreateClientConfig config) {
public <T> SimpleEntry<String, T> createClient(SDKTypeEnum clientTypeEnum, String uniqueKey, CreateSDKConfig config) {

Map<String, Object> clients = this.clientMap.get(clientTypeEnum);

Expand All @@ -99,7 +99,7 @@ public <T> SimpleEntry<String, T> createClient(ClientTypeEnum clientTypeEnum, St
}
}

public void deleteClient(ClientTypeEnum clientTypeEnum, String uniqueKey) {
public void deleteClient(SDKTypeEnum clientTypeEnum, String uniqueKey) {
Map<String, Object> clients = this.clientMap.get(clientTypeEnum);
SDKOperation<?> operation = this.clientCreateOperationMap.get(clientTypeEnum);
try {
Expand All @@ -110,7 +110,7 @@ public void deleteClient(ClientTypeEnum clientTypeEnum, String uniqueKey) {
clients.remove(uniqueKey);
}

public Object getClient(ClientTypeEnum clientTypeEnum, String uniqueKey) {
public Object getClient(SDKTypeEnum clientTypeEnum, String uniqueKey) {
return this.clientMap.get(clientTypeEnum).get(uniqueKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client;
package org.apache.eventmesh.dashboard.console.function.SDK;

import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;

import java.util.AbstractMap.SimpleEntry;

Expand All @@ -28,7 +28,7 @@
*/
public interface SDKOperation<T> {

public SimpleEntry<String, T> createClient(CreateClientConfig clientConfig);
public SimpleEntry<String, T> createClient(CreateSDKConfig clientConfig);


public void close(Object client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client;
package org.apache.eventmesh.dashboard.console.function.SDK;

public enum ClientTypeEnum {
public enum SDKTypeEnum {

RUNTIME,

Expand All @@ -29,10 +29,10 @@ public enum ClientTypeEnum {

STORAGE_REDIS,

CENTER_NACOS,
CENTER_NACOS_CONFIG,
META_NACOS,
META_NACOS_CONFIG,

CENTER_NACOS_NAMING,
META_NACOS_NAMING,


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

package org.apache.eventmesh.dashboard.console.function.client.config;
package org.apache.eventmesh.dashboard.console.function.SDK.config;

import lombok.Data;

@Data
public class CreateNacosConfig implements CreateClientConfig {
public class CreateNacosConfig implements CreateSDKConfig {

private String serverAddress;

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

package org.apache.eventmesh.dashboard.console.function.client.config;
package org.apache.eventmesh.dashboard.console.function.SDK.config;

import lombok.Data;

@Data
public class CreateRedisConfig implements CreateClientConfig {
public class CreateRedisConfig implements CreateSDKConfig {

private String redisUrl;

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

package org.apache.eventmesh.dashboard.console.function.client.config;
package org.apache.eventmesh.dashboard.console.function.SDK.config;

import org.apache.rocketmq.client.consumer.listener.MessageListener;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;

import lombok.Data;

@Data
public class CreateRocketmqConfig implements CreateClientConfig {
public class CreateRocketmqConfig implements CreateSDKConfig {

// common
private String nameServerUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client.config;
package org.apache.eventmesh.dashboard.console.function.SDK.config;

/**
* Config to create an SDK client, usually contains an address url.
*/
public interface CreateClientConfig {
public interface CreateSDKConfig {

String getUniqueKey();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client.operation;
package org.apache.eventmesh.dashboard.console.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.client.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;

import java.util.AbstractMap.SimpleEntry;

public class EtcdSDKOperation extends AbstractSDKOperation {
@Override
public SimpleEntry createClient(CreateClientConfig clientConfig) {
public SimpleEntry createClient(CreateSDKConfig clientConfig) {
return null;
}

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

package org.apache.eventmesh.dashboard.console.function.client.operation;
package org.apache.eventmesh.dashboard.console.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.client.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateNacosConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateNacosConfig;

import java.util.AbstractMap.SimpleEntry;
import java.util.Properties;
Expand All @@ -34,7 +34,7 @@
public class NacosConfigSDKOperation extends AbstractSDKOperation<ConfigService> {

@Override
public SimpleEntry<String, ConfigService> createClient(CreateClientConfig clientConfig) {
public SimpleEntry<String, ConfigService> createClient(CreateSDKConfig clientConfig) {
ConfigService configService = null;
CreateNacosConfig config = (CreateNacosConfig) clientConfig;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client.operation;
package org.apache.eventmesh.dashboard.console.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.client.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateNacosConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateNacosConfig;

import java.util.AbstractMap.SimpleEntry;
import java.util.Properties;
Expand All @@ -35,7 +35,7 @@
public class NacosNamingSDKOperation extends AbstractSDKOperation<NamingService> {

@Override
public SimpleEntry<String, NamingService> createClient(CreateClientConfig clientConfig) {
public SimpleEntry<String, NamingService> createClient(CreateSDKConfig clientConfig) {
NamingService namingService = null;
CreateNacosConfig config = (CreateNacosConfig) clientConfig;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client.operation;
package org.apache.eventmesh.dashboard.console.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.client.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.client.wrapper.NacosClientWrapper;
import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.wrapper.NacosSDKWrapper;

import java.util.AbstractMap.SimpleEntry;

import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.naming.NamingService;

public class NacosSDKOperation extends AbstractSDKOperation<NacosClientWrapper> {
public class NacosSDKOperation extends AbstractSDKOperation<NacosSDKWrapper> {

private final NacosConfigSDKOperation nacosConfigClientCreateOperation = new NacosConfigSDKOperation();
private final NacosNamingSDKOperation nacosNamingClientCreateOperation = new NacosNamingSDKOperation();

@Override
public SimpleEntry<String, NacosClientWrapper> createClient(CreateClientConfig createClientConfig) {
public SimpleEntry<String, NacosSDKWrapper> createClient(CreateSDKConfig createClientConfig) {
SimpleEntry<String, ConfigService> configSimpleEntry = nacosConfigClientCreateOperation.createClient(createClientConfig);
SimpleEntry namingSimpleEntry = nacosNamingClientCreateOperation.createClient(createClientConfig);
if (configSimpleEntry.getKey() != namingSimpleEntry.getKey()) {
throw new RuntimeException("Nacos config and naming server address not match");
}
NacosClientWrapper nacosClient = new NacosClientWrapper(
NacosSDKWrapper nacosClient = new NacosSDKWrapper(
(ConfigService) configSimpleEntry.getValue(), (NamingService) namingSimpleEntry.getValue()
);
return new SimpleEntry<>(configSimpleEntry.getKey(), nacosClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client.operation;
package org.apache.eventmesh.dashboard.console.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.client.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateRedisConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateRedisConfig;

import java.util.AbstractMap.SimpleEntry;

Expand All @@ -29,7 +29,7 @@
public class RedisSDKOperation extends AbstractSDKOperation<StatefulRedisConnection<String, String>> {

@Override
public SimpleEntry<String, StatefulRedisConnection<String, String>> createClient(CreateClientConfig clientConfig) {
public SimpleEntry<String, StatefulRedisConnection<String, String>> createClient(CreateSDKConfig clientConfig) {
String redisUrl = ((CreateRedisConfig) clientConfig).getRedisUrl();
RedisClient redisClient = RedisClient.create(redisUrl);
return new SimpleEntry<>(clientConfig.getUniqueKey(), redisClient.connect());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client.operation;
package org.apache.eventmesh.dashboard.console.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.client.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateRocketmqConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateRocketmqConfig;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
Expand All @@ -32,7 +32,7 @@
public class RocketMQProduceSDKOperation extends AbstractSDKOperation<DefaultMQProducer> {

@Override
public SimpleEntry<String, DefaultMQProducer> createClient(CreateClientConfig clientConfig) {
public SimpleEntry<String, DefaultMQProducer> createClient(CreateSDKConfig clientConfig) {
DefaultMQProducer producer = null;
try {
CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.function.client.operation;
package org.apache.eventmesh.dashboard.console.function.SDK.operation;

import org.apache.eventmesh.dashboard.console.function.client.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateClientConfig;
import org.apache.eventmesh.dashboard.console.function.client.config.CreateRocketmqConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.AbstractSDKOperation;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateSDKConfig;
import org.apache.eventmesh.dashboard.console.function.SDK.config.CreateRocketmqConfig;

import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.exception.MQClientException;
Expand All @@ -32,7 +32,7 @@
public class RocketMQPushConsumerSDKOperation extends AbstractSDKOperation<DefaultMQPushConsumer> {

@Override
public SimpleEntry<String, DefaultMQPushConsumer> createClient(CreateClientConfig clientConfig) {
public SimpleEntry<String, DefaultMQPushConsumer> createClient(CreateSDKConfig clientConfig) {
DefaultMQPushConsumer consumer = null;
try {
CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig;
Expand Down
Loading

0 comments on commit 559da54

Please sign in to comment.