Skip to content

Commit

Permalink
Merge 250ca98 into fec3189
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyangyong committed Nov 7, 2017
2 parents fec3189 + 250ca98 commit c27a053
Show file tree
Hide file tree
Showing 75 changed files with 864 additions and 954 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<module>docker-build-config</module>
<module>saga-format</module>
<module>saga-discovery</module>
<module>saga-web</module>
</modules>

<properties>
Expand All @@ -41,7 +42,7 @@
<log4j.version>2.6.2</log4j.version>
<spring.boot.version>1.4.5.RELEASE</spring.boot.version>
<spring.cloud.version>Camden.SR6</spring.cloud.version>
<java.chassis.version>0.2.0</java.chassis.version>
<java.chassis.version>0.4.0</java.chassis.version>
<spring.version>4.3.7.RELEASE</spring.version>
<akka.version>2.5.6</akka.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<configuration>
<images>
<image>
<name>servicecomb/service-center:0.2.0</name>
<name>servicecomb/service-center:latest</name>
<alias>service-center</alias>
<run>
<wait>
Expand Down
19 changes: 15 additions & 4 deletions saga-demo/dependency-free-transaction-demo/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ services:
links:
- "service-center:sc.servicecomb.io"
ports:
- "8080:8080"
- "8080"

flight-booking-service:
image: "flight-booking-service:0.0.3-SNAPSHOT"
hostname: flight
links:
- "service-center:sc.servicecomb.io"
ports:
- "8081:8080"
- "8080"

hotel-reservation-service:
image: "hotel-reservation-service:0.0.3-SNAPSHOT"
hostname: hotel
links:
- "service-center:sc.servicecomb.io"
ports:
- "8082:8080"
- "8080"

payment-service:
image: "payment-service:0.0.3-SNAPSHOT"
Expand All @@ -68,7 +68,18 @@ services:
environment:
- JAVA_OPTS=-Dspring.profiles.active=prd,servicecomb -Dcse.service.registry.address=http://sc.servicecomb.io:30100
ports:
- "8083:8080"
- "8080:8080"
depends_on:
mysql:
condition: service_healthy

