Synchronous call to NT procedure run(..) method.

Wraps coreCall with statistics.

@return True if done and null if there is an
async task still running.
6442
protected boolean call(Object... paramListIn) {
        m_perCallStats = m_statsCollector.beginProcedure();

        // if we're keeping track, calculate parameter size
        if (m_perCallStats.samplingProcedure()) {
            ParameterSet params = ParameterSet.fromArrayNoCopy(paramListIn);
            m_perCallStats.setParameterSize(params.getSerializedSize());
        }

        ClientResponseImpl response = coreCall(paramListIn);

        // null response means this procedure isn't over and has some async component
        if (response == null) {
            return false;
        }

        // if the whole call is done (no async bits)

        // if we're keeping track, calculate result size
        if (m_perCallStats.samplingProcedure()) {
            m_perCallStats.setResultSize(response.getResults());
        }
        m_statsCollector.endProcedure(response.getStatus() == ClientResponse.USER_ABORT,
                                      (response.getStatus() != ClientResponse.USER_ABORT) &&
                                      (response.getStatus() != ClientResponse.SUCCESS),
                                      m_perCallStats);
        // allow the GC to collect per-call stats if this proc isn't called for a while
        m_perCallStats = null;

        // send the response to caller
        // must be done as IRM to CI mailbox for backpressure accounting
        response.setClientHandle(m_clientHandle);
        InitiateResponseMessage irm = InitiateResponseMessage.messageForNTProcResponse(m_ciHandle,
                                                                                       m_ccxn.connectionId(),
                                                                                       response);
        m_mailbox.deliver(irm);

        // remove record of this procedure in NTPS
        // only done if procedure is really done
        m_ntProcService.handleNTProcEnd(this);

        return true;
    }
615451
public boolean performFinish() {
		final String containerName = page.getContainerName();
		final int    mep = page.getSelectedMep();
		final TransportEnum inboundTransport = page.getSelectedInboundTransport();
		final TransportEnum outboundTransport = page.getSelectedOutboundTransport();
		final TransformerEnum transformerType = page.getTransformerType(); 

		IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
		final String mavenHome = prefs.getString(P_MAVEN_HOME);
		final int mavenEclipseGoalType = MavenEclipseGoalEnum.ECLIPSE_ECLIPSE.ordinal();
		
		final String serviceName = page.getServiceName();
		IRunnableWithProgress op = new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) throws InvocationTargetException {
				try {
					doFinish(mavenHome, mavenEclipseGoalType, containerName, mep, inboundTransport, outboundTransport, transformerType, serviceName, monitor);
				} catch (CoreException e) {
					e.printStackTrace();
					throw new InvocationTargetException(e);
				} catch (Throwable e) {
					e.printStackTrace();
					if (e instanceof RuntimeException) {
						throw (RuntimeException)e;
					} else {
						throw new InvocationTargetException(e);
					}
				} finally {
					monitor.done();
				}
			}
		};
		try {
			getContainer().run(true, false, op);
		} catch (InterruptedException e) {
			return false;
		} catch (InvocationTargetException e) {
			Throwable realException = e.getTargetException();
			MessageDialog.openError(getShell(), "Error", realException.getMessage());
			return false;
		}
		return true;
	}
501271
public Boolean call() throws Exception {
    Boolean 	result;

    try {
      result = doRun();
    }
    catch (Exception e) {
      m_Exception = e;
      throw e;
    }
    finally {
      cleanUp();
    }
    return result;
  }
886384
def run_sync(self) -> int:
        '''
        '''
        exit_status = asyncio.get_event_loop().run_until_complete(self.run())

        # The following loop close procedure should avoid deadlock while
        # allowing all callbacks to process before close()
        asyncio.get_event_loop().stop()
        asyncio.get_event_loop().run_forever()
        asyncio.get_event_loop().close()
        return exit_status
614582
@Override
    public Void call() throws TTException {
        updateOnly();
        if (mCommit == EShredderCommit.COMMIT) {
            mWtx.commit();
        }
        return null;
    }
