Search in sources :

Example 46 with PartitionSchema

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

the class KettleDatabaseRepositoryTransDelegate method readPartitionSchemas.

/**
 * Read the partitions in the repository and add them to this transformation if they are not yet present.
 *
 * @param transMeta
 *          The transformation to load into.
 * @param overWriteShared
 *          if an object with the same name exists, overwrite
 * @throws KettleException
 */
public void readPartitionSchemas(TransMeta transMeta, boolean overWriteShared) throws KettleException {
    try {
        ObjectId[] dbids = repository.getPartitionSchemaIDs(false);
        for (int i = 0; i < dbids.length; i++) {
            // Load last version
            PartitionSchema partitionSchema = repository.loadPartitionSchema(dbids[i], null);
            // Check if there already is
            PartitionSchema check = transMeta.findPartitionSchema(partitionSchema.getName());
            // one in the transformation
            if (check == null || overWriteShared) {
                if (!Utils.isEmpty(partitionSchema.getName())) {
                    transMeta.addOrReplacePartitionSchema(partitionSchema);
                    if (!overWriteShared) {
                        partitionSchema.setChanged(false);
                    }
                }
            }
        }
    } catch (KettleException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Log.UnableToReadPartitionSchemaFromRepository"), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PartitionSchema(org.pentaho.di.partition.PartitionSchema)

Example 47 with PartitionSchema

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

the class RepositoryExplorerDialog method editPartitionSchema.

public void editPartitionSchema(String partitionSchemaName) {
    try {
        ObjectId id = rep.getPartitionSchemaID(partitionSchemaName);
        // Load the last version
        PartitionSchema partitionSchema = rep.loadPartitionSchema(id, null);
        PartitionSchemaDialog dd = new PartitionSchemaDialog(shell, partitionSchema, rep.readDatabases(), variableSpace);
        if (dd.open()) {
            rep.insertLogEntry("Updating partition schema '" + partitionSchema.getName() + "'");
            rep.save(partitionSchema, Const.VERSION_COMMENT_EDIT_VERSION, null);
            if (!partitionSchemaName.equalsIgnoreCase(partitionSchema.getName())) {
                refreshTree();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Edit.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Edit.UnexpectedError.Message") + partitionSchemaName + "]", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PartitionSchemaDialog(org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog)

Example 48 with PartitionSchema

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

the class RepositoryExplorerDialog method newPartitionSchema.

public void newPartitionSchema() {
    try {
        PartitionSchema partitionSchema = new PartitionSchema();
        PartitionSchemaDialog dd = new PartitionSchemaDialog(shell, partitionSchema, rep.readDatabases(), variableSpace);
        if (dd.open()) {
            // See if this slave server already exists...
            ObjectId idPartitionSchema = rep.getPartitionSchemaID(partitionSchema.getName());
            if (idPartitionSchema == null) {
                rep.insertLogEntry("Creating new partition schema '" + partitionSchema.getName() + "'");
                rep.save(partitionSchema, Const.VERSION_COMMENT_INITIAL_VERSION, null);
            } else {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.AlreadyExists.Message"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.AlreadyExists.Title"));
                mb.open();
            }
            // Refresh tree...
            refreshTree();
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.UnexpectedError.Message"), e);
    }
}
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) PartitionSchemaDialog(org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 49 with PartitionSchema

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

the class PartitionsController method refreshPartitions.

public void refreshPartitions() {
    if (repository != null) {
        final List<UIPartition> tmpList = new ArrayList<UIPartition>();
        Runnable r = () -> {
            try {
                if (repository instanceof RepositoryExtended) {
                    List<PartitionSchema> partitionSchemas = ((RepositoryExtended) repository).getPartitions(false);
                    partitionSchemas.forEach(partitionSchema -> tmpList.add(new UIPartition(partitionSchema)));
                } else {
                    ObjectId[] partitionIdList = repository.getPartitionSchemaIDs(false);
                    for (ObjectId partitionId : partitionIdList) {
                        PartitionSchema partition = repository.loadPartitionSchema(partitionId, null);
                        // Add the partition schema to the list
                        tmpList.add(new UIPartition(partition));
                    }
                }
            } catch (KettleException e) {
                if (mainController == null || !mainController.handleLostRepository(e)) {
                    // convert to runtime exception so it bubbles up through the UI
                    throw new RuntimeException(e);
                }
            }
        };
        doWithBusyIndicator(r);
        partitionList.setChildren(tmpList);
    }
}
Also used : RepositoryExplorerDialog(org.pentaho.di.ui.repository.dialog.RepositoryExplorerDialog) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) PartitionSchema(org.pentaho.di.partition.PartitionSchema) PartitionSchemaDialog(org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog) ArrayList(java.util.ArrayList) UIPartitions(org.pentaho.di.ui.repository.repositoryexplorer.model.UIPartitions) Const(org.pentaho.di.core.Const) SwtBindingFactory(org.pentaho.ui.xul.swt.SwtBindingFactory) RepositoryExplorer(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer) VariableSpace(org.pentaho.di.core.variables.VariableSpace) BaseMessages(org.pentaho.di.i18n.BaseMessages) Shell(org.eclipse.swt.widgets.Shell) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) Repository(org.pentaho.di.repository.Repository) Variables(org.pentaho.di.core.variables.Variables) Collection(java.util.Collection) XulTree(org.pentaho.ui.xul.containers.XulTree) UIPartition(org.pentaho.di.ui.repository.repositoryexplorer.model.UIPartition) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) Binding(org.pentaho.ui.xul.binding.Binding) XulButton(org.pentaho.ui.xul.components.XulButton) List(java.util.List) ObjectId(org.pentaho.di.repository.ObjectId) SWT(org.eclipse.swt.SWT) MessageBox(org.eclipse.swt.widgets.MessageBox) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IUISupportController(org.pentaho.di.ui.repository.repositoryexplorer.IUISupportController) KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ArrayList(java.util.ArrayList) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) ArrayList(java.util.ArrayList) List(java.util.List) UIPartition(org.pentaho.di.ui.repository.repositoryexplorer.model.UIPartition)

