MCPcopy Index your code
hub / github.com/apache/tomcat / setCluster

Method setCluster

java/org/apache/catalina/core/ContainerBase.java:352–392  ·  view source on GitHub ↗
(Cluster cluster)

Source from the content-addressed store, hash-verified

350
351
352 @Override
353 public void setCluster(Cluster cluster) {
354
355 Cluster oldCluster;
356 Lock writeLock = clusterLock.writeLock();
357 writeLock.lock();
358 try {
359 // Change components if necessary
360 oldCluster = this.cluster;
361 if (oldCluster == cluster) {
362 return;
363 }
364 this.cluster = cluster;
365 // Start the new component if necessary
366 if (cluster != null) {
367 cluster.setContainer(this);
368 }
369 } finally {
370 writeLock.unlock();
371 }
372
373 // Stop the old component if necessary
374 if (getState().isAvailable() && (oldCluster instanceof Lifecycle)) {
375 try {
376 ((Lifecycle) oldCluster).stop();
377 } catch (LifecycleException e) {
378 log.error(sm.getString("containerBase.cluster.stop"), e);
379 }
380 }
381
382 if (getState().isAvailable() && (cluster instanceof Lifecycle)) {
383 try {
384 ((Lifecycle) cluster).start();
385 } catch (LifecycleException e) {
386 log.error(sm.getString("containerBase.cluster.start"), e);
387 }
388 }
389
390 // Report this property change to interested listeners
391 support.firePropertyChange("cluster", oldCluster, cluster);
392 }
393
394
395 @Override

Callers

nothing calls this directly

Calls 10

writeLockMethod · 0.80
lockMethod · 0.65
setContainerMethod · 0.65
unlockMethod · 0.65
isAvailableMethod · 0.65
getStateMethod · 0.65
stopMethod · 0.65
errorMethod · 0.65
getStringMethod · 0.65
startMethod · 0.65

Tested by

no test coverage detected