TEPHRA-315 tephra-example maven setup is broken

fix examples maven structure
update some maven plugin versions
diff --git a/pom.xml b/pom.xml
index 0acd1bd..f923fe6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -407,7 +407,6 @@
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
-          <version>3.1</version>
           <configuration>
             <source>1.7</source>
             <target>1.7</target>
@@ -418,7 +417,6 @@
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
-          <version>2.14.1</version>
           <configuration>
             <argLine>-Xmx4096m -Djava.awt.headless=true -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true</argLine>
             <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}</redirectTestOutputToFile>
@@ -441,11 +439,16 @@
           </configuration>
         </plugin>
 
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>build-helper-maven-plugin</artifactId>
+          <version>3.2.0</version>
+        </plugin>
+
         <!-- License check -->
         <plugin>
           <groupId>org.apache.rat</groupId>
           <artifactId>apache-rat-plugin</artifactId>
-          <version>0.10</version>
           <executions>
             <execution>
               <id>rat-check</id>
@@ -516,7 +519,6 @@
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-release-plugin</artifactId>
-          <version>2.5</version>
           <configuration>
             <tagNameFormat>v@{project.version}</tagNameFormat>
             <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
@@ -538,22 +540,18 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.1</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.14.1</version>
       </plugin>
       <plugin>
         <groupId>org.apache.rat</groupId>
         <artifactId>apache-rat-plugin</artifactId>
-        <version>0.10</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
-        <version>2.12.1</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -652,62 +650,6 @@
         </plugins>
       </build>
     </profile>
-
-    <!-- Profile to generate apache release -->
-    <profile>
-      <id>apache-release</id>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-assembly-plugin</artifactId>
-            <configuration>
-              <finalName>apache-tephra-${project.version}</finalName>
-              <formats>
-                <format>tar.gz</format>
-              </formats>
-            </configuration>
-          </plugin>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-remote-resources-plugin</artifactId>
-            <configuration>
-              <!-- Disable this plugin so that it won't generate a DEPENDENCIES file in the source tar -->
-              <skip>true</skip>
-            </configuration>
-          </plugin>
-
-          <!-- Compute checksum of release artifact -->
-          <plugin>
-            <inherited>false</inherited>
-            <groupId>net.ju-n.maven.plugins</groupId>
-            <artifactId>checksum-maven-plugin</artifactId>
-            <executions>
-              <execution>
-                <goals>
-                  <goal>files</goal>
-                </goals>
-              </execution>
-            </executions>
-            <configuration>
-              <algorithms>
-                <algorithm>MD5</algorithm>
-                <algorithm>SHA-512</algorithm>
-              </algorithms>
-              <fileSets>
-                <fileSet>
-                  <directory>${project.build.directory}</directory>
-                  <includes>
-                    <include>apache-tephra-${project.version}-${sourceReleaseAssemblyDescriptor}.tar.gz</include>
-                  </includes>
-                </fileSet>
-              </fileSets>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-
   </profiles>
 
 </project>
diff --git a/tephra-core-shaded/pom.xml b/tephra-core-shaded/pom.xml
index 3e63b24..33a1ae6 100644
--- a/tephra-core-shaded/pom.xml
+++ b/tephra-core-shaded/pom.xml
@@ -45,6 +45,21 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
         <configuration>
+          <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+            <dependencyReducedPomLocation>${basedir}/target/dependency-reduced-pom.xml</dependencyReducedPomLocation>
+            <createSourcesJar>true</createSourcesJar>
+            <artifactSet>
+              <includes>
+                <include>org.apache.tephra:tephra-core</include>
+                <include>org.apache.twill:twill-api</include>
+                <include>org.apache.twill:twill-common</include>
+                <include>org.apache.twill:twill-core</include>
+                <include>org.apache.twill:twill-discovery-api</include>
+                <include>org.apache.twill:twill-discovery-core</include>
+                <include>org.apache.twill:twill-zookeeper</include>
+                <include>com.google.guava:guava</include>
+              </includes>
+            </artifactSet>
           <filters>
             <filter>
               <artifact>*:*</artifact>
@@ -74,32 +89,6 @@
             </transformer>
           </transformers>
         </configuration>
-        <executions>
-          <execution>
-            <id>default-shaded</id>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
-              <dependencyReducedPomLocation>${basedir}/target/dependency-reduced-pom.xml</dependencyReducedPomLocation>
-              <createSourcesJar>true</createSourcesJar>
-              <artifactSet>
-                <includes>
-                  <include>org.apache.tephra:tephra-core</include>
-                  <include>org.apache.twill:twill-api</include>
-                  <include>org.apache.twill:twill-common</include>
-                  <include>org.apache.twill:twill-core</include>
-                  <include>org.apache.twill:twill-discovery-api</include>
-                  <include>org.apache.twill:twill-discovery-core</include>
-                  <include>org.apache.twill:twill-zookeeper</include>
-                  <include>com.google.guava:guava</include>
-                </includes>
-              </artifactSet>
-            </configuration>
-          </execution>
-        </executions>
       </plugin>
     </plugins>
   </build>
diff --git a/tephra-core/pom.xml b/tephra-core/pom.xml
index c6f9443..f419364 100644
--- a/tephra-core/pom.xml
+++ b/tephra-core/pom.xml
@@ -128,7 +128,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
-        <version>2.4</version>
         <executions>
           <execution>
             <id>test-jar</id>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-1.3/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-1.3/pom.xml
index f6cc10d..637d392 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-1.3/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-1.3/pom.xml
@@ -31,7 +31,6 @@
   <properties>
     <hadoop.version>2.5.1</hadoop.version>
     <hbase13.version>1.3.1</hbase13.version>
-    <hbase.scrdir>src-1.3</hbase.scrdir>
   </properties>
 
   <build>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-1.4/pom.xml
index 3e343b1..058bcc8 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-1.4/pom.xml
@@ -34,8 +34,12 @@
   </properties>
 
   <build>
-    <sourceDirectory>src/main/java</sourceDirectory>
-    <testSourceDirectory>src/test/java</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
   </build>
 
   <dependencies>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/main/java/org/apache/tephra/examples/BalanceBooks.java b/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/main/java/org/apache/tephra/examples/BalanceBooks.java
deleted file mode 100644
index b970598..0000000
--- a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/main/java/org/apache/tephra/examples/BalanceBooks.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tephra.examples;
-
-import com.google.common.io.Closeables;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-import org.apache.hadoop.conf.Configuration;
-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 org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.client.Table;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.tephra.TransactionConflictException;
-import org.apache.tephra.TransactionContext;
-import org.apache.tephra.TransactionFailureException;
-import org.apache.tephra.TransactionSystemClient;
-import org.apache.tephra.distributed.TransactionServiceClient;
-import org.apache.tephra.hbase.TransactionAwareHTable;
-import org.apache.tephra.hbase.coprocessor.TransactionProcessor;
-import org.apache.tephra.runtime.ConfigModule;
-import org.apache.tephra.runtime.DiscoveryModules;
-import org.apache.tephra.runtime.TransactionClientModule;
-import org.apache.tephra.runtime.TransactionModules;
-import org.apache.tephra.runtime.ZKModule;
-import org.apache.tephra.util.ConfigurationFactory;
-import org.apache.twill.zookeeper.ZKClientService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Simple example application that launches a number of concurrent clients, one per "account".  Each client attempts to
- * make withdrawals from other clients, and deposit the same amount to its own account in a single transaction.
- * Since this means the client will be updating both its own row and the withdrawee's row, this will naturally lead to
- * transaction conflicts.  All clients will run for a specified number of iterations.  When the processing is complete,
- * the total sum of all rows should be zero, if transactional integrity was maintained.
- *
- * <p>
- *   You can run the BalanceBooks application with the following command:
- *   <pre>
- *     ./bin/tephra run org.apache.tephra.examples.BalanceBooks [num clients] [num iterations]
- *   </pre>
- *   where <code>[num clients]</code> is the number of concurrent client threads to use, and
- *   <code>[num iterations]</code> is the number of "transfer" operations to perform per client thread.
- * </p>
- */
-public class BalanceBooks implements Closeable {
-  private static final Logger LOG = LoggerFactory.getLogger(BalanceBooks.class);
-
-  private static final int MAX_AMOUNT = 100;
-  private static final byte[] TABLE = Bytes.toBytes("testbalances");
-  private static final byte[] FAMILY = Bytes.toBytes("f");
-  private static final byte[] COL = Bytes.toBytes("b");
-
-  private final int totalClients;
-  private final int iterations;
-
-  private Configuration conf;
-  private ZKClientService zkClient;
-  private TransactionServiceClient txClient;
-  private Connection conn;
-
-  public BalanceBooks(int totalClients, int iterations) {
-    this(totalClients, iterations, new ConfigurationFactory().get());
-  }
-
-  public BalanceBooks(int totalClients, int iterations, Configuration conf) {
-    this.totalClients = totalClients;
-    this.iterations = iterations;
-    this.conf = conf;
-  }
-
-  /**
-   * Sets up common resources required by all clients.
-   */
-  public void init() throws IOException {
-    Injector injector = Guice.createInjector(
-        new ConfigModule(conf),
-        new ZKModule(),
-        new DiscoveryModules().getDistributedModules(),
-        new TransactionModules().getDistributedModules(),
-        new TransactionClientModule()
-    );
-
-    zkClient = injector.getInstance(ZKClientService.class);
-    zkClient.startAndWait();
-    txClient = injector.getInstance(TransactionServiceClient.class);
-    conn = ConnectionFactory.createConnection(conf);
-    createTableIfNotExists(conf, TABLE, new byte[][]{ FAMILY });
-  }
-
-  /**
-   * Runs all clients and waits for them to complete.
-   */
-  public void run() throws IOException, InterruptedException {
-    List<Client> clients = new ArrayList<>(totalClients);
-    for (int i = 0; i < totalClients; i++) {
-      Client c = new Client(i, totalClients, iterations);
-      c.init(txClient, conn.getTable(TableName.valueOf(TABLE)));
-      c.start();
-      clients.add(c);
-    }
-
-    for (Client c : clients) {
-      c.join();
-      Closeables.closeQuietly(c);
-    }
-  }
-
-  /**
-   * Validates the current state of the data stored at the end of the test.  Each update by a client consists of two
-   * parts: a withdrawal of a random amount from a randomly select other account, and a corresponding to deposit to
-   * the client's own account.  So, if all the updates were performed consistently (no partial updates or partial
-   * rollbacks), then the total sum of all balances at the end should be 0.
-   */
-  public boolean verify() {
-    boolean success = false;
-    try {
-      TransactionAwareHTable table = new TransactionAwareHTable(conn.getTable(TableName.valueOf(TABLE)));
-      TransactionContext context = new TransactionContext(txClient, table);
-
-      LOG.info("VERIFYING BALANCES");
-      context.start();
-      long totalBalance = 0;
-
-      try (ResultScanner scanner = table.getScanner(new Scan())) {
-        for (Result r : scanner) {
-          if (!r.isEmpty()) {
-            int rowId = Bytes.toInt(r.getRow());
-            long balance = Bytes.toLong(r.getValue(FAMILY, COL));
-            totalBalance += balance;
-            LOG.info("Client #{}: balance = ${}", rowId, balance);
-          }
-        }
-      }
-      if (totalBalance == 0) {
-        LOG.info("PASSED!");
-        success = true;
-      } else {
-        LOG.info("FAILED! Total balance should be 0 but was {}", totalBalance);
-      }
-      context.finish();
-    } catch (Exception e) {
-      LOG.error("Failed verification check", e);
-    }
-    return success;
-  }
-
-  /**
-   * Frees up the underlying resources common to all clients.
-   */
-  public void close() {
-    try {
-      if (conn != null) {
-        conn.close();
-      }
-    } catch (IOException ignored) { }
-
-    if (zkClient != null) {
-      zkClient.stopAndWait();
-    }
-  }
-
-  protected void createTableIfNotExists(Configuration conf, byte[] tableName, byte[][] columnFamilies)
-      throws IOException {
-    try (Admin admin = this.conn.getAdmin()) {
-      HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
-      for (byte[] family : columnFamilies) {
-        HColumnDescriptor columnDesc = new HColumnDescriptor(family);
-        columnDesc.setMaxVersions(Integer.MAX_VALUE);
-        desc.addFamily(columnDesc);
-      }
-      desc.addCoprocessor(TransactionProcessor.class.getName());
-      admin.createTable(desc);
-    }
-  }
-
-  public static void main(String[] args) {
-    if (args.length != 2) {
-      System.err.println("Usage: java " + BalanceBooks.class.getName() + " <num clients> <iterations>");
-      System.err.println("\twhere <num clients> >= 2");
-      System.exit(1);
-    }
-
-    try (BalanceBooks bb = new BalanceBooks(Integer.parseInt(args[0]), Integer.parseInt(args[1]))) {
-      bb.init();
-      bb.run();
-      bb.verify();
-    } catch (Exception e) {
-      LOG.error("Failed during BalanceBooks run", e);
-    }
-  }
-
-  /**
-   * Represents a single client actor in the test.  Each client runs as a separate thread.
-   *
-   * For the given number of iterations, the client will:
-   * <ol>
-   *   <li>select a random other client from which to withdraw</li>
-   *   <li>select a random amount from 0 to MAX_AMOUNT</li>
-   *   <li>start a new transaction and: deduct the amount from the other client's acccount, and deposit
-   *       the same amount to its own account.</li>
-   * </ol>
-   *
-   * Since multiple clients operate concurrently and contend over a set of constrained resources
-   * (the client accounts), it is expected that a portion of the attempted transactions will encounter
-   * conflicts, due to a simultaneous deduction from or deposit to one the same accounts which has successfully
-   * committed first.  In this case, the updates from the transaction encountering the conflict should be completely
-   * rolled back, leaving the data in a consistent state.
-   */
-  private static class Client extends Thread implements Closeable {
-    private final int id;
-    private final int totalClients;
-    private final int iterations;
-
-    private final Random random = new Random();
-
-    private TransactionContext txContext;
-    private TransactionAwareHTable txTable;
-
-
-    public Client(int id, int totalClients, int iterations) {
-      this.id = id;
-      this.totalClients = totalClients;
-      this.iterations = iterations;
-    }
-
-    /**
-     * Sets up any resources needed by the individual client.
-     *
-     * @param txClient the transaction client to use in accessing the transaciton service
-     * @param table the HBase table instance to use for accessing storage
-     */
-    public void init(TransactionSystemClient txClient, Table table) {
-      txTable = new TransactionAwareHTable(table);
-      txContext = new TransactionContext(txClient, txTable);
-    }
-
-    public void run() {
-      try {
-        for (int i = 0; i < iterations; i++) {
-          runOnce();
-        }
-      } catch (TransactionFailureException e) {
-        LOG.error("Client #{}: Failed on exception", id, e);
-      }
-    }
-
-    /**
-     * Runs a single iteration of the client logic.
-     */
-    private void runOnce() throws TransactionFailureException {
-      int withdrawee = getNextWithdrawee();
-      int amount = getAmount();
-
-      try {
-        txContext.start();
-        long withdraweeBalance = getCurrentBalance(withdrawee);
-        long ownBalance = getCurrentBalance(id);
-        long withdraweeNew = withdraweeBalance - amount;
-        long ownNew = ownBalance + amount;
-
-        setBalance(withdrawee, withdraweeNew);
-        setBalance(id, ownNew);
-        LOG.debug("Client #{}: Withdrew ${} from #{}; withdrawee old={}, new={}; own old={}, new={}",
-            id, amount, withdrawee, withdraweeBalance, withdraweeNew, ownBalance, ownNew);
-        txContext.finish();
-
-      } catch (IOException ioe) {
-        LOG.error("Client #{}: Unhandled client failure", id, ioe);
-        txContext.abort();
-      } catch (TransactionConflictException tce) {
-        LOG.debug("CONFLICT: client #{} attempting to withdraw from #{}", id, withdrawee);
-        txContext.abort(tce);
-      } catch (TransactionFailureException tfe) {
-        LOG.error("Client #{}: Unhandled transaction failure", id, tfe);
-        txContext.abort(tfe);
-      }
-    }
-
-    private long getCurrentBalance(int id) throws IOException {
-      Result r = txTable.get(new Get(Bytes.toBytes(id)));
-      byte[] balanceBytes = r.getValue(FAMILY, COL);
-      if (balanceBytes == null) {
-        return 0;
-      }
-      return Bytes.toLong(balanceBytes);
-    }
-
-    private void setBalance(int id, long balance) throws IOException {
-      txTable.put(new Put(Bytes.toBytes(id)).addColumn(FAMILY, COL, Bytes.toBytes(balance)));
-    }
-
-    private int getNextWithdrawee() {
-      int next;
-      do {
-        next = random.nextInt(totalClients);
-      } while (next == id);
-      return next;
-    }
-
-    private int getAmount() {
-      return random.nextInt(MAX_AMOUNT);
-    }
-
-    public void close() throws IOException {
-      txTable.close();
-    }
-  }
-}
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/main/java/org/apache/tephra/examples/package-info.java b/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/main/java/org/apache/tephra/examples/package-info.java
deleted file mode 100644
index a0e67d5..0000000
--- a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/main/java/org/apache/tephra/examples/package-info.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This package contains example applications for Tephra designed to illustrate sample Tephra usage
- * and provide out-of-the-box sample applications which can be run to test cluster functionality.
- *
- * <p>Currently the following applications are provided:
- *
- * <ul>
- *   <li><strong>BalanceBooks</strong> - this application runs a specified number of concurrent clients in separate
- *     threads, which perform transactions to make withdrawals from each other's accounts and deposits to their own
- *     accounts.  At the end of the test, the total value of all account balances is verified to be equal to zero,
- *     which confirms that transactional integrity was not violated.
- *   </li>
- * </ul>
- * </p>
- *
- * <p>
- *   Note that, for simplicity, the examples package is currently hardcoded to compile against a specific HBase
- *   version (currently 2.0).  In the future, we should provide Maven profiles to allow compiling the examples
- *   against each of the supported HBase versions.
- * </p>
- */
-package org.apache.tephra.examples;
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/test/java/org/apache/tephra/examples/BalanceBooksTest.java b/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/test/java/org/apache/tephra/examples/BalanceBooksTest.java
deleted file mode 100644
index 4dfe107..0000000
--- a/tephra-examples/tephra-examples-post-1.3/hbase-1.4/src/test/java/org/apache/tephra/examples/BalanceBooksTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tephra.examples;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Scopes;
-import com.google.inject.util.Modules;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.tephra.TransactionSystemClient;
-import org.apache.tephra.TxConstants;
-import org.apache.tephra.distributed.TransactionService;
-import org.apache.tephra.persist.InMemoryTransactionStateStorage;
-import org.apache.tephra.persist.TransactionStateStorage;
-import org.apache.tephra.runtime.ConfigModule;
-import org.apache.tephra.runtime.DiscoveryModules;
-import org.apache.tephra.runtime.TransactionClientModule;
-import org.apache.tephra.runtime.TransactionModules;
-import org.apache.tephra.runtime.ZKModule;
-import org.apache.tephra.util.Tests;
-import org.apache.twill.zookeeper.ZKClientService;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests the {@link BalanceBooks} program.
- */
-public class BalanceBooksTest {
-  private static final Logger LOG = LoggerFactory.getLogger(BalanceBooksTest.class);
-  private static HBaseTestingUtility testUtil;
-  private static TransactionService txService;
-  private static ZKClientService zkClientService;
-
-  @ClassRule
-  public static TemporaryFolder tmpFolder = new TemporaryFolder();
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    testUtil = new HBaseTestingUtility();
-    Configuration conf = testUtil.getConfiguration();
-    conf.setBoolean(TxConstants.Manager.CFG_DO_PERSIST, false);
-    conf.set(TxConstants.Manager.CFG_TX_SNAPSHOT_DIR, tmpFolder.newFolder().getAbsolutePath());
-
-    // Tune down the connection thread pool size
-    conf.setInt("hbase.hconnection.threads.core", 5);
-    conf.setInt("hbase.hconnection.threads.max", 10);
-    // Tunn down handler threads in regionserver
-    conf.setInt("hbase.regionserver.handler.count", 10);
-
-    // Set to random port
-    conf.setInt("hbase.master.port", 0);
-    conf.setInt("hbase.master.info.port", 0);
-    conf.setInt("hbase.regionserver.port", 0);
-    conf.setInt("hbase.regionserver.info.port", 0);
-
-    testUtil.startMiniCluster();
-
-    String zkClusterKey = testUtil.getClusterKey(); // hostname:clientPort:parentZnode
-    String zkQuorum = zkClusterKey.substring(0, zkClusterKey.lastIndexOf(':'));
-    LOG.info("Zookeeper Quorum is running at {}", zkQuorum);
-    conf.set(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM, zkQuorum);
-
-    Injector injector = Guice.createInjector(
-        new ConfigModule(conf),
-        new ZKModule(),
-        new DiscoveryModules().getDistributedModules(),
-        Modules.override(new TransactionModules().getDistributedModules())
-            .with(new AbstractModule() {
-              @Override
-              protected void configure() {
-                bind(TransactionStateStorage.class).to(InMemoryTransactionStateStorage.class).in(Scopes.SINGLETON);
-              }
-            }),
-        new TransactionClientModule()
-    );
-
-    zkClientService = injector.getInstance(ZKClientService.class);
-    zkClientService.startAndWait();
-
-    // start a tx server
-    txService = injector.getInstance(TransactionService.class);
-    try {
-      LOG.info("Starting transaction service");
-      txService.startAndWait();
-    } catch (Exception e) {
-      LOG.error("Failed to start service: ", e);
-      throw e;
-    }
-
-    Tests.waitForTxReady(injector.getInstance(TransactionSystemClient.class));
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    if (txService != null) {
-      txService.stopAndWait();
-    }
-    if (zkClientService != null) {
-      zkClientService.stopAndWait();
-    }
-    testUtil.shutdownMiniCluster();
-  }
-
-  @Test
-  public void testBalanceBooks() throws Exception {
-    try (BalanceBooks bb = new BalanceBooks(5, 100, testUtil.getConfiguration())) {
-      bb.init();
-      bb.run();
-      assertTrue(bb.verify());
-    }
-  }
-}
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-1.5/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-1.5/pom.xml
index 74667c1..e3fe9a3 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-1.5/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-1.5/pom.xml
@@ -34,8 +34,12 @@
   </properties>
 
   <build>
