use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobExecutorTest method setUp.
@Before
public void setUp() throws Exception {
executor = StepMockUtil.getStep(JobExecutor.class, JobExecutorMeta.class, "TransExecutorUnitTest");
executor = spy(executor);
executor.setInputRowMeta(mock(RowMetaInterface.class));
doNothing().when(executor).discardLogLines(any(JobExecutorData.class));
meta = new JobExecutorMeta();
data = new JobExecutorData();
Job job = mock(Job.class);
doReturn(job).when(executor).createJob(any(Repository.class), any(JobMeta.class), any(LoggingObjectInterface.class));
doReturn(ArrayUtils.EMPTY_STRING_ARRAY).when(job).listParameters();
data.groupBuffer = new ArrayList<>();
data.groupSize = -1;
data.groupTime = -1;
data.groupField = null;
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class RunConfigurationInjectExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
if (!(object instanceof JobExecutionExtension)) {
return;
}
JobExecutionExtension extension = (JobExecutionExtension) object;
Job job = extension.job;
JobMeta jobMeta = job.getJobMeta();
final EmbeddedMetaStore embeddedMetaStore = jobMeta.getEmbeddedMetaStore();
RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
// will load and save to meta all run configurations
for (JobEntryTrans trans : job.getActiveJobEntryTransformations().values()) {
RunConfiguration loadedRunConfiguration = runConfigurationManager.load(jobMeta.environmentSubstitute(trans.getRunConfiguration()));
embeddedRunConfigurationManager.save(loadedRunConfiguration);
}
for (JobEntryJob subJob : job.getActiveJobEntryJobs().values()) {
RunConfiguration loadedRunConfiguration = runConfigurationManager.load(jobMeta.environmentSubstitute(subJob.getRunConfiguration()));
embeddedRunConfigurationManager.save(loadedRunConfiguration);
}
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobGraph method startJob.
public synchronized void startJob(JobExecutionConfiguration executionConfiguration) throws KettleException {
//
if (job == null || job.isFinished() && !job.isActive()) {
// Auto save feature...
//
handleJobMetaChanges(jobMeta);
//
if (((jobMeta.getName() != null && jobMeta.getObjectId() != null && spoon.rep != null) || (jobMeta.getFilename() != null && spoon.rep == null)) && // Didn't change
!jobMeta.hasChanged()) {
if (job == null || (job != null && !job.isActive())) {
try {
//
if (executionConfiguration.isClearingLog()) {
jobLogDelegate.clearLog();
}
//
if (job != null) {
KettleLogStore.discardLines(job.getLogChannelId(), true);
}
JobMeta runJobMeta;
if (spoon.rep != null) {
runJobMeta = spoon.rep.loadJob(jobMeta.getName(), jobMeta.getRepositoryDirectory(), null, null);
} else {
runJobMeta = new JobMeta(null, jobMeta.getFilename(), null, jobMeta.getMetaStore(), null);
}
String spoonObjectId = UUID.randomUUID().toString();
SimpleLoggingObject spoonLoggingObject = new SimpleLoggingObject("SPOON", LoggingObjectType.SPOON, null);
spoonLoggingObject.setContainerObjectId(spoonObjectId);
spoonLoggingObject.setLogLevel(executionConfiguration.getLogLevel());
job = new Job(spoon.rep, runJobMeta, spoonLoggingObject);
job.setLogLevel(executionConfiguration.getLogLevel());
job.shareVariablesWith(jobMeta);
job.setInteractive(true);
job.setGatheringMetrics(executionConfiguration.isGatheringMetrics());
job.setArguments(executionConfiguration.getArgumentStrings());
// Pass specific extension points...
//
job.getExtensionDataMap().putAll(executionConfiguration.getExtensionOptions());
// Add job entry listeners
//
job.addJobEntryListener(createRefreshJobEntryListener());
//
if (!Utils.isEmpty(executionConfiguration.getStartCopyName())) {
JobEntryCopy startJobEntryCopy = runJobMeta.findJobEntry(executionConfiguration.getStartCopyName(), executionConfiguration.getStartCopyNr(), false);
job.setStartJobEntryCopy(startJobEntryCopy);
}
// Set the named parameters
Map<String, String> paramMap = executionConfiguration.getParams();
Set<String> keys = paramMap.keySet();
for (String key : keys) {
job.getJobMeta().setParameterValue(key, Const.NVL(paramMap.get(key), ""));
}
job.getJobMeta().activateParameters();
log.logMinimal(BaseMessages.getString(PKG, "JobLog.Log.StartingJob"));
job.start();
jobGridDelegate.previousNrItems = -1;
// Link to the new jobTracker!
jobGridDelegate.jobTracker = job.getJobTracker();
// Attach a listener to notify us that the transformation has
// finished.
job.addJobListener(new JobAdapter() {
public void jobFinished(Job job) {
JobGraph.this.jobFinished();
}
});
// Show the execution results views
//
addAllTabs();
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobLog.Dialog.CanNotOpenJob.Title"), BaseMessages.getString(PKG, "JobLog.Dialog.CanNotOpenJob.Message"), e);
job = null;
}
} else {
MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
m.setText(BaseMessages.getString(PKG, "JobLog.Dialog.JobIsAlreadyRunning.Title"));
m.setMessage(BaseMessages.getString(PKG, "JobLog.Dialog.JobIsAlreadyRunning.Message"));
m.open();
}
} else {
if (jobMeta.hasChanged()) {
showSaveFileMessage();
} else if (spoon.rep != null && jobMeta.getName() == null) {
MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
m.setText(BaseMessages.getString(PKG, "JobLog.Dialog.PleaseGiveThisJobAName.Title"));
m.setMessage(BaseMessages.getString(PKG, "JobLog.Dialog.PleaseGiveThisJobAName.Message"));
m.open();
} else {
MessageBox m = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
m.setText(BaseMessages.getString(PKG, "JobLog.Dialog.NoFilenameSaveYourJobFirst.Title"));
m.setMessage(BaseMessages.getString(PKG, "JobLog.Dialog.NoFilenameSaveYourJobFirst.Message"));
m.open();
}
}
setControlStates();
}
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class TransGraph method attachActiveJob.
/**
* Finds the last active job in the running transformation to the opened jobMeta
*
* @param jobGraph
* @param stepMeta
*/
private void attachActiveJob(JobGraph jobGraph, StepMeta stepMeta) {
if (trans != null && jobGraph != null) {
Job subJob = trans.getActiveSubjobs().get(stepMeta.getName());
jobGraph.setJob(subJob);
if (!jobGraph.isExecutionResultsPaneVisible()) {
jobGraph.showExecutionResults();
}
jobGraph.setControlStates();
}
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class MLLPSocketCache method getServerSocketStreamSource.
public MLLPSocketCacheEntry getServerSocketStreamSource(String server, int port) throws Exception {
final String key = createKey(server, port);
MLLPSocketCacheEntry s = map.get(key);
if (s != null) {
return s;
}
// Open the socket for this server/port combination.
//
ServerSocket serverSocket = new ServerSocket(port);
StreamSource streamSource = new ServerSocketStreamSource(serverSocket, server);
MLLPTransport transport = new MLLPTransport(streamSource);
transport.connect();
final MLLPSocketCacheEntry entry = new MLLPSocketCacheEntry(serverSocket, streamSource, transport);
entry.setJobListener(new JobAdapter() {
@Override
public void jobFinished(Job job) throws KettleException {
KettleException exception = null;
try {
entry.getTransport().disconnect();
} catch (Exception e) {
exception = new KettleException(e);
}
try {
entry.getStreamSource().disconnect();
} catch (Exception e) {
exception = new KettleException(e);
}
try {
entry.getServerSocket().close();
} catch (Exception e) {
exception = new KettleException(e);
}
map.remove(key);
if (exception != null) {
throw exception;
}
}
});
// Store a copy in our map to make sure that only the first return value contains the job listener.
//
map.put(key, new MLLPSocketCacheEntry(serverSocket, streamSource, transport));
return entry;
}
Aggregations