Пример #1
0
  @Override
  public void copyForUpdate(DataContainer container, boolean writeSkewCheck) {
    if (isChanged()) return; // already copied

    // mark entry as changed.
    setChanged();

    if (writeSkewCheck) {
      // check for write skew.
      InternalCacheEntry ice = container.get(key);
      Object actualValue = ice == null ? null : ice.getValue();

      // Note that this identity-check is intentional.  We don't *want* to call actualValue.equals()
      // since that defeats the purpose.
      // the implicit "versioning" we have in R_R creates a new wrapper "value" instance for every
      // update.
      if (actualValue != null && actualValue != value) {
        String errormsg =
            new StringBuilder()
                .append("Detected write skew on key [")
                .append(getKey())
                .append("].  Another process has changed the entry since we last read it!")
                .toString();
        if (log.isWarnEnabled()) log.warn(errormsg + ".  Unable to copy entry for update.");
        throw new CacheException(errormsg);
      }
    }
    // make a backup copy
    oldValue = value;
  }
 public static void killCacheManagers(EmbeddedCacheManager... cacheManagers) {
   // stop the caches first so that stopping the cache managers doesn't trigger a rehash
   for (EmbeddedCacheManager cm : cacheManagers) {
     try {
       killCaches(getRunningCaches(cm));
     } catch (Throwable e) {
       log.warn("Problems stopping cache manager " + cm, e);
     }
   }
   for (EmbeddedCacheManager cm : cacheManagers) {
     try {
       if (cm != null) cm.stop();
     } catch (Throwable e) {
       log.warn("Problems killing cache manager " + cm, e);
     }
   }
 }
 public static void clearContent(List<? extends EmbeddedCacheManager> cacheManagers) {
   for (EmbeddedCacheManager cm : cacheManagers) {
     try {
       clearContent(cm);
     } catch (Throwable e) {
       log.warn("Problems clearing cache manager " + cm, e);
     }
   }
 }
Пример #4
0
 public void forget(Xid externalXid) throws XAException {
   Xid xid = convertXid(externalXid);
   if (trace) log.tracef("forget called for xid %s", xid);
   try {
     recoveryManager.removeRecoveryInformationFromCluster(null, xid, true);
   } catch (Exception e) {
     log.warn("Exception removing recovery information: ", e);
     throw new XAException(XAException.XAER_RMERR);
   }
 }
 /**
  * Get the systemwide used TransactionManager
  *
  * @return TransactionManager
  */
 public TransactionManager getTransactionManager() {
   if (!lookupDone) doLookups();
   if (tm != null) return tm;
   if (lookupFailed) {
     // fall back to a dummy from Infinispan
     tm = DummyTransactionManager.getInstance();
     log.warn("Falling back to DummyTransactionManager from Infinispan");
   }
   return tm;
 }
 @Override
 public void stop() {
   try {
     DataSources.destroy(pooledDataSource);
     if (log.isTraceEnabled()) {
       log.debug("Successfully stopped PooledConnectionFactory.");
     }
   } catch (SQLException sqle) {
     log.warn("Could not destroy C3P0 connection pool: " + pooledDataSource, sqle);
   }
 }
 private synchronized void fetchClusterWideStatsIfNeeded() {
   if (launchNewDistTask()) {
     try {
       List<CompletableFuture<Map<String, Number>>> responseList =
           des.submitEverywhere(new DistributedCacheStatsCallable());
       updateFieldsFromResponseMap(responseList);
     } catch (Exception e) {
       log.warn("Could not execute cluster wide cache stats operation ", e);
     } finally {
       statsUpdateTimestamp = ts.time();
     }
   }
 }
 private void logBefore(boolean checkout) {
   if (log.isTraceEnabled()) {
     String operation = checkout ? "checkout" : "release";
     try {
       log.trace(
           "DataSource before "
               + operation
               + " (NumBusyConnectionsAllUsers) : "
               + pooledDataSource.getNumBusyConnectionsAllUsers()
               + ", (NumConnectionsAllUsers) : "
               + pooledDataSource.getNumConnectionsAllUsers());
     } catch (SQLException e) {
       log.warn("Unexpected", e);
     }
   }
 }
  private void broadcastInvalidateForPrepare(
      List<WriteCommand> modifications, Transaction tx, InvocationContext ctx) throws Throwable {
    if (ctx.isInTxScope() && !isLocalModeForced(ctx)) {
      if (modifications == null || modifications.isEmpty()) return;
      InvalidationFilterVisitor filterVisitor = new InvalidationFilterVisitor(modifications.size());
      filterVisitor.visitCollection(null, modifications);

      if (filterVisitor.containsPutForExternalRead) {
        log.debug("Modification list contains a putForExternalRead operation.  Not invalidating.");
      } else if (filterVisitor.containsLocalModeFlag) {
        log.debug("Modification list contains a local mode flagged operation.  Not invalidating.");
      } else {
        try {
          invalidateAcrossCluster(
              defaultSynchronous, ctx, filterVisitor.result.toArray(), false, null);
        } catch (Throwable t) {
          log.warn("Unable to broadcast evicts as a part of the prepare phase.  Rolling back.", t);
          if (t instanceof RuntimeException) throw (RuntimeException) t;
          else throw new RuntimeException("Unable to broadcast invalidation messages", t);
        }
      }
    }
  }