/* (non-Javadoc)
@see com.emc.ecs.nfsclient.nfs.Nfs#sendCommit(com.emc.ecs.nfsclient.nfs.NfsCommitRequest)
773295
public Nfs3CommitResponse sendCommit(NfsCommitRequest request) throws IOException {
        Nfs3CommitResponse response = new Nfs3CommitResponse();
        _rpcWrapper.callRpcNaked(request, response, _server);
        return response;
    }
373565
public void runCommit(boolean forceRollback) throws HeuristicMixedException, HeuristicRollbackException, RollbackException {
      if (trace) {
         log.tracef("runCommit(forceRollback=%b) invoked in transaction with Xid=%s", forceRollback, xid);
      }
      if (forceRollback) {
         markRollbackOnly(new RollbackException(FORCE_ROLLBACK_MESSAGE));
      }

      int notifyAfterStatus = 0;

      try {
         if (status == Status.STATUS_MARKED_ROLLBACK) {
            notifyAfterStatus = Status.STATUS_ROLLEDBACK;
            rollbackResources();
         } else {
            notifyAfterStatus = Status.STATUS_COMMITTED;
            commitResources();
         }
      } finally {
         notifyAfterCompletion(notifyAfterStatus);
         DummyBaseTransactionManager.setTransaction(null);
      }
      throwRollbackExceptionIfAny(forceRollback);
   }
1047191
protected void sendTransacted(Destination destination, Serializable message) {
        send(destination, message, null, null, true);
    }
1060756
public void localCommit()
    {
        if (log.isDebugEnabled()) log.debug("commit was called");
        if (!this.isInLocalTransaction)
        {
            throw new TransactionNotInProgressException("Not in transaction, call begin() before commit()");
        }
        try
        {
            if(!broker.isManaged())
            {
                if (batchCon != null)
                {
                    batchCon.commit();
                }
                else if (con != null)
                {
                    con.commit();
                }
            }
            else
            {
                if(log.isDebugEnabled()) log.debug(
                        "Found managed environment setting in PB, will skip Connection.commit() call");
            }
        }
        catch (SQLException e)
        {
            log.error("Commit on underlying connection failed, try to rollback connection", e);
            this.localRollback();
            throw new TransactionAbortedException("Commit on connection failed", e);
        }
        finally
        {
            this.isInLocalTransaction = false;
            restoreAutoCommitState();
            this.releaseConnection();
        }
    }
1084071
@Override
    public void actionCommit() {

        List<Throwable> errors = new ArrayList<Throwable>();

        if (getUsers().isEmpty()) {
            setCommitErrors(
                Collections.singletonList((Throwable)new CmsIllegalStateException(
                    Messages.get().container(Messages.ERR_NO_SELECTED_USER_WITH_EMAIL_0))));
            return;
        }
        try {
            Iterator<CmsUser> itUsers = getUsers().iterator();
            while (itUsers.hasNext()) {
                CmsUser user = itUsers.next();
                OpenCms.getSessionManager().sendBroadcast(
                    getCms().getRequestContext().getCurrentUser(),
                    m_msgInfo.getMsg(),
                    user);
            }
        } catch (Throwable t) {
            errors.add(t);
        }
        // set the list of errors to display when saving failed
        setCommitErrors(errors);
    }
1339825
@Override
    public void actionCommit() {

        List<Throwable> errors = new ArrayList<Throwable>();

        try {
            // set the edited message
            OpenCms.getLoginManager().setLoginMessage(getCms(), m_loginMessage);
            // update the system configuration
            OpenCms.writeConfiguration(CmsVariablesConfiguration.class);
            // clear the message object
            setDialogObject(null);
        } catch (Throwable t) {
            errors.add(t);
        }

        // set the list of errors to display when saving failed
        setCommitErrors(errors);
    }
255234
@Override
  public void commit() throws IOException {
    try {
      LOG.info("Flushing pending insert.");
      this.commands.flush();
      LOG.info("Commiting transaction.");
      this.conn.commit();
    } catch (Exception e) {
      this.failed = true;
      throw new RuntimeException(e);
    }
  }
936498
@Override
    public void actionCommit() {

        List<Throwable> errors = new ArrayList<Throwable>();

        try {
            // if new create it first
            if (isNewUser()) {
                // test the group name
                CmsGroup group = null;
                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getGroup())) {
                    group = getCms().readGroup(getGroup());
                }

                if (group != null) {
                    if (group.getSimpleName().equals(OpenCms.getDefaultUsers().getGroupAdministrators())) {
                        // in case the administrators group is selected, the administrator role must be selected also
                        if (getRole().equals(NO_ROLE)) {
                            throw new CmsIllegalArgumentException(
                                Messages.get().container(Messages.ERR_ADD_TO_ADMINISTRATORS_GROUP_0));
                        }
                        CmsRole role = CmsRole.valueOfRoleName(getRole());
                        if (!CmsRole.ROOT_ADMIN.getRoleName().equals(role.getRoleName())
                            && !CmsRole.ADMINISTRATOR.getRoleName().equals(role.getRoleName())) {
                            throw new CmsIllegalArgumentException(
                                Messages.get().container(Messages.ERR_ADD_TO_ADMINISTRATORS_GROUP_0));
                        }
                    } else if (group.getSimpleName().equals(OpenCms.getDefaultUsers().getGroupUsers())) {
                        // in case the users group is selected, the user should have at least one role
                        if (getRole().equals(NO_ROLE)) {
                            throw new CmsIllegalArgumentException(
                                Messages.get().container(Messages.ERR_ADD_TO_USERS_GROUP_0));
                        }
                    } else if (group.getSimpleName().equals(OpenCms.getDefaultUsers().getGroupGuests())) {
                        // in case the users group is selected, the user should have at least one role
                        if (!getRole().equals(NO_ROLE)) {
                            throw new CmsIllegalArgumentException(
                                Messages.get().container(Messages.ERR_ADD_TO_GUESTS_GROUP_0));
                        }
                    }
                }
                m_pwdInfo.validate();
                CmsUser newUser = createUser(
                    m_paramOufqn + m_user.getSimpleName(),
                    m_pwdInfo.getNewPwd(),
                    m_user.getDescription(),
                    m_user.getAdditionalInfo());
                newUser.setFirstname(m_user.getFirstname());
                newUser.setLastname(m_user.getLastname());
                newUser.setEmail(m_user.getEmail());
                newUser.setAddress(m_user.getAddress());
                newUser.setManaged(m_user.isManaged());
                newUser.setEnabled(m_user.isEnabled());

                m_user = newUser;
            } else if (CmsStringUtil.isNotEmpty(m_pwdInfo.getNewPwd())) {
                m_pwdInfo.validate();
                getCms().setPassword(m_user.getName(), m_pwdInfo.getNewPwd());
            }

            // write the edited user
            writeUser(m_user);
            // set starting membership
            if (isNewUser()) {
                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getGroup())) {
                    getCms().addUserToGroup(m_user.getName(), getGroup());
                }
                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getRole()) && !getRole().equals(NO_ROLE)) {
                    OpenCms.getRoleManager().addUserToRole(
                        getCms(),
                        CmsRole.valueOfRoleName(getRole()).forOrgUnit(m_paramOufqn),
                        m_user.getName());
                }
            }
            // set starting settings
            CmsUserSettings settings = new CmsUserSettings(m_user);
            settings.setLocale(CmsLocaleManager.getLocale(getLanguage()));
            settings.setStartSite(getSite());
            // set starting project
            if (isNewUser()) {
                settings.setStartProject(getParamOufqn() + getStartProject());
            } else {
                settings.setStartProject(getStartProject());
            }

            boolean webuserOu = false;
            try {
                webuserOu = OpenCms.getOrgUnitManager().readOrganizationalUnit(
                    getCms(),
                    getParamOufqn()).hasFlagWebuser();
            } catch (CmsException e) {
                // ignore
            }
            // only set the start folder for non web users
            if (!webuserOu) {
                CmsObject tmp = OpenCms.initCmsObject(getCms());
                tmp.getRequestContext().setSiteRoot(getSite());
                String folder = tmp.getRequestContext().removeSiteRoot(getStartFolder());
                try {
                    CmsResource res = tmp.readResource(folder);
                    String siteRoot = OpenCms.getSiteManager().getSiteRoot(res.getRootPath());
                    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(siteRoot)
                        && CmsStringUtil.isNotEmptyOrWhitespaceOnly(tmp.getRequestContext().getSiteRoot())
                        && !tmp.getRequestContext().getSiteRoot().equals("/")) {
                        folder = res.getRootPath().substring(siteRoot.length());
                    }
                } catch (CmsException e) {
                    throw new CmsIllegalArgumentException(
                        Messages.get().container(Messages.ERR_SELECTED_FOLDER_NOT_IN_SITE_0));
                }
                settings.setStartFolder(folder);
            }
            settings.setStartView(getStartView());
            settings.save(getCms());

            // refresh the list
            Map<?, ?> objects = (Map<?, ?>)getSettings().getListObject();
            if (objects != null) {
                objects.remove(getListClass());
            }
        } catch (Throwable t) {
            errors.add(t);
        }

        if (errors.isEmpty() && isNewUser()) {
            if ((getParamCloseLink() != null) && (getParamCloseLink().indexOf("path=" + getListRootPath()) > -1)) {
                // set closelink
                Map<String, String[]> argMap = new HashMap<String, String[]>();
                argMap.put(PARAM_USERID, new String[] {m_user.getId().toString()});
                argMap.put("oufqn", new String[] {m_paramOufqn});
                setParamCloseLink(CmsToolManager.linkForToolPath(getJsp(), getListRootPath() + "/edit", argMap));
            }
        }
        // set the list of errors to display when saving failed
        setCommitErrors(errors);
    }
77189
@Override
	public void commit() throws RemoteException {
		tx.commit();
		try {
			tx = VanillaDb.txMgr().newTransaction(isolationLevel, readOnly);
		} catch (Exception e) {
			throw new RemoteException("error creating transaction ", e);
		}
	}
558984
public void commit() throws DBException, RemoteException
    {
        BaseTransport transport = this.createProxyTransport(COMMIT);
        Object strReturn = transport.sendMessageAndGetReply();
        Object objReturn = transport.convertReturnObject(strReturn);
        this.checkDBException(objReturn);
    }
789235
@Override
    public void commit() throws DataCorruptedException, IOException, IllegalStateException
    {
        try {
            this.txContext.finish();
        } catch (final TransactionFailureException tfe1) {
            try {
                this.txContext.abort();
            } catch (final TransactionFailureException tfe2) {
            }
            throw new IOException("Error trying to commit transaction.", tfe1);
        }
    }
505807
public Nfs3CommitRequest makeCommitRequest(byte[] fileHandle, long offsetToCommit, int dataSizeToCommit) throws FileNotFoundException {
        return new Nfs3CommitRequest(fileHandle, offsetToCommit, dataSizeToCommit, _credential);
    }
1206496
@Override
    public void actionCommit() {

        List<Throwable> errors = new ArrayList<Throwable>();

        try {
            // set the synchronize settings
            CmsUserSettings userSettings = new CmsUserSettings(getCms());
            m_synchronizeSettings.checkValues(getCms());
            userSettings.setSynchronizeSettings(m_synchronizeSettings);
            userSettings.save(getCms());
            setDialogObject(null);
        } catch (Throwable t) {
            errors.add(t);
        }

        // set the list of errors to display when saving failed
        setCommitErrors(errors);
    }
1145615
public void distributeCommit()
                    throws SystemException, HeuristicHazardException, HeuristicMixedException, HeuristicRollbackException {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "distributeCommit");

        final TransactionState ts = _transaction.getTransactionState();
        ts.setCommittingStateUnlogged();

        // Shuffle resources around according to commit priority order
        _retryRequired = sortResources();
        if (!_retryRequired) {
            _outcome = true;
            _retryRequired = distributeOutcome();
        } else {
            updateHeuristicOutcome(StatefulResource.HEURISTIC_HAZARD);
        }

        if (_systemException != null) {
            final Throwable toThrow = new SystemException().initCause(_systemException);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "distributeCommit", toThrow);
            throw (SystemException) toThrow;
        }

        // check for heuristics ... as we will move forget processing to TransactionImpl later
        if (HeuristicOutcome.isHeuristic(_heuristicOutcome)) {
            switch (_heuristicOutcome) {
                case StatefulResource.HEURISTIC_COMMIT:
                    break;

                case StatefulResource.HEURISTIC_ROLLBACK:
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "distributeCommit", "HeuristicRollbackException");
                    throw new HeuristicRollbackException();

                case StatefulResource.HEURISTIC_HAZARD:
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "distributeCommit", "HeuristicHazardException");
                    throw new HeuristicHazardException();

                default:
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "distributeCommit", "HeuristicMixedException");
                    throw new HeuristicMixedException();
            }
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "distributeCommit");
    }
455929
public Response sendTransaction(Transaction transaction) throws PeerException {

        logger.debug("peer.sendTransaction");

        // Send the transaction to the peer node via grpc
        // The rpc specification on the peer side is:
        //     rpc ProcessTransaction(Transaction) returns (Response) {}
        Response response = peerClient.processTransaction(transaction.getTxBuilder().build());

        if (response.getStatus() != Response.StatusCode.SUCCESS) {
            return response;
        }

        logger.debug(String.format("peer.sendTransaction: received %s", response.getMsg().toStringUtf8()));

        // Check transaction type here, as invoke is an asynchronous call,
        // whereas a deploy and a query are synchonous calls. As such,
        // invoke will emit 'submitted' and 'error', while a deploy/query
        // will emit 'complete' and 'error'.

        Fabric.Transaction.Type txType = transaction.getTxBuilder().getType();
        switch (txType) {
            case CHAINCODE_DEPLOY: // async
                String txid = response.getMsg().toStringUtf8();
                // Deploy transaction has been completed
                if (txid == null || txid.isEmpty()) {
                    throw new ExecuteException("the deploy response is missing the transaction UUID");
                } else if (!this.waitForDeployComplete(txid)) {
                    throw new ExecuteException("the deploy request is submitted, but is not completed");
                } else {
                    return response;
                }
            case CHAINCODE_INVOKE: // async
                txid = response.getMsg().toStringUtf8();
                // Invoke transaction has been submitted
                if (txid == null || txid.isEmpty()) {
                    throw new ExecuteException("the invoke response is missing the transaction UUID");
                } else if(!this.waitForInvokeComplete(txid)) {
                    throw new ExecuteException("the invoke request is submitted, but is not completed");
                } else {
                    return response;
                }
            case CHAINCODE_QUERY: // sync
                return response;
            default: // not implemented
                throw new ExecuteException("processTransaction for this transaction type is not yet implemented!");
        }
    }
660031
public NfsCommitRequest makeCommitRequest(long offsetToCommit, int dataSizeToCommit) throws IOException {
        return getNfs().makeCommitRequest(getFileHandle(), offsetToCommit, dataSizeToCommit);
    }
5105
private void sendUpdatePartitionInfoRpcCall(
			final Iterable<PartitionInfo> partitionInfos) {

		final LogicalSlot slot = assignedResource;

		if (slot != null) {
			final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
			final TaskManagerLocation taskManagerLocation = slot.getTaskManagerLocation();

			CompletableFuture<Acknowledge> updatePartitionsResultFuture = taskManagerGateway.updatePartitions(attemptId, partitionInfos, rpcTimeout);

			updatePartitionsResultFuture.whenCompleteAsync(
				(ack, failure) -> {
					// fail if there was a failure
					if (failure != null) {
						fail(new IllegalStateException("Update task on TaskManager " + taskManagerLocation +
							" failed due to:", failure));
					}
				}, getVertex().getExecutionGraph().getJobMasterMainThreadExecutor());
		}
	}