Search in sources :

Example 61 with PartitionSchema

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

the class PartitionDelegate method dataNodeToElement.

public void dataNodeToElement(DataNode rootNode, RepositoryElementInterface element) throws KettleException {
    PartitionSchema partitionSchema = (PartitionSchema) element;
    partitionSchema.setDynamicallyDefined(rootNode.getProperty(PROP_DYNAMIC_DEFINITION).getBoolean());
    partitionSchema.setNumberOfPartitionsPerSlave(getString(rootNode, PROP_PARTITIONS_PER_SLAVE));
    // Also, load all the properties we can find...
    DataNode attrNode = rootNode.getNode(NODE_ATTRIBUTES);
    long partitionSchemaSize = attrNode.getProperty(PROP_NB_PARTITION_SCHEMA).getLong();
    for (int i = 0; i < partitionSchemaSize; i++) {
        DataProperty property = attrNode.getProperty(String.valueOf(i));
        partitionSchema.getPartitionIDs().add(Const.NVL(property.getString(), ""));
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty)

Example 62 with PartitionSchema

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

the class PartitionDelegate method dataNodeToElement.

// ~ Methods =========================================================================================================
public RepositoryElementInterface dataNodeToElement(DataNode rootNode) throws KettleException {
    PartitionSchema partitionSchema = new PartitionSchema();
    dataNodeToElement(rootNode, partitionSchema);
    return partitionSchema;
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema)

Example 63 with PartitionSchema

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

the class PartitionDelegate method assemble.

public PartitionSchema assemble(RepositoryFile file, NodeRepositoryFileData data, VersionSummary version) throws KettleException {
    PartitionSchema partitionSchema = (PartitionSchema) dataNodeToElement(data.getNode());
    partitionSchema.setName(file.getTitle());
    partitionSchema.setObjectId(new StringObjectId(file.getId().toString()));
    partitionSchema.setObjectRevision(repo.createObjectRevision(version));
    partitionSchema.clearChanged();
    return partitionSchema;
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 64 with PartitionSchema

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

the class PartitionDelegate method elementToDataNode.

public DataNode elementToDataNode(RepositoryElementInterface element) throws KettleException {
    PartitionSchema partitionSchema = (PartitionSchema) element;
    DataNode rootNode = new DataNode(NODE_ROOT);
    // Check for naming collision
    ObjectId partitionId = repo.getPartitionSchemaID(partitionSchema.getName());
    if (partitionId != null && !partitionSchema.getObjectId().equals(partitionId)) {
        // We have a naming collision, abort the save
        throw new KettleException("Failed to save object to repository. Object [" + partitionSchema.getName() + "] already exists.");
    }
    rootNode.setProperty(PROP_DYNAMIC_DEFINITION, partitionSchema.isDynamicallyDefined());
    rootNode.setProperty(PROP_PARTITIONS_PER_SLAVE, partitionSchema.getNumberOfPartitionsPerSlave());
    // Save the cluster-partition relationships
    DataNode attrNode = rootNode.addNode(NODE_ATTRIBUTES);
    attrNode.setProperty(PROP_NB_PARTITION_SCHEMA, partitionSchema.getPartitionIDs().size());
    for (int i = 0; i < partitionSchema.getPartitionIDs().size(); i++) {
        attrNode.setProperty(String.valueOf(i), partitionSchema.getPartitionIDs().get(i));
    }
    return rootNode;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode)

Example 65 with PartitionSchema

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

the class PurRepository method deepCopy.

private Map<RepositoryObjectType, List<? extends SharedObjectInterface>> deepCopy(Map<RepositoryObjectType, List<? extends SharedObjectInterface>> orig) throws KettleException {
    Map<RepositoryObjectType, List<? extends SharedObjectInterface>> copy = new EnumMap<RepositoryObjectType, List<? extends SharedObjectInterface>>(RepositoryObjectType.class);
    sharedObjectsLock.writeLock().lock();
    try {
        for (Entry<RepositoryObjectType, List<? extends SharedObjectInterface>> entry : orig.entrySet()) {
            RepositoryObjectType type = entry.getKey();
            List<? extends SharedObjectInterface> value = entry.getValue();
            List<SharedObjectInterface> newValue = new ArrayList<SharedObjectInterface>(value.size());
            for (SharedObjectInterface obj : value) {
                SharedObjectInterface newValueItem;
                if (obj instanceof DatabaseMeta) {
                    DatabaseMeta databaseMeta = (DatabaseMeta) ((DatabaseMeta) obj).clone();
                    databaseMeta.setObjectId(((DatabaseMeta) obj).getObjectId());
                    databaseMeta.setChangedDate(obj.getChangedDate());
                    databaseMeta.clearChanged();
                    newValueItem = databaseMeta;
                } else if (obj instanceof SlaveServer) {
                    SlaveServer slaveServer = (SlaveServer) ((SlaveServer) obj).clone();
                    slaveServer.setObjectId(((SlaveServer) obj).getObjectId());
                    slaveServer.clearChanged();
                    newValueItem = slaveServer;
                } else if (obj instanceof PartitionSchema) {
                    PartitionSchema partitionSchema = (PartitionSchema) ((PartitionSchema) obj).clone();
                    partitionSchema.setObjectId(((PartitionSchema) obj).getObjectId());
                    partitionSchema.clearChanged();
                    newValueItem = partitionSchema;
                } else if (obj instanceof ClusterSchema) {
                    ClusterSchema clusterSchema = ((ClusterSchema) obj).clone();
                    clusterSchema.setObjectId(((ClusterSchema) obj).getObjectId());
                    clusterSchema.clearChanged();
                    newValueItem = clusterSchema;
                } else {
                    throw new KettleException("unknown shared object class");
                }
                newValue.add(newValueItem);
            }
            copy.put(type, newValue);
        }
    } finally {
        sharedObjectsLock.writeLock().unlock();
    }
    return copy;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ArrayList(java.util.ArrayList) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) ArrayList(java.util.ArrayList) List(java.util.List) SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface) EnumMap(java.util.EnumMap) 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