Search in sources :

Example 1 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class Job method init.

public void init() {
    status = new AtomicInteger();
    jobListeners = new ArrayList<JobListener>();
    jobEntryListeners = new ArrayList<JobEntryListener>();
    delegationListeners = new ArrayList<DelegationListener>();
    // these 2 maps are being modified concurrently and must be thread-safe
    activeJobEntryTransformations = new ConcurrentHashMap<JobEntryCopy, JobEntryTrans>();
    activeJobEntryJobs = new ConcurrentHashMap<JobEntryCopy, JobEntryJob>();
    extensionDataMap = new HashMap<String, Object>();
    jobTracker = new JobTracker(jobMeta);
    synchronized (jobEntryResults) {
        jobEntryResults.clear();
    }
    errors = new AtomicInteger(0);
    batchId = -1;
    passedBatchId = -1;
    maxJobEntriesLogged = Const.toInt(EnvUtil.getSystemProperty(Const.KETTLE_MAX_JOB_ENTRIES_LOGGED), 1000);
    result = null;
    startJobEntryCopy = null;
    startJobEntryResult = null;
    this.setDefaultLogCommitSize();
}
Also used : JobTracker(org.pentaho.di.core.gui.JobTracker) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) FileObject(org.apache.commons.vfs2.FileObject) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob)

Example 2 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class JobExecutionConfiguration method getUsedArguments.

public void getUsedArguments(JobMeta jobMeta, String[] commandLineArguments, IMetaStore metaStore) {
    for (JobEntryCopy jobEntryCopy : jobMeta.jobcopies) {
        if (jobEntryCopy.isTransformation()) {
            JobEntryTrans jobEntryTrans = (JobEntryTrans) jobEntryCopy.getEntry();
            try {
                TransMeta transMeta = jobEntryTrans.getTransMeta(repository, metaStore, jobMeta);
                Map<String, String> map = transMeta.getUsedArguments(commandLineArguments);
                for (Map.Entry<String, String> entry : map.entrySet()) {
                    arguments.putIfAbsent(entry.getKey(), entry.getValue());
                }
            } catch (KettleException ke) {
            // suppress exceptions at this time - we will let the runtime report on any errors
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) TransMeta(org.pentaho.di.trans.TransMeta) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class MetaFileLoaderImplTest method setupJobEntryTrans.

private void setupJobEntryTrans() throws Exception {
    JobEntryTrans jobEntryTrans = new JobEntryTrans();
    jobEntryBase = jobEntryTrans;
    JobMeta parentJobMeta = spy(new JobMeta());
    LogChannelInterface logger = mock(LogChannelInterface.class);
    metaFileCache = new MetaFileCacheImpl(logger);
    parentJobMeta.setMetaFileCache(metaFileCache);
    when(parentJobMeta.getNamedClusterEmbedManager()).thenReturn(namedClusterEmbedManager);
    jobEntryTrans.setParentJobMeta(parentJobMeta);
    keyPath = getClass().getResource(TRANS_FILE).getPath();
    jobEntryTrans.setFileName(keyPath);
    Job job = new Job();
    space = job;
    jobEntryTrans.setParentJob(job);
    targetMetaName = TRANS_FILE;
    jobEntryTrans.setTransname(targetMetaName);
    jobEntryTrans.setTransObjectId(null);
    // repo stuff
    keyPath = convertToRepoKeyPath(keyPath);
    jobEntryTrans.setDirectory(keyPath.substring(0, keyPath.lastIndexOf("/")));
    jobEntryTrans.setTransObjectId(null);
    RepositoryDirectoryInterface rdi = mock(RepositoryDirectoryInterface.class);
    when(rdi.findDirectory(jobEntryTrans.getDirectory())).thenReturn(rdi);
    when(repository.loadRepositoryDirectoryTree()).thenReturn(rdi);
    TransMeta transMeta = new TransMeta();
    transMeta.setName(stripExtension(TRANS_FILE));
    when(repository.loadTransformation(TRANS_FILE, rdi, null, true, null)).thenReturn(transMeta);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) TransMeta(org.pentaho.di.trans.TransMeta) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) Job(org.pentaho.di.job.Job) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface)

Example 4 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans 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 5 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans 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

JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)19 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)16 JobMeta (org.pentaho.di.job.JobMeta)12 Test (org.junit.Test)8 KettleException (org.pentaho.di.core.exception.KettleException)6 TransMeta (org.pentaho.di.trans.TransMeta)5 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)4 DefaultRunConfiguration (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration)4 JobEntryJob (org.pentaho.di.job.entries.job.JobEntryJob)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)3 Job (org.pentaho.di.job.Job)3 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 List (java.util.List)2 FileObject (org.apache.commons.vfs2.FileObject)2 ObjectLocationSpecificationMethod (org.pentaho.di.core.ObjectLocationSpecificationMethod)2