Search in sources :

Example 21 with PartitionSchema

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

the class StepMetaTest method createStepPartitioningMeta.

private static StepPartitioningMeta createStepPartitioningMeta(String method, String schemaName) throws Exception {
    StepPartitioningMeta meta = new StepPartitioningMeta(method, new PartitionSchema(schemaName, Collections.<String>emptyList()));
    meta.setPartitionSchemaName("schema_name");
    return meta;
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema)

Example 22 with PartitionSchema

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

the class PurRepositoryIT method testNewNonAmbiguousNaming.

@Test
public void testNewNonAmbiguousNaming() throws Exception {
    PurRepository repo = (PurRepository) repository;
    System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "N");
    // $NON-NLS-1$
    PartitionSchema partSchema1 = createPartitionSchema("find.me");
    // $NON-NLS-1$
    PartitionSchema partSchema2 = createPartitionSchema("find|me");
    repository.save(partSchema1, VERSION_COMMENT_V1, null);
    repository.save(partSchema2, VERSION_COMMENT_V1, null);
    Map<RepositoryObjectType, List<? extends SharedObjectInterface>> sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
    repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
    List<PartitionSchema> partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
    assertEquals(2, partitionSchemas.size());
    System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "Y");
    // $NON-NLS-1$
    PartitionSchema partSchema3 = createPartitionSchema("another.one");
    // $NON-NLS-1$
    PartitionSchema partSchema4 = createPartitionSchema("another|one");
    repository.save(partSchema3, VERSION_COMMENT_V1, null);
    repository.save(partSchema4, VERSION_COMMENT_V1, null);
    sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
    repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
    partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
    assertEquals(3, partitionSchemas.size());
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) HashMap(java.util.HashMap) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) ArrayList(java.util.ArrayList) AbstractList(java.util.AbstractList) List(java.util.List) SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface) Test(org.junit.Test)

Example 23 with PartitionSchema

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

the class TransDelegate method loadSharedObjects.

@SuppressWarnings("unchecked")
public SharedObjects loadSharedObjects(final RepositoryElementInterface element, final Map<RepositoryObjectType, List<? extends SharedObjectInterface>> sharedObjectsByType) throws KettleException {
    TransMeta transMeta = (TransMeta) element;
    transMeta.setSharedObjects(transMeta.readSharedObjects());
    // Repository objects take priority so let's overwrite them...
    // 
    readDatabases(transMeta, true, (List<DatabaseMeta>) sharedObjectsByType.get(RepositoryObjectType.DATABASE));
    readPartitionSchemas(transMeta, true, (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA));
    readSlaves(transMeta, true, (List<SlaveServer>) sharedObjectsByType.get(RepositoryObjectType.SLAVE_SERVER));
    readClusters(transMeta, true, (List<ClusterSchema>) sharedObjectsByType.get(RepositoryObjectType.CLUSTER_SCHEMA));
    return transMeta.getSharedObjects();
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) TransMeta(org.pentaho.di.trans.TransMeta) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 24 with PartitionSchema

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

the class PartitionsController method removePartition.

public void removePartition() {
    String partitionSchemaName = "";
    try {
        Collection<UIPartition> partitions = partitionsTable.getSelectedItems();
        if (partitions != null && !partitions.isEmpty()) {
            for (Object obj : partitions) {
                if (obj != null && obj instanceof UIPartition) {
                    UIPartition partition = (UIPartition) obj;
                    PartitionSchema partitionSchema = partition.getPartitionSchema();
                    partitionSchemaName = partitionSchema.getName();
                    // Make sure the partition to delete exists in the repository
                    ObjectId partitionId = repository.getPartitionSchemaID(partitionSchema.getName());
                    if (partitionId == null) {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                        mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.DoesNotExists.Message", partitionSchemaName));
                        mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"));
                        mb.open();
                    } else {
                        repository.deletePartitionSchema(partitionId);
                        if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
                            mainController.getSharedObjectSyncUtil().deletePartitionSchema(partitionSchema);
                        }
                    }
                }
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.NoItemSelected.Message"));
            mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"));
            mb.open();
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.UnexpectedError.Message") + partitionSchemaName + "]", e);
        }
    } finally {
        refreshPartitions();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) UIPartition(org.pentaho.di.ui.repository.repositoryexplorer.model.UIPartition) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 25 with PartitionSchema

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

the class PartitionsController method createPartition.

public void createPartition() {
    try {
        PartitionSchema partition = new PartitionSchema();
        PartitionSchemaDialog partitionDialog = new PartitionSchemaDialog(shell, partition, repository.readDatabases(), variableSpace);
        if (partitionDialog.open()) {
            // See if this partition already exists...
            ObjectId idPartition = repository.getPartitionSchemaID(partition.getName());
            if (idPartition == null) {
                if (partition.getName() != null && !partition.getName().equals("")) {
                    repository.insertLogEntry(BaseMessages.getString(RepositoryExplorer.class, "PartitionsController.Message.CreatingPartition", partition.getName()));
                    repository.save(partition, Const.VERSION_COMMENT_INITIAL_VERSION, null);
                    if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
                        mainController.getSharedObjectSyncUtil().reloadTransformationRepositoryObjects(true);
                    }
                } else {
                    MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                    mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.InvalidName.Message"));
                    mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.Title"));
                    mb.open();
                }
            } else {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.AlreadyExists.Message"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.AlreadyExists.Title"));
                mb.open();
            }
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.UnexpectedError.Message"), e);
        }
    } finally {
        refreshPartitions();
    }
}
Also used : RepositoryExplorer(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer) KettleException(org.pentaho.di.core.exception.KettleException) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PartitionSchemaDialog(org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

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