Skip to content

Commit

Permalink
Upped to HBase 1.2.1 and Hadoop 2.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgeorge committed May 29, 2016
1 parent cbb4bd0 commit 3cf7498
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.ScanType;
import org.apache.hadoop.hbase.regionserver.Store;
Expand Down Expand Up @@ -292,7 +293,7 @@ public void preSplit(
@Override
public void postSplit(
ObserverContext<RegionCoprocessorEnvironment> observerContext,
HRegion hRegion, HRegion hRegion1) throws IOException {
Region region, Region region1) throws IOException {
addCallCount("postSplit");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import org.apache.hadoop.hbase.coprocessor.BaseRegionServerObserver;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALKey;

// cc RegionServerObserverExample Example region server observer that ...
public class RegionServerObserverExample extends BaseRegionServerObserver {
public static final Log LOG = LogFactory.getLog(HRegion.class);
public static final Log LOG = LogFactory.getLog(Region.class);

@Override
public void postMerge(ObserverContext<RegionServerCoprocessorEnvironment> c,
HRegion regionA, HRegion regionB, HRegion mergedRegion) throws IOException {
Region regionA, Region regionB, Region mergedRegion) throws IOException {
HRegionInfo regionInfo = mergedRegion.getRegionInfo();
// mergedRegion.getWAL().append(mergedRegion.getTableDesc(), regionInfo,
// new WALKey(mergedRegion.getRegionName(), regionInfo.getTable()),
Expand Down
4 changes: 2 additions & 2 deletions ch05/src/main/java/coprocessor/DelayRegionCloseObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public StoreFile.Reader preStoreFileReaderOpen(
try {
long delay = rnd.nextInt(3);
LOG.info("@@@ Delaying region " +
ctx.getEnvironment().getRegion().getRegionNameAsString() +
" for " + delay + " seconds...");
ctx.getEnvironment().getRegion().getRegionInfo().
getRegionNameAsString() + " for " + delay + " seconds...");
Thread.sleep(delay * 1000);
} catch (InterruptedException ie) {
LOG.error(ie);
Expand Down
14 changes: 7 additions & 7 deletions ch08/src/main/java/coprocessor/ScanControlObserverEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import java.io.IOException;
import java.util.BitSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;

import com.google.common.collect.ImmutableList;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -37,15 +38,12 @@
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.protobuf.ResponseConverter;

import com.google.protobuf.RpcController;
import com.google.protobuf.Service;

import coprocessor.generated.ScanControlProtos;
import org.apache.hadoop.hbase.regionserver.DeleteTracker;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.ScanType;
import org.apache.hadoop.hbase.regionserver.Store;
Expand All @@ -56,6 +54,8 @@
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.wal.WALKey;

import coprocessor.generated.ScanControlProtos;

// cc ScanControlObserverEndpoint Observer and endpoint for scan operations
// vv ScanControlObserverEndpoint
@SuppressWarnings("deprecation") // because of API usage
Expand Down Expand Up @@ -267,7 +267,7 @@ public void preSplit(ObserverContext<RegionCoprocessorEnvironment> c,

@Override
public void postSplit(ObserverContext<RegionCoprocessorEnvironment> c,
HRegion l, HRegion r) throws IOException {
Region l, Region r) throws IOException {

}

Expand Down
41 changes: 41 additions & 0 deletions ch09/src/main/java/transactions/MultiRowMutationExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package transactions;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Coprocessor;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import util.HBaseHelper;

// cc LoadWithTableDescriptorExample2 Load a coprocessor using the table descriptor using provided method
public class MultiRowMutationExample {

public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
Connection connection = ConnectionFactory.createConnection(conf);
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
TableName tableName = TableName.valueOf("testtable");

// vv LoadWithTableDescriptorExample2
HTableDescriptor htd = new HTableDescriptor(tableName) // co LoadWithTableDescriptorExample2-1-Create Use fluent interface to create and configure the instance.
.addFamily(new HColumnDescriptor("colfam1"))
/*[*/.addCoprocessor(RegionObserverExample.class.getCanonicalName(),
null, Coprocessor.PRIORITY_USER, null);/*]*/ // co LoadWithTableDescriptorExample2-2-AddCP Use the provided method to add the coprocessor.

Admin admin = connection.getAdmin();
admin.createTable(htd);
// ^^ LoadWithTableDescriptorExample2

System.out.println(admin.getTableDescriptor(tableName));
admin.close();
connection.close();
}
}
63 changes: 26 additions & 37 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,28 @@
<url>http://github.com/larsgeorge/hbase-book</url>
</scm>

<repositories>
<repository>
<id>apache-releases</id>
<url>https://repository.apache.org/content/repositories/releases/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
<repository>
<id>cloudera-releases</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!--<repositories>-->
<!--<repository>-->
<!--<id>cloudera-releases</id>-->
<!--<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>-->
<!--<releases>-->
<!--<enabled>true</enabled>-->
<!--</releases>-->
<!--<snapshots>-->
<!--<enabled>true</enabled>-->
<!--</snapshots>-->
<!--</repository>-->
<!--</repositories>-->

<properties>
<jdkLevel>1.7</jdkLevel>
<requiredMavenVersion>[2.1,)</requiredMavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>

<hadoop.version>2.7.2</hadoop.version>
<zookeeper.version>3.4.8</zookeeper.version>
<hbase.version>1.2.1</hbase.version>
</properties>

<build>
Expand Down Expand Up @@ -90,7 +79,7 @@
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.6.0</version>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<groupId>commons-cli</groupId>
Expand Down Expand Up @@ -249,7 +238,7 @@
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.6.0</version>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<artifactId>hadoop-annotations</artifactId>
Expand Down Expand Up @@ -424,7 +413,7 @@
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
<version>2.6.0</version>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-codec</artifactId>
Expand Down Expand Up @@ -455,12 +444,12 @@
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-annotations</artifactId>
<version>2.6.0</version>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
Expand All @@ -487,7 +476,7 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>1.0.0</version>
<version>${hbase.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.avro</groupId>
Expand Down Expand Up @@ -690,7 +679,7 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
<version>1.0.0</version>
<version>${hbase.version}</version>
<exclusions>
<exclusion>
<artifactId>hbase-annotations</artifactId>
Expand Down Expand Up @@ -753,7 +742,7 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-protocol</artifactId>
<version>1.0.0</version>
<version>${hbase.version}</version>
<exclusions>
<exclusion>
<artifactId>findbugs-annotations</artifactId>
Expand All @@ -780,7 +769,7 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>1.0.0</version>
<version>${hbase.version}</version>
<exclusions>
<exclusion>
<artifactId>hbase-protocol</artifactId>
Expand Down Expand Up @@ -939,7 +928,7 @@
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-annotations</artifactId>
<version>1.0.0</version>
<version>${hbase.version}</version>
<exclusions>
<exclusion>
<artifactId>findbugs-annotations</artifactId>
Expand Down

0 comments on commit 3cf7498

Please sign in to comment.