public void createBroker() { int desiredNumber = model.getBrokerCount() + 1; if (scalingInProgress.startWork(desiredNumber)) { try { ReplicationController replicationController = getBrokerReplicationController(); ReplicationControllerSpec spec = replicationController.getSpec(); int currentDesiredNumber = 0; if (spec != null) { currentDesiredNumber = spec.getReplicas(); } else { spec = new ReplicationControllerSpec(); replicationController.setSpec(spec); } if (desiredNumber == (currentDesiredNumber + 1)) { replicationController.getSpec().setReplicas(desiredNumber); kubernetes.replicationControllers().inNamespace(namespace).withName(getReplicationControllerId()).replace(replicationController); LOG.info("Updated Broker Replication Controller desired state from " + currentDesiredNumber + " to " + desiredNumber); } } catch (Throwable e) { LOG.error("Failed to create a Broker", e); } } }