Skip to content

Commit

Permalink
[dbs-leipzig#862] replaced deprecated api usage of hbase store (dbs-l…
Browse files Browse the repository at this point in the history
…eipzig#880)

* [dbs-leipzig#862] replaced deprecated api usage of hbase store and reordered params of HBase config class constructor
* fixes [dbs-leipzig#862]
  • Loading branch information
ChrizZz110 authored and merando committed Jul 13, 2018
1 parent ffb945b commit 5e42607
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 159 deletions.
Expand Up @@ -17,6 +17,7 @@

import org.apache.commons.lang.StringUtils;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.hadoop.hbase.TableName;
import org.gradoop.common.model.impl.pojo.Edge;
import org.gradoop.common.model.impl.pojo.EdgeFactory;
import org.gradoop.common.model.impl.pojo.GraphHead;
Expand Down Expand Up @@ -53,16 +54,16 @@ public class GradoopHBaseConfig extends GradoopStoreConfig<
/**
* Graph table name.
*/
private final String graphTableName;
private final TableName graphTableName;
/**
* EPGMVertex table name.
*/
private final String vertexTableName;
private final TableName vertexTableName;

/**
* EPGMEdge table name.
*/
private final String edgeTableName;
private final TableName edgeTableName;

/**
* Graph head handler.
Expand Down Expand Up @@ -108,16 +109,13 @@ private GradoopHBaseConfig(
checkArgument(!StringUtils.isEmpty(edgeTableName),
"EPGMEdge table name was null or empty");

this.graphTableName = graphTableName;
this.vertexTableName = vertexTableName;
this.edgeTableName = edgeTableName;
this.graphTableName = TableName.valueOf(graphTableName);
this.vertexTableName = TableName.valueOf(vertexTableName);
this.edgeTableName = TableName.valueOf(edgeTableName);

this.graphHeadHandler =
checkNotNull(graphHeadHandler, "GraphHeadHandler was null");
this.vertexHandler =
checkNotNull(vertexHandler, "VertexHandler was null");
this.edgeHandler =
checkNotNull(edgeHandler, "EdgeHandler was null");
this.graphHeadHandler = checkNotNull(graphHeadHandler, "GraphHeadHandler was null");
this.vertexHandler = checkNotNull(vertexHandler, "VertexHandler was null");
this.edgeHandler = checkNotNull(edgeHandler, "EdgeHandler was null");
}

/**
Expand All @@ -130,9 +128,9 @@ private GradoopHBaseConfig(
*/
private GradoopHBaseConfig(
GradoopHBaseConfig config,
String graphTableName,
String vertexTableName,
String edgeTableName,
String graphTableName
String edgeTableName
) {
this(config.getGraphHeadHandler(),
config.getVertexHandler(),
Expand All @@ -147,11 +145,10 @@ private GradoopHBaseConfig(
* Creates a default Configuration using POJO handlers for vertices, edges
* and graph heads and default table names.
*
*@param env apache flink execution environment
* @param env apache flink execution environment
* @return Default Gradoop HBase configuration.
*/
public static GradoopHBaseConfig
getDefaultConfig(ExecutionEnvironment env) {
public static GradoopHBaseConfig getDefaultConfig(ExecutionEnvironment env) {
GraphHeadHandler<GraphHead> graphHeadHandler =
new HBaseGraphHeadHandler<>(new GraphHeadFactory());
VertexHandler<Vertex, Edge> vertexHandler =
Expand All @@ -166,7 +163,8 @@ private GradoopHBaseConfig(
env,
HBaseConstants.DEFAULT_TABLE_GRAPHS,
HBaseConstants.DEFAULT_TABLE_VERTICES,
HBaseConstants.DEFAULT_TABLE_EDGES);
HBaseConstants.DEFAULT_TABLE_EDGES
);
}

/**
Expand All @@ -181,23 +179,22 @@ private GradoopHBaseConfig(
*/
public static GradoopHBaseConfig createConfig(
GradoopHBaseConfig gradoopConfig,
String graphTableName,
String vertexTableName,
String edgeTableName,
String graphTableName
String edgeTableName
) {
return new GradoopHBaseConfig(gradoopConfig, graphTableName,
vertexTableName, edgeTableName);
return new GradoopHBaseConfig(gradoopConfig, graphTableName, vertexTableName, edgeTableName);
}

public String getVertexTableName() {
public TableName getVertexTableName() {
return vertexTableName;
}

public String getEdgeTableName() {
public TableName getEdgeTableName() {
return edgeTableName;
}

public String getGraphTableName() {
public TableName getGraphTableName() {
return graphTableName;
}

Expand Down
Expand Up @@ -16,11 +16,12 @@
package org.gradoop.common.storage.impl.hbase;

import com.google.common.base.Preconditions;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.gradoop.common.config.GradoopHBaseConfig;
import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.pojo.Edge;
Expand Down Expand Up @@ -56,56 +57,53 @@ public class HBaseEPGMStore implements
EPGMGraphOutput {
//TODO make HBaseEPGMStore implement EPGMGraphPredictableOutput

/**
* Default value for clearing buffer on fail.
*/
private static final boolean DEFAULT_CLEAR_BUFFER_ON_FAIL = true;
/**
* Default value for enabling auto flush in HBase.
*/
private static final boolean DEFAULT_ENABLE_AUTO_FLUSH = true;

/**
* Gradoop configuration.
*/
private final GradoopHBaseConfig config;

/**
* HBase table for storing graphs.
*/
private final HTable graphHeadTable;
private final Table graphHeadTable;
/**
* HBase table for storing vertex data.
*/
private final HTable vertexTable;
private final Table vertexTable;
/**
* HBase table for storing edge data.
*/
private final HTable edgeTable;
private final Table edgeTable;
/**
* HBase admin instance
*/
private final Admin admin;
/**
* Auto flush flag, default false
*/
private volatile boolean autoFlush;

/**
* Creates a HBaseEPGMStore based on the given parameters. All parameters
* are mandatory and must not be {@code null}.
*
* @param graphHeadTable HBase table to store graph data
* @param vertexTable HBase table to store vertex data
* @param edgeTable HBase table to store edge data
* @param config Gradoop Configuration
* @param graphHeadTable HBase table to store graph data
* @param vertexTable HBase table to store vertex data
* @param edgeTable HBase table to store edge data
* @param config Gradoop Configuration
* @param admin HBase admin instance
*/
public HBaseEPGMStore(
final HTable graphHeadTable,
final HTable vertexTable,
final HTable edgeTable,
final GradoopHBaseConfig config
final Table graphHeadTable,
final Table vertexTable,
final Table edgeTable,
final GradoopHBaseConfig config,
final Admin admin
) {
this.graphHeadTable = Preconditions.checkNotNull(graphHeadTable);
this.vertexTable = Preconditions.checkNotNull(vertexTable);
this.edgeTable = Preconditions.checkNotNull(edgeTable);
this.config = Preconditions.checkNotNull(config);

this.graphHeadTable.setAutoFlush(DEFAULT_ENABLE_AUTO_FLUSH, DEFAULT_CLEAR_BUFFER_ON_FAIL);
this.vertexTable.setAutoFlush(DEFAULT_ENABLE_AUTO_FLUSH, DEFAULT_CLEAR_BUFFER_ON_FAIL);
this.edgeTable.setAutoFlush(DEFAULT_ENABLE_AUTO_FLUSH, DEFAULT_CLEAR_BUFFER_ON_FAIL);
this.admin = Preconditions.checkNotNull(admin);
}

/**
Expand Down Expand Up @@ -152,6 +150,9 @@ public void writeGraphHead(@Nonnull final PersistentGraphHead graphHead) throws
put = graphHeadHandler.writeGraphHead(put, graphHead);
// write to table
graphHeadTable.put(put);
if (autoFlush) {
admin.flush(graphHeadTable.getName());
}
}

/**
Expand All @@ -166,6 +167,9 @@ public void writeVertex(@Nonnull final PersistentVertex<Edge> vertexData) throws
put = vertexHandler.writeVertex(put, vertexData);
// write to table
vertexTable.put(put);
if (autoFlush) {
admin.flush(vertexTable.getName());
}
}

/**
Expand All @@ -180,6 +184,9 @@ public void writeEdge(@Nonnull final PersistentEdge<Vertex> edgeData) throws IOE
// write edge data to Put
put = edgeHandler.writeEdge(put, edgeData);
edgeTable.put(put);
if (autoFlush) {
admin.flush(edgeTable.getName());
}
}

/**
Expand Down Expand Up @@ -267,19 +274,17 @@ public ClosableIterator<Edge> getEdgeSpace(int cacheSize) throws IOException {
*/
@Override
public void setAutoFlush(boolean autoFlush) {
vertexTable.setAutoFlush(autoFlush, true);
edgeTable.setAutoFlush(autoFlush, true);
graphHeadTable.setAutoFlush(autoFlush, true);
this.autoFlush = autoFlush;
}

/**
* {@inheritDoc}
*/
@Override
public void flush() throws IOException {
vertexTable.flushCommits();
edgeTable.flushCommits();
graphHeadTable.flushCommits();
admin.flush(vertexTable.getName());
admin.flush(edgeTable.getName());
admin.flush(graphHeadTable.getName());
}

/**
Expand Down
Expand Up @@ -16,7 +16,7 @@
package org.gradoop.common.storage.impl.hbase.api;

import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.gradoop.common.model.impl.id.GradoopId;
Expand Down Expand Up @@ -109,12 +109,8 @@ Put writeProperties(
* Creates table based on the given table descriptor.
*
* @param admin HBase admin
* @param tableDescriptor description of the table used by that specific
* handler
* @throws IOException
* @param tableDescriptor description of the table used by that specific handler
* @throws IOException on failure
*/
void createTable(
final HBaseAdmin admin,
final HTableDescriptor tableDescriptor
) throws IOException;
void createTable(final Admin admin, final HTableDescriptor tableDescriptor) throws IOException;
}

0 comments on commit 5e42607

Please sign in to comment.