Search in sources :

Example 6 with JobEntryLogTable

use of org.pentaho.di.core.logging.JobEntryLogTable in project pentaho-kettle by pentaho.

the class Job method writeJobEntryLogInformation.

/**
 * Write job entry log information.
 *
 * @throws KettleException
 *           the kettle exception
 */
protected void writeJobEntryLogInformation() throws KettleException {
    Database db = null;
    JobEntryLogTable jobEntryLogTable = getJobMeta().getJobEntryLogTable();
    try {
        db = createDataBase(jobEntryLogTable.getDatabaseMeta());
        db.shareVariablesWith(this);
        db.connect();
        db.setCommit(logCommitSize);
        for (JobEntryCopy copy : getJobMeta().getJobCopies()) {
            db.writeLogRecord(jobEntryLogTable, LogStatus.START, copy, this);
        }
        db.cleanupLogRecords(jobEntryLogTable);
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(PKG, "Job.Exception.UnableToJobEntryInformationToLogTable"), e);
    } finally {
        if (!db.isAutoCommit()) {
            db.commitLog(true, jobEntryLogTable);
        }
        db.disconnect();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Database(org.pentaho.di.core.database.Database) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleJobException(org.pentaho.di.core.exception.KettleJobException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 7 with JobEntryLogTable

use of org.pentaho.di.core.logging.JobEntryLogTable in project pentaho-kettle by pentaho.

the class RepositoryTestBase method createJobMeta.

protected JobMeta createJobMeta(String jobName) throws Exception {
    RepositoryDirectoryInterface rootDir = loadStartDirectory();
    JobMeta jobMeta = new JobMeta();
    jobMeta.setName(jobName);
    jobMeta.setDescription(EXP_JOB_DESC);
    jobMeta.setExtendedDescription(EXP_JOB_EXTENDED_DESC);
    jobMeta.setRepositoryDirectory(rootDir.findDirectory(DIR_JOBS));
    jobMeta.setJobversion(EXP_JOB_VERSION);
    jobMeta.setJobstatus(EXP_JOB_STATUS);
    jobMeta.setCreatedUser(EXP_JOB_CREATED_USER);
    jobMeta.setCreatedDate(EXP_JOB_CREATED_DATE);
    jobMeta.setModifiedUser(EXP_JOB_MOD_USER);
    jobMeta.setModifiedDate(EXP_JOB_MOD_DATE);
    jobMeta.addParameterDefinition(EXP_JOB_PARAM_1_NAME, EXP_JOB_PARAM_1_DEF, EXP_JOB_PARAM_1_DESC);
    // TODO mlowery other jobLogTable fields could be set for testing here
    JobLogTable jobLogTable = JobLogTable.getDefault(jobMeta, jobMeta);
    jobLogTable.setConnectionName(EXP_JOB_LOG_TABLE_CONN_NAME);
    jobLogTable.setLogInterval(EXP_JOB_LOG_TABLE_INTERVAL);
    jobLogTable.setSchemaName(EXP_JOB_LOG_TABLE_SCHEMA_NAME);
    jobLogTable.setLogSizeLimit(EXP_JOB_LOG_TABLE_SIZE_LIMIT);
    jobLogTable.setTableName(EXP_JOB_LOG_TABLE_TABLE_NAME);
    jobLogTable.setTimeoutInDays(EXP_JOB_LOG_TABLE_TIMEOUT_IN_DAYS);
    jobMeta.setJobLogTable(jobLogTable);
    // TODO mlowery other jobEntryLogTable fields could be set for testing here
    JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault(jobMeta, jobMeta);
    jobEntryLogTable.setConnectionName(EXP_JOB_LOG_TABLE_CONN_NAME);
    jobEntryLogTable.setSchemaName(EXP_JOB_LOG_TABLE_SCHEMA_NAME);
    jobEntryLogTable.setTableName(EXP_JOB_LOG_TABLE_TABLE_NAME);
    jobEntryLogTable.setTimeoutInDays(EXP_JOB_LOG_TABLE_TIMEOUT_IN_DAYS);
    jobMeta.setJobEntryLogTable(jobEntryLogTable);
    // TODO mlowery other channelLogTable fields could be set for testing here
    ChannelLogTable channelLogTable = ChannelLogTable.getDefault(jobMeta, jobMeta);
    channelLogTable.setConnectionName(EXP_JOB_LOG_TABLE_CONN_NAME);
    channelLogTable.setSchemaName(EXP_JOB_LOG_TABLE_SCHEMA_NAME);
    channelLogTable.setTableName(EXP_JOB_LOG_TABLE_TABLE_NAME);
    channelLogTable.setTimeoutInDays(EXP_JOB_LOG_TABLE_TIMEOUT_IN_DAYS);
    jobMeta.setChannelLogTable(channelLogTable);
    jobMeta.setBatchIdPassed(EXP_JOB_BATCH_ID_PASSED);
    jobMeta.setSharedObjectsFile(EXP_JOB_SHARED_OBJECTS_FILE);
    DatabaseMeta entryDbMeta = createDatabaseMeta(EXP_DBMETA_NAME_JOB.concat(jobName));
    repository.save(entryDbMeta, VERSION_COMMENT_V1, null);
    deleteStack.push(entryDbMeta);
    JobEntryCopy jobEntryCopy1 = createJobEntry1Copy(entryDbMeta);
    jobMeta.addJobEntry(jobEntryCopy1);
    JobEntryCopy jobEntryCopy2 = createJobEntry2Copy(entryDbMeta);
    jobMeta.addJobEntry(jobEntryCopy2);
    jobMeta.addJobHop(createJobHopMeta(jobEntryCopy1, jobEntryCopy2));
    jobMeta.addNote(createNotePadMeta(jobName));
    return jobMeta;
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobLogTable(org.pentaho.di.core.logging.JobLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 8 with JobEntryLogTable

use of org.pentaho.di.core.logging.JobEntryLogTable in project pentaho-kettle by pentaho.

the class PurRepositoryUnitTest method onlyGlobalVariablesOfLogTablesSetToNull.

@Test
public void onlyGlobalVariablesOfLogTablesSetToNull() {
    try {
        System.setProperty(Const.KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT, "true");
        PurRepositoryExporter purRepoExporter = new PurRepositoryExporter(mock(PurRepository.class));
        String hardcodedString = "hardcoded";
        String globalParam = "${" + Const.KETTLE_TRANS_LOG_TABLE + "}";
        StepLogTable stepLogTable = StepLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
        stepLogTable.setConnectionName(hardcodedString);
        stepLogTable.setSchemaName(hardcodedString);
        stepLogTable.setTimeoutInDays(hardcodedString);
        stepLogTable.setTableName(globalParam);
        JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
        jobEntryLogTable.setConnectionName(hardcodedString);
        jobEntryLogTable.setSchemaName(hardcodedString);
        jobEntryLogTable.setTimeoutInDays(hardcodedString);
        jobEntryLogTable.setTableName(globalParam);
        List<LogTableInterface> logTables = new ArrayList<>();
        logTables.add(jobEntryLogTable);
        logTables.add(stepLogTable);
        purRepoExporter.setGlobalVariablesOfLogTablesNull(logTables);
        for (LogTableInterface logTable : logTables) {
            assertEquals(logTable.getConnectionName(), hardcodedString);
            assertEquals(logTable.getSchemaName(), hardcodedString);
            assertEquals(logTable.getTimeoutInDays(), hardcodedString);
            assertEquals(logTable.getTableName(), null);
        }
    } finally {
        System.setProperty(Const.KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT, "false");
    }
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) StepLogTable(org.pentaho.di.core.logging.StepLogTable) ArrayList(java.util.ArrayList) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with JobEntryLogTable

use of org.pentaho.di.core.logging.JobEntryLogTable in project pentaho-kettle by pentaho.

the class PurRepositoryUnitTest method globalVariablesOfLogTablesNotSetToNull.

@Test
public void globalVariablesOfLogTablesNotSetToNull() {
    PurRepositoryExporter purRepoExporter = new PurRepositoryExporter(mock(PurRepository.class));
    String globalParam = "${" + Const.KETTLE_TRANS_LOG_TABLE + "}";
    StepLogTable stepLogTable = StepLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    stepLogTable.setConnectionName(globalParam);
    stepLogTable.setSchemaName(globalParam);
    stepLogTable.setTimeoutInDays(globalParam);
    stepLogTable.setTableName(globalParam);
    JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    jobEntryLogTable.setConnectionName(globalParam);
    jobEntryLogTable.setSchemaName(globalParam);
    jobEntryLogTable.setTimeoutInDays(globalParam);
    jobEntryLogTable.setTableName(globalParam);
    List<LogTableInterface> logTables = new ArrayList<>();
    logTables.add(jobEntryLogTable);
    logTables.add(stepLogTable);
    purRepoExporter.setGlobalVariablesOfLogTablesNull(logTables);
    for (LogTableInterface logTable : logTables) {
        assertEquals(logTable.getConnectionName(), globalParam);
        assertEquals(logTable.getSchemaName(), globalParam);
        assertEquals(logTable.getTimeoutInDays(), globalParam);
        assertEquals(logTable.getTableName(), globalParam);
    }
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) StepLogTable(org.pentaho.di.core.logging.StepLogTable) ArrayList(java.util.ArrayList) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with JobEntryLogTable

use of org.pentaho.di.core.logging.JobEntryLogTable in project pentaho-kettle by pentaho.

the class JobDialog method getLogInfo.

private void getLogInfo(int previousLogTableIndex) {
    if (previousLogTableIndex < 0) {
        return;
    }
    // Remember the that was entered data...
    // 
    LogTableInterface modifiedLogTable = logTables.get(previousLogTableIndex);
    LogTableUserInterface logTableUserInterface = logTableUserInterfaces.get(previousLogTableIndex);
    if (logTableUserInterface != null) {
        logTableUserInterface.retrieveLogTableOptions(modifiedLogTable);
    } else {
        if (modifiedLogTable instanceof JobLogTable) {
            getJobLogTableOptions((JobLogTable) modifiedLogTable);
        } else if (modifiedLogTable instanceof ChannelLogTable) {
            getChannelLogTableOptions((ChannelLogTable) modifiedLogTable);
        } else if (modifiedLogTable instanceof JobEntryLogTable) {
            getJobEntryLogTableOptions((JobEntryLogTable) modifiedLogTable);
        }
    }
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) JobLogTable(org.pentaho.di.core.logging.JobLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable)

Aggregations

JobEntryLogTable (org.pentaho.di.core.logging.JobEntryLogTable)13 ChannelLogTable (org.pentaho.di.core.logging.ChannelLogTable)8 JobLogTable (org.pentaho.di.core.logging.JobLogTable)8 LogTableInterface (org.pentaho.di.core.logging.LogTableInterface)6 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Database (org.pentaho.di.core.database.Database)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 KettleValueException (org.pentaho.di.core.exception.KettleValueException)3 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)3 Matchers.anyString (org.mockito.Matchers.anyString)2 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleJobException (org.pentaho.di.core.exception.KettleJobException)2 StepLogTable (org.pentaho.di.core.logging.StepLogTable)2 DuplicateParamException (org.pentaho.di.core.parameters.DuplicateParamException)2 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 JobMeta (org.pentaho.di.job.JobMeta)2 Date (java.util.Date)1