Java Code Examples for org.apache.hadoop.hbase.HConstants#ZOOKEEPER_QUORUM

The following examples show how to use org.apache.hadoop.hbase.HConstants#ZOOKEEPER_QUORUM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBaseLookupFunction.java    From flink with Apache License 2.0 6 votes vote down vote up
private org.apache.hadoop.conf.Configuration prepareRuntimeConfiguration() {
	// create default configuration from current runtime env (`hbase-site.xml` in classpath) first,
	// and overwrite configuration using serialized configuration from client-side env (`hbase-site.xml` in classpath).
	// user params from client-side have the highest priority
	org.apache.hadoop.conf.Configuration runtimeConfig = HBaseConfigurationUtil.deserializeConfiguration(
		serializedConfig,
		HBaseConfiguration.create());

	// do validation: check key option(s) in final runtime configuration
	if (StringUtils.isNullOrWhitespaceOnly(runtimeConfig.get(HConstants.ZOOKEEPER_QUORUM))) {
		LOG.error("can not connect to HBase without {} configuration", HConstants.ZOOKEEPER_QUORUM);
		throw new IllegalArgumentException("check HBase configuration failed, lost: '" + HConstants.ZOOKEEPER_QUORUM + "'!");
	}

	return runtimeConfig;
}
 
Example 2
Source File: HBaseRowDataLookupFunction.java    From flink with Apache License 2.0 6 votes vote down vote up
private Configuration prepareRuntimeConfiguration() {
	// create default configuration from current runtime env (`hbase-site.xml` in classpath) first,
	// and overwrite configuration using serialized configuration from client-side env (`hbase-site.xml` in classpath).
	// user params from client-side have the highest priority
	Configuration runtimeConfig = HBaseConfigurationUtil.deserializeConfiguration(
		serializedConfig,
		HBaseConfigurationUtil.getHBaseConfiguration());

	// do validation: check key option(s) in final runtime configuration
	if (StringUtils.isNullOrWhitespaceOnly(runtimeConfig.get(HConstants.ZOOKEEPER_QUORUM))) {
		LOG.error("can not connect to HBase without {} configuration", HConstants.ZOOKEEPER_QUORUM);
		throw new IllegalArgumentException("check HBase configuration failed, lost: '" + HConstants.ZOOKEEPER_QUORUM + "'!");
	}

	return runtimeConfig;
}
 
Example 3
Source File: HBaseLookupFunction.java    From flink with Apache License 2.0 6 votes vote down vote up
private org.apache.hadoop.conf.Configuration prepareRuntimeConfiguration() {
	// create default configuration from current runtime env (`hbase-site.xml` in classpath) first,
	// and overwrite configuration using serialized configuration from client-side env (`hbase-site.xml` in classpath).
	// user params from client-side have the highest priority
	org.apache.hadoop.conf.Configuration runtimeConfig = HBaseConfigurationUtil.deserializeConfiguration(
		serializedConfig,
		HBaseConfigurationUtil.getHBaseConfiguration());

	// do validation: check key option(s) in final runtime configuration
	if (StringUtils.isNullOrWhitespaceOnly(runtimeConfig.get(HConstants.ZOOKEEPER_QUORUM))) {
		LOG.error("can not connect to HBase without {} configuration", HConstants.ZOOKEEPER_QUORUM);
		throw new IllegalArgumentException("check HBase configuration failed, lost: '" + HConstants.ZOOKEEPER_QUORUM + "'!");
	}

	return runtimeConfig;
}
 
Example 4
Source File: HBaseUpsertSinkFunction.java    From flink with Apache License 2.0 5 votes vote down vote up
private org.apache.hadoop.conf.Configuration prepareRuntimeConfiguration() throws IOException {
	// create default configuration from current runtime env (`hbase-site.xml` in classpath) first,
	// and overwrite configuration using serialized configuration from client-side env (`hbase-site.xml` in classpath).
	// user params from client-side have the highest priority
	org.apache.hadoop.conf.Configuration runtimeConfig = HBaseConfigurationUtil.deserializeConfiguration(serializedConfig, HBaseConfiguration.create());

	// do validation: check key option(s) in final runtime configuration
	if (StringUtils.isNullOrWhitespaceOnly(runtimeConfig.get(HConstants.ZOOKEEPER_QUORUM))) {
		LOG.error("Can not connect to HBase without {} configuration", HConstants.ZOOKEEPER_QUORUM);
		throw new IOException("Check HBase configuration failed, lost: '" + HConstants.ZOOKEEPER_QUORUM + "'!");
	}

	return runtimeConfig;
}
 
Example 5
Source File: CsvToKeyValueMapper.java    From phoenix with Apache License 2.0 5 votes vote down vote up
/**
 * Build up the JDBC URL for connecting to Phoenix.
 *
 * @return the full JDBC URL for a Phoenix connection
 */
