Search in sources :

Example 71 with PartitionSchema

use of org.pentaho.di.partition.PartitionSchema 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 72 with PartitionSchema

use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.

the class SharedObjectSyncUtilTest method synchronizePartitionSchemasDeleteFromRepository.

@Test
public void synchronizePartitionSchemasDeleteFromRepository() throws Exception {
    try {
        spoon.rep = repository;
        when(spoon.getRepository()).thenReturn(repository);
        final String objectId = "object-id";
        final String partitionName = "partsch";
        TransMeta trans1 = createTransMeta();
        trans1.setRepository(repository);
        trans1.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        PartitionSchema part1 = createPartitionSchema(partitionName, false);
        part1.setObjectId(new StringObjectId(objectId));
        trans1.addOrReplacePartitionSchema(part1);
        spoon.delegates.trans.addTransformation(trans1);
        TransMeta trans2 = createTransMeta();
        trans2.setRepository(repository);
        trans2.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        PartitionSchema part2 = createPartitionSchema(partitionName, false);
        part2.setObjectId(new StringObjectId(objectId));
        trans2.addOrReplacePartitionSchema(part2);
        spoon.delegates.trans.addTransformation(trans2);
        assertFalse(trans1.getPartitionSchemas().isEmpty());
        spoon.delegates.partitions.delPartitionSchema(trans2, part2);
        verify(repository).deletePartitionSchema(part2.getObjectId());
        assertTrue(trans1.getPartitionSchemas().isEmpty());
    } finally {
        spoon.rep = null;
        when(spoon.getRepository()).thenReturn(null);
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) TransMeta(org.pentaho.di.trans.TransMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 73 with PartitionSchema

use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.

the class SharedObjectSyncUtilTest method createPartitionSchema.

private static PartitionSchema createPartitionSchema(String name, boolean shared) {
    PartitionSchema partitionSchema = new PartitionSchema();
    partitionSchema.setName(name);
    partitionSchema.setNumberOfPartitionsPerSlave(BEFORE_SYNC_VALUE);
    partitionSchema.setShared(shared);
    return partitionSchema;
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema)

Example 74 with PartitionSchema

use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.

the class SharedObjectSyncUtilTest method synchronizePartitionSchemas_use_case_sensitive_name.

@Test
public void synchronizePartitionSchemas_use_case_sensitive_name() throws Exception {
    TransMeta transformarion1 = createTransMeta();
    PartitionSchema partitionSchema1 = createPartitionSchema("PartitionSchema", true);
    transformarion1.setPartitionSchemas(Collections.singletonList(partitionSchema1));
    spoonDelegates.trans.addTransformation(transformarion1);
    TransMeta transformarion2 = createTransMeta();
    PartitionSchema partitionSchema2 = createPartitionSchema("Partitionschema", true);
    transformarion2.setPartitionSchemas(Collections.singletonList(partitionSchema2));
    spoonDelegates.trans.addTransformation(transformarion2);
    partitionSchema2.setNumberOfPartitionsPerSlave(AFTER_SYNC_VALUE);
    sharedUtil.synchronizePartitionSchemas(partitionSchema2);
    assertThat(partitionSchema1.getNumberOfPartitionsPerSlave(), equalTo(BEFORE_SYNC_VALUE));
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) TransMeta(org.pentaho.di.trans.TransMeta) Test(org.junit.Test)

Aggregations

PartitionSchema (org.pentaho.di.partition.PartitionSchema)74 KettleException (org.pentaho.di.core.exception.KettleException)26 TransMeta (org.pentaho.di.trans.TransMeta)19 StepMeta (org.pentaho.di.trans.step.StepMeta)19 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)18 SlaveServer (org.pentaho.di.cluster.SlaveServer)18 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)17 StepPartitioningMeta (org.pentaho.di.trans.step.StepPartitioningMeta)17 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)15 ObjectId (org.pentaho.di.repository.ObjectId)14 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)10 List (java.util.List)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)8 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)6 StringObjectId (org.pentaho.di.repository.StringObjectId)6 PartitionSchemaDialog (org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog)6 MessageBox (org.eclipse.swt.widgets.MessageBox)5 Point (org.pentaho.di.core.gui.Point)5 IOException (java.io.IOException)4