-    <sourceDirectory>src/main/java</sourceDirectory>
-    <testSourceDirectory>src/test/java</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
   </build>
 
   <dependencies>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-1.6/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-1.6/pom.xml
index 849447b..28e8a19 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-1.6/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-1.6/pom.xml
@@ -34,8 +34,12 @@
   </properties>
 
   <build>
-    <sourceDirectory>src/main/java</sourceDirectory>
-    <testSourceDirectory>src/test/java</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
   </build>
 
   <dependencies>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-2.0/pom.xml
index c6eae5b..f3fc1a3 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-2.0/pom.xml
@@ -33,20 +33,21 @@
   </properties>
 
   <build>
-    <sourceDirectory>src/main/java</sourceDirectory>
-    <testSourceDirectory>src/test/java</testSourceDirectory>
-      <plugins>
-        <!-- Compiler -->
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>3.1</version>
-          <configuration>
-            <source>1.8</source>
-            <target>1.8</target>
-          </configuration>
-        </plugin>
-      </plugins>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+      <!-- Compiler -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 
   <dependencies>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/main/java/org/apache/tephra/examples/BalanceBooks.java b/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/main/java/org/apache/tephra/examples/BalanceBooks.java
deleted file mode 100644
index b970598..0000000
--- a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/main/java/org/apache/tephra/examples/BalanceBooks.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tephra.examples;
-
-import com.google.common.io.Closeables;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-import org.apache.hadoop.conf.Configuration;
-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 org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.client.Table;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.tephra.TransactionConflictException;
-import org.apache.tephra.TransactionContext;
-import org.apache.tephra.TransactionFailureException;
-import org.apache.tephra.TransactionSystemClient;
-import org.apache.tephra.distributed.TransactionServiceClient;
-import org.apache.tephra.hbase.TransactionAwareHTable;
-import org.apache.tephra.hbase.coprocessor.TransactionProcessor;
-import org.apache.tephra.runtime.ConfigModule;
-import org.apache.tephra.runtime.DiscoveryModules;
-import org.apache.tephra.runtime.TransactionClientModule;
-import org.apache.tephra.runtime.TransactionModules;
-import org.apache.tephra.runtime.ZKModule;
-import org.apache.tephra.util.ConfigurationFactory;
-import org.apache.twill.zookeeper.ZKClientService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Simple example application that launches a number of concurrent clients, one per "account".  Each client attempts to
- * make withdrawals from other clients, and deposit the same amount to its own account in a single transaction.
- * Since this means the client will be updating both its own row and the withdrawee's row, this will naturally lead to
- * transaction conflicts.  All clients will run for a specified number of iterations.  When the processing is complete,
- * the total sum of all rows should be zero, if transactional integrity was maintained.
- *
- * <p>
- *   You can run the BalanceBooks application with the following command:
- *   <pre>
- *     ./bin/tephra run org.apache.tephra.examples.BalanceBooks [num clients] [num iterations]
- *   </pre>
- *   where <code>[num clients]</code> is the number of concurrent client threads to use, and
- *   <code>[num iterations]</code> is the number of "transfer" operations to perform per client thread.
- * </p>
- */
-public class BalanceBooks implements Closeable {
-  private static final Logger LOG = LoggerFactory.getLogger(BalanceBooks.class);
-
-  private static final int MAX_AMOUNT = 100;
-  private static final byte[] TABLE = Bytes.toBytes("testbalances");
-  private static final byte[] FAMILY = Bytes.toBytes("f");
-  private static final byte[] COL = Bytes.toBytes("b");
-
-  private final int totalClients;
-  private final int iterations;
-
-  private Configuration conf;
-  private ZKClientService zkClient;
-  private TransactionServiceClient txClient;
-  private Connection conn;
-
-  public BalanceBooks(int totalClients, int iterations) {
-    this(totalClients, iterations, new ConfigurationFactory().get());
-  }
-
-  public BalanceBooks(int totalClients, int iterations, Configuration conf) {
-    this.totalClients = totalClients;
-    this.iterations = iterations;
-    this.conf = conf;
-  }
-
-  /**
-   * Sets up common resources required by all clients.
-   */
-  public void init() throws IOException {
-    Injector injector = Guice.createInjector(
-        new ConfigModule(conf),
-        new ZKModule(),
-        new DiscoveryModules().getDistributedModules(),
-        new TransactionModules().getDistributedModules(),
-        new TransactionClientModule()
-    );
-
-    zkClient = injector.getInstance(ZKClientService.class);
-    zkClient.startAndWait();
-    txClient = injector.getInstance(TransactionServiceClient.class);
-    conn = ConnectionFactory.createConnection(conf);
-    createTableIfNotExists(conf, TABLE, new byte[][]{ FAMILY });
-  }
-
-  /**
-   * Runs all clients and waits for them to complete.
-   */
-  public void run() throws IOException, InterruptedException {
-    List<Client> clients = new ArrayList<>(totalClients);
-    for (int i = 0; i < totalClients; i++) {
-      Client c = new Client(i, totalClients, iterations);
-      c.init(txClient, conn.getTable(TableName.valueOf(TABLE)));
-      c.start();
-      clients.add(c);
-    }
-
-    for (Client c : clients) {
-      c.join();
-      Closeables.closeQuietly(c);
-    }
-  }
-
-  /**
-   * Validates the current state of the data stored at the end of the test.  Each update by a client consists of two
-   * parts: a withdrawal of a random amount from a randomly select other account, and a corresponding to deposit to
-   * the client's own account.  So, if all the updates were performed consistently (no partial updates or partial
-   * rollbacks), then the total sum of all balances at the end should be 0.
-   */
-  public boolean verify() {
-    boolean success = false;
-    try {
-      TransactionAwareHTable table = new TransactionAwareHTable(conn.getTable(TableName.valueOf(TABLE)));
-      TransactionContext context = new TransactionContext(txClient, table);
-
-      LOG.info("VERIFYING BALANCES");
-      context.start();
-      long totalBalance = 0;
-
-      try (ResultScanner scanner = table.getScanner(new Scan())) {
-        for (Result r : scanner) {
-          if (!r.isEmpty()) {
-            int rowId = Bytes.toInt(r.getRow());
-            long balance = Bytes.toLong(r.getValue(FAMILY, COL));
-            totalBalance += balance;
-            LOG.info("Client #{}: balance = ${}", rowId, balance);
-          }
-        }
-      }
-      if (totalBalance == 0) {
-        LOG.info("PASSED!");
-        success = true;
-      } else {
-        LOG.info("FAILED! Total balance should be 0 but was {}", totalBalance);
-      }
-      context.finish();
-    } catch (Exception e) {
-      LOG.error("Failed verification check", e);
-    }
-    return success;
-  }
-
-  /**
-   * Frees up the underlying resources common to all clients.
-   */
-  public void close() {
-    try {
-      if (conn != null) {
-        conn.close();
-      }
-    } catch (IOException ignored) { }
-
-    if (zkClient != null) {
-      zkClient.stopAndWait();
-    }
-  }
-
-  protected void createTableIfNotExists(Configuration conf, byte[] tableName, byte[][] columnFamilies)
-      throws IOException {
-    try (Admin admin = this.conn.getAdmin()) {
-      HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
-      for (byte[] family : columnFamilies) {
-        HColumnDescriptor columnDesc = new HColumnDescriptor(family);
-        columnDesc.setMaxVersions(Integer.MAX_VALUE);
-        desc.addFamily(columnDesc);
-      }
-      desc.addCoprocessor(TransactionProcessor.class.getName());
-      admin.createTable(desc);
-    }
-  }
-
-  public static void main(String[] args) {
-    if (args.length != 2) {
-      System.err.println("Usage: java " + BalanceBooks.class.getName() + " <num clients> <iterations>");
-      System.err.println("\twhere <num clients> >= 2");
-      System.exit(1);
-    }
-
-    try (BalanceBooks bb = new BalanceBooks(Integer.parseInt(args[0]), Integer.parseInt(args[1]))) {
-      bb.init();
-      bb.run();
-      bb.verify();
-    } catch (Exception e) {
-      LOG.error("Failed during BalanceBooks run", e);
-    }
-  }
-
-  /**
-   * Represents a single client actor in the test.  Each client runs as a separate thread.
-   *
-   * For the given number of iterations, the client will:
-   * <ol>
-   *   <li>select a random other client from which to withdraw</li>
-   *   <li>select a random amount from 0 to MAX_AMOUNT</li>
-   *   <li>start a new transaction and: deduct the amount from the other client's acccount, and deposit
-   *       the same amount to its own account.</li>
-   * </ol>
-   *
-   * Since multiple clients operate concurrently and contend over a set of constrained resources
-   * (the client accounts), it is expected that a portion of the attempted transactions will encounter
-   * conflicts, due to a simultaneous deduction from or deposit to one the same accounts which has successfully
-   * committed first.  In this case, the updates from the transaction encountering the conflict should be completely
-   * rolled back, leaving the data in a consistent state.
-   */
-  private static class Client extends Thread implements Closeable {
-    private final int id;
-    private final int totalClients;
-    private final int iterations;
-
-    private final Random random = new Random();
-
-    private TransactionContext txContext;
-    private TransactionAwareHTable txTable;
-
-
-    public Client(int id, int totalClients, int iterations) {
-      this.id = id;
-      this.totalClients = totalClients;
-      this.iterations = iterations;
-    }
-
-    /**
-     * Sets up any resources needed by the individual client.
-     *
-     * @param txClient the transaction client to use in accessing the transaciton service
-     * @param table the HBase table instance to use for accessing storage
-     */
-    public void init(TransactionSystemClient txClient, Table table) {
-      txTable = new TransactionAwareHTable(table);
-      txContext = new TransactionContext(txClient, txTable);
-    }
-
-    public void run() {
-      try {
-        for (int i = 0; i < iterations; i++) {
-          runOnce();
-        }
-      } catch (TransactionFailureException e) {
-        LOG.error("Client #{}: Failed on exception", id, e);
-      }
-    }
-
-    /**
-     * Runs a single iteration of the client logic.
-     */
-    private void runOnce() throws TransactionFailureException {
-      int withdrawee = getNextWithdrawee();
-      int amount = getAmount();
-
-      try {
-        txContext.start();
-        long withdraweeBalance = getCurrentBalance(withdrawee);
-        long ownBalance = getCurrentBalance(id);
-        long withdraweeNew = withdraweeBalance - amount;
-        long ownNew = ownBalance + amount;
-
-        setBalance(withdrawee, withdraweeNew);
-        setBalance(id, ownNew);
-        LOG.debug("Client #{}: Withdrew ${} from #{}; withdrawee old={}, new={}; own old={}, new={}",
-            id, amount, withdrawee, withdraweeBalance, withdraweeNew, ownBalance, ownNew);
-        txContext.finish();
-
-      } catch (IOException ioe) {
-        LOG.error("Client #{}: Unhandled client failure", id, ioe);
-        txContext.abort();
-      } catch (TransactionConflictException tce) {
-        LOG.debug("CONFLICT: client #{} attempting to withdraw from #{}", id, withdrawee);
-        txContext.abort(tce);
-      } catch (TransactionFailureException tfe) {
-        LOG.error("Client #{}: Unhandled transaction failure", id, tfe);
-        txContext.abort(tfe);
-      }
-    }
-
-    private long getCurrentBalance(int id) throws IOException {
-      Result r = txTable.get(new Get(Bytes.toBytes(id)));
-      byte[] balanceBytes = r.getValue(FAMILY, COL);
-      if (balanceBytes == null) {
-        return 0;
-      }
-      return Bytes.toLong(balanceBytes);
-    }
-
-    private void setBalance(int id, long balance) throws IOException {
-      txTable.put(new Put(Bytes.toBytes(id)).addColumn(FAMILY, COL, Bytes.toBytes(balance)));
-    }
-
-    private int getNextWithdrawee() {
-      int next;
-      do {
-        next = random.nextInt(totalClients);
-      } while (next == id);
-      return next;
-    }
-
-    private int getAmount() {
-      return random.nextInt(MAX_AMOUNT);
-    }
-
-    public void close() throws IOException {
-      txTable.close();
-    }
-  }
-}
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/main/java/org/apache/tephra/examples/package-info.java b/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/main/java/org/apache/tephra/examples/package-info.java
deleted file mode 100644
index a0e67d5..0000000
--- a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/main/java/org/apache/tephra/examples/package-info.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This package contains example applications for Tephra designed to illustrate sample Tephra usage
- * and provide out-of-the-box sample applications which can be run to test cluster functionality.
- *
- * <p>Currently the following applications are provided:
- *
- * <ul>
- *   <li><strong>BalanceBooks</strong> - this application runs a specified number of concurrent clients in separate
- *     threads, which perform transactions to make withdrawals from each other's accounts and deposits to their own
- *     accounts.  At the end of the test, the total value of all account balances is verified to be equal to zero,
- *     which confirms that transactional integrity was not violated.
- *   </li>
- * </ul>
- * </p>
- *
- * <p>
- *   Note that, for simplicity, the examples package is currently hardcoded to compile against a specific HBase
- *   version (currently 2.0).  In the future, we should provide Maven profiles to allow compiling the examples
- *   against each of the supported HBase versions.
- * </p>
- */
-package org.apache.tephra.examples;
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/test/java/org/apache/tephra/examples/BalanceBooksTest.java b/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/test/java/org/apache/tephra/examples/BalanceBooksTest.java
deleted file mode 100644
index 4dfe107..0000000
--- a/tephra-examples/tephra-examples-post-1.3/hbase-2.0/src/test/java/org/apache/tephra/examples/BalanceBooksTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tephra.examples;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Scopes;
-import com.google.inject.util.Modules;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.tephra.TransactionSystemClient;
-import org.apache.tephra.TxConstants;
-import org.apache.tephra.distributed.TransactionService;
-import org.apache.tephra.persist.InMemoryTransactionStateStorage;
-import org.apache.tephra.persist.TransactionStateStorage;
-import org.apache.tephra.runtime.ConfigModule;
-import org.apache.tephra.runtime.DiscoveryModules;
-import org.apache.tephra.runtime.TransactionClientModule;
-import org.apache.tephra.runtime.TransactionModules;
-import org.apache.tephra.runtime.ZKModule;
-import org.apache.tephra.util.Tests;
-import org.apache.twill.zookeeper.ZKClientService;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests the {@link BalanceBooks} program.
- */
-public class BalanceBooksTest {
-  private static final Logger LOG = LoggerFactory.getLogger(BalanceBooksTest.class);
-  private static HBaseTestingUtility testUtil;
-  private static TransactionService txService;
-  private static ZKClientService zkClientService;
-
-  @ClassRule
-  public static TemporaryFolder tmpFolder = new TemporaryFolder();
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    testUtil = new HBaseTestingUtility();
-    Configuration conf = testUtil.getConfiguration();
-    conf.setBoolean(TxConstants.Manager.CFG_DO_PERSIST, false);
-    conf.set(TxConstants.Manager.CFG_TX_SNAPSHOT_DIR, tmpFolder.newFolder().getAbsolutePath());
-
-    // Tune down the connection thread pool size
-    conf.setInt("hbase.hconnection.threads.core", 5);
-    conf.setInt("hbase.hconnection.threads.max", 10);
-    // Tunn down handler threads in regionserver
-    conf.setInt("hbase.regionserver.handler.count", 10);
-
-    // Set to random port
-    conf.setInt("hbase.master.port", 0);
-    conf.setInt("hbase.master.info.port", 0);
-    conf.setInt("hbase.regionserver.port", 0);
-    conf.setInt("hbase.regionserver.info.port", 0);
-
-    testUtil.startMiniCluster();
-
-    String zkClusterKey = testUtil.getClusterKey(); // hostname:clientPort:parentZnode
-    String zkQuorum = zkClusterKey.substring(0, zkClusterKey.lastIndexOf(':'));
-    LOG.info("Zookeeper Quorum is running at {}", zkQuorum);
-    conf.set(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM, zkQuorum);
-
-    Injector injector = Guice.createInjector(
-        new ConfigModule(conf),
-        new ZKModule(),
-        new DiscoveryModules().getDistributedModules(),
-        Modules.override(new TransactionModules().getDistributedModules())
-            .with(new AbstractModule() {
-              @Override
-              protected void configure() {
-                bind(TransactionStateStorage.class).to(InMemoryTransactionStateStorage.class).in(Scopes.SINGLETON);
-              }
-            }),
-        new TransactionClientModule()
-    );
-
-    zkClientService = injector.getInstance(ZKClientService.class);
-    zkClientService.startAndWait();
-
-    // start a tx server
-    txService = injector.getInstance(TransactionService.class);
-    try {
-      LOG.info("Starting transaction service");
-      txService.startAndWait();
-    } catch (Exception e) {
-      LOG.error("Failed to start service: ", e);
-      throw e;
-    }
-
-    Tests.waitForTxReady(injector.getInstance(TransactionSystemClient.class));
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    if (txService != null) {
-      txService.stopAndWait();
-    }
-    if (zkClientService != null) {
-      zkClientService.stopAndWait();
-    }
-    testUtil.shutdownMiniCluster();
-  }
-
-  @Test
-  public void testBalanceBooks() throws Exception {
-    try (BalanceBooks bb = new BalanceBooks(5, 100, testUtil.getConfiguration())) {
-      bb.init();
-      bb.run();
-      assertTrue(bb.verify());
-    }
-  }
-}
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-2.1/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-2.1/pom.xml
index 6b348b3..2ca170c 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-2.1/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-2.1/pom.xml
@@ -33,20 +33,21 @@
   </properties>
 
   <build>
