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);
}
}
}
}
}
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;
}
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;
}
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();
}
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();
}
Aggregations