Search in sources :

Example 36 with SlaveServer

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

the class JobDelegate method readSlaves.

/**
 * Add the slave servers in the repository to this job if they are not yet present.
 *
 * @param JobMeta
 *          The job to load into.
 * @param overWriteShared
 *          if an object with the same name exists, overwrite
 */
protected void readSlaves(JobMeta jobMeta, boolean overWriteShared, List<SlaveServer> slaveServers) {
    for (SlaveServer slaveServer : slaveServers) {
        if (overWriteShared || jobMeta.findSlaveServer(slaveServer.getName()) == null) {
            if (!Utils.isEmpty(slaveServer.getName())) {
                slaveServer.shareVariablesWith(jobMeta);
                jobMeta.addOrReplaceSlaveServer(slaveServer);
                if (!overWriteShared) {
                    slaveServer.setChanged(false);
                }
            }
        }
    }
}
Also used : SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 37 with SlaveServer

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

the class SlaveDelegate method elementToDataNode.

public DataNode elementToDataNode(RepositoryElementInterface element) throws KettleException {
    SlaveServer slaveServer = (SlaveServer) element;
    DataNode rootNode = new DataNode(NODE_ROOT);
    /*
     * // Check for naming collision ObjectId slaveId = repo.getSlaveID(slaveServer.getName()); if (slaveId != null &&
     * slaveServer.getObjectId()!=null && !slaveServer.getObjectId().equals(slaveId)) { // We have a naming collision,
     * abort the save throw new KettleException("Failed to save object to repository. Object [" + slaveServer.getName()
     * + "] already exists."); }
     */
    // Create or version a new slave node
    // 
    rootNode.setProperty(PROP_HOST_NAME, slaveServer.getHostname());
    rootNode.setProperty(PROP_PORT, slaveServer.getPort());
    rootNode.setProperty(PROP_WEBAPP_NAME, slaveServer.getWebAppName());
    rootNode.setProperty(PROP_USERNAME, slaveServer.getUsername());
    rootNode.setProperty(PROP_PASSWORD, Encr.encryptPasswordIfNotUsingVariables(slaveServer.getPassword()));
    rootNode.setProperty(PROP_PROXY_HOST_NAME, slaveServer.getProxyHostname());
    rootNode.setProperty(PROP_PROXY_PORT, slaveServer.getProxyPort());
    rootNode.setProperty(PROP_NON_PROXY_HOSTS, slaveServer.getNonProxyHosts());
    rootNode.setProperty(PROP_MASTER, slaveServer.isMaster());
    return rootNode;
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 38 with SlaveServer

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

the class SlaveDelegate method dataNodeToElement.

public RepositoryElementInterface dataNodeToElement(DataNode rootNode) throws KettleException {
    SlaveServer slaveServer = new SlaveServer();
    dataNodeToElement(rootNode, slaveServer);
    return slaveServer;
}
Also used : SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 39 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer 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 40 with SlaveServer

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

the class CarteTest method test.

// this test isn't consistent/doesn't work.
@Ignore
@Test
public void test() throws Exception {
    CountDownLatch latch = new CountDownLatch(1);
    System.setProperty(Const.KETTLE_SLAVE_DETECTION_TIMER, "100");
    SlaveServer master = new SlaveServer();
    master.setHostname("127.0.0.1");
    master.setPort("9000");
    master.setUsername("cluster");
    master.setPassword("cluster");
    master.setMaster(true);
    SlaveServerConfig config = new SlaveServerConfig();
    config.setSlaveServer(master);
    Carte carte = new Carte(config);
    SlaveServerDetection slaveServerDetection = mock(SlaveServerDetection.class);
    carte.getWebServer().getDetections().add(slaveServerDetection);
    SlaveServer slaveServer = mock(SlaveServer.class, RETURNS_MOCKS);
    when(slaveServerDetection.getSlaveServer()).thenReturn(slaveServer);
    when(slaveServer.getStatus()).thenAnswer(new Answer<SlaveServerStatus>() {

        @Override
        public SlaveServerStatus answer(InvocationOnMock invocation) throws Throwable {
            SlaveServerDetection anotherDetection = mock(SlaveServerDetection.class);
            carte.getWebServer().getDetections().add(anotherDetection);
            latch.countDown();
            return new SlaveServerStatus();
        }
    });
    latch.await(10, TimeUnit.SECONDS);
    assertEquals(carte.getWebServer().getDetections().size(), 2);
    carte.getWebServer().stopServer();
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) CountDownLatch(java.util.concurrent.CountDownLatch) SlaveServer(org.pentaho.di.cluster.SlaveServer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

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