Search in sources :

Example 1 with SlaveServerConfig

use of org.pentaho.di.www.SlaveServerConfig 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 SlaveServerConfig

use of org.pentaho.di.www.SlaveServerConfig in project pentaho-metaverse by pentaho.

the class DIRepositoryLocator method getRepository.

/**
 * Returns the DI repository instance to use
 * @return DI repository instance
 * @throws Exception If the repository instance cannot be returned
 */
protected Repository getRepository() throws Exception {
    if (repository == null) {
        TransformationMap transformationMap = CarteSingleton.getInstance().getTransformationMap();
        SlaveServerConfig slaveServerConfig = transformationMap.getSlaveServerConfig();
        repository = slaveServerConfig.getRepository();
    }
    if (repository == null) {
        LOG.error(Messages.getErrorString("ERROR.RepositoryNotFoundInConfiguration"));
    }
    return repository;
}
Also used : TransformationMap(org.pentaho.di.www.TransformationMap) SlaveServerConfig(org.pentaho.di.www.SlaveServerConfig)

Example 3 with SlaveServerConfig

use of org.pentaho.di.www.SlaveServerConfig in project pentaho-platform by pentaho.

the class DIServerConfigTest method setup.

@Before
public void setup() throws Exception {
    IApplicationContext mockAppContext = mock(IApplicationContext.class);
    when(mockAppContext.getFullyQualifiedServerURL()).thenReturn(SERVER_URL);
    PentahoSystem.setApplicationContext(mockAppContext);
    IPentahoSession pentahoSession = mock(IPentahoSession.class);
    when(pentahoSession.getName()).thenReturn(MOCK_USER);
    PentahoSessionHolder.setSession(pentahoSession);
    baseConfig = new SlaveServerConfig();
    pluginRegistry = mock(PluginRegistry.class);
    purRepositoryMeta = mock(RepositoryMeta.class);
    purRepository = mock(Repository.class);
    purMetaStore = mock(IMetaStore.class);
    when(pluginRegistry.loadClass(RepositoryPluginType.class, DIServerConfig.PUR_REPOSITORY_PLUGIN_ID, Repository.class)).thenReturn(purRepository);
    when(pluginRegistry.loadClass(RepositoryPluginType.class, DIServerConfig.PUR_REPOSITORY_PLUGIN_ID, RepositoryMeta.class)).thenReturn(purRepositoryMeta);
    when(purRepository.getMetaStore()).thenReturn(purMetaStore);
    when(purMetaStore.getName()).thenReturn("Mock MetaStore");
    logChannel = mock(LogChannel.class);
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) Repository(org.pentaho.di.repository.Repository) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) LogChannel(org.pentaho.di.core.logging.LogChannel) IApplicationContext(org.pentaho.platform.api.engine.IApplicationContext) SlaveServerConfig(org.pentaho.di.www.SlaveServerConfig) IMetaStore(org.pentaho.metastore.api.IMetaStore) Before(org.junit.Before)

Example 4 with SlaveServerConfig

use of org.pentaho.di.www.SlaveServerConfig in project pentaho-platform by pentaho.

the class KettleSystemListener method startup.

public boolean startup(final IPentahoSession session) {
    // Default DI_HOME System Property if not set
    if (StringUtils.isEmpty(System.getProperty("DI_HOME"))) {
        String defaultKettleHomePath = PentahoSystem.getApplicationContext().getSolutionPath("system" + File.separator + "kettle");
        logger.error("DI_HOME System Property not properly set. The default location of " + defaultKettleHomePath + " will be used.");
        System.setProperty("DI_HOME", defaultKettleHomePath);
    }
    if (usePlatformLogFile) {
        KettleLogStore.init(false, false);
        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 = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "system" + File.separator + "kettle" + File.separator + "slave-server-config.xml";
        File slaveServerConfigFile = new File(PentahoSystem.getApplicationContext().getSolutionPath(slaveServerConfigFilename));
        if (slaveServerConfigFile.exists()) {
            InputStream is = new FileInputStream(slaveServerConfigFile);
            Node configNode = getSlaveServerConfigNode(is);
            SlaveServerConfig config = new DIServerConfig(new LogChannel("Slave server config"), configNode);
            config.setFilename(slaveServerConfigFile.getAbsolutePath());
            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 : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) LogChannel(org.pentaho.di.core.logging.LogChannel) SlaveServerConfig(org.pentaho.di.www.SlaveServerConfig) SlaveServer(org.pentaho.di.cluster.SlaveServer) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 5 with SlaveServerConfig

use of org.pentaho.di.www.SlaveServerConfig in project pentaho-kettle by pentaho.

the class CarteResource method getConfigDetails.

@GET
@Path("/configDetails")
@Produces({ MediaType.APPLICATION_JSON })
public List<NVPair> getConfigDetails() {
    SlaveServerConfig serverConfig = CarteSingleton.getInstance().getTransformationMap().getSlaveServerConfig();
    List<NVPair> list = new ArrayList<NVPair>();
    list.add(new NVPair("maxLogLines", "" + serverConfig.getMaxLogLines()));
    list.add(new NVPair("maxLogLinesAge", "" + serverConfig.getMaxLogTimeoutMinutes()));
    list.add(new NVPair("maxObjectsAge", "" + serverConfig.getObjectTimeoutMinutes()));
    list.add(new NVPair("configFile", "" + serverConfig.getFilename()));
    return list;
}
Also used : ArrayList(java.util.ArrayList) SlaveServerConfig(org.pentaho.di.www.SlaveServerConfig) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SlaveServerConfig (org.pentaho.di.www.SlaveServerConfig)7 File (java.io.File)4 LogChannel (org.pentaho.di.core.logging.LogChannel)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 SlaveServer (org.pentaho.di.cluster.SlaveServer)2 Database (org.pentaho.di.core.database.Database)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 SlaveSequence (org.pentaho.di.www.SlaveSequence)2 Node (org.w3c.dom.Node)2 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 Before (org.junit.Before)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 Repository (org.pentaho.di.repository.Repository)1 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)1 TransformationMap (org.pentaho.di.www.TransformationMap)1