Пример #1
0
 @Override
 public WAL getWAL(final byte[] identifier) throws IOException {
   final byte[] group = strategy.group(identifier);
   WALProvider provider = cached.get(group);
   if (null == provider) {
     provider = populateCache(group);
   }
   return provider.getWAL(identifier);
 }
Пример #2
0
 /** Populate the cache for this group. */
 WALProvider populateCache(final byte[] group) throws IOException {
   final WALProvider temp =
       factory.getProvider(
           DELEGATE_PROVIDER,
           DEFAULT_DELEGATE_PROVIDER,
           listeners,
           providerId + "-" + UUID.randomUUID());
   final WALProvider extant = cached.putIfAbsent(group, temp);
   if (null != extant) {
     // someone else beat us to initializing, just take what they set.
     temp.close();
     return extant;
   }
   return temp;
 }
Пример #3
0
 @Override
 public void close() throws IOException {
   // save the last exception and rethrow
   IOException failure = null;
   for (WALProvider provider : cached.values()) {
     try {
       provider.close();
     } catch (IOException exception) {
       LOG.error("Problem closing provider '" + provider + "': " + exception.getMessage());
       LOG.debug("Details of problem shutting down provider '" + provider + "'", exception);
       failure = exception;
     }
   }
   if (failure != null) {
     throw failure;
   }
 }