accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/2] git commit: Merge branch '1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT
Date Mon, 18 Nov 2013 03:26:50 GMT
Merge branch '1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT

Conflicts:
	core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/45fbee69
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/45fbee69
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/45fbee69

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 45fbee6937549048c74fe176f201c246de0f5e0a
Parents: 0b8cca0 6b87c87
Author: Josh Elser <elserj@apache.org>
Authored: Sun Nov 17 22:08:31 2013 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Sun Nov 17 22:26:13 2013 -0500

----------------------------------------------------------------------
 .../client/impl/MultiTableBatchWriterImpl.java  | 168 ++++--
 .../accumulo/core/client/impl/Tables.java       |   7 +
 .../test/MultiTableBatchWriterTest.java         | 539 +++++++++++++++++++
 3 files changed, 679 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/45fbee69/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
index 0d2d44d,49c02d9..7eea455
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
@@@ -65,32 -78,60 +78,60 @@@ public class MultiTableBatchWriterImpl 
      public void flush() {
        throw new UnsupportedOperationException("Must flush all tables, can not flush an individual
table");
      }
-     
+ 
+   }
+ 
+   /**
+    * CacheLoader which will look up the internal table ID for a given table name.
+    */
+   private class TableNameToIdLoader extends CacheLoader<String,String> {
+ 
+     @Override
+     public String load(String tableName) throws Exception {
+       String tableId = Tables.getNameToIdMap(instance).get(tableName);
+ 
+       if (tableId == null)
+         throw new TableNotFoundException(tableId, tableName, null);
+ 
+       if (Tables.getTableState(instance, tableId) == TableState.OFFLINE)
+         throw new TableOfflineException(instance, tableId);
+ 
+       return tableId;
+     }
+ 
    }
-   
+ 
    private TabletServerBatchWriter bw;
-   private HashMap<String,BatchWriter> tableWriters;
+   private ConcurrentHashMap<String,BatchWriter> tableWriters;
    private Instance instance;
-   
+   private final LoadingCache<String,String> nameToIdCache;
+ 
 -  public MultiTableBatchWriterImpl(Instance instance, TCredentials credentials, BatchWriterConfig
config) {
 +  public MultiTableBatchWriterImpl(Instance instance, Credentials credentials, BatchWriterConfig
config) {
-     ArgumentChecker.notNull(instance, credentials);
+     this(instance, credentials, config, DEFAULT_CACHE_TIME, DEFAULT_CACHE_TIME_UNIT);
+   }
+ 
 -  public MultiTableBatchWriterImpl(Instance instance, TCredentials credentials, BatchWriterConfig
config, long cacheTime, TimeUnit cacheTimeUnit) {
++  public MultiTableBatchWriterImpl(Instance instance, Credentials credentials, BatchWriterConfig
config, long cacheTime, TimeUnit cacheTimeUnit) {
+     ArgumentChecker.notNull(instance, credentials, config, cacheTimeUnit);
      this.instance = instance;
      this.bw = new TabletServerBatchWriter(instance, credentials, config);
-     tableWriters = new HashMap<String,BatchWriter>();
-     this.closed = false;
+     tableWriters = new ConcurrentHashMap<String,BatchWriter>();
+     this.closed = new AtomicBoolean(false);
+     this.cacheLastState = new AtomicLong(0);
+ 
+     // Potentially up to ~500k used to cache names to IDs with "segments" of (maybe) ~1000
entries
+     nameToIdCache = CacheBuilder.newBuilder().expireAfterWrite(cacheTime, cacheTimeUnit).concurrencyLevel(10).maximumSize(10000).initialCapacity(20)
+         .build(new TableNameToIdLoader());
    }
-   
-   @Override
+ 
    public boolean isClosed() {
-     return this.closed;
+     return this.closed.get();
    }
-   
-   @Override
+ 
    public void close() throws MutationsRejectedException {
+     this.closed.set(true);
      bw.close();
-     this.closed = true;
    }
-   
+ 
    /**
     * Warning: do not rely upon finalize to close this class. Finalize is not guaranteed
to be called.
     */

http://git-wip-us.apache.org/repos/asf/accumulo/blob/45fbee69/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
----------------------------------------------------------------------


Mime
View raw message