private void instanceChanged(final IInstanceKey instance, final Optional<IScheduledTask> state) { storage.write( (NoResult.Quiet) storeProvider -> { IJobKey job = instance.getJobKey(); UpdateFactory.Update update = updates.get(job); if (update != null) { if (update.getUpdater().containsInstance(instance.getInstanceId())) { LOG.info("Forwarding task change for " + InstanceKeys.toString(instance)); try { evaluateUpdater( storeProvider, update, getOnlyMatch(storeProvider.getJobUpdateStore(), queryActiveByJob(job)), ImmutableMap.of(instance.getInstanceId(), state)); } catch (UpdateStateException e) { throw Throwables.propagate(e); } } else { LOG.info( "Instance " + instance + " is not part of active update for " + JobKeys.canonicalString(job)); } } }); }
/** * Dumps a cron job struct. * * @return HTTP response. */ @GET @Path("/cron/{role}/{environment}/{job}") @Produces(MediaType.TEXT_HTML) public Response dump( @PathParam("role") final String role, @PathParam("environment") final String environment, @PathParam("job") final String job) { final IJobKey jobKey = JobKeys.from(role, environment, job); return dumpEntity( "Cron job " + JobKeys.canonicalString(jobKey), new Work.Quiet<Optional<? extends TBase<?, ?>>>() { @Override public Optional<JobConfiguration> apply(StoreProvider storeProvider) { return storeProvider .getCronJobStore() .fetchJob(jobKey) .transform(IJobConfiguration::newBuilder); } }); }
private static String formatLockKey(ILockKey lockKey) { return lockKey.getSetField() == _Fields.JOB ? JobKeys.canonicalString(lockKey.getJob()) : "Unknown lock key type: " + lockKey.getSetField(); }