This is the entry point where work is added to the connect work list.
As a result, a separate thread from the caller will do the work.

@param work
information about the connect
@return true if request was dispatched, false if not
179407
protected boolean dispatchConnect(ConnectInfo work) {
        if (work.getSyncObject() != null) {
            // user thread waiting for work
            work.getSyncObject().simpleNotify();
            return true;
        }
        // dispatch async work
        return dispatchWorker(new Worker(work));
    }
731445
@Override
  public void addListener(INetworkConnectionListener listener) {
    if (!this.listeners.contains(listener)) {
      this.listeners.add(listener);
    }
  }
304439
private boolean isWorkMethodSynchronized(Class<? extends Work> workClass, String methodName)
   {
      try
      {
         Method method = SecurityActions.getMethod(workClass, methodName, new Class[0]);
         if (Modifier.isSynchronized(method.getModifiers()))
            return true;
      }
      catch (NoSuchMethodException e)
      {
         //Never happens, Work implementation should have these methods
      }

      return false;
   }
1035269
public void startWork(String workUnit) throws InterruptedException {
        if (waitInProgress.get())
            LOG.warn("Claiming work during wait!");
        LOG.info("Successfully claimed {}: {}. Starting...", config.workUnitName, workUnit);
        final boolean added = myWorkUnits.add(workUnit);

        if (added) {
            if (balancingPolicy instanceof MeteredBalancingPolicy) {
                MeteredBalancingPolicy mbp = (MeteredBalancingPolicy) balancingPolicy;
                Meter meter = mbp.findOrCreateMetrics(workUnit);
                ((SmartListener) listener).startWork(workUnit, meter);
            } else {
                ((ClusterListener) listener).startWork(workUnit);
            }
        } else {
            LOG.warn("Detected that %s is already a member of my work units; not starting twice!", workUnit);
        }
    }
88955
final boolean tryExternalUnpush(ForkJoinTask<?> task) {
        int r = ThreadLocalRandom.getProbe();
        WorkQueue[] ws; WorkQueue w; int wl;
        return ((ws = workQueues) != null &&
                (wl = ws.length) > 0 &&
                (w = ws[(wl - 1) & r & SQMASK]) != null &&
                w.trySharedUnpush(task));
    }
35833
private boolean blocked(Task task) throws InterruptedException
   {
      lock.lockInterruptibly();

      try
      {
         TaskAttribute executing =
               enabled.size() > 0
                     ? enabled.get(enabled.size() - 1).getCommand().getTaskAttribute()
                     : null;
         {
            switch (task.getCommand().getTaskAttribute())
            {
               case SIMPLE :
                  if (executing == null || executing == TaskAttribute.SIMPLE)
                     return false;
                  else
                     return true;
               case HEAD_OF_QUEUE :
                  return false;
               case ORDERED :
                  if (executing == null)
                     return false;
                  else
                     return true;
               default :
                  throw new RuntimeException("Unsupported task tag: "
                        + task.getCommand().getTaskAttribute().name());
            }
         }
      }
      finally
      {
         lock.unlock();
      }
   }
1206336
private boolean schedule(Task task) {
        int index = bufferIndex();
        int buffered = bufferLengths.incrementAndGet(index);

        if (task.isWrite()) {
            buffers[index].add(task);
            drainStatus.set(REQUIRED);
            return false;
        }

        // A buffer may discard a read task if its length exceeds a tolerance level
        if (buffered <= MAXIMUM_BUFFER_SIZE) {
            buffers[index].add(task);
            return (buffered <= BUFFER_THRESHOLD);
        } else { // not optimized for fail-safe scenario
            bufferLengths.decrementAndGet(index);
            return false;
        }
    }
295733
public static void doOnMainThread(final OnMainThreadJob onMainThreadJob) {
        uiHandler.post(new Runnable() {
            @Override
            public void run() {
                onMainThreadJob.doInUIThread();
            }
        });
    }
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;
            }
        }
    }
