You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/08/05 14:47:19 UTC
[servicecomb-pack] 08/38: SCB-1369 Delete unused method & class
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git
commit b7f4cb0e2c0e5409cd922a45aa0f91e0f4512525
Author: Lei Zhang <co...@gmail.com>
AuthorDate: Fri Jul 26 14:51:05 2019 +0800
SCB-1369 Delete unused method & class
---
.../pack/alpha/core/fsm/PackSagaEvent.java | 150 ---------------------
.../servicecomb/pack/alpha/fsm/model/SagaData.java | 18 ---
.../eventbus/EventSubscribeBeanPostProcessor.java | 62 ---------
.../src/main/resources/application.yaml | 3 +-
.../alpha/server/fsm/AlphaIntegrationFsmTest.java | 13 +-
5 files changed, 11 insertions(+), 235 deletions(-)
diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/fsm/PackSagaEvent.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/fsm/PackSagaEvent.java
deleted file mode 100644
index 1588c55..0000000
--- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/fsm/PackSagaEvent.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- *
- * http://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 org.apache.servicecomb.pack.alpha.core.fsm;
-
-import java.util.Date;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-
-@Entity
-@Table(name = "PACK_SAGA_EVENT")
-public class PackSagaEvent {
- @Transient
- public static final long MAX_TIMESTAMP = 253402214400000L; // 9999-12-31 00:00:00
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long surrogateId;
-
- private String serviceName;
- private String instanceId;
- private Date creationTime;
- private String globalTxId;
- private String localTxId;
- private String parentTxId;
- private String type;
- private String compensationMethod;
- private Date expiryTime;
- private String retryMethod;
- private int retries;
- private byte[] payloads;
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static final class Builder {
-
- private String serviceName;
- private String instanceId;
- private Date creationTime;
- private String globalTxId;
- private String localTxId;
- private String parentTxId;
- private String type;
- private String compensationMethod;
- private Date expiryTime;
- private String retryMethod;
- private int retries;
- private byte[] payloads;
-
- private Builder() {
- }
-
- public Builder serviceName(String serviceName) {
- this.serviceName = serviceName;
- return this;
- }
-
- public Builder instanceId(String instanceId) {
- this.instanceId = instanceId;
- return this;
- }
-
- public Builder creationTime(Date creationTime) {
- this.creationTime = creationTime;
- return this;
- }
-
- public Builder globalTxId(String globalTxId) {
- this.globalTxId = globalTxId;
- return this;
- }
-
- public Builder localTxId(String localTxId) {
- this.localTxId = localTxId;
- return this;
- }
-
- public Builder parentTxId(String parentTxId) {
- this.parentTxId = parentTxId;
- return this;
- }
-
- public Builder type(String type) {
- this.type = type;
- return this;
- }
-
- public Builder compensationMethod(String compensationMethod) {
- this.compensationMethod = compensationMethod;
- return this;
- }
-
- public Builder expiryTime(Date expiryTime) {
- this.expiryTime = expiryTime;
- return this;
- }
-
- public Builder retryMethod(String retryMethod) {
- this.retryMethod = retryMethod;
- return this;
- }
-
- public Builder retries(int retries) {
- this.retries = retries;
- return this;
- }
-
- public Builder payloads(byte[] payloads) {
- this.payloads = payloads;
- return this;
- }
-
- public PackSagaEvent build() {
- PackSagaEvent packSagaEvent = new PackSagaEvent();
- packSagaEvent.instanceId = this.instanceId;
- packSagaEvent.serviceName = this.serviceName;
- packSagaEvent.localTxId = this.localTxId;
- packSagaEvent.retryMethod = this.retryMethod;
- packSagaEvent.creationTime = this.creationTime;
- packSagaEvent.compensationMethod = this.compensationMethod;
- packSagaEvent.payloads = this.payloads;
- packSagaEvent.globalTxId = this.globalTxId;
- packSagaEvent.retries = this.retries;
- packSagaEvent.type = this.type;
- packSagaEvent.parentTxId = this.parentTxId;
- packSagaEvent.expiryTime = this.expiryTime;
- return packSagaEvent;
- }
- }
-}
diff --git a/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/model/SagaData.java b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/model/SagaData.java
index e9a5f60..8f8e8f2 100644
--- a/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/model/SagaData.java
+++ b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/model/SagaData.java
@@ -19,13 +19,11 @@ package org.apache.servicecomb.pack.alpha.fsm.model;
import java.io.Serializable;
import java.util.Date;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.servicecomb.pack.alpha.core.fsm.PackSagaEvent;
import org.apache.servicecomb.pack.alpha.fsm.SagaActorState;
import org.apache.servicecomb.pack.alpha.fsm.event.base.BaseEvent;
@@ -136,22 +134,6 @@ public class SagaData implements Serializable {
return events;
}
- public List<PackSagaEvent> toPackSagaEventList(){
- List<PackSagaEvent> packSagaEventList = new LinkedList<>();
- events.forEach(event -> {
- packSagaEventList.add(PackSagaEvent.builder()
- .serviceName(serviceName)
- .instanceId(instanceId)
- .globalTxId(globalTxId)
- .localTxId(event.getLocalTxId())
- .parentTxId(event.getParentTxId())
- .creationTime(event.getCreateTime())
- .type(event.getClass().getSimpleName())
- .build());
- });
- return packSagaEventList;
- }
-
public static Builder builder() {
return new Builder();
}
diff --git a/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/spring/integration/eventbus/EventSubscribeBeanPostProcessor.java b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/spring/integration/eventbus/EventSubscribeBeanPostProcessor.java
deleted file mode 100644
index 11f2cb0..0000000
--- a/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/spring/integration/eventbus/EventSubscribeBeanPostProcessor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- *
- * http://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 org.apache.servicecomb.pack.alpha.fsm.spring.integration.eventbus;
-
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-
-public class EventSubscribeBeanPostProcessor implements BeanPostProcessor {
-
- @Autowired(required = false)
- @Qualifier("sagaEventBus")
- EventBus eventBus;
-
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
- return bean;
- }
-
- /**
- * If the spring bean's method defines @Subscribe, then register the spring bean into the Guava
- * Event
- */
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if(eventBus !=null){
- Method[] methods = bean.getClass().getMethods();
- for (Method method : methods) {
- Annotation[] annotations = method.getAnnotations();
- for (Annotation annotation : annotations) {
- if (annotation.annotationType().equals(Subscribe.class)) {
- eventBus.register(bean);
- return bean;
- }
- }
- }
- }
- return bean;
- }
-}
\ No newline at end of file
diff --git a/alpha/alpha-server/src/main/resources/application.yaml b/alpha/alpha-server/src/main/resources/application.yaml
index 6b5180f..ba00719 100644
--- a/alpha/alpha-server/src/main/resources/application.yaml
+++ b/alpha/alpha-server/src/main/resources/application.yaml
@@ -65,8 +65,9 @@ management:
health:
redis:
enabled: false
+ elasticsearch:
+ enabled: false
----
spring:
profiles: ssl
alpha:
diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/fsm/AlphaIntegrationFsmTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/fsm/AlphaIntegrationFsmTest.java
index 1865de2..257ca08 100644
--- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/fsm/AlphaIntegrationFsmTest.java
+++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/fsm/AlphaIntegrationFsmTest.java
@@ -44,6 +44,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@@ -62,9 +64,9 @@ import org.springframework.test.context.junit4.SpringRunner;
"akkaConfig.akka.persistence.snapshot-store.plugin=akka.persistence.snapshot-store.local",
"akkaConfig.akka.persistence.snapshot-store.local.dir=target/example/snapshots",
//elasticsearch
- "alpha.feature.akka.transcation.repository.channel.type=memory",
- "alpha.feature.akka.transcation.repository.type=elasticsearch",
- "spring.data.elasticsearch.cluster-name=alpha-cluster",
+ "alpha.feature.akka.transaction.repository.channel.type=memory",
+ "alpha.feature.akka.transaction.repository.type=elasticsearch",
+ "spring.data.elasticsearch.cluster-name=elasticsearch",
"spring.data.elasticsearch.cluster-nodes=localhost:9300",
"spring.elasticsearch.rest.uris=http://localhost:9200"
})
@@ -78,10 +80,13 @@ public class AlphaIntegrationFsmTest {
@Autowired
private Map<String, Map<String, OmegaCallback>> omegaCallbacks;
+ @MockBean
+ ElasticsearchTemplate elasticsearchTemplate;
+
@BeforeClass
public static void beforeClass() {
omegaEventSender.configClient(NettyChannelBuilder.forAddress("0.0.0.0", port).usePlaintext().build());
- SagaDataExtension.autoCleanSagaDataMap=false;
+ //SagaDataExtension.autoCleanSagaDataMap=false;
}
@AfterClass