@VisibleForTesting
static String getJdbcUrl(Configuration conf) {
    String zkQuorum = conf.get(HConstants.ZOOKEEPER_QUORUM);
    if (zkQuorum == null) {
        throw new IllegalStateException(HConstants.ZOOKEEPER_QUORUM + " is not configured");
    }
    return PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
}
 
Example 6
Source File: HBaseSinkFunction.java    From flink with Apache License 2.0 5 votes vote down vote up
private org.apache.hadoop.conf.Configuration prepareRuntimeConfiguration() throws IOException {
	// create default configuration from current runtime env (`hbase-site.xml` in classpath) first,
	// and overwrite configuration using serialized configuration from client-side env (`hbase-site.xml` in classpath).
	// user params from client-side have the highest priority
	org.apache.hadoop.conf.Configuration runtimeConfig = HBaseConfigurationUtil.deserializeConfiguration(serializedConfig, HBaseConfigurationUtil.getHBaseConfiguration());

	// do validation: check key option(s) in final runtime configuration
	if (StringUtils.isNullOrWhitespaceOnly(runtimeConfig.get(HConstants.ZOOKEEPER_QUORUM))) {
		LOG.error("Can not connect to HBase without {} configuration", HConstants.ZOOKEEPER_QUORUM);
		throw new IOException("Check HBase configuration failed, lost: '" + HConstants.ZOOKEEPER_QUORUM + "'!");
	}

	return runtimeConfig;
}
 
Example 7
Source File: ServerCommandLine.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Print into log some of the important hbase attributes.
 */
private static void logHBaseConfigs(Configuration conf) {
  final String [] keys = new String [] {
    // Expand this list as you see fit.
    "hbase.tmp.dir",
    HConstants.HBASE_DIR,
    HConstants.CLUSTER_DISTRIBUTED,
    HConstants.ZOOKEEPER_QUORUM,

  };
  for (String key: keys) {
    LOG.info(key + ": " + conf.get(key));
  }
}
 
Example 8
Source File: ZKConfig.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Separate the given key into the three configurations it should contain:
 * hbase.zookeeper.quorum, hbase.zookeeper.client.port
 * and zookeeper.znode.parent
 * @param key
 * @return the three configuration in the described order
 * @throws IOException
 */
public static ZKClusterKey transformClusterKey(String key) throws IOException {
  String[] parts = key.split(":");

  if (parts.length == 3) {
    if (!parts[2].matches("/.*[^/]")) {
      throw new IOException("Cluster key passed " + key + " is invalid, the format should be:" +
          HConstants.ZOOKEEPER_QUORUM + ":" + HConstants.ZOOKEEPER_CLIENT_PORT + ":"
          + HConstants.ZOOKEEPER_ZNODE_PARENT);
    }
    return new ZKClusterKey(parts [0], Integer.parseInt(parts [1]), parts [2]);
  }

  if (parts.length > 3) {
    // The quorum could contain client port in server:clientport format, try to transform more.
    String zNodeParent = parts [parts.length - 1];
    if (!zNodeParent.matches("/.*[^/]")) {
      throw new IOException("Cluster key passed " + key + " is invalid, the format should be:"
          + HConstants.ZOOKEEPER_QUORUM + ":" + HConstants.ZOOKEEPER_CLIENT_PORT + ":"
          + HConstants.ZOOKEEPER_ZNODE_PARENT);
    }

    String clientPort = parts [parts.length - 2];

    // The first part length is the total length minus the lengths of other parts and minus 2 ":"
    int endQuorumIndex = key.length() - zNodeParent.length() - clientPort.length() - 2;
    String quorumStringInput = key.substring(0, endQuorumIndex);
    String[] serverHosts = quorumStringInput.split(",");

    // The common case is that every server has its own client port specified - this means
    // that (total parts - the ZNodeParent part - the ClientPort part) is equal to
    // (the number of "," + 1) - "+ 1" because the last server has no ",".
    if ((parts.length - 2) == (serverHosts.length + 1)) {
      return new ZKClusterKey(quorumStringInput, Integer.parseInt(clientPort), zNodeParent);
    }

    // For the uncommon case that some servers has no port specified, we need to build the
    // server:clientport list using default client port for servers without specified port.
    return new ZKClusterKey(
        buildZKQuorumServerString(serverHosts, clientPort),
        Integer.parseInt(clientPort),
        zNodeParent);
  }

  throw new IOException("Cluster key passed " + key + " is invalid, the format should be:" +
      HConstants.ZOOKEEPER_QUORUM + ":" + HConstants.ZOOKEEPER_CLIENT_PORT + ":"
      + HConstants.ZOOKEEPER_ZNODE_PARENT);
}