1253923
protected boolean setResult(Object result) {
        for (; ; ) {
            Object currentState = this.state;

            if (isDoneState(currentState)) {
                return false;
            }

            if (STATE.compareAndSet(this, currentState, result)) {
                done();
                notifyThreadsWaitingOnGet();
                runAsynchronous((ExecutionCallbackNode) currentState, result);
                break;
            }
        }
        return true;
    }
1024868
private void executeAsyncCallRunnable(Runnable runnable, String callName, boolean blocking) {
		// make sure the executor is initialized. lock against concurrent calls to this function
		synchronized (this) {
			if (executionState != ExecutionState.RUNNING) {
				return;
			}

			// get ourselves a reference on the stack that cannot be concurrently modified
			BlockingCallMonitoringThreadPool executor = this.asyncCallDispatcher;
			if (executor == null) {
				// first time use, initialize
				checkState(userCodeClassLoader != null, "userCodeClassLoader must not be null");

				// Under normal execution, we expect that one thread will suffice, this is why we
				// keep the core threads to 1. In the case of a synchronous savepoint, we will block
				// the checkpointing thread, so we need an additional thread to execute the
				// notifyCheckpointComplete() callback. Finally, we aggressively purge (potentially)
				// idle thread so that we do not risk to have many idle thread on machines with multiple
				// tasks on them. Either way, only one of them can execute at a time due to the
				// checkpoint lock.

				executor = new BlockingCallMonitoringThreadPool(
						new DispatcherThreadFactory(
							TASK_THREADS_GROUP,
							"Async calls on " + taskNameWithSubtask,
							userCodeClassLoader));
				this.asyncCallDispatcher = executor;

				// double-check for execution state, and make sure we clean up after ourselves
				// if we created the dispatcher while the task was concurrently canceled
				if (executionState != ExecutionState.RUNNING) {
					executor.shutdown();
					asyncCallDispatcher = null;
					return;
				}
			}

			LOG.debug("Invoking async call {} on task {}", callName, taskNameWithSubtask);

			try {
				executor.submit(runnable, blocking);
			}
			catch (RejectedExecutionException e) {
				// may be that we are concurrently finished or canceled.
				// if not, report that something is fishy
				if (executionState == ExecutionState.RUNNING) {
					throw new RuntimeException("Async call with a " + (blocking ? "" : "non-") + "blocking call was rejected, even though the task is running.", e);
				}
			}
		}
	}
