Java Code Examples for org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager#restartGracefully()

The following examples show how to use org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager#restartGracefully() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XssCsrfSkipPatternsTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Configures ESB as required for the test case.
 *
 * @throws Exception if an error occurs while configuring ESB
 */
private void changeESBConfiguration() throws Exception {

    String carbonHome = CarbonUtils.getCarbonHome();
    carbonXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "carbon.xml");
    File configuredCarbonXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "carbon-security.xml");

    catalinaXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "tomcat"
            + File.separator + "catalina-server.xml");

    File configuredCatalinaXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "catalina-server-security.xml");

    scm = new ServerConfigurationManager(context);
    scm.applyConfigurationWithoutRestart(configuredCarbonXML, carbonXML, true);
    scm.applyConfigurationWithoutRestart(configuredCatalinaXML, catalinaXML, true);
    scm.restartGracefully();
    super.init();
}
 
Example 2
Source File: XssCsrfSkipPatternsTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Resets the configuration changes done to what was there before.
 *
 * @throws Exception if an error occurs while applying previous configurations
 */
private void resetESBConfiguration() throws Exception {

    String carbonHome = CarbonUtils.getCarbonHome();
    carbonXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "carbon.xml");
    File configuredCarbonXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "carbon-default.xml");

    catalinaXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "tomcat"
            + File.separator + "catalina-server.xml");
    File configuredCatalinaXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "catalina-server-default.xml");

    scm = new ServerConfigurationManager(context);
    scm.applyConfigurationWithoutRestart(configuredCarbonXML, carbonXML, true);
    scm.applyConfigurationWithoutRestart(configuredCatalinaXML, catalinaXML, true);
    scm.restartGracefully();
}
 
Example 3
Source File: StormManagerServiceTestCase.java    From product-cep with Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    log.info("Initializing CEP server to act as storm manager");

    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    serverConfigManager = new ServerConfigurationManager(cepServer);

    log.info("Replacing " + EVENT_PROCESSING_FILE);
    String eventProcessingFileLocation = RESOURCE_LOCATION + File.separator + EVENT_PROCESSING_FILE;
    String cepEventProcessorFileLocation = CARBON_HOME + File.separator + "repository" + File.separator
            + "conf" + File.separator + EVENT_PROCESSING_FILE;
    serverConfigManager.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation), new File(cepEventProcessorFileLocation), true);

    log.info("Replacing " + AXIS2_XML_FILE);
    String axis2FileLocation = RESOURCE_LOCATION + File.separator + AXIS2_XML_FILE;
    String cepAxis2FileLocation = CARBON_HOME + File.separator + "repository" + File.separator + "conf"
            + File.separator + "axis2" + File.separator + AXIS2_XML_FILE;
    serverConfigManager.applyConfigurationWithoutRestart(new File(axis2FileLocation), new File(cepAxis2FileLocation), true);

    log.info("Restarting CEP server");
    serverConfigManager.restartGracefully();
    // Waiting for the server to restart
    Thread.sleep(5000);

    log.info("Initialization completed");
}
 
Example 4
Source File: DAS561TestCase.java    From product-cep with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    cepServer = new AutomationContext("CEP", "cep002", TestUserMode.SUPER_TENANT_ADMIN);
    server = new CarbonTestServerManager(cepServer, 801);
    ServerConfigurationManager serverConfigManager1 = new ServerConfigurationManager(cepServer);
    manager.startServers(server);
    String CARBON_HOME = server.getCarbonHome();

    String outputEventAdapterConfFileLocation = RESOURCE_LOCATION1 + File.separator +
            OUTPUT_EVENT_ADAPTER_CONF_FILE;
    String cepoutputEventAdapterConfFileLocation = CARBON_HOME + File.separator + "repository" + File.separator
            + "conf" + File.separator + OUTPUT_EVENT_ADAPTER_CONF_FILE;
    serverConfigManager1.applyConfigurationWithoutRestart(new File(outputEventAdapterConfFileLocation),
            new File(cepoutputEventAdapterConfFileLocation), true);

    log.info("Restarting CEP server");
    serverConfigManager1.restartGracefully();
    Thread.sleep(5000);

    String backendURL = cepServer.getContextUrls().getBackEndUrl();
    String loggedInSessionCookie = getSessionCookie(cepServer);
    eventStreamManagerAdminServiceClient = configurationUtil
            .getEventStreamManagerAdminServiceClient(backendURL, loggedInSessionCookie);
    eventPublisherAdminServiceClient = configurationUtil
            .getEventPublisherAdminServiceClient(backendURL, loggedInSessionCookie);
    eventSimulatorAdminServiceClient = configurationUtil
            .getEventSimulatorAdminServiceClient(backendURL, loggedInSessionCookie);

    NDataSourceAdminServiceClient dataSourceAdminService =
            new NDataSourceAdminServiceClient(backendURL, loggedInSessionCookie);
    WSDataSourceMetaInfo dataSourceInfo = getDataSourceInformation("WSO2CEP_DB");
    dataSourceAdminService.addDataSource(dataSourceInfo);
}
 