web:
image: "saga-web:0.0.3-SNAPSHOT"
hostname: web
links:
- "service-center:sc.servicecomb.io"
- "saga:saga.servicecomb.io"
environment:
- JAVA_OPTS=-Dspring.profiles.active=prd,servicecomb -Dcse.service.registry.address=http://sc.servicecomb.io:30100
ports:
- "8888:8888"
1 change: 1 addition & 0 deletions saga-demo/dependency-free-transaction-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<module>hotel-reservation-service</module>
<module>payment-service</module>
<module>demo-tests</module>
<module>../../docker-build-config</module>
</modules>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ service_description:
cse:
service:
registry:
address: http://127.0.0.1:30100
address: http://sc.servicecomb.io:30100
rest:
address: 0.0.0.0:8080
handler:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -35,6 +36,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -78,6 +80,7 @@ public SagaController(SagaExecutionComponent sagaExecutionComponent, SagaEventRe
@ApiResponse(code = 400, response = String.class, message = "illegal request content"),
@ApiResponse(code = 500, response = String.class, message = "transaction failed")
})
@CrossOrigin
@RequestMapping(value = "requests", method = POST, consumes = TEXT_PLAIN_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> processRequests(@RequestBody String request) {
try {
Expand Down Expand Up @@ -109,6 +112,7 @@ public ResponseEntity<Map<String, List<SagaEventVo>>> allEvents() {
@ApiResponse(code = 200, response = String.class, message = "success"),
@ApiResponse(code = 400, response = String.class, message = "illegal request content"),
})
@CrossOrigin
@RequestMapping(value = "requests", method = GET)
public ResponseEntity<SagaExecutionQueryResult> queryExecutions(
@RequestParam(name = "pageIndex") String pageIndex,
Expand All @@ -130,7 +134,8 @@ private boolean isRequestParamValid(String pageIndex, String pageSize, String st
try {
if (Integer.parseInt(pageIndex) >= 0 && Integer.parseInt(pageSize) > 0) {
Date start = "NaN-NaN-NaN NaN:NaN:NaN".equals(startTime) ? new Date(0) : this.dateFormat.parse(startTime);
Date end = "NaN-NaN-NaN NaN:NaN:NaN".equals(endTime) ? new Date(Long.MAX_VALUE) : this.dateFormat.parse(endTime);
Date end =
"NaN-NaN-NaN NaN:NaN:NaN".equals(endTime) ? new Date(Long.MAX_VALUE) : this.dateFormat.parse(endTime);
return start.getTime() <= end.getTime();
}
} catch (NumberFormatException | ParseException ignored) {
Expand All @@ -141,6 +146,7 @@ private boolean isRequestParamValid(String pageIndex, String pageSize, String st
@ApiResponses({
@ApiResponse(code = 200, response = String.class, message = "success"),
})
@CrossOrigin
@RequestMapping(value = "requests/{sagaId}", method = GET)
public ResponseEntity<SagaExecutionDetail> queryExecutionDetail(@PathVariable String sagaId) {
return ResponseEntity.ok(queryService.querySagaExecutionDetail(sagaId));
Expand Down Expand Up @@ -197,14 +203,14 @@ public SagaExecution(long id, String sagaId, long startTime, long completedTime,

@JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE)
static class SagaExecutionDetail {
public Map<String, List<String>> router;
public Map<String, HashSet<String>> router;
public Map<String, String> status;
public Map<String, String> error;

public SagaExecutionDetail() {
}

public SagaExecutionDetail(Map<String, List<String>> router, Map<String, String> status,
public SagaExecutionDetail(Map<String, HashSet<String>> router, Map<String, String> status,
Map<String, String> error) {
this();
this.router = router;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -45,8 +46,8 @@
import io.servicecomb.saga.core.SagaStartedEvent;
import io.servicecomb.saga.core.TransactionAbortedEvent;
import io.servicecomb.saga.core.TransactionEndedEvent;
import io.servicecomb.saga.core.dag.GraphBuilder;
import io.servicecomb.saga.core.application.interpreter.FromJsonFormat;
import io.servicecomb.saga.core.dag.GraphBuilder;
import io.servicecomb.saga.core.dag.GraphCycleDetectorImpl;
import io.servicecomb.saga.core.dag.Node;
import io.servicecomb.saga.core.dag.SingleLeafDirectedAcyclicGraph;
Expand Down Expand Up @@ -75,7 +76,7 @@ public SagaExecutionQueryResult querySagaExecution(String pageIndex, String page
String startTime, String endTime) throws ParseException {

Date start = "NaN-NaN-NaN NaN:NaN:NaN".equals(startTime) ? new Date(0) : this.dateFormat.parse(startTime);
Date end = "NaN-NaN-NaN NaN:NaN:NaN".equals(endTime) ? new Date(Long.MAX_VALUE) : this.dateFormat.parse(endTime);
Date end = "NaN-NaN-NaN NaN:NaN:NaN".equals(endTime) ? new Date() : this.dateFormat.parse(endTime);

List<SagaExecution> requests = new ArrayList<>();
Page<SagaEventEntity> startEvents = repo.findByTypeAndCreationTimeBetweenOrderByIdDesc(
Expand Down Expand Up @@ -103,7 +104,7 @@ public SagaExecutionDetail querySagaExecutionDetail(String sagaId) {
SagaEventEntity[] entities = repo.findBySagaId(sagaId).toArray(new SagaEventEntity[0]);
Optional<SagaEventEntity> sagaStartEvent = Arrays.stream(entities)
.filter(entity -> SagaStartedEvent.class.getSimpleName().equals(entity.type())).findFirst();
Map<String, List<String>> router = new HashMap<>();
Map<String, HashSet<String>> router = new HashMap<>();
Map<String, String> status = new HashMap<>();
Map<String, String> error = new HashMap<>();
if (sagaStartEvent.isPresent()) {
Expand Down Expand Up @@ -141,9 +142,9 @@ public SagaExecutionDetail querySagaExecutionDetail(String sagaId) {
return new SagaExecutionDetail(router, status, error);
}

private void loopLoadGraphNodes(Map<String, List<String>> router, Node<SagaRequest> node) {
private void loopLoadGraphNodes(Map<String, HashSet<String>> router, Node<SagaRequest> node) {
if (isNodeValid(node)) {
List<String> point = router.computeIfAbsent(node.value().id(), key -> new ArrayList<>());
HashSet<String> point = router.computeIfAbsent(node.value().id(), key -> new HashSet<>());
for (Node<SagaRequest> child : node.children()) {
point.add(child.value().id());
loopLoadGraphNodes(router, child);
Expand Down
6 changes: 0 additions & 6 deletions saga-web/out/artifacts/web_site_war_exploded/WEB-INF/web.xml

This file was deleted.

14 changes: 0 additions & 14 deletions saga-web/out/artifacts/web_site_war_exploded/index.jsp

This file was deleted.

52 changes: 0 additions & 52 deletions saga-web/out/artifacts/web_site_war_exploded/result.jsp

This file was deleted.

24 changes: 0 additions & 24 deletions saga-web/out/artifacts/web_site_war_exploded/style.css

This file was deleted.

0 comments on commit c27a053

Please sign in to comment.