@Override
  public void executeCommand(Command command, ExecutionHandlerContext context) {

    CacheTransactionManager txm = context.getCacheTransactionManager();

    if (!context.hasTransaction()) {
      command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
      return;
    }

    TransactionId transactionId = context.getTransactionID();

    txm.resume(transactionId);

    boolean hasError = hasError(context.getTransactionQueue());

    if (hasError) txm.rollback();
    else {
      try {
        txm.commit();
      } catch (CommitConflictException e) {
        command.setResponse(
            Coder.getErrorResponse(
                context.getByteBufAllocator(), RedisConstants.ERROR_COMMIT_CONFLICT));
        context.clearTransaction();
        return;
      }
    }

    ByteBuf response = constructResponseExec(context);
    command.setResponse(response);

    context.clearTransaction();
  }
  /** Check that remote persistent regions cause conflicts */
  public void testPersistentRestriction() throws Exception {
    final CacheTransactionManager txMgr = this.getCache().getCacheTransactionManager();
    final String misConfigRegionName = getUniqueName();
    Region misConfigRgn = getCache().createRegion(misConfigRegionName, getDiskRegionAttributes());
    Invoke.invokeInEveryVM(
        new SerializableRunnable("testPersistentRestriction: Illegal Region Configuration") {
          public void run() {
            try {
              getCache().createRegion(misConfigRegionName, getDiskRegionAttributes());
              // rgn1.put("misConfigKey", "oldmisConfigVal");
            } catch (CacheException e) {
              Assert.fail("While creating region", e);
            }
          }
        });
    misConfigRgn.put("misConfigKey", "oldmisConfigVal");

    txMgr.begin();

    try {
      misConfigRgn.put("misConfigKey", "newmisConfigVal");
      fail("Expected an IllegalStateException with information about misconfigured regions");
    } catch (UnsupportedOperationException expected) {
      getSystem().getLogWriter().info("Expected exception: " + expected);
      txMgr.rollback();
    }
    misConfigRgn.destroyRegion();
  }
 @Override
 protected Transaction<CacheTransactionManager> beginTransactionInternal() {
   GemfireDatastore datastore = (GemfireDatastore) getDatastore();
   final CacheTransactionManager tm = datastore.getGemfireCache().getCacheTransactionManager();
   tm.begin();
   return new GemfireTransaction(tm);
 }
 public boolean isActive() {
   return transactionManager.exists();
 }
 public void rollback() {
   transactionManager.rollback();
 }
 public void commit() {
   transactionManager.commit();
 }