18738
@Override
    protected boolean performRequest() {

        boolean cancelledDone = false;
        // If we were worken up because we have work to do, do it.
        Set<SelectionKey> keySet = selector.selectedKeys();
        Iterator<SelectionKey> selectedIterator = keySet.iterator();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "performRequest - processing " + keySet.size() + " items");
        }
        while (selectedIterator.hasNext()) {
            SelectionKey selectedKey = selectedIterator.next();
            // safely remove key from set while looping
            selectedIterator.remove();
            ConnectInfo connectInfo = (ConnectInfo) selectedKey.attachment();
            connectInfo.setFinish();
            if (wqm.dispatchConnect(connectInfo)) {
                selectedKey.cancel();
                cancelledDone = true;
            }
        }
        return cancelledDone;
    }
249815
synchronized boolean doReConnect() throws IOException {

        // In case we are still connected, test the connection and see if we can reuse it
        if(connectionManager.isConnected()) {
            try {
                final Future<Long> result = channelHandler.executeRequest(ManagementPingRequest.INSTANCE, null).getResult();
                result.get(15, TimeUnit.SECONDS); // Hmm, perhaps 15 is already too much
                return true;
            } catch (Exception e) {
                ServerLogger.AS_ROOT_LOGGER.debugf(e, "failed to ping the host-controller, going to reconnect");
            }
            // Disconnect - the HC might have closed the connection without us noticing and is asking for a reconnect
            final Connection connection = connectionManager.getConnection();
            StreamUtils.safeClose(connection);
            if(connection != null) {
                try {
                    // Wait for the connection to be closed
                    connection.awaitClosed();
                } catch (InterruptedException e) {
                    throw new InterruptedIOException();
                }
            }
        }

        boolean ok = false;
        final Connection connection = connectionManager.connect();
        try {
            // Reconnect to the host-controller
            final ActiveOperation<Boolean, Void> result = channelHandler.executeRequest(new ServerReconnectRequest(), null);
            try {
                boolean inSync = result.getResult().get();
                ok = true;
                reconnectRunner = null;
                return inSync;
            } catch (ExecutionException e) {
                throw new IOException(e);
            } catch (InterruptedException e) {
                throw new InterruptedIOException();
            }
        } finally {
            if(!ok) {
                StreamUtils.safeClose(connection);
            }
        }
    }
331810
private void addThread() {
        Thread t = new WorkerThread(workQueue);
        threads.add(t);
        t.start();            
    }
377195
public static synchronized boolean canConnect(String url) {
        boolean result = false;
        HttpURLConnection conn = null;
        try {
            conn = getNormalCon(formatUrl(url));
            conn.connect();

            int resultCode = conn.getResponseCode();
            result = (200 == resultCode);

                /*
            if (!result) {
                Log.d("canConnect", resultCode + "|" + url);
            }
            // */

        } catch (IOException e) {
            result = false;
//            Log.e("canConnect", url + "|error:" + e.toString());
        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }

        return result;
    }
1194762
protected boolean checkConnection()
    {
        try{
            super.checkConnection();
        }
        finally
        {
            if (_jarConnection==null)
            {
                _entry=null;
                _file=null;
                _jarFile=null;
                _list=null;
            }
        }
        return _jarFile!=null;
    }
596887
boolean takeTaskPermit()
    {
        while (true)
        {
            long current = permits.get();
            int taskPermits = taskPermits(current);
            if (taskPermits == 0)
                return false;
            if (permits.compareAndSet(current, updateTaskPermits(current, taskPermits - 1)))
            {
                if (taskPermits == maxTasksQueued && hasRoom.hasWaiters())
                    hasRoom.signalAll();
                return true;
            }
        }
    }
470683
@Override
    public boolean isSupported(Task task) {
        for (TaskProcessorFactory factory : factories) {
            if (factory.isSupported(task)) {
                return true;
            }
        }
        return false;
    }
132879
private static boolean isNetworkConnectException(Throwable e) {
        do {
            if (IOException.class.isInstance(e)) {
                return true;
            }
            e = e.getCause();
        } while (e != null);
        return false;
    }