Package org.springframework.xd.dirt.cluster

Examples of org.springframework.xd.dirt.cluster.ContainerAttributes


  }

  @Bean
  public ContainerAttributes containerAttributes() {

    final ContainerAttributes containerAttributes = new ContainerAttributes();
    setConfiguredContainerAttributes(containerAttributes);

    final String containerIp = environment.getProperty(CONTAINER_ATTRIBUTES_PREFIX
        + ContainerAttributes.IP_ADDRESS_KEY);
    final String containerHostname = environment.getProperty(CONTAINER_ATTRIBUTES_PREFIX
        + ContainerAttributes.HOST_KEY);

    containerAttributes.setIp(StringUtils.hasText(containerIp) ? containerIp : RuntimeUtils.getIpAddress());
    containerAttributes.setHost(StringUtils.hasText(containerHostname) ? containerHostname : RuntimeUtils.getHost());

    containerAttributes.setPid(RuntimeUtils.getPid());
    return containerAttributes;
  }
View Full Code Here


  private class IdInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
      ContainerAttributes containerAttributes = applicationContext.getParent().getBean(ContainerAttributes.class);
      applicationContext.setId(containerAttributes.getId());
    }
View Full Code Here

    }
    catch (KeeperException.NodeExistsException e) {
      // ignore
    }

    ContainerAttributes containerAttributes = new ContainerAttributes(id).setPid(pid).setHost(host).setIp(ip);
    containerAttributes.put("groups", "g1,g2,g3");
    Container entity = new Container(id, containerAttributes);
    Container savedContainer = containerRepository.save(entity);
    assertNotNull(savedContainer);
    ContainerAttributes savedAttributes = savedContainer.getAttributes();
    assertEquals(id, savedAttributes.getId());
    assertEquals(pid, savedAttributes.getPid());
    assertEquals(host, savedAttributes.getHost());
    assertEquals(ip, savedAttributes.getIp());
    assertEquals(groups, savedAttributes.getGroups());

    containerAttributes = new ContainerAttributes(id2).setPid(pid).setHost(host).setIp(ip);
    entity = new Container(id2, containerAttributes);
    savedContainer = containerRepository.save(entity);
    assertNotNull(savedContainer);
    assertSavedContainer(id2, containerAttributes);
  }
View Full Code Here

  @Test
  public void findContainerAttributesById() {
    Container foundContainer = containerRepository.findOne(id);
    assertNotNull(foundContainer);
    ContainerAttributes attributes = foundContainer.getAttributes();
    assertNotNull(attributes);
    assertEquals(id, attributes.getId());
    assertEquals(pid, attributes.getPid());
    assertEquals(host, attributes.getHost());
    assertEquals(ip, attributes.getIp());
    assertEquals(groups, attributes.getGroups());
  }
View Full Code Here

  @Test
  public void updateContainerAttributes() {
    Container foundContainer = containerRepository.findOne(id);
    assertNotNull(foundContainer);
    ContainerAttributes containerAttributes = new ContainerAttributes(id).setPid(12345).setHost("randomHost").setIp(
        "randomIP");
    containerAttributes.put("groups", "test1,test2");
    Container entity = new Container(id, containerAttributes);
    containerRepository.update(entity);
    assertSavedContainer(id, containerAttributes);
  }
View Full Code Here

  @Test
  public void updateNonExistingContainer() {
    exception.expect(ZooKeeperAccessException.class);
    exception.expectMessage("Could not find container with id " + id + 10);
    ContainerAttributes containerAttributes = new ContainerAttributes(id + 10).setPid(12345).setHost("randomHost").setIp(
        "randomIP");
    containerAttributes.put("groups", "test1,test2");
    Container entity = new Container(id + 10, containerAttributes);
    containerRepository.update(entity);
  }
View Full Code Here

  @Test
  public void findContainerNoGroups() {
    Container foundContainer = containerRepository.findOne(id2);
    assertNotNull(foundContainer);
    ContainerAttributes attributes = foundContainer.getAttributes();
    assertNotNull(attributes);
    assertEquals(id2, attributes.getId());
    assertEquals(pid, attributes.getPid());
    assertEquals(host, attributes.getHost());
    assertEquals(ip, attributes.getIp());
    assertEquals(0, attributes.getGroups().size());
  }
View Full Code Here

    Map<String, Plugin> pluginMap = pluginContext.getBeansOfType(Plugin.class);
    assertTrue(pluginMap.size() > 0);

    assertSame(containerContext.getBean(ZooKeeperConnection.class), adminContext.getBean(ZooKeeperConnection.class));

    ContainerAttributes containerAttributes = containerContext.getBean(ContainerAttributes.class);
    assertEquals(RuntimeUtils.getHost(), containerAttributes.getHost());
    ApplicationUtils.dumpContainerApplicationContextConfiguration(containerContext);

    AdminAttributes adminAttributes = adminContext.getBean(AdminAttributes.class);
    assertEquals(RuntimeUtils.getHost(), adminAttributes.getHost());
  }
View Full Code Here

    MockEnvironment environment = new MockEnvironment();

    final ContainerServerApplication containerServerApplication = new ContainerServerApplication();
    containerServerApplication.setEnvironment(environment);

    final ContainerAttributes containerAttributes = containerServerApplication.containerAttributes();
    Assert.assertNotNull(containerAttributes);
    Assert.assertEquals(defaultIp, containerAttributes.getIp());
    Assert.assertEquals(defaultHostname, containerAttributes.getHost());

  }
View Full Code Here

    environment.setProperty(CONTAINER_HOST_KEY, customHostname);

    final ContainerServerApplication containerServerApplication = new ContainerServerApplication();
    containerServerApplication.setEnvironment(environment);

    final ContainerAttributes containerAttributes = containerServerApplication.containerAttributes();
    Assert.assertNotNull(containerAttributes);
    Assert.assertEquals(customIp, containerAttributes.getIp());
    Assert.assertEquals(customHostname, containerAttributes.getHost());
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.dirt.cluster.ContainerAttributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.