@Test public void testUpdatePodIfNotExist() throws Exception { String a = "a"; String b = "b"; Pod podA = new Pod(); setName(podA, "a"); assertTrue(model.updatePodIfNotExist(a, podA)); assertEquals("should have created an 'a'", podA, model.getPod(a)); assertTrue("should have created an 'a'", podA == model.getPod(a)); Pod podB = new Pod(); setName(podB, "b"); assertFalse(model.updatePodIfNotExist(a, podB)); assertTrue(model.getPod("a") != podB); assertTrue(model.updatePodIfNotExist(b, podB)); assertEquals("should have created an 'b'", podB, model.getPod(b)); assertTrue("should have created an 'b'", podB == model.getPod(b)); LOG.info("Created pods: {}", model.getPodMap()); }
@Override public boolean updatePodIfNotExist(String id, Pod pod) { Pod oldValue = getInternalPodMap(namespace).putIfAbsent(id, pod); return oldValue == null; }
LocalKubernetesModel implements KubernetesModel { @Override public boolean updatePodIfNotExist(String id, Pod pod) { Pod oldValue = getInternalPodMap(namespace).putIfAbsent(id, pod); return oldValue == null; } }
LocalKubernetesModel implements KubernetesModel { @Override public boolean updatePodIfNotExist(String id, Pod pod) { Pod oldValue = getInternalPodMap(namespace).putIfAbsent(id, pod); return oldValue == null; } LocalKubernetesModel(); }
LocalKubernetesModel implements KubernetesModel { @Override public boolean updatePodIfNotExist(String id, Pod pod) { Pod oldValue = getInternalPodMap(namespace).putIfAbsent(id, pod); return oldValue == null; } LocalKubernetesModel(); @Override String getNamespace(); @Override void setNamespace(String namespace); @Override ImmutableMap<String, Pod> getPodMap(); ImmutableMap<String, Pod> getPodMap(String namespace); @Override PodList getPods(); @Override PodList getPods(String namespace); @Override ImmutableList<Pod> getPods(Map<String, String> replicaSelector); @Override ImmutableList<Pod> getPods(Filter<Pod> podFilter); @Override Pod getPod(String id); @Override Pod getPod(String id, String namespace); @Override void updatePod(String id, Pod pod); @Override String getOrCreateId(String id, String kind); @Override boolean updatePodIfNotExist(String id, Pod pod); @Override Pod deletePod(String podId, String namespace); @Override ImmutableMap<String, PodCurrentContainer> getPodRunningContainers(KubernetesModel model); @Override ReplicationController getReplicationController(String id); @Override ReplicationController getReplicationController(String id, String namespace); @Override ReplicationControllerList getReplicationControllers(); @Override ReplicationControllerList getReplicationControllers(String namespace); @Override ImmutableMap<String, ReplicationController> getReplicationControllerMap(); @Override void updateReplicationController(String id, ReplicationController replicationController); @Override void deleteReplicationController(String controllerId, String namespace); @Override ServiceList getServices(); @Override ServiceList getServices(String namespace); @Override Service getService(String id); @Override Service getService(String id, String namespace); @Override ImmutableMap<String, Service> getServiceMap(); @Override void updateService(String id, Service entity); @Override void deleteService(String serviceId, String namespace); @Override String createID(String kind); }
LocalKubernetesModel implements KubernetesModel { @Override public boolean updatePodIfNotExist(String id, Pod pod) { Pod oldValue = getInternalPodMap(namespace).putIfAbsent(id, pod); return oldValue == null; } LocalKubernetesModel(); @Override String getNamespace(); @Override void setNamespace(String namespace); @Override ImmutableMap<String, Pod> getPodMap(); ImmutableMap<String, Pod> getPodMap(String namespace); @Override PodList getPods(); @Override PodList getPods(String namespace); @Override ImmutableList<Pod> getPods(Map<String, String> replicaSelector); @Override ImmutableList<Pod> getPods(Filter<Pod> podFilter); @Override Pod getPod(String id); @Override Pod getPod(String id, String namespace); @Override void updatePod(String id, Pod pod); @Override String getOrCreateId(String id, String kind); @Override boolean updatePodIfNotExist(String id, Pod pod); @Override Pod deletePod(String podId, String namespace); @Override ImmutableMap<String, PodCurrentContainer> getPodRunningContainers(KubernetesModel model); @Override ReplicationController getReplicationController(String id); @Override ReplicationController getReplicationController(String id, String namespace); @Override ReplicationControllerList getReplicationControllers(); @Override ReplicationControllerList getReplicationControllers(String namespace); @Override ImmutableMap<String, ReplicationController> getReplicationControllerMap(); @Override void updateReplicationController(String id, ReplicationController replicationController); @Override void deleteReplicationController(String controllerId, String namespace); @Override ServiceList getServices(); @Override ServiceList getServices(String namespace); @Override Service getService(String id); @Override Service getService(String id, String namespace); @Override ImmutableMap<String, Service> getServiceMap(); @Override void updateService(String id, Service entity); @Override void deleteService(String serviceId, String namespace); @Override String createID(String kind); static final String DEFAULT_NAMESPACE; }