public ProgramSchedule(String name, String description, ProgramId programId, Map<String, String> properties, Trigger trigger, List<? extends Constraint> constraints, long timeoutMillis) { this.description = description; this.programId = programId; this.scheduleId = programId.getParent().schedule(name); this.properties = properties; this.trigger = trigger; this.constraints = constraints; this.timeoutMillis = timeoutMillis; }
@Override public void resume() { try { scheduleClient.resume(programId.getParent().schedule(schedName)); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void suspend() { try { scheduleClient.suspend(programId.getParent().schedule(schedName)); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public String status(int expectedCode) { try { return scheduleClient.getStatus(programId.getParent().schedule(schedName)); } catch (Exception e) { throw Throwables.propagate(e); } } };
@Override public boolean programExists(ProgramId id) { ApplicationSpecification appSpec = getApplication(id.getParent()); return appSpec != null && programExists(id, appSpec); }
@Override public void apply() throws Exception { usageDataset.unregister(worker1.getParent()); } });
@Override public void apply() throws Exception { usageDataset.unregister(worker1.getParent()); } });
@Override public Void call() throws Exception { String namespace = String.format("%s.%s", programId.getApplication(), programId.getProgram()); NamespaceId namespaceId = programId.getNamespaceId(); for (Map.Entry<String, Collection<Long>> entry : streamGroups.asMap().entrySet()) { streamConsumerFactory.dropAll(namespaceId.stream(entry.getKey()), namespace, entry.getValue()); } queueAdmin.dropAllForFlow(programId.getParent().flow(programId.getEntityName())); return null; } });
@Override public DataTracer getDataTracer(String dataTracerName) { ApplicationId applicationId = programRunId.getParent().getParent(); return DataTracerFactoryProvider.get(applicationId).getDataTracer(applicationId, dataTracerName); }
/** * Gets a {@link Trigger} associated with this program name, type and schedule name */ private synchronized Trigger getTrigger(TriggerKey key, ProgramId program, String scheduleName) throws org.quartz.SchedulerException, NotFoundException { Trigger trigger = scheduler.getTrigger(key); if (trigger == null) { throw new NotFoundException(String.format("Time trigger with trigger key '%s' in schedule '%s' was not found", key.getName(), program.getParent().schedule(scheduleName).toString())); } return trigger; }
/** * Gets a {@link Trigger} associated with this program name, type and schedule name */ private synchronized Trigger getTrigger(TriggerKey key, ProgramId program, String scheduleName) throws org.quartz.SchedulerException, NotFoundException { Trigger trigger = scheduler.getTrigger(key); if (trigger == null) { throw new NotFoundException(String.format("Time trigger with trigger key '%s' in schedule '%s' was not found", key.getName(), program.getParent().schedule(scheduleName).toString())); } return trigger; }
/** * Retrieve all schedule records for a given program. * * @param programId the program for which to list the schedule records. * @return a list of schedule records for the program; never null */ public List<ProgramScheduleRecord> listScheduleRecords(ProgramId programId) { byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); return listSchedulesRecordsWithPrefix(prefix, schedule -> programId.equals(schedule.getProgramId())); }
public static Program fromEntityId(ProgramId programId) { return new Program(Id.Application.fromEntityId(programId.getParent()), programId.getType(), programId.getProgram()); } }
/** * Retrieve all schedules for a given program. * * @param programId the program for which to list the schedules. * @return a list of schedules for the program; never null */ public List<ProgramSchedule> listSchedules(ProgramId programId) { byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); return listSchedulesWithPrefix(prefix, schedule -> programId.equals(schedule.getProgramId())); }
@Override public Runnable create(String name) { ProgramRunner programRunner = programRunnerFactory.create(programType); try { ProgramId programId = workflowProgram.getId().getParent().program(programType, name); Program program = Programs.create(cConf, workflowProgram, programId, programRunner); return getProgramRunnable(name, programRunner, program); } catch (Exception e) { closeProgramRunner(programRunner); throw Throwables.propagate(e); } }
@Override public ProgramController createProgramController(TwillController twillController, ProgramDescriptor programDescriptor, RunId runId) { FlowSpecification flowSpec = programDescriptor.getSpecification(); DistributedFlowletInstanceUpdater instanceUpdater = new DistributedFlowletInstanceUpdater( programDescriptor.getProgramId(), twillController, queueAdmin, streamAdmin, getFlowletQueues(programDescriptor.getProgramId().getParent(), flowSpec), txExecutorFactory, impersonator ); return new FlowTwillProgramController(programDescriptor.getProgramId(), twillController, instanceUpdater, runId).startListen(); }
private void addProgram(MDSKey.Builder keyBuilder, ProgramId program) { keyBuilder.add(PROGRAM_MARKER) .add(program.getNamespace()) .add(program.getParent().getEntityName()) .add(program.getType().getCategoryName()) .add(program.getEntityName()); }
private LoggingContext createLoggingContext(ProgramId programId, RunId runId, @Nullable WorkflowProgramInfo workflowProgramInfo) { if (workflowProgramInfo == null) { return new MapReduceLoggingContext(programId.getNamespace(), programId.getApplication(), programId.getProgram(), runId.getId()); } ProgramId workflowProramId = programId.getParent().workflow(workflowProgramInfo.getName()); return new WorkflowProgramLoggingContext(workflowProramId.getNamespace(), workflowProramId.getApplication(), workflowProramId.getProgram(), workflowProgramInfo.getRunId().getId(), ProgramType.MAPREDUCE, programId.getProgram(), runId.getId()); }
private void addProgram(MDSKey.Builder keyBuilder, ProgramId program) { keyBuilder.add(PROGRAM_MARKER) .add(program.getNamespace()) .add(program.getParent().getEntityName()) .add(program.getType().getCategoryName()) .add(program.getEntityName()); }