@Override int getCurrentReplicas(ReplicationController current) { return current.getStatus().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 static ReplicationControllerStatus getOrCreatetStatus(ReplicationController replicationController) { ReplicationControllerStatus currentState = replicationController.getStatus(); if (currentState == null) { currentState = new ReplicationControllerStatus(); replicationController.setStatus(currentState); } return currentState; }
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); } } };
exchange.getOut().setBody(rcScaled.getStatus().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 createBroker() { int desiredNumber = model.getBrokerCount() + 1; if (scalingInProgress.startWork(desiredNumber)) { try { String id = getOrCreateBrokerReplicationControllerId(); ReplicationController replicationController = kubernetes.getReplicationController(id); ReplicationControllerStatus status = replicationController.getStatus(); int currentDesiredNumber = 0; if (status != null) { currentDesiredNumber = status.getReplicas(); } else { status = new ReplicationControllerStatus(); replicationController.setStatus(status); } if (desiredNumber == (currentDesiredNumber + 1)) { replicationController.getStatus().setReplicas(desiredNumber); kubernetes.updateReplicationController(id, replicationController); LOG.error("Updated Broker Replication Controller desired state from " + currentDesiredNumber + " to " + desiredNumber); } } catch (Throwable e) { LOG.error("Failed to create a Broker", e); } } }
public void destroyBroker(BrokerModel brokerModel) { int desiredNumber = model.getBrokerCount() - 1; if (scalingInProgress.startWork(desiredNumber)) { try { String id = getOrCreateBrokerReplicationControllerId(); ReplicationController replicationController = kubernetes.getReplicationController(id); int currentDesiredNumber = replicationController.getStatus().getReplicas(); if (desiredNumber == (currentDesiredNumber - 1)) { replicationController.getStatus().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.updateReplicationController(id, replicationController); LOG.error("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 ReplicationControllerFluentImpl(ReplicationController instance){ this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
public ReplicationControllerBuilder(ReplicationControllerFluent<?> fluent,ReplicationController instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); this.validationEnabled = validationEnabled; } public ReplicationControllerBuilder(ReplicationController instance){
public ReplicationControllerBuilder(ReplicationController instance,Boolean validationEnabled){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); this.validationEnabled = validationEnabled; }
public ReplicationControllerBuilder( ReplicationControllerFluent<?> fluent , ReplicationController instance ){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); } public ReplicationControllerBuilder( ReplicationController instance ){
public ReplicationControllerBuilder( ReplicationControllerFluent<?> fluent , ReplicationController instance ){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); } public ReplicationControllerBuilder( ReplicationController instance ){
public ReplicationControllerBuilder( ReplicationController instance ){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
public ReplicationControllerBuilder( ReplicationController instance ){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
ReplicationController rc = resource.get(); if (rc != null) { ReplicationControllerStatus status = rc.getStatus(); Integer replicas = status.getReplicas(); } else {