/** * Main method test of single update for IP deployment time example * * @param url Database JDBC URL to connect with * @param username Database username * @param password Database password * @param providerId ID of example provider * @param serviceId ID of example service * @throws InitialisationException thrown on failure to initialise class due to invalid input * parameters */ private static void singleUpdateIpDeployment( String url, String username, String password, String providerId, String serviceId) throws InitialisationException { // The risk value to set in this example final double riskValue = 1.0; // GRAPHTYPE_IP_DEPLOYMENT_SLA_RISKLEVEL RiskPropagator riskPropagator = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_IP, RiskPropagator.SERVICEPHASE_DEPLOYMENT, providerId, serviceId, RiskPropagator.GRAPHTYPE_IP_DEPLOYMENT_SLA_RISKLEVEL); riskPropagator.setRiskValue(riskValue); riskPropagator.addRiskValue(); }
/** * Main method test of continuous update for SP operation time example * * @param url Database JDBC URL to connect with * @param username Database username * @param password Database password * @param providerId ID of example provider * @param serviceId ID of example service * @throws InitialisationException thrown on failure to initialise class due to invalid input * parameters */ private static void continuousUpdateSpOperation( String url, String username, String password, String providerId, String serviceId) throws InitialisationException { // The risk values to set in this example final double initialRiskValue = 1.0; final double newRiskValueOne = 1.1; // GRAPHTYPE_SP_OPERATION_SLA_RISKLEVEL RiskPropagator riskPropagator = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_SP, RiskPropagator.SERVICEPHASE_OPERATION, providerId, serviceId, RiskPropagator.GRAPHTYPE_SP_OPERATION_SLA_RISKLEVEL); // Initial value we want to save riskPropagator.setRiskValue(initialRiskValue); // Check to see riskPropagatorOne is running (i.e this would be used // in a while loop to start the riskPropagator instance once only // instead of duplicating code outside the while loop to set the // first risk value) if (!riskPropagator.isExecuting()) { // Start up the thread committing the initial value to the // database riskPropagator.start(); } try { // Let the riskPropagator commit this value some more Thread.sleep(THREAD_SLEEP_LONG); // New value we want to set some time later riskPropagator.setRiskValue(newRiskValueOne); Thread.sleep(THREAD_SLEEP_LONG); // Check to see if the thread is still running before we try to kill // it if (riskPropagator.isExecuting()) { // Stop the thread from committing values to the database riskPropagator.kill(); } } catch (InterruptedException e) { LOGGER.error("RiskPropagator Test: Thread interrupted", e); return; } }
/** * Main method test of continuous update for IP operation time example * * @param url Database JDBC URL to connect with * @param username Database username * @param password Database password * @param providerId ID of example provider * @param serviceId ID of example service * @throws InitialisationException thrown on failure to initialise class due to invalid input * parameters */ private static void continuousUpdateIpOperation( String url, String username, String password, String providerId, String serviceId) throws InitialisationException { /** NOTE: See continuousUpdateSpOperation() for detailed explanation of code and annotations. */ // The risk values to set in this example final double initialRiskValue = 1.0; final double newRiskValueOne = 1.1; final double newRiskValueTwo = 1.2; final double newRiskValueThree = 1.3; final double newRiskValueFour = 1.4; // Concurrently add values for: // GRAPHTYPE_IP_OPERATION_PHYSICAL_HOST_RISKLEVEL // GRAPHTYPE_IP_OPERATION_VIRTUAL_MACHINE_RISKLEVEL // GRAPHTYPE_IP_OPERATION_SLA_RISKLEVEL // GRAPHTYPE_IP_OPERATION_TOTAL_RISKLEVEL RiskPropagator riskPropagatorOne = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_IP, RiskPropagator.SERVICEPHASE_OPERATION, providerId, serviceId, RiskPropagator.GRAPHTYPE_IP_OPERATION_PHYSICAL_HOST_RISKLEVEL); riskPropagatorOne.setRiskValue(initialRiskValue); RiskPropagator riskPropagatorTwo = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_IP, RiskPropagator.SERVICEPHASE_OPERATION, providerId, serviceId, RiskPropagator.GRAPHTYPE_IP_OPERATION_VIRTUAL_MACHINE_RISKLEVEL); riskPropagatorTwo.setRiskValue(initialRiskValue); RiskPropagator riskPropagatorThree = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_IP, RiskPropagator.SERVICEPHASE_OPERATION, providerId, serviceId, RiskPropagator.GRAPHTYPE_IP_OPERATION_SLA_RISKLEVEL); riskPropagatorThree.setRiskValue(initialRiskValue); RiskPropagator riskPropagatorFour = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_IP, RiskPropagator.SERVICEPHASE_OPERATION, providerId, serviceId, RiskPropagator.GRAPHTYPE_IP_OPERATION_TOTAL_RISKLEVEL); riskPropagatorFour.setRiskValue(initialRiskValue); if (!riskPropagatorOne.isExecuting()) { riskPropagatorOne.start(); } if (!riskPropagatorTwo.isExecuting()) { riskPropagatorTwo.start(); } if (!riskPropagatorThree.isExecuting()) { riskPropagatorThree.start(); } if (!riskPropagatorFour.isExecuting()) { riskPropagatorFour.start(); } try { Thread.sleep(THREAD_SLEEP_LONG); riskPropagatorOne.setRiskValue(newRiskValueOne); riskPropagatorTwo.setRiskValue(newRiskValueTwo); riskPropagatorThree.setRiskValue(newRiskValueThree); riskPropagatorFour.setRiskValue(newRiskValueFour); Thread.sleep(THREAD_SLEEP_LONG); if (riskPropagatorOne.isExecuting()) { riskPropagatorOne.kill(); } if (riskPropagatorTwo.isExecuting()) { riskPropagatorTwo.kill(); } if (riskPropagatorThree.isExecuting()) { riskPropagatorThree.kill(); } if (riskPropagatorFour.isExecuting()) { riskPropagatorFour.kill(); } } catch (InterruptedException e) { LOGGER.error("RiskPropagator Test: Thread interrupted", e); return; } }
/** * Main method test of single update for SP deployment time example * * @param url Database JDBC URL to connect with * @param username Database username * @param password Database password * @param providerIdOne ID of first example provider * @param serviceIdOne ID of first example service * @param providerIdTwo ID of second example provider * @param serviceIdTwo ID of second example service * @throws InitialisationException thrown on failure to initialise class due to invalid input * parameters */ private static void singleUpdateSpDeployment( String url, String username, String password, String providerIdOne, String serviceIdOne, String providerIdTwo, String serviceIdTwo) throws InitialisationException { // The risk value to set in this example final double riskValue = 1.0; // Test with an EXISTING provider and service ID // GRAPHTYPE_SP_DEPLOYMENT_RELATIVE_IP_SLA_RISKLEVEL RiskPropagator riskPropagator; riskPropagator = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_SP, RiskPropagator.SERVICEPHASE_DEPLOYMENT, // Test with an existing provider ID providerIdOne, // Test with an existing service ID serviceIdOne, RiskPropagator.GRAPHTYPE_SP_DEPLOYMENT_RELATIVE_IP_SLA_RISKLEVEL); // Set the value we want to save riskPropagator.setRiskValue(riskValue); // Commit the value to the database riskPropagator.addRiskValue(); // Test with an NON-EXISTENT provider and service ID // GRAPHTYPE_SP_DEPLOYMENT_RELATIVE_IP_SLA_RISKLEVEL riskPropagator = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_SP, RiskPropagator.SERVICEPHASE_DEPLOYMENT, // Test with an non-existent provider ID providerIdTwo, // Test with an non-existent service ID serviceIdTwo, RiskPropagator.GRAPHTYPE_SP_DEPLOYMENT_RELATIVE_IP_SLA_RISKLEVEL); // Set the value we want to save riskPropagator.setRiskValue(riskValue); // Commit the value to the database riskPropagator.addRiskValue(); // GRAPHTYPE_SP_DEPLOYMENT_NORMALISED_SLA_RISKLEVEL riskPropagator = new RiskPropagator( url, username, password, RiskPropagator.PROVIDERTYPE_SP, RiskPropagator.SERVICEPHASE_DEPLOYMENT, providerIdTwo, serviceIdTwo, RiskPropagator.GRAPHTYPE_SP_DEPLOYMENT_NORMALISED_SLA_RISKLEVEL); riskPropagator.setRiskValue(riskValue); riskPropagator.addRiskValue(); }