Calculates next heartbeat interval using cluster size.
Heartbeat interval is incremented by 1 second for every 100 nodes by default.
@return next heartbeat interval.
425409
public int getNextHeartbeatInterval() {
    // get the no of task trackers
    int clusterSize = getClusterStatus().getTaskTrackers();
    int heartbeatInterval =  Math.max(
                                (int)(1000 * HEARTBEATS_SCALING_FACTOR *
                                      Math.ceil((double)clusterSize /
                                                NUM_HEARTBEATS_IN_SECOND)),
                                HEARTBEAT_INTERVAL_MIN) ;
    return heartbeatInterval;
  }
72900
ClusterHeartbeat createCluster(String clusterName)
  {
    ClusterHeartbeat cluster = _clusterMap.get(clusterName);
    
    if (cluster == null) {
      cluster = new ClusterHeartbeat(clusterName, this);
      
      _clusterMap.putIfAbsent(clusterName, cluster);
      
      cluster = _clusterMap.get(clusterName);
    }
    
    return cluster;
  }
1051629
public SoundCloudTrack next() {
        mCurrentTrackIndex = (mCurrentTrackIndex + 1) % mSoundCloudPlaylist.getTracks().size();
        return mSoundCloudPlaylist.getTracks().get(mCurrentTrackIndex);
    }
223915
public Interval<C> ahead() {
        if(this.hasNone()) {
            return new Interval(this.dimension, Range.all());
        }
        if(this.range.equals(Range.all())) {
            return new Interval(this.dimension);
        }
        return new Interval(this.dimension,
                            Range.downTo(this.range.upperEndpoint(),
                            reverse(this.range.upperBoundType())));
    }
1083785
private void getNextEventIndex() {
        for (int i = next + 1; i < events.size(); i++) {
            String evName = getValueOr(events.get(i), "event", "");
            if (evName.equals(eventType)) {
                next = i;
                return;
            }
        }
        next = events.size();
    }
651282
private void heartbeatToClusterManager() throws IOException {
    CoronaConf coronaConf = new CoronaConf(fConf);
    int numCpu = coronaConf.getInt("mapred.coronatasktracker.num.cpus",
      resourceCalculatorPlugin.getNumProcessors());
    if (numCpu == ResourceCalculatorPlugin.UNAVAILABLE) {
      numCpu = 1;
    }
    LOG.info("Will report " + numCpu + " CPUs");
    int totalMemoryMB = (int) (resourceCalculatorPlugin.getPhysicalMemorySize() / 1024D / 1024);
    ComputeSpecs total = new ComputeSpecs((short)numCpu);
    total.setNetworkMBps((short)100);
    total.setMemoryMB(totalMemoryMB);
    total.setDiskGB(
       (int)(getDiskSpace(false) / 1024D / 1024 / 1024));
    String appInfo = null;
    if (getLocalHostAddress() != null) {
      appInfo = getLocalHostAddress() + ":" + actionServerAddr.getPort();
    }
    else {
      appInfo = getLocalHostname() + ":" + actionServerAddr.getPort();
    }
    Map<ResourceType, String> resourceInfos =
        new EnumMap<ResourceType, String>(ResourceType.class);
    resourceInfos.put(ResourceType.MAP, appInfo);
    resourceInfos.put(ResourceType.REDUCE, appInfo);
    resourceInfos.put(ResourceType.JOBTRACKER, appInfo);

    while (running && !shuttingDown) {
      try {
        long now = System.currentTimeMillis();
        Thread.sleep(heartbeatCMInterval);

        float cpuUsage = resourceCalculatorPlugin.getCpuUsage();
        if (cpuUsage == ResourceCalculatorPlugin.UNAVAILABLE) {
          cpuUsage = 0;
        }
        ComputeSpecs free = new ComputeSpecs((short)(numCpu * cpuUsage / 100D));
        // TODO find free network.
        free.setNetworkMBps((short)100);
        int availableMemoryMB =
            (int)(resourceCalculatorPlugin.
                getAvailablePhysicalMemorySize() / 1024D / 1024);
        free.setMemoryMB(availableMemoryMB);
        long freeDiskSpace = getDiskSpace(true);
        long freeLogDiskSpace = getLogDiskFreeSpace();
        free.setDiskGB((int)(
          Math.min(freeDiskSpace, freeLogDiskSpace) / 1024D / 1024 / 1024));
        // TT puts it's MR specific host:port tuple here
        ClusterNodeInfo node = new ClusterNodeInfo
          (this.getName(), clusterManagerCallbackServerAddr, total);
        node.setFree(free);
        node.setResourceInfos(resourceInfos);

        LOG.debug("ClusterManager heartbeat: " + node.toString());
        if (client == null) {
          initializeClusterManagerClient();
        }
        NodeHeartbeatResponse nodeHeartbeatResponse =
          client.nodeHeartbeat(node);
        if (nodeHeartbeatResponse.restartFlag) {
          LOG.fatal("Get CM notice to exit");
          System.exit(0);
        }
        clusterManagerConnectRetries = 0;
        lastCMHeartbeat = System.currentTimeMillis();

        markUnresponsiveTasks();
        killOverflowingTasks();

        //we've cleaned up, resume normal operation
        if (!acceptNewTasks && isIdle()) {
          acceptNewTasks=true;
        }
        //The check below may not be required every iteration but we are
        //erring on the side of caution here. We have seen many cases where
        //the call to jetty's getLocalPort() returns different values at
        //different times. Being a real paranoid here.
        checkJettyPort();
      } catch (InterruptedException ie) {
        LOG.info("Interrupted. Closing down.");
        return;
      } catch (DisallowedNode ex) {
        LOG.error("CM has excluded node, shutting down TT");
        shutdown();
      } catch (SafeModeException e) {
        LOG.info("Cluster Manager is in Safe Mode");
        try {
          ClusterManagerAvailabilityChecker.
            waitWhileClusterManagerInSafeMode(coronaConf);
        } catch (IOException ie) {
          LOG.error("Could not wait while Cluster Manager is in Safe Mode ",
                    ie);
        }
      } catch (TException ex) {
        if (!shuttingDown) {
          LOG.error("Error connecting to CM. " + clusterManagerConnectRetries
            + "th retry. Retry in 10 seconds.", ex);
          closeClusterManagerClient();
          if (++clusterManagerConnectRetries >= MAX_CM_CONNECT_RETRIES) {
            LOG.error("Cannot connect to CM " + clusterManagerConnectRetries +
              " times. Shutting down TT");
            shutdown();
          }
          try {
            Thread.sleep(10000L);
          } catch (InterruptedException ie) {
          }
          ClusterManagerAvailabilityChecker.
            waitWhileClusterManagerInSafeMode(coronaConf);
        }
      }
    }
  }