Example 50 with PartitionSchema

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

the class KettleFileRepository method readTransSharedObjects.

@Override
public SharedObjects readTransSharedObjects(TransMeta transMeta) throws KettleException {
    // First the normal shared objects...
    // 
    SharedObjects sharedObjects = transMeta.readSharedObjects();
    // 
    for (ObjectId id : getDatabaseIDs(false)) {
        // Load last version
        DatabaseMeta databaseMeta = loadDatabaseMeta(id, null);
        databaseMeta.shareVariablesWith(transMeta);
        transMeta.addOrReplaceDatabase(databaseMeta);
    }
    for (ObjectId id : getSlaveIDs(false)) {
        // Load last version
        SlaveServer slaveServer = loadSlaveServer(id, null);
        slaveServer.shareVariablesWith(transMeta);
        transMeta.addOrReplaceSlaveServer(slaveServer);
    }
    for (ObjectId id : getClusterIDs(false)) {
        // Load last version
        ClusterSchema clusterSchema = loadClusterSchema(id, transMeta.getSlaveServers(), null);
        clusterSchema.shareVariablesWith(transMeta);
        transMeta.addOrReplaceClusterSchema(clusterSchema);
    }
    for (ObjectId id : getPartitionSchemaIDs(false)) {
        // Load last version
        PartitionSchema partitionSchema = loadPartitionSchema(id, null);
        transMeta.addOrReplacePartitionSchema(partitionSchema);
    }
    return sharedObjects;
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PartitionSchema(org.pentaho.di.partition.PartitionSchema) SharedObjects(org.pentaho.di.shared.SharedObjects) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

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