Try acquiring the job lock and return whether the lock is successfully locked.

@param properties the job properties
174149
private boolean tryLockJob(Properties properties) {
    try {
      if (Boolean.valueOf(properties.getProperty(ConfigurationKeys.JOB_LOCK_ENABLED_KEY, Boolean.TRUE.toString()))) {
        this.jobLockOptional = Optional.of(getJobLock(properties, new JobLockEventListener() {
          @Override
          public void onLost() {
            executeCancellation();
          }
        }));
      }
      return !this.jobLockOptional.isPresent() || this.jobLockOptional.get().tryLock();
    } catch (JobLockException ioe) {
      LOG.error(String.format("Failed to acquire job lock for job %s: %s", this.jobContext.getJobId(), ioe), ioe);
      return false;
    }
  }
413271
public void unlock( Key job_key ) { 
    if( _key != null ) {
      Log.debug(Log.Tag.Sys.LOCKS,"unlock "+_key+" by job "+job_key);
      new Unlock(job_key).invoke(_key); 
    }
  }
599370
def job_set_properties(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/setProperties' % object_id, input_params, always_retry=always_retry, **kwargs)
767511
public void doMonitor() {
    while (running) {
      String[] keys = null;
      // Make a copy of the names of the current jobs.
      synchronized(jobs) {
        keys = jobs.keySet().toArray(new String[0]);
      }

      // Check all the jobs. We do not want to block access to `jobs`
      // because that will prevent new jobs from being added.
      // This is safe because JobMonitor.run is the only code that can
      // remove a job from `jobs`. Thus all elements in `keys` will have
      // valid values.
      Map<String, List<DistRaid>> finishedJobs =
        new HashMap<String, List<DistRaid>>();

      for (String key: keys) {
        // For each policy being monitored, get the list of jobs running.
        DistRaid[] jobListCopy = null;
        synchronized(jobs) {
          List<DistRaid> jobList = jobs.get(key);
          synchronized(jobList) {
            jobListCopy = jobList.toArray(new DistRaid[jobList.size()]);
          }
        }
        // The code that actually contacts the JobTracker is not synchronized,
        // it uses copies of the list of jobs.
        for (DistRaid job: jobListCopy) {
          // Check each running job.
          try {
            boolean complete = job.checkComplete();
            if (complete) {
              addJob(finishedJobs, key, job);
              if (job.successful()) {
                jobsSucceeded++;
              }
            } else if (System.currentTimeMillis() -
                job.getStartTime() > maximumRunningTime){
              // If the job is running for more than one day
              throw new Exception("Job " + job.getJobID() + 
                  " is hanging more than " + maximumRunningTime/1000
                  + " seconds. Kill it");
            }
          } catch (Exception e) {
            // If there was an error, consider the job finished.
            addJob(finishedJobs, key, job);
            try {
              job.killJob();
            } catch (Exception ee) {
              LOG.error(ee);
            }
          }
        }
      }

      if (finishedJobs.size() > 0) {
        for (String key: finishedJobs.keySet()) {
          List<DistRaid> finishedJobList = finishedJobs.get(key);
          // Iterate through finished jobs and remove from jobs.
          // removeJob takes care of locking.
          for (DistRaid job: finishedJobList) {
            addCounter(raidProgress, job, INT_CTRS);
            removeJob(jobs, key, job);
            addJob(history, key, job);
            // delete the temp directory 
            job.cleanUp();
          }
        }
      }

      try {
        Thread.sleep(jobMonitorInterval);
      } catch (InterruptedException ie) {
      }
    }
  }
718258
public boolean setProperties(Dictionary<String, String> properties)
    {
        boolean success = super.setProperties(properties);
        proxyURLPrefix = this.getProperty(PROXY);
        if (proxyURLPrefix != null)
            if (proxyURLPrefix.endsWith("/"))
                proxyURLPrefix = proxyURLPrefix.substring(0, proxyURLPrefix.length() - 1);
        return success;
    }
1185028
protected boolean hasLocks()
   {
      try
      {
         return hasLocks.run();
      }
      catch (LockException e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }
      return true;
   }
1007841
@VisibleForTesting
  Map<String, String> printableJobProperties(Props jobProps) {
    Predicate<String> keyPredicate = new Predicate<String>() {

      @Override
      public boolean apply(String key) {
        if (StringUtils.isEmpty(key)) {
          return true;
        }
        key = key.toLowerCase();
        return !(key.contains("pass") && key.contains("word"));
      }

    };
    return Maps.filterKeys(jobProps.getFlattened(), keyPredicate);
  }
323796
@Override
	public synchronized void setProperties(Map<Object, Object> properties)
	{
		if(this.properties == null)
			this.properties = new Properties();
		
		
		this.properties.putAll(properties);
	}
250708
void checkAllLocks() throws BackendException {
        StoreTransaction lt = getConsistentTx();
        for (ExpectedValueCheckingStore store : expectedValuesByStore.keySet()) {
            Locker locker = store.getLocker();
            // Ignore locks on stores without a locker
            if (null == locker)
                continue;
            locker.checkLocks(lt);
        }
    }
132770
protected boolean lockJobIfNeeded() {
    try {
      if (job.isExclusive()) {
        processEngineConfiguration.getCommandExecutor().execute(new LockExclusiveJobCmd(job));
      }

    } catch (Throwable lockException) {
      if (log.isDebugEnabled()) {
        log.debug("Could not lock exclusive job. Unlocking job so it can be acquired again. Catched exception: " + lockException.getMessage());
      }

      // Release the job again so it can be acquired later or by another node
      unacquireJob();
      
      return false;
    }
    
    return true;
  }
860971
public void setProperties(Map<String, Object> properties)
    {
        if (this.getTask() != null)
            this.getTask().setProperties(properties);
    }
544108
public void into(Properties properties) {
        for (String name : this.properties.stringPropertyNames()) {
            properties.setProperty(name, this.properties.getProperty(name));
        }
    }
124425
public void setJobs(java.util.Collection<SigningJob> jobs) {
        if (jobs == null) {
            this.jobs = null;
            return;
        }

        this.jobs = new java.util.ArrayList<SigningJob>(jobs);
    }
971428
function isLockHolder(task, requestorId) {
  if(!task.semaphore) {
    throw new LockError('TaskNotLocked');
  }
  var requestKey  = hashKey(requestorId, task.id);

  return requestKey === task.semaphore.key;
}
203386
private synchronized boolean tryServerLock() throws IOException {
        if (!lockFile.exists() || lockFileChannel == null)
            return false;

        boolean lockObtained = true;

        try {
            serverLock = lockFileChannel.tryLock();

            // if server lock is not valid, it could not be obtained
            if (serverLock == null || !serverLock.isValid())
                lockObtained = false;
        } catch (OverlappingFileLockException e) {
            lockObtained = false;
        } catch (IOException e) {
            lockObtained = false;
        } finally {
            // make sure we release so the other process can obtain the lock file
            if (serverLock != null)
                serverLock.release();
        }

        return lockObtained;
    }
566914
public boolean tryLock(String key, String request) {
        //get connection
        Object connection = getConnection();
        String result ;
        if (connection instanceof Jedis){
            result =  ((Jedis) connection).set(lockPrefix + key, request, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, 10 * TIME);
            ((Jedis) connection).close();
        }else {
            result = ((JedisCluster) connection).set(lockPrefix + key, request, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, 10 * TIME);

        }

        if (LOCK_MSG.equals(result)) {
            return true;
        } else {
            return false;
        }
    }
1172928
public void pauseJob(JobKey jobKey, T jedis) throws JobPersistenceException {
        for (OperableTrigger trigger : getTriggersForJob(jobKey, jedis)) {
            pauseTrigger(trigger.getKey(), jedis);
        }
    }