958262
public int getHighestClusterCount() {
    int maxClusters = 0;

    for(int i = 0; i < numclusters.length; i++) {
      maxClusters = Math.max(maxClusters, numclusters[i]);
    }
    return maxClusters;
  }
86667
private int determineHeartbeatInterval(Map properties)
    {
        // How often should we heartbeat?
        int heartbeatInterval = JFapChannelConstants.DEFAULT_HEARTBEAT_INTERVAL;
        try
        {
            heartbeatInterval = Integer.parseInt(RuntimeInfo.getProperty(JFapChannelConstants.RUNTIMEINFO_KEY_HEARTBEAT_INTERVAL, "" + heartbeatInterval));
        } catch (NumberFormatException nfe)
        {
            // No FFDC code needed
        }

        if (properties != null)
        {
            String intervalStr = (String) properties.get(JFapChannelConstants.CHANNEL_CONFIG_HEARTBEAT_INTERVAL_PROPERTY);
            if (intervalStr != null)
            {
                try
                {
                    heartbeatInterval = Integer.parseInt(intervalStr);
                } catch (NumberFormatException nfe)
                {
                    // No FFDC code needed
                }
            }
        }
        return heartbeatInterval;
    }
1155640
public int getTotalClusterCount() {
    int clusterCount = 0;

    for(int i = 0; i < numclusters.length; i++) {
      clusterCount += numclusters[i];
    }

    return clusterCount;
  }
484737
public boolean checkHeartBeat() {

        String dataPath = executorMeta.getLocalDir();
        File localstate = new File(dataPath + "/data/" + startType + "/" + startType + ".heartbeat/");
        Long modefyTime = localstate.lastModified();

        if (System.currentTimeMillis() - modefyTime > JOYConstants.EXECUTOR_HEARTBEAT_TIMEOUT) {

            LOG.info("----------------------");
            modefyTime = localstate.lastModified();
            LOG.info(modefyTime.toString());

            LOG.info(Long.toString(new Date().getTime()));
            LOG.info(dataPath + "/data/" + startType + "/" + startType + ".heartbeat/");

            LOG.info("can't get heartbeat over " + String.valueOf(JOYConstants.EXECUTOR_HEARTBEAT_TIMEOUT) + " seconds");
            return false;
        } else
            return true;
    }
