コード例 #1
0
  @SuppressWarnings("unchecked")
  @Override
  public Collection<GatewayMixer> getMixers() {

    log.debug("Getting list with all active mixers");
    try {

      List<GatewayMixer> mixers = new ArrayList<GatewayMixer>();
      Selector selector = Pelops.createSelector(schemaName);
      LinkedHashMap<Bytes, List<Column>> rows =
          selector.getColumnsFromRows(
              "mixers",
              Selector.newKeyRange("", "", 10000), // 10000 mixers limit,
              false,
              ConsistencyLevel.ONE);

      for (Map.Entry<Bytes, List<Column>> row : rows.entrySet()) {
        if (row.getValue().size() > 0) {
          mixers.add(buildMixer(row.getValue(), row.getKey().toUTF8()));
        }
      }

      return mixers;
    } catch (PelopsException pe) {
      log.error(pe.getMessage(), pe);
      return Collections.EMPTY_LIST;
    }
  }
コード例 #2
0
  @Override
  public RayoNode getNode(String rayoNode) {

    log.debug("Getting node with id: [%s]", rayoNode);
    RayoNode node = null;
    try {
      Selector selector = Pelops.createSelector(schemaName);
      Map<String, List<SuperColumn>> rows =
          selector.getSuperColumnsFromRowsUtf8Keys(
              "nodes",
              Selector.newKeyRange("", "", 100), // 100 platforms limit should be enough :)
              Selector.newColumnsPredicate(rayoNode),
              ConsistencyLevel.ONE);

      Iterator<Entry<String, List<SuperColumn>>> it = rows.entrySet().iterator();
      while (it.hasNext()) {
        Entry<String, List<SuperColumn>> element = it.next();
        String currPlatform = element.getKey();
        List<SuperColumn> platformOccurrences = element.getValue();
        for (SuperColumn column : platformOccurrences) {
          if (node == null) {
            node = new RayoNode();
            node = buildNode(column.getColumns());
            node.setHostname(rayoNode);
          }
          node.addPlatform(currPlatform);
        }
      }
    } catch (PelopsException pe) {
      log.error(pe.getMessage(), pe);
      return null;
    }
    return node;
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  @Override
  public List<Application> getApplications() {

    try {
      log.debug("Finding all applications");

      List<Application> applications = new ArrayList<Application>();
      Selector selector = Pelops.createSelector(schemaName);
      LinkedHashMap<Bytes, List<Column>> rows =
          selector.getColumnsFromRows(
              "applications",
              Selector.newKeyRange("", "", 10000), // 10000 applications limite,
              false,
              ConsistencyLevel.ONE);

      for (Map.Entry<Bytes, List<Column>> row : rows.entrySet()) {
        if (row.getValue().size() > 0) {
          Application application = new Application(row.getKey().toUTF8());
          populateApplicationData(application, row.getValue());
          applications.add(application);
        }
      }

      return applications;
    } catch (PelopsException pe) {
      log.error(pe.getMessage(), pe);
      return Collections.EMPTY_LIST;
    }
  }
コード例 #4
0
  @SuppressWarnings("unchecked")
  @Override
  public List<GatewayVerb> getVerbs() {

    log.debug("Getting list with all active verb");
    try {

      List<GatewayVerb> verbs = new ArrayList<GatewayVerb>();
      Selector selector = Pelops.createSelector(schemaName);
      LinkedHashMap<Bytes, List<Column>> rows =
          selector.getColumnsFromRows(
              "verbs",
              Selector.newKeyRange("", "", 10000), // 10000 mixers limit,
              false,
              ConsistencyLevel.ONE);

      for (Map.Entry<Bytes, List<Column>> row : rows.entrySet()) {
        if (row.getValue().size() > 0) {
          for (Column column : row.getValue()) {
            GatewayVerb verb =
                new GatewayVerb(
                    row.getKey().toUTF8(),
                    Bytes.toUTF8(column.getName()),
                    Bytes.toUTF8(column.getValue()));
            verbs.add(verb);
          }
        }
      }

      return verbs;
    } catch (PelopsException pe) {
      log.error(pe.getMessage(), pe);
      return Collections.EMPTY_LIST;
    }
  }
コード例 #5
0
  private List<String> getAllRowNames(
      String columnFamily, int numColumns, boolean excludeIfLessColumns, String colName) {

    List<String> result = new ArrayList<String>();
    try {
      Selector selector = Pelops.createSelector(schemaName);
      final int PAGE_SIZE = 100;
      String currRow = "";
      while (true) {
        SlicePredicate predicate = null;
        if (colName == null) {
          predicate = Selector.newColumnsPredicateAll(false, numColumns);
        } else {
          predicate = Selector.newColumnsPredicate(colName, colName, false, numColumns);
        }

        Map<String, List<Column>> rows =
            selector.getColumnsFromRowsUtf8Keys(
                columnFamily,
                Selector.newKeyRange(currRow, "", PAGE_SIZE),
                predicate,
                ConsistencyLevel.ONE);

        Iterator<Entry<String, List<Column>>> it = rows.entrySet().iterator();
        while (it.hasNext()) {
          Entry<String, List<Column>> element = it.next();
          if (excludeIfLessColumns && element.getValue().size() < numColumns) {
            continue;
          }
          currRow = element.getKey();
          if (!result.contains(currRow)) {
            result.add(currRow);
          }
        }

        if (rows.keySet().size() < PAGE_SIZE) break;
      }

    } catch (PelopsException pe) {
      log.error(pe.getMessage(), pe);
    }

    return result;
  }