Example 5
Source File: RegistryConfiguratorTestCase.java    From product-es with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.greg")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
public void testSetupServerEnvironment() throws Exception {

    copyResources();
    copyJarFiles();
    editConfigurationFiles();
    updateRegistry();
    addResourceFileToRegistry();
    ServerConfigurationManager serverConfigurationManager =
            new ServerConfigurationManager(automationContext);
    serverConfigurationManager.restartGracefully();
    Thread.sleep(12000);

}
 
Example 6
Source File: RegistryConfiguratorTestCase.java    From product-es with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.greg")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
public void testSetupServerEnvironment() throws Exception {

    copyResources();
    copyJarFiles();
    editConfigurationFiles();
    updateRegistry();
    addResourceFileToRegistry();
    ServerConfigurationManager serverConfigurationManager =
            new ServerConfigurationManager(automationContext);
    serverConfigurationManager.restartGracefully();
    Thread.sleep(12000);

}
 
Example 7
Source File: CEPIntegrationTest.java    From product-cep with Apache License 2.0 4 votes vote down vote up
protected void gracefullyRestartServer() throws Exception {
    ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(cepServer);
    serverConfigurationManager.restartGracefully();
}
 
Example 8
Source File: HATestCase.java    From product-cep with Apache License 2.0 4 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    machineIP = findAddress("localhost");
    cepServer1 = new AutomationContext("CEP", "cep002", TestUserMode.SUPER_TENANT_ADMIN);
    cepServer2 = new AutomationContext("CEP", "cep003", TestUserMode.SUPER_TENANT_ADMIN);
    server1 = new CarbonTestServerManager(cepServer1, 801);
    server2 = new CarbonTestServerManager(cepServer2, 802);
    ServerConfigurationManager serverConfigManager1 = new ServerConfigurationManager(cepServer1);
    ServerConfigurationManager serverConfigManager2 = new ServerConfigurationManager(cepServer2);
    manager.startServers(server1, server2);
    String CARBON_HOME1 = server1.getCarbonHome();
    String CARBON_HOME2 = server2.getCarbonHome();

    String eventProcessingFileLocation = RESOURCE_LOCATION1 + File.separator + EVENT_PROCESSING_FILE;
    String cepEventProcessorFileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator
            + "conf" + File.separator + EVENT_PROCESSING_FILE;
    serverConfigManager1.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation), new File(cepEventProcessorFileLocation), true);
    replaceIP(cepEventProcessorFileLocation);
    String axis2FileLocation = RESOURCE_LOCATION1 + File.separator + AXIS2_XML_FILE;
    String cepAxis2FileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf"
            + File.separator + "axis2" + File.separator + AXIS2_XML_FILE;
    serverConfigManager1.applyConfigurationWithoutRestart(new File(axis2FileLocation), new File(cepAxis2FileLocation), true);
    replaceIP(cepAxis2FileLocation);

    log.info("Restarting CEP server1");
    serverConfigManager1.restartGracefully();
    // Waiting for the server to restart
    Thread.sleep(5000);

    String eventProcessingFileLocation2 = RESOURCE_LOCATION2 + File.separator + EVENT_PROCESSING_FILE;
    String cepEventProcessorFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator
            + "conf" + File.separator + EVENT_PROCESSING_FILE;
    serverConfigManager2.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation2), new File(cepEventProcessorFileLocation2), true);
    replaceIP(cepEventProcessorFileLocation2);
    String axis2FileLocation2 = RESOURCE_LOCATION2 + File.separator + AXIS2_XML_FILE;
    String cepAxis2FileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf"
            + File.separator + "axis2" + File.separator + AXIS2_XML_FILE;
    serverConfigManager2.applyConfigurationWithoutRestart(new File(axis2FileLocation2), new File(cepAxis2FileLocation2), true);
    replaceIP(cepAxis2FileLocation2);

    serverConfigManager2.restartGracefully();
    // Waiting for the server to restart
    Thread.sleep(5000);

    String backendURL1 = cepServer1.getContextUrls().getBackEndUrl();
    String loggedInSessionCookie = getSessionCookie(cepServer1);
    eventReceiverAdminServiceClient1 = configurationUtil.getEventReceiverAdminServiceClient(backendURL1, loggedInSessionCookie);
    eventStreamManagerAdminServiceClient1 = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL1, loggedInSessionCookie);
    eventPublisherAdminServiceClient1 = configurationUtil.getEventPublisherAdminServiceClient(backendURL1, loggedInSessionCookie);
    String backendURL2 = cepServer2.getContextUrls().getBackEndUrl();
    String loggedInSessionCookie2 = getSessionCookie(cepServer2);
    eventReceiverAdminServiceClient2 = configurationUtil.getEventReceiverAdminServiceClient(backendURL2, loggedInSessionCookie2);
    eventStreamManagerAdminServiceClient2 = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL2, loggedInSessionCookie2);
    eventPublisherAdminServiceClient2 = configurationUtil.getEventPublisherAdminServiceClient(backendURL2, loggedInSessionCookie2);
}
 
Example 9
Source File: MBIntegrationBaseTest.java    From product-ei with Apache License 2.0 2 votes vote down vote up
/**
 * Gracefully restart the current server which was deployed by the test suit. This can be used when a large
 * amount or large size of messages are tested to clean up the server before or after the test.
 *
 * @throws Exception
 */
protected void restartServer()
        throws Exception {
    serverManager = new ServerConfigurationManager(automationContext);
    serverManager.restartGracefully();
}