Search in sources :

Example 1 with Service

use of org.iobserve.simulate.petstore.data.Service in project iobserve-analysis by research-iobserve.

the class SimulatePetStoreMain method createModel.

private static SimulationModel createModel(final Settings configuration) {
    final SimulationModel model = new SimulationModel(configuration.getDelay(), configuration.getLocations(), configuration.getIterations());
    final Random random = new Random();
    model.getServices().add(new Service("jpetstore-account-database", SimulatePetStoreMain.createIP(0), ISOCountryCode.GERMANY));
    model.getServices().add(new Service("jpetstore-catalog-database", SimulatePetStoreMain.createIP(1), ISOCountryCode.GERMANY));
    model.getServices().add(new Service("jpetstore-order-database", SimulatePetStoreMain.createIP(2), ISOCountryCode.GERMANY));
    model.getServices().add(new Service("jpetstore-order-service", SimulatePetStoreMain.createIP(3), ISOCountryCode.GERMANY));
    model.getServices().add(new Service("jpetstore-catalog-service", SimulatePetStoreMain.createIP(4), ISOCountryCode.GERMANY));
    model.getServices().add(new Service("jpetstore-frontend-service", SimulatePetStoreMain.createIP(5), ISOCountryCode.GERMANY));
    for (int i = 0; i < configuration.getAccounting(); i++) {
        final ISOCountryCode countryCode = configuration.getLocations().get(random.nextInt(configuration.getLocations().size()));
        model.getServices().add(new Service("jpetstore-account-service", SimulatePetStoreMain.createIP(i + 6), countryCode));
    }
    return model;
}
Also used : Random(java.util.Random) ISOCountryCode(org.iobserve.common.record.ISOCountryCode) Service(org.iobserve.simulate.petstore.data.Service) SimulationModel(org.iobserve.simulate.petstore.data.SimulationModel)

Example 2 with Service

use of org.iobserve.simulate.petstore.data.Service in project iobserve-analysis by research-iobserve.

the class SimulatePetStoreMain method executeModel.

private static void executeModel(final SimulationModel model, final Settings configuration) throws InterruptedException {
    // initial deploy all.
    SimulatePetStoreMain.LOGGER.info("Initial deployment");
    for (final Service service : model.getServices()) {
        SimulatePetStoreMain.createDeployEvent(service);
        Thread.sleep(model.getMigrationDelay());
    }
    final Random random = new Random();
    // alternate deployments.
    int logFrameLength = model.getIterations() / 100;
    if (logFrameLength < 100) {
        logFrameLength = 100;
    }
    for (int i = 0; i < model.getIterations(); i++) {
        if (i % logFrameLength == 0) {
            SimulatePetStoreMain.LOGGER.info("Iterating migrations {}", i);
        }
        final int serviceNumber = random.nextInt(configuration.getAccounting()) + 6;
        final Service service = model.getServices().get(serviceNumber);
        SimulatePetStoreMain.createUndeployEvent(service);
        service.setCountry(configuration.getLocations().get(random.nextInt(configuration.getLocations().size())));
        SimulatePetStoreMain.createDeployEvent(service);
        Thread.sleep(model.getMigrationDelay());
    }
    SimulatePetStoreMain.LOGGER.info("Scenario complete.");
}
Also used : Random(java.util.Random) Service(org.iobserve.simulate.petstore.data.Service)

Aggregations

Random (java.util.Random)2 Service (org.iobserve.simulate.petstore.data.Service)2 ISOCountryCode (org.iobserve.common.record.ISOCountryCode)1 SimulationModel (org.iobserve.simulate.petstore.data.SimulationModel)1