-    <sourceDirectory>src/main/java</sourceDirectory>
-    <testSourceDirectory>src/test/java</testSourceDirectory>
-      <plugins>
-        <!-- Compiler -->
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>3.1</version>
-          <configuration>
-            <source>1.8</source>
-            <target>1.8</target>
-          </configuration>
-        </plugin>
-      </plugins>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+      <!-- Compiler -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 
   <dependencies>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-2.2/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-2.2/pom.xml
index a7627d8..b34f898 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-2.2/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-2.2/pom.xml
@@ -33,20 +33,21 @@
   </properties>
 
   <build>
-    <sourceDirectory>src/main/java</sourceDirectory>
-    <testSourceDirectory>src/test/java</testSourceDirectory>
-      <plugins>
-        <!-- Compiler -->
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>3.1</version>
-          <configuration>
-            <source>1.8</source>
-            <target>1.8</target>
-          </configuration>
-        </plugin>
-      </plugins>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+      <!-- Compiler -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 
   <dependencies>
diff --git a/tephra-examples/tephra-examples-post-1.3/hbase-2.3/pom.xml b/tephra-examples/tephra-examples-post-1.3/hbase-2.3/pom.xml
index 704249c..380b0a0 100644
--- a/tephra-examples/tephra-examples-post-1.3/hbase-2.3/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/hbase-2.3/pom.xml
@@ -33,20 +33,21 @@
   </properties>
 
   <build>
