Search in sources :

Example 61 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class JobEntryColumnsExistTest method setUp.

@Before
public void setUp() {
    Job parentJob = new Job(null, new JobMeta());
    jobEntry = spy(new JobEntryColumnsExist(""));
    parentJob.getJobMeta().addJobEntry(new JobEntryCopy(jobEntry));
    parentJob.setStopped(false);
    jobEntry.setParentJob(parentJob);
    parentJob.setLogLevel(LogLevel.NOTHING);
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    jobEntry.setDatabase(dbMeta);
    db = spy(new Database(jobEntry, dbMeta));
    jobEntry.setParentJob(parentJob);
    jobEntry.setTablename(TABLENAME);
    jobEntry.setArguments(COLUMNS);
    jobEntry.setSchemaname(SCHEMANAME);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Database(org.pentaho.di.core.database.Database) Job(org.pentaho.di.job.Job) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Before(org.junit.Before)

Example 62 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class JobEntryTransIntIT method testPDI14676.

/*
   * Tests whether the job can force a transformation to stop, when the job is asked to stop.
   * A timeout parameter is required, to avoid a failed unit test from running forever.
   */
@Test(timeout = 30000)
public void testPDI14676() throws KettleException, IOException, InterruptedException {
    String transFilename = createPDI14676Transformation();
    // Setup Job
    JobEntrySpecial startEntry = new JobEntrySpecial("Start", true, false);
    JobEntryCopy startCopy = new JobEntryCopy(startEntry);
    startCopy.setLocation(50, 50);
    startCopy.setDrawn();
    JobEntryTrans transEntry = new JobEntryTrans("PDI-13676 example");
    transEntry.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
    transEntry.setFileName(transFilename);
    JobEntryCopy transCopy = new JobEntryCopy(transEntry);
    transCopy.setLocation(200, 50);
    transCopy.setDrawn();
    JobMeta jobMeta = new JobMeta();
    jobMeta.addJobEntry(startCopy);
    jobMeta.addJobEntry(transCopy);
    jobMeta.addJobHop(new JobHopMeta(startCopy, transCopy));
    // Run job
    Job jobInstance = new Job(null, jobMeta);
    jobInstance.start();
    // Allow job startup time
    while (!jobInstance.isActive()) {
        if (jobInstance.isStopped() || jobInstance.isFinished()) {
            break;
        }
        Thread.sleep(10);
    }
    // Let the job run for a short period
    Thread.sleep(300);
    assertFalse(jobInstance.isStopped());
    assertFalse(jobInstance.isFinished());
    // Tell the job to stop.
    jobInstance.stopAll();
    assertTrue(jobInstance.isStopped());
    // Allow the job's thread to stop and be cleaned up
    while (!jobInstance.isFinished() || jobInstance.isActive()) {
        Thread.sleep(10);
    }
    // Ensure that the job and the thread have both stopped
    assertTrue(jobInstance.isFinished());
    assertFalse(jobInstance.isAlive());
}
Also used : JobEntrySpecial(org.pentaho.di.job.entries.special.JobEntrySpecial) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) JobHopMeta(org.pentaho.di.job.JobHopMeta) Job(org.pentaho.di.job.Job) Test(org.junit.Test)

Example 63 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class RunConfigurationDelegateTest method testUpdateLoadedJobs_PDI16777.

@Test
public void testUpdateLoadedJobs_PDI16777() {
    JobEntryTrans trans = new JobEntryTrans();
    trans.setRunConfiguration("key");
    JobMeta meta = new JobMeta();
    meta.addJobEntry(new JobEntryCopy(trans));
    JobMeta[] jobs = new JobMeta[] { meta };
    doReturn(jobs).when(spoon).getLoadedJobs();
    DefaultRunConfiguration config = new DefaultRunConfiguration();
    config.setName("Test");
    config.setServer("localhost");
    delegate.updateLoadedJobs("key", config);
    assertEquals("Test", trans.getRunConfiguration());
    assertEquals("localhost", trans.getRemoteSlaveServerName());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 64 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class RunConfigurationImportExtensionPoint method createSlaveServerRunConfigurations.

private List<RunConfiguration> createSlaveServerRunConfigurations(List<String> existingConfigurationNames, AbstractMeta abstractMeta) {
    List<RunConfiguration> runConfigurations = new ArrayList<>();
    if (abstractMeta instanceof JobMeta) {
        JobMeta jobMeta = (JobMeta) abstractMeta;
        Map<String, List<JobEntryTrans>> slaveServerGroups = jobMeta.getJobCopies().stream().map(JobEntryCopy::getEntry).filter(entry -> entry instanceof JobEntryTrans).map(entry -> (JobEntryTrans) entry).filter(entry -> Utils.isEmpty(entry.getRunConfiguration())).filter(entry -> !Utils.isEmpty(entry.getRemoteSlaveServerName())).collect(Collectors.groupingBy(JobEntryTrans::getRemoteSlaveServerName));
        slaveServerGroups.forEach((remoteServerName, entries) -> {
            String runConfigurationName = createRunConfigurationName(existingConfigurationNames, remoteServerName);
            DefaultRunConfiguration runConfiguration = createRunConfiguration(runConfigurationName, remoteServerName);
            runConfigurations.add(runConfiguration);
            entries.forEach(e -> e.setRunConfiguration(runConfiguration.getName()));
        });
    }
    return runConfigurations;
}
Also used : RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) EmbeddedMetaStore(org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore) KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Utils(org.pentaho.di.core.util.Utils) AbstractMeta(org.pentaho.di.base.AbstractMeta) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) RunConfigurationManager(org.pentaho.di.engine.configuration.impl.RunConfigurationManager) List(java.util.List) EmbeddedRunConfigurationManager(org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager) DefaultRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider) Map(java.util.Map) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ExtensionPointInterface(org.pentaho.di.core.extension.ExtensionPointInterface) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Comparator(java.util.Comparator) ExtensionPoint(org.pentaho.di.core.extension.ExtensionPoint) JobMeta(org.pentaho.di.job.JobMeta) RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) ArrayList(java.util.ArrayList) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) ArrayList(java.util.ArrayList) List(java.util.List)

