Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HBase init error when Kerberos is enabled #1294

Merged
merged 3 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import com.baidu.hugegraph.type.define.Action;
import com.baidu.hugegraph.type.define.HugeKeys;
import com.baidu.hugegraph.type.define.IndexType;
import com.baidu.hugegraph.type.define.SchemaStatus;
import com.baidu.hugegraph.util.CollectionUtil;
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.InsertionOrderUtil;
Expand Down
4 changes: 3 additions & 1 deletion hugegraph-dist/src/assembly/static/bin/init-store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ ensure_path_writable $PLUGINS

if [ -n "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME"/bin/java
EXT="$JAVA_HOME/jre/lib/ext:$LIB:$PLUGINS"
else
JAVA=java
EXT="$LIB:$PLUGINS"
fi

cd $TOP

echo "Initializing HugeGraph Store..."

$JAVA -cp $LIB/hugegraph-dist-*.jar -Djava.ext.dirs=$LIB:$PLUGINS \
$JAVA -cp $LIB/hugegraph-dist-*.jar -Djava.ext.dirs=$EXT \
com.baidu.hugegraph.cmd.InitStore \
"$CONF"/gremlin-server.yaml "$CONF"/rest-server.properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public static synchronized HbaseOptions instance() {
"/etc/krb5.conf"
);

public static final ConfigOption<String> HBASE_HBASE_SITE =
new ConfigOption<>(
"hbase.hbase_site",
"The HBase's configuration file",
null,
"/etc/hbase/conf/hbase-site.xml"
);

public static final ConfigOption<String> HBASE_KERBEROS_PRINCIPAL =
new ConfigOption<>(
"hbase.kerberos_principal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.concurrent.Future;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
Expand Down Expand Up @@ -135,6 +136,9 @@ public synchronized void open() throws IOException {
hConfig.setInt("hbase.hconnection.threads.max",
config.get(HbaseOptions.HBASE_THREADS_MAX));

String hbaseSite = config.get(HbaseOptions.HBASE_HBASE_SITE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be null? don't addResource if hbaseSite is null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config item's default value is /etc/hbase/conf/hbase-site.xml.If not setting,program will get default value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if there not exist file "/etc/hbase/conf/hbase-site.xml"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The program runs normally.If not modified,program read the file from hbase-common-2.0.6.jar, it does not exist actually but prograpm runs normally.

  public static Configuration addHbaseResources(Configuration conf) {
    conf.addResource("hbase-default.xml");
    conf.addResource("hbase-site.xml");

    checkDefaultsVersion(conf);
    return conf;
  }

hConfig.addResource(new Path(hbaseSite));

if(isEnableKerberos) {
String krb5Conf = config.get(HbaseOptions.HBASE_KRB5_CONF);
System.setProperty("java.security.krb5.conf", krb5Conf);
Expand Down