-    <sourceDirectory>src/main/java</sourceDirectory>
-    <testSourceDirectory>src/test/java</testSourceDirectory>
-      <plugins>
-        <!-- Compiler -->
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>3.1</version>
-          <configuration>
-            <source>1.8</source>
-            <target>1.8</target>
-          </configuration>
-        </plugin>
-      </plugins>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+      <!-- Compiler -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 
   <dependencies>
diff --git a/tephra-examples/tephra-examples-post-1.3/pom.xml b/tephra-examples/tephra-examples-post-1.3/pom.xml
index a3985c4..7a14e81 100644
--- a/tephra-examples/tephra-examples-post-1.3/pom.xml
+++ b/tephra-examples/tephra-examples-post-1.3/pom.xml
@@ -46,7 +46,6 @@
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
-          <version>3.0.0</version>
           <executions>
             <execution>
               <id>add-source</id>
diff --git a/tephra-examples/tephra-examples-pre-1.3/pom.xml b/tephra-examples/tephra-examples-pre-1.3/pom.xml
index 2c6306d..3155dca 100644
--- a/tephra-examples/tephra-examples-pre-1.3/pom.xml
+++ b/tephra-examples/tephra-examples-pre-1.3/pom.xml
@@ -42,7 +42,6 @@
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
-          <version>3.0.0</version>
           <executions>
             <execution>
               <id>add-source</id>
