|
11 | 11 | import modelengine.fit.waterflow.domain.context.repo.flowcontext.FlowContextRepo; |
12 | 12 | import modelengine.fit.waterflow.domain.context.repo.flowlock.FlowLocks; |
13 | 13 | import modelengine.fit.waterflow.domain.enums.FlowNodeType; |
14 | | -import modelengine.fit.waterflow.domain.stream.reactive.Subscription; |
15 | | -import modelengine.fit.waterflow.domain.utils.IdGenerator; |
16 | 14 | import modelengine.fit.waterflow.domain.utils.UUIDUtil; |
17 | 15 |
|
18 | | -import java.util.LinkedHashMap; |
19 | 16 | import java.util.List; |
20 | | -import java.util.Map; |
21 | | -import java.util.Optional; |
22 | | -import java.util.concurrent.ConcurrentHashMap; |
23 | 17 | import java.util.stream.Collectors; |
24 | 18 |
|
25 | 19 | /** |
@@ -77,44 +71,20 @@ private static <I> From<I> initFrom(String streamId, FlowContextRepo repo, FlowC |
77 | 71 | } |
78 | 72 |
|
79 | 73 | private static class ConditionFrom<I> extends From<I> { |
80 | | - private final Map<String, Map<String, Subscription<I>>> sessionSubscription = new ConcurrentHashMap<>(); |
81 | | - |
82 | 74 | public ConditionFrom(String streamId, FlowContextRepo repo, FlowContextMessenger messenger, FlowLocks locks) { |
83 | 75 | super(streamId, repo, messenger, locks); |
84 | 76 | } |
85 | 77 |
|
86 | 78 | @Override |
87 | 79 | public void offer(List<FlowContext<I>> contexts) { |
88 | | - this.offerUserContexts(contexts); |
89 | | - } |
90 | | - |
91 | | - private void offerUserContexts(List<FlowContext<I>> contexts) { |
92 | 80 | this.getSubscriptions().forEach(subscription -> { |
93 | 81 | List<FlowContext<I>> matched = contexts.stream() |
94 | 82 | .filter(context -> subscription.getWhether().is(context.getData())) |
95 | | - .peek(context -> { |
96 | | - this.record(subscription, context); |
97 | | - }) |
98 | 83 | .collect(Collectors.toList()); |
99 | 84 | matched.forEach(contexts::remove); |
100 | 85 | subscription.cache(matched); |
101 | 86 | }); |
102 | 87 | } |
103 | 88 |
|
104 | | - private void record(Subscription<I> subscription, FlowContext<I> context) { |
105 | | - String sessionId = getSessionId(context); |
106 | | - if (sessionId == null) { |
107 | | - return; |
108 | | - } |
109 | | - this.sessionSubscription.putIfAbsent(sessionId, new LinkedHashMap<>()); |
110 | | - Map<String, Subscription<I>> subscriptionMap = this.sessionSubscription.get(sessionId); |
111 | | - if (!subscriptionMap.containsKey(subscription.getId())) { |
112 | | - subscriptionMap.put(subscription.getId(), subscription); |
113 | | - } |
114 | | - } |
115 | | - |
116 | | - private String getSessionId(FlowContext<I> context) { |
117 | | - return Optional.ofNullable(context.getSession()).map(IdGenerator::getId).orElse(null); |
118 | | - } |
119 | 89 | } |
120 | 90 | } |
0 commit comments