Example 65 with JobEntryCopy

use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.

the class RunConfigurationImportExtensionPointTest method shouldCreateRunConfigurationsForSlaveServer.

@Test
public void shouldCreateRunConfigurationsForSlaveServer() throws Exception {
    JobMeta jobMeta = mock(JobMeta.class);
    JobEntryCopy jobEntryCopy1 = mock(JobEntryCopy.class);
    JobEntryCopy jobEntryCopy2 = mock(JobEntryCopy.class);
    JobEntryCopy jobEntryCopy3 = mock(JobEntryCopy.class);
    JobEntryTrans trans1 = mock(JobEntryTrans.class);
    JobEntryTrans trans2 = mock(JobEntryTrans.class);
    JobEntryTrans trans3 = mock(JobEntryTrans.class);
    ArgumentCaptor<DefaultRunConfiguration> rcCaptor = ArgumentCaptor.forClass(DefaultRunConfiguration.class);
    when(jobMeta.getEmbeddedMetaStore()).thenReturn(embeddedMetaStore);
    when(jobMeta.getSlaveServers()).thenReturn(Arrays.asList(new SlaveServer("carte1", "host1", "1234", "user", "passw"), new SlaveServer("carte2", "host2", "1234", "user", "passw")));
    when(jobMeta.getJobCopies()).thenReturn(Arrays.asList(jobEntryCopy1, jobEntryCopy2, jobEntryCopy3));
    when(jobEntryCopy1.getEntry()).thenReturn(trans1);
    when(jobEntryCopy2.getEntry()).thenReturn(trans2);
    when(jobEntryCopy3.getEntry()).thenReturn(trans3);
    when(trans1.getRemoteSlaveServerName()).thenReturn("carte1");
    when(trans2.getRemoteSlaveServerName()).thenReturn("carte1");
    when(trans3.getRemoteSlaveServerName()).thenReturn("carte2");
    when(trans1.getRunConfiguration()).thenReturn(null);
    when(trans2.getRunConfiguration()).thenReturn(null);
    when(trans3.getRunConfiguration()).thenReturn(null);
    when(runConfigurationManager.getNames()).thenReturn(Collections.singletonList("pentaho_auto_carte1_config"));
    runConfigurationImportExtensionPoint.callExtensionPoint(log, jobMeta);
    verify(runConfigurationManager, times(2)).save(rcCaptor.capture());
    verify(trans1).setRunConfiguration("pentaho_auto_carte1_config_1");
    verify(trans2).setRunConfiguration("pentaho_auto_carte1_config_1");
    verify(trans3).setRunConfiguration("pentaho_auto_carte2_config");
    List<DefaultRunConfiguration> allValues = rcCaptor.getAllValues();
    DefaultRunConfiguration runConfiguration1 = allValues.get(0);
    assertEquals("pentaho_auto_carte1_config_1", runConfiguration1.getName());
    assertEquals("carte1", runConfiguration1.getServer());
    DefaultRunConfiguration runConfiguration2 = allValues.get(1);
    assertEquals("pentaho_auto_carte2_config", runConfiguration2.getName());
    assertEquals("carte2", runConfiguration2.getServer());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) SlaveServer(org.pentaho.di.cluster.SlaveServer) Test(org.junit.Test)

Aggregations

JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)149 Point (org.pentaho.di.core.gui.Point)54 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)51 JobMeta (org.pentaho.di.job.JobMeta)47 KettleException (org.pentaho.di.core.exception.KettleException)30 Test (org.junit.Test)28 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)28 NotePadMeta (org.pentaho.di.core.NotePadMeta)24 JobHopMeta (org.pentaho.di.job.JobHopMeta)24 ArrayList (java.util.ArrayList)18 Job (org.pentaho.di.job.Job)18 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)16 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)15 MessageBox (org.eclipse.swt.widgets.MessageBox)13 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)10 Result (org.pentaho.di.core.Result)8 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)8 AreaOwner (org.pentaho.di.core.gui.AreaOwner)8 JobEntrySpecial (org.pentaho.di.job.entries.special.JobEntrySpecial)8 Before (org.junit.Before)7