Skip to content

Commit 998e9b0

Browse files
authored
Merge pull request #123 from oracle/async_review
Async review comments
2 parents 94010e2 + bdf47b0 commit 998e9b0

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

src/main/java/oracle/kubernetes/operator/Main.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -811,12 +811,12 @@ public NextAction apply(Packet packet) {
811811
WlsClusterConfig wlsClusterConfig = scan.getClusterConfig(clusterName);
812812
if (wlsClusterConfig != null) {
813813
for (WlsServerConfig wlsServerConfig : wlsClusterConfig.getServerConfigs()) {
814+
// done with the current cluster
815+
if (startedCount >= cs.getReplicas() && !startAll)
816+
continue cluster;
817+
814818
String serverName = wlsServerConfig.getName();
815819
if (!serverName.equals(asName) && !servers.contains(serverName)) {
816-
// done with the current cluster
817-
if (startedCount >= cs.getReplicas() && !startAll)
818-
continue cluster;
819-
820820
List<V1EnvVar> env = cs.getEnv();
821821
ServerStartup ssi = null;
822822
ssl = spec.getServerStartup();
@@ -871,15 +871,15 @@ else if (StartupControlConstants.AUTO_STARTUPCONTROL.equals(sc)) {
871871
int startedCount = 0;
872872
WlsClusterConfig config = wlsClusterConfig.getValue();
873873
for (WlsServerConfig wlsServerConfig : config.getServerConfigs()) {
874+
if (startedCount >= spec.getReplicas())
875+
break;
874876
String serverName = wlsServerConfig.getName();
875877
if (!serverName.equals(asName) && !servers.contains(serverName)) {
876878
// start server
877879
servers.add(serverName);
878880
ssic.add(new ServerStartupInfo(wlsServerConfig, config, null, null));
881+
startedCount++;
879882
}
880-
// outside the serverName check because these servers are already running
881-
if (++startedCount >= spec.getReplicas())
882-
break;
883883
}
884884
}
885885
}

src/main/java/oracle/kubernetes/operator/work/FiberGate.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ public void onThrowable(Packet packet, Throwable throwable) {
5555

5656
private static class WaitForOldFiberStep extends Step {
5757
private final AtomicReference<Fiber> old;
58-
private WaitForOldFiberStep current;
58+
private final AtomicReference<WaitForOldFiberStep> current;
5959

6060
public WaitForOldFiberStep(Fiber old, Step next) {
6161
super(next);
6262
this.old = new AtomicReference<>(old);
63-
current = this;
63+
current = new AtomicReference<>(this);
6464
}
6565

6666
@Override
6767
public NextAction apply(Packet packet) {
68-
Fiber o = current != null ? current.old.getAndSet(null) : null;
68+
WaitForOldFiberStep c = current.get();
69+
Fiber o = c != null ? c.old.getAndSet(null) : null;
6970
if (o == null) {
7071
return doNext(packet);
7172
}
@@ -74,13 +75,13 @@ public NextAction apply(Packet packet) {
7475
boolean isWillCall = o.cancelAndExitCallback(true, new ExitCallback() {
7576
@Override
7677
public void onExit() {
77-
current = o.getSPI(WaitForOldFiberStep.class);
78+
current.set(o.getSPI(WaitForOldFiberStep.class));
7879
fiber.resume(packet);
7980
}
8081
});
8182

8283
if (!isWillCall) {
83-
current = o.getSPI(WaitForOldFiberStep.class);
84+
current.set(o.getSPI(WaitForOldFiberStep.class));
8485
fiber.resume(packet);
8586
}
8687
});

src/main/java/oracle/kubernetes/operator/work/Packet.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55

66
import java.util.AbstractMap;
77
import java.util.Collections;
8-
import java.util.HashMap;
98
import java.util.Map;
109
import java.util.Set;
10+
import java.util.concurrent.ConcurrentHashMap;
11+
import java.util.concurrent.ConcurrentMap;
1112

1213
/**
1314
* Context of a single processing flow. Acts as a map and as a registry of components.
1415
*
1516
*/
1617
public class Packet extends AbstractMap<String, Object> implements ComponentRegistry, ComponentEx {
17-
private final Map<String, Component> components = new HashMap<String, Component>();
18-
private final Map<String, Object> delegate = new HashMap<String, Object>();
18+
private final ConcurrentMap<String, Component> components = new ConcurrentHashMap<String, Component>();
19+
private final ConcurrentMap<String, Object> delegate = new ConcurrentHashMap<String, Object>();
1920

2021
public Packet() {}
2122

@@ -33,9 +34,6 @@ public Packet clone() {
3334
}
3435

3536
public <S> S getSPI(Class<S> spiType) {
36-
if (components == null) {
37-
return null;
38-
}
3937
for (Component c : components.values()) {
4038
S s = c.getSPI(spiType);
4139
if (s != null) {
@@ -66,6 +64,6 @@ public Set<Entry<String, Object>> entrySet() {
6664

6765
@Override
6866
public Object put(String key, Object value) {
69-
return delegate.put(key, value);
67+
return value != null ? delegate.put(key, value) : delegate.remove(key);
7068
}
7169
}

0 commit comments

Comments
 (0)