Package org.springframework.xd.dirt.cluster

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


          containerAttributes.setManagementPort(String.valueOf(managementPort));
          String containerId = containerAttributes.getId();

          if (zkConnection.isConnected() && containerRepository.exists(containerId)) {
            containerRepository.update(new Container(containerId, containerAttributes));
          }
        }
      }
    }
  }
View Full Code Here


      synchronized (containerAttributes) {
        // reading the container attributes and writing them to
        // the container node must be an atomic operation; see
        // the handling of EmbeddedServletContainerInitializedEvent
        // in onApplicationEvent
        containerRepository.save(new Container(containerId, containerAttributes));
      }

      // if this container is rejoining, clear out the old cache and recreate
      if (deployments != null) {
        try {
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public Container findOne(String id) {
    Container container = null;
    String containerPath = path(id);
    ChildData childData = ensureCache().getCurrentData(containerPath);
    byte[] data = null;

    if (childData != null) {
      data = childData.getData();
    }
    if (data != null) {
      container = new Container(id, ZooKeeperUtils.bytesToMap(data));
    }

    return container;
  }
View Full Code Here

   */
  @Override
  public Iterable<Container> findAll(Iterable<String> ids) {
    List<Container> results = new ArrayList<Container>();
    for (String id : ids) {
      Container entity = findOne(id);
      if (entity != null) {
        results.add(entity);
      }
    }
    return results;
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
    ZooKeeperUtils.logCacheEvent(logger, event);
    Container container;
    switch (event.getType()) {
      case CHILD_ADDED:
        container = getContainer(event.getData());
        logger.info("Container arrived: {}", container);
        latestContainer.set(new ContainerArrival(container, System.currentTimeMillis()));
View Full Code Here

   *
   * @param data the ChildData that the ContainerListener event receives.
   * @return the container that represents name and attributes.
   */
  private Container getContainer(ChildData data) {
    return new Container(Paths.stripPath(data.getPath()), ZooKeeperUtils.bytesToMap(data.getData()));
  }
View Full Code Here

   * @throws NoSuchContainerException
   */
  @RequestMapping(value = "", method = RequestMethod.DELETE, params = "containerId")
  @ResponseStatus(HttpStatus.OK)
  public void shutdownContainer(String containerId) throws NoSuchContainerException, ContainerShutdownException {
    Container container = this.containerRepository.findOne(containerId);
    if (container != null) {
      String containerHost = container.getAttributes().getIp();
      String containerManagementPort = container.getAttributes().getManagementPort();
      RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
      try {
        restTemplate.postForObject(CONTAINER_HOST_URI_PROTOCOL + containerHost + ":"
            + containerManagementPort + managementContextPath + SHUTDOWN_ENDPOINT, Object.class,
            Object.class);
View Full Code Here

      // 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

    long timeout = System.currentTimeMillis() + 15000;
    boolean foundContainer = false;
    while (!foundContainer && System.currentTimeMillis() < timeout) {
      try {
        Thread.sleep(200);
        Container container = containerRepository.findOne(id);
        if (container != null && compareContainerAttributes(container.getAttributes(), containerAttributes)) {
          foundContainer = true;
        }
      }
      catch (InterruptedException e) {
        Thread.currentThread().interrupt();
View Full Code Here

        attr1.getIp().equals(attr2.getIp()) && (attr1.getPid() == attr2.getPid()));
  }

  @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());
View Full Code Here

TOP

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

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.