Search in sources :

Example 21 with StepPartitioningMeta

use of org.pentaho.di.trans.step.StepPartitioningMeta in project pentaho-kettle by pentaho.

the class TransPartitioningTest method prepareStepMetas_cl1_cl2.

/**
 * This is a case when we have 2 steps, but partitioned differently
 *
 * @throws KettlePluginException
 */
private void prepareStepMetas_cl1_cl2() throws KettlePluginException {
    StepMeta dummy1 = new StepMeta(ONE, null);
    StepMeta dummy2 = new StepMeta(TWO, null);
    PartitionSchema schema1 = new PartitionSchema("p1", Arrays.asList(new String[] { PID1, PID2 }));
    PartitionSchema schema2 = new PartitionSchema("p2", Arrays.asList(new String[] { PID1, PID2 }));
    StepPartitioningMeta partMeta1 = new StepPartitioningMeta("Mirror to all partitions", schema1);
    StepPartitioningMeta partMeta2 = new StepPartitioningMeta("Mirror to all partitions", schema2);
    partMeta1.setPartitionSchemaName(schema1.getName());
    partMeta2.setPartitionSchemaName(schema2.getName());
    dummy1.setStepPartitioningMeta(partMeta1);
    dummy2.setStepPartitioningMeta(partMeta2);
    chain.add(dummy1);
    chain.add(dummy2);
    for (StepMeta item : chain) {
        item.setStepMetaInterface(new DummyTransMeta());
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) StepPartitioningMeta(org.pentaho.di.trans.step.StepPartitioningMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)

Example 22 with StepPartitioningMeta

use of org.pentaho.di.trans.step.StepPartitioningMeta in project pentaho-kettle by pentaho.

the class PartitionSettingsTest method defaultSelectedSchemaIndexWhenSchemaNameIsNotDefined.

@Test
public void defaultSelectedSchemaIndexWhenSchemaNameIsNotDefined() throws Exception {
    PartitionSchema schema = new PartitionSchema();
    StepPartitioningMeta meta = mock(StepPartitioningMeta.class);
    when(meta.getPartitionSchema()).thenReturn(schema);
    when(stepMeta.getStepPartitioningMeta()).thenReturn(meta);
    List<String> schemas = Arrays.asList("test");
    when(partitionSchemasProvider.getPartitionSchemasNames(any(TransMeta.class))).thenReturn(schemas);
    assertEquals(0, settings.getDefaultSelectedSchemaIndex());
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) TransMeta(org.pentaho.di.trans.TransMeta) StepPartitioningMeta(org.pentaho.di.trans.step.StepPartitioningMeta) Test(org.junit.Test)

Example 23 with StepPartitioningMeta

use of org.pentaho.di.trans.step.StepPartitioningMeta in project pentaho-kettle by pentaho.

the class SpoonStepsDelegate method getPartitionerDialog.

public StepDialogInterface getPartitionerDialog(StepMeta stepMeta, StepPartitioningMeta partitioningMeta, TransMeta transMeta) throws KettleException {
    Partitioner partitioner = partitioningMeta.getPartitioner();
    String dialogClassName = partitioner.getDialogClassName();
    Class<?> dialogClass;
    Class<?>[] paramClasses = new Class<?>[] { Shell.class, StepMeta.class, StepPartitioningMeta.class, TransMeta.class };
    Object[] paramArgs = new Object[] { spoon.getShell(), stepMeta, partitioningMeta, transMeta };
    Constructor<?> dialogConstructor;
    try {
        dialogClass = partitioner.getClass().getClassLoader().loadClass(dialogClassName);
        dialogConstructor = dialogClass.getConstructor(paramClasses);
        return (StepDialogInterface) dialogConstructor.newInstance(paramArgs);
    } catch (Exception e) {
        // try the old way for compatibility
        Method method;
        try {
            Class<?>[] sig = new Class<?>[] { Shell.class, StepMetaInterface.class, TransMeta.class };
            method = stepMeta.getClass().getDeclaredMethod("getDialog", sig);
            if (method != null) {
                return (StepDialogInterface) method.invoke(stepMeta, new Object[] { spoon.getShell(), stepMeta, transMeta });
            }
        } catch (Throwable ignored) {
        }
        throw new KettleException(e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) StepDialogInterface(org.pentaho.di.trans.step.StepDialogInterface) TransMeta(org.pentaho.di.trans.TransMeta) Method(java.lang.reflect.Method) StepPartitioningMeta(org.pentaho.di.trans.step.StepPartitioningMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleException(org.pentaho.di.core.exception.KettleException) Shell(org.eclipse.swt.widgets.Shell) Partitioner(org.pentaho.di.trans.Partitioner)

Aggregations

StepPartitioningMeta (org.pentaho.di.trans.step.StepPartitioningMeta)23 PartitionSchema (org.pentaho.di.partition.PartitionSchema)18 StepMeta (org.pentaho.di.trans.step.StepMeta)14 KettleException (org.pentaho.di.core.exception.KettleException)8 TransMeta (org.pentaho.di.trans.TransMeta)7 Test (org.junit.Test)6 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)5 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)5 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)4 NotePadMeta (org.pentaho.di.core.NotePadMeta)4 TransHopMeta (org.pentaho.di.trans.TransHopMeta)4 StepErrorMeta (org.pentaho.di.trans.step.StepErrorMeta)4 SlaveServer (org.pentaho.di.cluster.SlaveServer)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 HashMap (java.util.HashMap)2