diff --git a/tephra-hbase-compat-1.1-base/pom.xml b/tephra-hbase-compat-1.1-base/pom.xml
index b337015..6b6d0d8 100644
--- a/tephra-hbase-compat-1.1-base/pom.xml
+++ b/tephra-hbase-compat-1.1-base/pom.xml
@@ -157,7 +157,6 @@
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
-          <version>3.0.0</version>
           <executions>
             <execution>
               <id>add-source</id>
diff --git a/tephra-hbase-compat-1.4-base/pom.xml b/tephra-hbase-compat-1.4-base/pom.xml
index cf5daf1..bfbd5bd 100644
--- a/tephra-hbase-compat-1.4-base/pom.xml
+++ b/tephra-hbase-compat-1.4-base/pom.xml
@@ -180,7 +180,6 @@
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
-          <version>3.0.0</version>
           <executions>
             <execution>
               <id>add-source</id>
diff --git a/tephra-hbase-compat-2.0-base/pom.xml b/tephra-hbase-compat-2.0-base/pom.xml
index 46ad9cf..611655e 100644
--- a/tephra-hbase-compat-2.0-base/pom.xml
+++ b/tephra-hbase-compat-2.0-base/pom.xml
@@ -167,7 +167,6 @@
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
-          <version>3.0.0</version>
           <executions>
             <execution>
               <id>add-source</id>