All Downloads are FREE. Search and download functionalities are using the official Maven repository.

water.api.UnlockTask Maven / Gradle / Ivy

package water.api;

import water.*;
import water.util.Log;

public class UnlockTask extends MRTask {
  final boolean _quiet;
  public UnlockTask() {_quiet = false; }
  public UnlockTask(boolean q) { _quiet = q; }
  @Override public byte priority() { return H2O.GUI_PRIORITY; }
  @Override public void setupLocal() {
    final KeySnapshot.KeyInfo[] kinfo = KeySnapshot.localSnapshot(true)._keyInfos;
    for(KeySnapshot.KeyInfo k:kinfo) {
      if(!k.isLockable()) continue;
      final Value val = DKV.get(k._key);
      if( val == null ) continue;
      final Lockable lockable = val.>get();
      final Key[] lockers = lockable._lockers;
      if (lockers != null) {
        // check that none of the locking jobs is still running
        for (Key locker : lockers) {
          if (locker != null && locker.type() == Key.JOB) {
            final Job job = locker.get();
            if (job != null && job.isRunning())
              throw new UnsupportedOperationException("Cannot unlock all keys since locking jobs are still running.");
          }
        }
        lockable.unlock_all();
        Log.info("Unlocked key '" + k._key + "' from " + lockers.length + " lockers.");
      }
    }
    if (!_quiet) Log.info("All keys are now unlocked.");
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy