Search in sources :

Example 1 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pdi-platform-plugin by pentaho.

the class KettleSystemListener method startup.

public boolean startup(final IPentahoSession session) {
    if (usePlatformLogFile) {
        initLogging();
    }
    hookInDataSourceProvider();
    try {
        KettleSystemListener.environmentInit(session);
    } catch (Throwable t) {
        t.printStackTrace();
        Logger.error(KettleSystemListener.class.getName(), Messages.getInstance().getErrorString(// $NON-NLS-1$
        "KettleSystemListener.ERROR_0001_PLUGIN_LOAD_FAILED"));
    }
    try {
        String slaveServerConfigFilename = "system" + File.separator + "kettle" + File.separator + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "slave-server-config.xml";
        File slaveServerConfigFile = new File(PentahoSystem.getApplicationContext().getSolutionPath(slaveServerConfigFilename));
        if (slaveServerConfigFile.exists()) {
            InputStream is = new FileInputStream(slaveServerConfigFile);
            DocumentBuilderFactory factory = XMLParserFactoryProducer.createSecureDocBuilderFactory();
            Document document = factory.newDocumentBuilder().parse(is);
            Node configNode = XMLHandler.getSubNode(document, SlaveServerConfig.XML_TAG);
            SlaveServerConfig config = new SlaveServerConfig(new LogChannel("Slave server config"), configNode);
            config.setFilename(slaveServerConfigFilename);
            SlaveServer slaveServer = new SlaveServer();
            config.setSlaveServer(slaveServer);
            CarteSingleton.setSlaveServerConfig(config);
        }
    } catch (Throwable t) {
        t.printStackTrace();
        Logger.error(KettleSystemListener.class.getName(), t.getMessage());
    }
    return true;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) LogChannel(org.pentaho.di.core.logging.LogChannel) Document(org.w3c.dom.Document) SlaveServerConfig(org.pentaho.di.www.SlaveServerConfig) SlaveServer(org.pentaho.di.cluster.SlaveServer) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class AbstractMeta method loadSharedObject.

protected boolean loadSharedObject(SharedObjectInterface object) {
    if (object instanceof DatabaseMeta) {
        DatabaseMeta databaseMeta = (DatabaseMeta) object;
        databaseMeta.shareVariablesWith(this);
        addOrReplaceDatabase(databaseMeta);
    } else if (object instanceof SlaveServer) {
        SlaveServer slaveServer = (SlaveServer) object;
        slaveServer.shareVariablesWith(this);
        addOrReplaceSlaveServer(slaveServer);
    } else {
        return false;
    }
    return true;
}
Also used : SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 3 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class RepositoryImporter method loadSharedObjects.

/**
 * Load the shared objects up front, replace them in the xforms/jobs loaded from XML. We do this for performance
 * reasons.
 *
 * @throws KettleException
 */
protected void loadSharedObjects() throws KettleException {
    sharedObjects = new SharedObjects();
    for (ObjectId id : rep.getDatabaseIDs(false)) {
        DatabaseMeta databaseMeta = rep.loadDatabaseMeta(id, null);
        validateImportedElement(importRules, databaseMeta);
        sharedObjects.storeObject(databaseMeta);
    }
    ObjectId[] slaveIDs = rep.getSlaveIDs(false);
    List<SlaveServer> slaveServers = new ArrayList<SlaveServer>(slaveIDs.length);
    for (ObjectId id : slaveIDs) {
        SlaveServer slaveServer = rep.loadSlaveServer(id, null);
        validateImportedElement(importRules, slaveServer);
        sharedObjects.storeObject(slaveServer);
        slaveServers.add(slaveServer);
    }
    for (ObjectId id : rep.getClusterIDs(false)) {
        ClusterSchema clusterSchema = rep.loadClusterSchema(id, slaveServers, null);
        validateImportedElement(importRules, clusterSchema);
        sharedObjects.storeObject(clusterSchema);
    }
    for (ObjectId id : rep.getPartitionSchemaIDs(false)) {
        PartitionSchema partitionSchema = rep.loadPartitionSchema(id, null);
        validateImportedElement(importRules, partitionSchema);
        sharedObjects.storeObject(partitionSchema);
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) ArrayList(java.util.ArrayList) 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)

Example 4 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository method getSlaveServers.

/**
 * @return a list of all the slave servers in the repository.
 * @throws KettleException
 */
public List<SlaveServer> getSlaveServers() throws KettleException {
    List<SlaveServer> list = new ArrayList<>();
    ObjectId[] slaveIDs = getSlaveIDs(false);
    for (int i = 0; i < slaveIDs.length; i++) {
        // Load last
        SlaveServer slaveServer = loadSlaveServer(slaveIDs[i], null);
        // version
        list.add(slaveServer);
    }
    return list;
}
Also used : LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) SlaveServer(org.pentaho.di.cluster.SlaveServer) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 5 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryClusterSchemaDelegate method loadClusterSchema.

public ClusterSchema loadClusterSchema(ObjectId id_cluster_schema, List<SlaveServer> slaveServers) throws KettleException {
    ClusterSchema clusterSchema = new ClusterSchema();
    RowMetaAndData row = getClusterSchema(id_cluster_schema);
    clusterSchema.setObjectId(id_cluster_schema);
    clusterSchema.setName(row.getString(KettleDatabaseRepository.FIELD_CLUSTER_NAME, null));
    clusterSchema.setBasePort(row.getString(KettleDatabaseRepository.FIELD_CLUSTER_BASE_PORT, null));
    clusterSchema.setSocketsBufferSize(row.getString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_BUFFER_SIZE, null));
    clusterSchema.setSocketsFlushInterval(row.getString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_FLUSH_INTERVAL, null));
    clusterSchema.setSocketsCompressed(row.getBoolean(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_COMPRESSED, true));
    clusterSchema.setDynamic(row.getBoolean(KettleDatabaseRepository.FIELD_CLUSTER_DYNAMIC, true));
    ObjectId[] pids = repository.getClusterSlaveIDs(id_cluster_schema);
    for (int i = 0; i < pids.length; i++) {
        // Load last version
        SlaveServer slaveServer = repository.loadSlaveServer(pids[i], null);
        SlaveServer reference = SlaveServer.findSlaveServer(slaveServers, slaveServer.getName());
        if (reference != null) {
            clusterSchema.getSlaveServers().add(reference);
        } else {
            clusterSchema.getSlaveServers().add(slaveServer);
        }
    }
    return clusterSchema;
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ObjectId(org.pentaho.di.repository.ObjectId) SlaveServer(org.pentaho.di.cluster.SlaveServer) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Aggregations

SlaveServer (org.pentaho.di.cluster.SlaveServer)110 KettleException (org.pentaho.di.core.exception.KettleException)35 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)32 Test (org.junit.Test)22 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)22 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)18 PartitionSchema (org.pentaho.di.partition.PartitionSchema)18 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 JobMeta (org.pentaho.di.job.JobMeta)16 ObjectId (org.pentaho.di.repository.ObjectId)16 StepMeta (org.pentaho.di.trans.step.StepMeta)14 ArrayList (java.util.ArrayList)13 TransMeta (org.pentaho.di.trans.TransMeta)11 Result (org.pentaho.di.core.Result)10 KettleFileException (org.pentaho.di.core.exception.KettleFileException)10 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)10 NotePadMeta (org.pentaho.di.core.NotePadMeta)9 Point (org.pentaho.di.core.gui.Point)8 List (java.util.List)7 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)7