997199
public synchronized RPC<V> call() {
      // Any Completer will not be carried over to remote; add it to the RPC call
      // so completion is signaled after the remote comes back.
    CountedCompleter cc = _dt.getCompleter();
    if( cc != null )  handleCompleter(cc);

    // If running on self, just submit to queues & do locally
    if( _target==H2O.SELF ) return handleLocal();

    // Keep a global record, for awhile
    if( _target != null ) _target.taskPut(_tasknum,this);
    try {
      if( _nack ) return this; // Racing Nack rechecked under lock; no need to send retry
      // We could be racing timeouts-vs-replies.  Blow off timeout if we have an answer.
      if( isDone() ) {
        if( _target != null ) _target.taskRemove(_tasknum);
        return this;
      }
      // Default strategy: (re)fire the packet and (re)start the timeout.  We
      // "count" exactly 1 failure: just whether or not we shipped via TCP ever
      // once.  After that we fearlessly (re)send UDP-sized packets until the
      // server replies.

      // Pack classloader/class & the instance data into the outgoing
      // AutoBuffer.  If it fits in a single UDP packet, ship it.  If not,
      // finish off the current AutoBuffer (which is now going TCP style), and
      // make a new UDP-sized packet.  On a re-send of a TCP-sized hunk, just
      // send the basic UDP control packet.
      if( !_sentTcp ) {
        while( true ) {         // Retry loop for broken TCP sends
          AutoBuffer ab = new AutoBuffer(_target,_dt.priority());
          try {
            final boolean t;
            ab.putTask(UDP.udp.exec, _tasknum).put1(CLIENT_UDP_SEND);
            ab.put(_dt);
            t = ab.hasTCP();
            assert sz_check(ab) : "Resend of " + _dt.getClass() + " changes size from " + _size + " to " + ab.size() + " for task#" + _tasknum;
            ab.close();        // Then close; send final byte
            _sentTcp = t;  // Set after close (and any other possible fail)
            break;             // Break out of retry loop
          } catch( AutoBuffer.AutoBufferException e ) {
            Log.info("IOException during RPC call: " + e._ioe.getMessage() + ",  AB=" + ab + ", for task#" + _tasknum + ", waiting and retrying...");
            ab.drainClose();
            try { Thread.sleep(500); } catch (InterruptedException ignore) {}
          }
        } // end of while(true)
      } else {
        // Else it was sent via TCP in a prior attempt, and we've timed out.
        // This means the caller's ACK/answer probably got dropped and we need
        // him to resend it (or else the caller is still processing our
        // request).  Send a UDP reminder - but with the CLIENT_TCP_SEND flag
        // instead of the UDP send, and no DTask (since it previously went via
        // TCP, no need to resend it).
        AutoBuffer ab = new AutoBuffer(_target,_dt.priority()).putTask(UDP.udp.exec,_tasknum);
        ab.put1(CLIENT_TCP_SEND).close();
      }
      // Double retry until we exceed existing age.  This is the time to delay
      // until we try again.  Note that we come here immediately on creation,
      // so the first doubling happens before anybody does any waiting.  Also
      // note the generous 5sec cap: ping at least every 5 sec.
      _retry += (_retry < MAX_TIMEOUT ) ? _retry : MAX_TIMEOUT;
      // Put self on the "TBD" list of tasks awaiting Timeout.
      // So: dont really 'forget' but remember me in a little bit.
//      UDPTimeOutThread.PENDING.put(_tasknum, this);
      return this;
    } catch( Throwable t ) {
      t.printStackTrace();
      throw Log.throwErr(t);
    }
  }
1302389
public static boolean existsBegunTxOnThread() {
        final Stack<BegunTx<?>> stack = threadLocal.get();
        return stack != null ? !stack.isEmpty() : false;
    }
817391
public synchronized boolean hasNext()
    {
        try
        {
            if (!isHasCalledCheck())
            {
                setHasCalledCheck(true);
                setHasNext(getRsAndStmt().m_rs.next());
                if (!getHasNext())
                {
                    autoReleaseDbResources();
                }
            }
        }
        catch (Exception ex)
        {
            setHasNext(false);
            autoReleaseDbResources();
            if(ex instanceof ResourceClosedException)
            {
                throw (ResourceClosedException)ex;
            }
            if(ex instanceof SQLException)
            {
                throw new PersistenceBrokerSQLException("Calling ResultSet.next() failed", (SQLException) ex);
            }
            else
            {
               throw new PersistenceBrokerException("Can't get next row from ResultSet", ex);
            }
        }
        if (logger.isDebugEnabled())
            logger.debug("hasNext() -> " + getHasNext());

        return getHasNext();
    }
610287
protected boolean doStart()
  {
    if (! _lifecycle.isActive()) {
      return false;
    }
    
    if (! isEnable()) {
      return false;
    }
    
    int startingCount = _startingCount.getAndIncrement();

    int threadCount = _threadCount.get() + startingCount;

    if (_threadMax < threadCount) {
      _startingCount.decrementAndGet();
      
      onThreadMax();
      
      return false;
    }
    else if (isIdleTooLow(startingCount)) {
      return true;
    }
    else {
      _startingCount.decrementAndGet();
      
      return false;
    }
  }
147670
RunnablePair takeAndClear() {
    RunnablePair entries;

    while ((entries = callbacks.get()) != END) {
      if (callbacks.compareAndSet(entries, END)) {
        return entries;
      }
    }

    return null;
  }
