Example #1
0
  private RayoNode store(RayoNode node) throws DatastoreException {

    Mutator mutator = Pelops.createMutator(schemaName);
    for (String platform : node.getPlatforms()) {
      mutator.writeSubColumns(
          "nodes",
          platform,
          node.getHostname(),
          mutator.newColumnList(
              mutator.newColumn("priority", String.valueOf(node.getPriority())),
              mutator.newColumn("weight", String.valueOf(node.getWeight())),
              mutator.newColumn("ip", node.getIpAddress()),
              mutator.newColumn("consecutive-errors", String.valueOf(node.getConsecutiveErrors())),
              mutator.newColumn("blacklisted", String.valueOf(node.isBlackListed()))));
    }

    mutator.writeColumn(
        "ips",
        Bytes.fromUTF8(node.getIpAddress()),
        mutator.newColumn(Bytes.fromUTF8("node"), Bytes.fromUTF8(node.getHostname())));

    try {
      mutator.execute(ConsistencyLevel.ONE);
      log.debug("Node [%s] stored successfully", node);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new DatastoreException(String.format("Could not create node [%s]", node));
    }
    return node;
  }
Example #2
0
  @Override
  public void storeAddresses(Collection<String> addresses, String jid) throws DatastoreException {

    log.debug("Storing addresses [%s] on application [%s]", addresses, jid);
    if (getApplication(jid) == null) {
      throw new ApplicationNotFoundException();
    }

    Mutator mutator = Pelops.createMutator(schemaName);
    for (String address : addresses) {
      mutator.writeColumn("addresses", Bytes.fromUTF8(address), mutator.newColumn(jid, jid));
    }

    try {
      mutator.execute(ConsistencyLevel.ONE);
      log.debug("Addresses [%s] stored successfully on application [%s]", addresses, jid);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new DatastoreException(
          String.format("Could not add addresses [%s] to application [%s]", addresses, jid));
    }
  }