Skip to content

Commit d4fb884

Browse files
authored
Merge pull request #534 from oracle/owls-70348_handleNamedUnclusteredServers
Handle named servers according to their cluster association
2 parents 74607b0 + e5bab28 commit d4fb884

File tree

4 files changed

+68
-67
lines changed

4 files changed

+68
-67
lines changed

operator/src/main/java/oracle/kubernetes/operator/steps/ManagedServersUpStep.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55
package oracle.kubernetes.operator.steps;
66

7-
import java.util.ArrayList;
8-
import java.util.Collection;
9-
import java.util.Collections;
10-
import java.util.HashMap;
11-
import java.util.List;
12-
import java.util.Map;
13-
import java.util.Optional;
7+
import java.util.*;
148
import javax.annotation.Nonnull;
159
import oracle.kubernetes.operator.DomainStatusUpdater;
1610
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
@@ -100,16 +94,20 @@ public NextAction apply(Packet packet) {
10094
LOGGER.fine(SERVERS_UP_MSG, factory.domain.getDomainUID(), getRunningServers(info));
10195
}
10296

103-
for (WlsServerConfig serverConfig : info.getScan().getServerConfigs().values()) {
104-
factory.addServerIfNeeded(serverConfig, null);
105-
}
97+
Set<String> clusteredServers = new HashSet<>();
10698

10799
for (WlsClusterConfig clusterConfig : info.getScan().getClusterConfigs().values()) {
108100
for (WlsServerConfig serverConfig : clusterConfig.getServerConfigs()) {
109101
factory.addServerIfNeeded(serverConfig, clusterConfig);
102+
clusteredServers.add(serverConfig.getName());
110103
}
111104
}
112105