1140490
protected final boolean runAllTasksFrom(Queue<Runnable> taskQueue) {
        Runnable task = pollTaskFrom(taskQueue);
        if (task == null) {
            return false;
        }
        for (;;) {
            safeExecute(task);
            task = pollTaskFrom(taskQueue);
            if (task == null) {
                return true;
            }
        }
    }
45487
boolean success(T result) {
        State<T> oldState;
        synchronized (mutex) {
            if (state.isCompleted()) {
                return false;
            }
            oldState = state;
            state = state.getSuccessState(result);
        }
        oldState.callSuccessCallbacks(result);
        return true;

    }
916080
public boolean callProcedure(InternalConnectionContext caller,
                                 Function<Integer, Boolean> backPressurePredicate,
                                 InternalConnectionStatsCollector statsCollector,
                                 ProcedureCallback procCallback, String proc, Object... fieldList) {
        Procedure catProc = InvocationDispatcher.getProcedureFromName(proc, getCatalogContext());
        if (catProc == null) {
            String fmt = "Cannot invoke procedure %s from streaming interface %s. Procedure not found.";
            m_logger.rateLimitedLog(SUPPRESS_INTERVAL, Level.ERROR, null, fmt, proc, caller);
            m_failedCount.incrementAndGet();
            return false;
        }

        StoredProcedureInvocation task = new StoredProcedureInvocation();

        task.setProcName(proc);
        task.setParams(fieldList);
        try {
            task = MiscUtils.roundTripForCL(task);
        } catch (Exception e) {
            String fmt = "Cannot invoke procedure %s from streaming interface %s. failed to create task.";
            m_logger.rateLimitedLog(SUPPRESS_INTERVAL, Level.ERROR, null, fmt, proc, caller);
            m_failedCount.incrementAndGet();
            return false;
        }
        int[] partitions = null;
        try {
            partitions = InvocationDispatcher.getPartitionsForProcedure(catProc, task);
        } catch (Exception e) {
            String fmt = "Can not invoke procedure %s from streaming interface %s. Partition not found.";
            m_logger.rateLimitedLog(SUPPRESS_INTERVAL, Level.ERROR, e, fmt, proc, caller);
            m_failedCount.incrementAndGet();
            return false;
        }

        boolean mp = (partitions[0] == MpInitiator.MP_INIT_PID) || (partitions.length > 1);
        final InternalClientResponseAdapter adapter = mp ? m_adapters.get(MpInitiator.MP_INIT_PID) : m_adapters.get(partitions[0]);
        InternalAdapterTaskAttributes kattrs = new InternalAdapterTaskAttributes(caller,  adapter.connectionId());

        final AuthUser user = getCatalogContext().authSystem.getImporterUser();

        if (!adapter.createTransaction(kattrs, proc, catProc, procCallback, statsCollector, task, user, partitions, false, backPressurePredicate)) {
            m_failedCount.incrementAndGet();
            return false;
        }
        m_submitSuccessCount.incrementAndGet();
        return true;
    }
698270
private boolean isSyncCollectionCreation(int seen) {
        if (seen == Const.INVOKESPECIAL) {
            if (Values.CONSTRUCTOR.equals(getNameConstantOperand())) {
                return (syncCollections.contains(getClassConstantOperand()));
            }
        } else if ((seen == Const.INVOKESTATIC) && "java/util/Collections".equals(getClassConstantOperand())) {
            String methodName = getNameConstantOperand();
            return ("synchronizedMap".equals(methodName) || "synchronizedSet".equals(methodName));
        }
        return false;
    }
859523
@Override
	public ISynchronizationPoint<Exception> start() {
		SynchronizationPoint<Exception> sp = new SynchronizationPoint<>();
		io.canStartReading().listenAsync(new Task.Cpu.FromRunnable(() -> {
			try {
				Starter start = new Starter(io, defaultEncoding, charactersBuffersSize, maxBuffers);
				stream = start.start();
				next().listenInline(sp);
			} catch (Exception e) {
				sp.error(e);
			}
		}, "Start parsing XML", io.getPriority()), true);
		return sp;
	}