@Override int getDesiredReplicas(ReplicationController item) { return item.getSpec().getReplicas(); }
@Override protected int getReplicas(ReplicationController obj) { return obj.getSpec().getReplicas(); }
public static boolean isReplicationControllerReady(ReplicationController r) { Utils.checkNotNull(r, "ReplicationController can't be null."); ReplicationControllerSpec spec = r.getSpec(); ReplicationControllerStatus status = r.getStatus(); if (status == null || status.getReadyReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReadyReplicas(); }
@Override protected int getReplicas(ReplicationController obj) { return obj.getSpec().getReplicas(); }
public static boolean isReplicationControllerReady(ReplicationController r) { Utils.checkNotNull(r, "ReplicationController can't be null."); ReplicationControllerSpec spec = r.getSpec(); ReplicationControllerStatus status = r.getStatus(); if (status == null || status.getReadyReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReadyReplicas(); }
public void run() { try { ReplicationController rc = get(); //If the rc is gone, we shouldn't wait. if (rc == null) { if (count == 0) { queue.put(true); return; } else { queue.put(new IllegalStateException("Can't wait for ReplicationController: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available.")); } } replicasRef.set(rc.getStatus().getReplicas()); if (Objects.equals(rc.getSpec().getReplicas(), rc.getStatus().getReplicas())) { queue.put(true); } else { LOG.debug("Only {}/{} replicas scheduled for ReplicationController: {} in namespace: {} seconds so waiting...", rc.getStatus().getReplicas(), rc.getSpec().getReplicas(), rc.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for ReplicationController to be scaled.", t); } } };
public ReplicationControllerSpecFluentImpl(ReplicationControllerSpec instance){ this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); }
public ReplicationControllerSpecBuilder(ReplicationControllerSpecFluent<?> fluent,ReplicationControllerSpec instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withReplicas(instance.getReplicas()); fluent.withSelector(instance.getSelector()); fluent.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; } public ReplicationControllerSpecBuilder(ReplicationControllerSpec instance){
public ReplicationControllerSpecBuilder(ReplicationControllerSpec instance,Boolean validationEnabled){ this.fluent = this; this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; }
public ReplicationControllerSpecBuilder( ReplicationControllerSpecFluent<?> fluent , ReplicationControllerSpec instance ){ this.fluent = fluent; fluent.withReplicas(instance.getReplicas()); fluent.withSelector(instance.getSelector()); fluent.withTemplate(instance.getTemplate()); fluent.withTemplateRef(instance.getTemplateRef()); } public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){
public ReplicationControllerSpecBuilder( ReplicationControllerSpecFluent<?> fluent , ReplicationControllerSpec instance ){ this.fluent = fluent; fluent.withReplicas(instance.getReplicas()); fluent.withSelector(instance.getSelector()); fluent.withTemplate(instance.getTemplate()); fluent.withTemplateRef(instance.getTemplateRef()); } public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){
public void destroyBroker(BrokerModel brokerModel) { int desiredNumber = model.getBrokerCount() - 1; if (scalingInProgress.startWork(desiredNumber)) { try { ReplicationController replicationController = getBrokerReplicationController(); int currentDesiredNumber = replicationController.getSpec().getReplicas(); if (desiredNumber == (currentDesiredNumber - 1)) { replicationController.getSpec().setReplicas(desiredNumber); model.remove(brokerModel); //Todo update when Kubernetes allows you to target exact pod to discard from replication controller //kubernetes.deletePod(brokerModel.getPod(),kubernetes.getNamespace()); Pod pod = brokerModel.getPod(); pod.getStatus().setStartTime("0"); //kubernetes.updateReplicationController(getReplicationControllerId(), replicationController,kubernetes.getNamespace()); LOG.info("Updated Broker Replication Controller desired state from " + currentDesiredNumber + " to " + desiredNumber + " and removed Broker " + brokerModel); } } catch (Throwable e) { LOG.error("Failed to create a Broker", e); } } }
public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){ this.fluent = this; this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); this.withTemplateRef(instance.getTemplateRef()); }
ReplicationControllerSpec spec = replicationController.getSpec(); if (spec != null) { Integer replicas = spec.getReplicas(); if (replicas != null && replicas > 0) { replicaCount = replicas;
public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){ this.fluent = this; this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); this.withTemplateRef(instance.getTemplateRef()); }
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); } } }
Integer replicas = oldSpec.getReplicas(); if (replicas != null) { newSpec.setReplicas(replicas); log.info("rollingUpgradePreserveScale " + rollingUpgradePreserveScale + " new replicas is " + (newSpec != null ? newSpec.getReplicas() : "<null>")); kubernetesClient.replicationControllers().inNamespace(namespace).withName(id).rolling().replace(replicationController); } else if (isRecreateMode()) {