Exemple #1
0
  private static List<Table> getExportTables(CatalogMap<Connector> connectors) {
    List<Table> retval = new ArrayList<Table>();

    for (Connector conn : connectors) {
      for (ConnectorTableInfo cti : conn.getTableinfo()) {
        retval.add(cti.getTable());
      }
    }
    return retval;
  }
  void initializeGenerationFromCatalog(
      final Connector conn,
      int hostId,
      HostMessenger messenger,
      List<Pair<Integer, Long>> partitions) {
    /*
     * Now create datasources based on the catalog
     */
    Iterator<ConnectorTableInfo> tableInfoIt = conn.getTableinfo().iterator();
    // Only populate partitions in use if export is actually happening
    Set<Integer> partitionsInUse = new HashSet<Integer>();
    while (tableInfoIt.hasNext()) {
      ConnectorTableInfo next = tableInfoIt.next();
      Table table = next.getTable();
      addDataSources(table, hostId, partitions);

      for (Pair<Integer, Long> p : partitions) {
        partitionsInUse.add(p.getFirst());
      }
    }

    createAndRegisterAckMailboxes(partitionsInUse, messenger);
  }
Exemple #3
0
  void compileConnector(final Connector conn, final Database catdb) throws VoltCompilerException {
    // Test the error paths before touching the catalog
    if (conn == null) {
      return;
    }

    // Figure out if the connector is enabled or disabled
    // Export will be disabled if there is no destination.
    boolean adminstate = conn.isEnabled();

    if (!conn.isEnabled()) {
      LOG.info(
          "Export configuration is present and is "
              + "configured to be disabled. Export will be disabled.");
    }

    // Catalog Connector
    // Relying on schema's enforcement of at most 1 connector
    org.voltdb.catalog.Connector catconn = catdb.getConnectors().add("0");
    catconn.setEnabled(adminstate);
    catconn.setLoaderclass(conn.getClazz());

    // add authorized users and groups
    final ArrayList<String> userslist = new ArrayList<String>();
    final ArrayList<String> groupslist = new ArrayList<String>();

    // @users
    if (conn.getUsers() != null) {
      for (String user : conn.getUsers().split(",")) {
        userslist.add(user);
      }
    }

    // @groups
    if (conn.getGroups() != null) {
      for (String group : conn.getGroups().split(",")) {
        groupslist.add(group);
      }
    }

    for (String userName : userslist) {
      final User user = catdb.getUsers().get(userName);
      if (user == null) {
        throw new VoltCompilerException(
            "Export connector "
                + conn.getClazz()
                + " has a user "
                + userName
                + " that does not exist");
      }
      final UserRef userRef = catconn.getAuthusers().add(userName);
      userRef.setUser(user);
    }
    for (String groupName : groupslist) {
      final Group group = catdb.getGroups().get(groupName);
      if (group == null) {
        throw new VoltCompilerException(
            "Export connector "
                + conn.getClazz()
                + " has a group "
                + groupName
                + " that does not exist");
      }
      final GroupRef groupRef = catconn.getAuthgroups().add(groupName);
      groupRef.setGroup(group);
    }

    // Catalog Connector.ConnectorTableInfo
    Integer i = 0;
    if (conn.getTables() != null) {
      for (Tables.Table xmltable : conn.getTables().getTable()) {
        // verify that the table exists in the catalog
        String tablename = xmltable.getName();
        org.voltdb.catalog.Table tableref = catdb.getTables().get(tablename);
        if (tableref == null) {
          LOG.warn(
              "While configuring export, table "
                  + tablename
                  + " was not present in "
                  + "the catalog. Export will be disabled for this table.");
          continue;
        }

        org.voltdb.catalog.ConnectorTableInfo cattable = catconn.getTableinfo().add(i.toString());
        cattable.setAppendonly(xmltable.isExportonly());
        cattable.setTable(tableref);
        ++i;
      }
    }
  }