Package org.springframework.xd.dirt.cluster

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


      List<String> children = zkConnection.getClient().getChildren().forPath(Paths.build(Paths.ADMINS));
      for (String child : children) {
        byte[] data = zkConnection.getClient().getData().forPath(
            Paths.build(Paths.ADMINS, child));
        if (data != null && data.length > 0) {
          results.add(new Admin(child, ZooKeeperUtils.bytesToMap(data)));
        }
      }

    }
    catch (Exception e) {
View Full Code Here


  public Admin findOne(String id) {
    try {
      byte[] data = zkConnection.getClient().getData().forPath(
          Paths.build(Paths.ADMINS, id));
      if (data != null && data.length > 0) {
        return new Admin(id, ZooKeeperUtils.bytesToMap(data));
      }
    }
    catch (Exception e) {
      throw ZooKeeperUtils.wrapThrowable(e);
    }
View Full Code Here

        }
        else {
          adminAttributes.setPort(port);
        }
        if (zkConnection.isConnected() && adminRepository.exists(adminAttributes.getId())) {
          adminRepository.update(new Admin(adminAttributes.getId(), adminAttributes));
        }
      }
    }
  }
View Full Code Here

      synchronized (adminAttributes) {
        // reading the container runtime attributes and writing them to
        // the container node must be an atomic operation; see
        // the handling of EmbeddedServletContainerInitializedEvent
        // in onApplicationEvent
        adminRepository.save(new Admin(containerId, adminAttributes));
      }
    }
    catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw ZooKeeperUtils.wrapThrowable(e);
View Full Code Here

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

    AdminAttributes adminAttributes = new AdminAttributes(id).setPid(pid).setHost(host).setIp(ip);
    Admin entity = new Admin(id, adminAttributes);
    Admin savedAdmin = adminRepository.save(entity);
    assertNotNull(savedAdmin);
    AdminAttributes savedAttributes = savedAdmin.getAttributes();
    assertEquals(id, savedAttributes.getId());
    assertEquals(pid, savedAttributes.getPid());
    assertEquals(host, savedAttributes.getHost());
    assertEquals(ip, savedAttributes.getIp());

    adminAttributes = new AdminAttributes(id2).setPid(pid).setHost(host).setIp(ip);
    entity = new Admin(id2, adminAttributes);
    savedAdmin = adminRepository.save(entity);
    assertNotNull(savedAdmin);
    assertSavedAdmin(id2, adminAttributes);
  }
View Full Code Here

    assertSavedAdmin(id2, adminAttributes);
  }

  @Test
  public void findContainerAttributesById() {
    Admin foundAdmin = adminRepository.findOne(id);
    assertNotNull(foundAdmin);
    AdminAttributes attributes = foundAdmin.getAttributes();
    assertNotNull(attributes);
    assertEquals(id, attributes.getId());
    assertEquals(pid, attributes.getPid());
    assertEquals(host, attributes.getHost());
    assertEquals(ip, attributes.getIp());
View Full Code Here

    assertEquals(ip, attributes.getIp());
  }

  @Test
  public void updateContainerAttributes() {
    Admin foundAdmin = adminRepository.findOne(id);
    assertNotNull(foundAdmin);
    AdminAttributes adminAttributes = new AdminAttributes(id).setPid(12345).setHost("randomHost").setIp(
        "randomIP");
    Admin entity = new Admin(id, adminAttributes);
    adminRepository.update(entity);
    assertSavedAdmin(id, adminAttributes);
  }
View Full Code Here

  public void updateNonExistingContainer() {
    exception.expect(ZooKeeperAccessException.class);
    exception.expectMessage("Could not find admin with id " + id + 10);
    AdminAttributes adminAttributes = new AdminAttributes(id + 10).setPid(12345).setHost("randomHost").setIp(
        "randomIP");
    Admin entity = new Admin(id + 10, adminAttributes);
    adminRepository.update(entity);
  }
View Full Code Here

    long timeout = System.currentTimeMillis() + 15000;
    boolean foundAdmin = false;
    while (!foundAdmin && System.currentTimeMillis() < timeout) {
      try {
        Thread.sleep(200);
        Admin admin = adminRepository.findOne(id);
        if (admin != null && compareAdminAttributes(admin.getAttributes(), adminAttributes)) {
          foundAdmin = true;
        }
      }
      catch (InterruptedException e) {
        Thread.currentThread().interrupt();
View Full Code Here

TOP

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

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.