Search in sources :

Example 1 with ConfigHash

use of alluxio.wire.ConfigHash in project alluxio by Alluxio.

the class ConfigHashSync method heartbeat.

@Override
public synchronized void heartbeat() {
    if (!mContext.getClientContext().getClusterConf().clusterDefaultsLoaded()) {
        // Wait until the initial cluster defaults are loaded.
        return;
    }
    ConfigHash hash;
    try {
        hash = mClient.getConfigHash();
    } catch (IOException e) {
        LOG.error("Failed to heartbeat to meta master to get configuration hash:", e);
        // Disconnect to reconnect in the next heartbeat.
        mClient.disconnect();
        return;
    }
    boolean isClusterConfUpdated = !hash.getClusterConfigHash().equals(mContext.getClientContext().getClusterConfHash());
    boolean isPathConfUpdated = !hash.getPathConfigHash().equals(mContext.getClientContext().getPathConfHash());
    if (isClusterConfUpdated || isPathConfUpdated) {
        try {
            mContext.reinit(isClusterConfUpdated, isPathConfUpdated);
            mException = null;
        } catch (UnavailableException e) {
            LOG.error("Failed to reinitialize FileSystemContext:", e);
        // Meta master might be temporarily unavailable, retry in next heartbeat.
        } catch (IOException e) {
            LOG.error("Failed to close FileSystemContext, interrupting the heartbeat thread", e);
            mException = e;
            // If the heartbeat keeps running, the context might be reinitialized successfully in the
            // next heartbeat, then the resources that are not closed in the old context are leaked.
            Thread.currentThread().interrupt();
        }
    }
}
Also used : UnavailableException(alluxio.exception.status.UnavailableException) IOException(java.io.IOException) ConfigHash(alluxio.wire.ConfigHash)

Aggregations

UnavailableException (alluxio.exception.status.UnavailableException)1 ConfigHash (alluxio.wire.ConfigHash)1 IOException (java.io.IOException)1