333785
int getNodeId(long nanoTime) {
        // Check if it is a time to check for updated nodeId. We need to recheck, because if duplicate node ID
        // is assigned during a network split, this will be resolved after a cluster merge.
        // We throttle the calls to avoid contention due to the lock+unlock call in getMemberListJoinVersion().
        int nodeId = this.nodeId;
        if (nodeId != NODE_ID_OUT_OF_RANGE && nextNodeIdUpdate <= nanoTime) {
            int newNodeId = getNodeEngine().getClusterService().getMemberListJoinVersion();
            assert newNodeId >= 0 : "newNodeId=" + newNodeId;
            newNodeId += nodeIdOffset;
            nextNodeIdUpdate = nanoTime + NODE_ID_UPDATE_INTERVAL_NS;
            if (newNodeId != nodeId) {
                nodeId = newNodeId;

                // If our node ID is out of range, assign NODE_ID_OUT_OF_RANGE to nodeId
                if ((nodeId & -1 << BITS_NODE_ID) != 0) {
                    outOfRangeMembers.add(getNodeEngine().getClusterService().getLocalMember().getUuid());
                    logger.severe("Node ID is out of range (" + nodeId + "), this member won't be able to generate IDs. "
                            + "Cluster restart is recommended.");
                    nodeId = NODE_ID_OUT_OF_RANGE;
                }

                // we ignore possible double initialization
                this.nodeId = nodeId;
                if (logger.isFineEnabled()) {
                    logger.fine("Node ID assigned to '" + name + "': " + nodeId);
                }
            }
        }

        return nodeId;
    }
123545
public boolean next() {
        final int currentIndex = current.getCurrentIndex();
        int nextIndex = currentIndex + 1;
        TestScript testScript = current.getTestScript();
        LOG.debug("debug.test", current);
        if (currentIndex < testScript.getTestStepCount()) {

            if (pm.isDebug()) {

                LOG.debug("debug.index", currentIndex, testScript.getTestStepCount());

                TestStep nextStep = testScript.getTestStep(nextIndex);

                if (nextStep != null && nextStep.isBreakPointEnabled()) {
                    LOG.info("debug.break.point");
                    pause();
                }
                nextIndex = getNextIndex(currentIndex);
            }

            if (nextIndex >= testScript.getTestStepCount()) {
                sendCaseEnd();
                return current.isContinued();
            }

            current.setCurrentIndex(nextIndex);
            current.setTestStep(current.getTestScript().getTestStep(nextIndex));
            sendStepStart();

            return true;
        } else {
            sendCaseEnd();
            return current.isContinued();
        }
    }
230061
public static Integer getSystemDoubleClickTimeMs() {
    Integer DEFAULT_INTERVAL_MS = 500;
    Toolkit t = Toolkit.getDefaultToolkit();

    if (t == null) {
      return DEFAULT_INTERVAL_MS;
    }

    Object o = t.getDesktopProperty("awt.multiClickInterval");
    if (o == null) {
      return DEFAULT_INTERVAL_MS;
    }

    return (Integer) o;
  }
323746
private void completeHeartbeat() {
    heartbeatFailures = 0;
    heartbeatFuture = nextHeartbeatFuture;
    nextHeartbeatFuture = null;
    updateGlobalIndex();
    if (heartbeatFuture != null) {
      heartbeatTime = System.currentTimeMillis();
      for (MemberState member : context.getClusterState().getRemoteMemberStates()) {
        appendEntries(member);
      }
    }
  }
1012640
public long nextKey() {
        // Note that per Oracle the currentTimeMillis is the current number of seconds past the epoch
        // in UTC (not in local time). Therefore, processes with exactly synchronized clocks will
        // always get the same value regardless of their timezone ...
        final long timestamp = System.currentTimeMillis();
        final int increment = counterFor(timestamp);
        if (increment <= maximumCounterValue) {
            return (timestamp << counterBits) + increment;
        }
        // The counter is surprisingly too high, so try again (repeatedly) until we get to the next millisecond ...
        return this.nextKey();
    }
667534
protected int getNextNode()
  {
    if (m_foundLast)
      return DTM.NULL;

    int next = m_iterator.next();
    
    if (m_isFresh)
      m_isFresh = false;

    if (DTM.NULL == next)
      this.m_foundLast = true;

    return next;
  }
1128979
private int determineHeartbeatInterval(Map properties) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "determineHeartbeatInterval", properties);

        // How often should we heartbeat?
        int heartbeatInterval = JFapChannelConstants.DEFAULT_HEARTBEAT_INTERVAL;
        try {
            //669424: using RuntimeInfo.getPropertyWithMsg as this would log a message
            // when the property is different to the default value passed.
            heartbeatInterval = Integer.parseInt(RuntimeInfo.getPropertyWithMsg(JFapChannelConstants.RUNTIMEINFO_KEY_HEARTBEAT_INTERVAL, "" + heartbeatInterval));
        } catch (NumberFormatException nfe) {
            // No FFDC code needed
        }

        if (properties != null) {
            String intervalStr = (String) properties.get(JFapChannelConstants.CHANNEL_CONFIG_HEARTBEAT_INTERVAL_PROPERTY);
            if (intervalStr != null) {
                try {
                    heartbeatInterval = Integer.parseInt(intervalStr);
                } catch (NumberFormatException nfe) {
                    // No FFDC code needed
                }
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "determineHeartbeatInterval", heartbeatInterval);

        return heartbeatInterval;
    }