Search in sources :

Example 6 with ConnectionFailedException

use of alluxio.exception.ConnectionFailedException in project alluxio by Alluxio.

the class BlockMasterSync method heartbeat.

/**
 * Heartbeats to the master node about the change in the worker's managed space.
 */
@Override
public void heartbeat() {
    // Prepare metadata for the next heartbeat
    BlockHeartbeatReport blockReport = mBlockWorker.getReport();
    BlockStoreMeta storeMeta = mBlockWorker.getStoreMeta();
    // Send the heartbeat and execute the response
    Command cmdFromMaster = null;
    List<alluxio.grpc.Metric> metrics = MetricsSystem.reportWorkerMetrics();
    try {
        cmdFromMaster = mMasterClient.heartbeat(mWorkerId.get(), storeMeta.getCapacityBytesOnTiers(), storeMeta.getUsedBytesOnTiers(), blockReport.getRemovedBlocks(), blockReport.getAddedBlocks(), blockReport.getLostStorage(), metrics);
        handleMasterCommand(cmdFromMaster);
        mLastSuccessfulHeartbeatMs = System.currentTimeMillis();
    } catch (IOException | ConnectionFailedException e) {
        // An error occurred, log and ignore it or error if heartbeat timeout is reached
        if (cmdFromMaster == null) {
            LOG.error("Failed to receive master heartbeat command.", e);
        } else {
            LOG.error("Failed to receive or execute master heartbeat command: {}", cmdFromMaster.toString(), e);
        }
        mMasterClient.disconnect();
        if (mHeartbeatTimeoutMs > 0) {
            if (System.currentTimeMillis() - mLastSuccessfulHeartbeatMs >= mHeartbeatTimeoutMs) {
                if (ServerConfiguration.getBoolean(PropertyKey.TEST_MODE)) {
                    throw new RuntimeException("Master heartbeat timeout exceeded: " + mHeartbeatTimeoutMs);
                }
                // TODO(andrew): Propagate the exception to the main thread and exit there.
                ProcessUtils.fatalError(LOG, "Master heartbeat timeout exceeded: %d", mHeartbeatTimeoutMs);
            }
        }
    }
}
Also used : Command(alluxio.grpc.Command) IOException(java.io.IOException) ConnectionFailedException(alluxio.exception.ConnectionFailedException)

Aggregations

ConnectionFailedException (alluxio.exception.ConnectionFailedException)6 IOException (java.io.IOException)4 InetSocketAddress (java.net.InetSocketAddress)2 PropertyKey (alluxio.PropertyKey)1 BlockMasterClient (alluxio.client.block.BlockMasterClient)1 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)1 BlockAlreadyExistsException (alluxio.exception.BlockAlreadyExistsException)1 Command (alluxio.grpc.Command)1 HeartbeatThread (alluxio.heartbeat.HeartbeatThread)1 AlluxioTException (alluxio.thrift.AlluxioTException)1 BlockMeta (alluxio.worker.block.meta.BlockMeta)1 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)1 CommandHandlingExecutor (alluxio.worker.job.command.CommandHandlingExecutor)1 TaskExecutorManager (alluxio.worker.job.task.TaskExecutorManager)1 URL (java.net.URL)1 Test (org.junit.Test)1