106+
for (WlsServerConfig serverConfig : info.getScan().getServerConfigs().values()) {
107+
if (!clusteredServers.contains(serverConfig.getName()))
108+
factory.addServerIfNeeded(serverConfig, null);
109+
}
110+
113111
info.setServerStartupInfo(factory.getStartupInfos());
114112
LOGGER.exiting();
115113
return doNext(

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsDynamicServerConfig.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.util.ArrayList;
88
import java.util.List;
9+
import org.apache.commons.lang3.builder.ToStringBuilder;
910

1011
/** Contains configuration of a WLS server that belongs to a dynamic cluster */
1112
public class WlsDynamicServerConfig extends WlsServerConfig {
@@ -118,24 +119,6 @@ public boolean isDynamicServer() {
118119

119120
@Override
120121
public String toString() {
121-
return "WlsDynamicServerConfig{"
122-
+ "name='"
123-
+ name
124-
+ '\''
125-
+ ", listenPort="
126-
+ listenPort
127-
+ ", listenAddress='"
128-
+ listenAddress
129-
+ '\''
130-
+ ", sslListenPort="
131-
+ sslListenPort
132-
+ ", sslPortEnabled="
133-
+ sslPortEnabled
134-
+ ", machineName='"
135-
+ machineName
136-
+ '\''
137-
+ ", networkAccessPoints="
138-
+ networkAccessPoints
139-
+ '}';
122+
return new ToStringBuilder(this).toString();
140123
}
141124
}

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsServerConfig.java

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.ArrayList;
88
import java.util.List;
99
import java.util.Map;
10+
import org.apache.commons.lang3.builder.EqualsBuilder;
11+
import org.apache.commons.lang3.builder.HashCodeBuilder;
12+
import org.apache.commons.lang3.builder.ToStringBuilder;
1013

1114
/** Contains configuration of a WebLogic server */
1215
public class WlsServerConfig {
@@ -256,26 +259,48 @@ private static String getSSLSearchFields() {
256259
return "'enabled', 'listenPort'";
257260
}
258261

262+
@Override
263+
public boolean equals(Object o) {
264+
if (this == o) return true;
265+
266+
if (o == null || getClass() != o.getClass()) return false;
267+
268+
WlsServerConfig that = (WlsServerConfig) o;
269+
270+
return new EqualsBuilder()
271+
.append(sslPortEnabled, that.sslPortEnabled)
272+
.append(name, that.name)
273+
.append(listenPort, that.listenPort)
274+
.append(listenAddress, that.listenAddress)
275+
.append(sslListenPort, that.sslListenPort)
276+
.append(machineName, that.machineName)
277+
.append(networkAccessPoints, that.networkAccessPoints)
278+
.isEquals();
279+
}
280+
281+
@Override
282+
public int hashCode() {
283+
return new HashCodeBuilder(17, 37)
284+
.append(name)
285+
.append(listenPort)
286+
.append(listenAddress)
287+
.append(sslListenPort)
288+
.append(sslPortEnabled)
289+
.append(machineName)
290+
.append(networkAccessPoints)
291+
.toHashCode();
292+
}
293+
259294
@Override
260295
public String toString() {
261-
return "WlsServerConfig{"
262-
+ "name='"
263-
+ name
264-
+ '\''
265-
+ ", listenPort="
266-
+ listenPort
267-
+ ", listenAddress='"
268-
+ listenAddress
269-
+ '\''
270-
+ ", sslListenPort="
271-
+ sslListenPort
272-
+ ", sslPortEnabled="
273-
+ sslPortEnabled
274-
+ ", machineName='"
275-
+ machineName
276-
+ '\''
277-
+ ", networkAccessPoints="
278-
+ networkAccessPoints
279-
+ '}';
296+
return new ToStringBuilder(this)
297+
.append("name", name)
298+
.append("listenPort", listenPort)
299+
.append("listenAddress", listenAddress)
300+
.append("sslListenPort", sslListenPort)
301+
.append("sslPortEnabled", sslPortEnabled)
302+
.append("machineName", machineName)
303+
.append("networkAccessPoints", networkAccessPoints)
304+
.toString();
280305
}
281306
}

operator/src/test/java/oracle/kubernetes/operator/steps/ManagedServersUpStepTest.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,16 @@
99
import static oracle.kubernetes.operator.steps.ManagedServersUpStep.SERVERS_UP_MSG;
1010
import static oracle.kubernetes.operator.steps.ManagedServersUpStepTest.TestStepFactory.getServerStartupInfo;
1111
import static oracle.kubernetes.operator.steps.ManagedServersUpStepTest.TestStepFactory.getServers;
12-
import static oracle.kubernetes.weblogic.domain.v2.ConfigurationConstants.START_ALWAYS;
13-
import static oracle.kubernetes.weblogic.domain.v2.ConfigurationConstants.START_IF_NEEDED;
14-
import static oracle.kubernetes.weblogic.domain.v2.ConfigurationConstants.START_NEVER;
15-
import static org.hamcrest.Matchers.contains;
16-
import static org.hamcrest.Matchers.containsInAnyOrder;
17-
import static org.hamcrest.Matchers.empty;
18-
import static org.hamcrest.Matchers.equalTo;
19-
import static org.hamcrest.Matchers.hasItem;
20-
import static org.hamcrest.Matchers.instanceOf;
21-
import static org.hamcrest.Matchers.notNullValue;
22-
import static org.hamcrest.Matchers.nullValue;
23-
import static org.hamcrest.Matchers.sameInstance;
12+
import static oracle.kubernetes.weblogic.domain.v2.ConfigurationConstants.*;
13+
import static org.hamcrest.Matchers.*;
2414
import static org.hamcrest.junit.MatcherAssert.assertThat;
2515

2616
import com.meterware.simplestub.Memento;
2717
import com.meterware.simplestub.StaticStubSupport;
2818
import io.kubernetes.client.models.V1EnvVar;
2919
import io.kubernetes.client.models.V1ObjectMeta;
3020
import io.kubernetes.client.models.V1Pod;
31-
import java.util.ArrayList;
32-
import java.util.Arrays;
33-
import java.util.Collection;
34-
import java.util.Collections;
35-
import java.util.List;
21+
import java.util.*;
3622
import java.util.logging.Level;
3723
import java.util.logging.LogRecord;
3824
import oracle.kubernetes.TestUtils;
@@ -53,7 +39,6 @@
5339
import oracle.kubernetes.weblogic.domain.v2.DomainSpec;
5440
import org.junit.After;
5541
import org.junit.Before;
56-
import org.junit.Ignore;
5742
import org.junit.Test;
5843

5944
/**
@@ -428,7 +413,6 @@ public void withStartAllWhenWlsClusterNotInDomainSpec_addClusteredServersToListU
428413
}
429414

430415
@Test
431-
@Ignore
432416
public void whenWlsClusterNotInDomainSpec_recordServerAndClusterConfigs() {
433417
setCluster1Replicas(3);
434418
addWlsServers("ms1", "ms2", "ms3", "ms4", "ms5");
@@ -442,6 +426,17 @@ public void whenWlsClusterNotInDomainSpec_recordServerAndClusterConfigs() {
442426
assertThat(getServerStartupInfo("ms1").getNodePort(), nullValue());
443427
}
444428

429+
@Test
430+
public void whenWlsClusterNotInDomainSpec_startUpToLimit() {
431+
setCluster1Replicas(3);
432+
addWlsServers("ms1", "ms2", "ms3", "ms4", "ms5");
433+
addWlsCluster("cluster1", "ms1", "ms2", "ms3", "ms4", "ms5");
434+
435+
invokeStep();
436+
437+
assertThat(getServers(), containsInAnyOrder("ms1", "ms2", "ms3"));
438+
}
439+
445440
@Test
446441
public void withStartPolicyAlways_addNonManagedServers() {
447442
startAllServers();

0 commit comments

Comments
 (0)