/** * Configures this instance from the given configuration service. */ public void configure (ServerConfiguration configSource) { serverConfiguration = configSource; configSource.configureMe(this); }
/** * Computes actual distribution and balancing costs by random selection */ @Override public String initialize (Competition competition, List<String> completedInits) { super.init(); balancingCost = null; serverProps.configureMe(this); if (null == balancingCost) balancingCost = 0D; log.info("Configured BM: balancing cost = " + balancingCost + ", (pPlus',pMinus') = (" + pPlusPrime + "," + pMinusPrime + ")"); serverProps.publishConfiguration(this); return "BalancingMarket"; }
/** * Saves state of EvCustomer instances */ @Override public void saveBootstrapState () { service.getServerConfiguration().saveBootstrapState(evCustomers); }
return; serverConfiguration.configureMe(this); structures = new HashMap<>(); try { clazz = Class.forName("org.powertac.factoredcustomer." + classname); Collection<?> list = serverConfiguration.configureInstances(clazz); if (list == null) { structures.put(classname, new HashMap<>());
/** * Retrieves the list of configured beans */ public Map<String, Collection<?>> getBeans () { if (null != beans) { // already configured return beans; } configure(); beans = new HashMap<>(); for (String classname : beanTypes) { Class<?> clazz; try { clazz = Class.forName("org.powertac.evcustomer.beans." + classname); Collection<?> list = serverConfiguration.configureInstances(clazz); beans.put(classname, list); log.info("Loaded " + list.size() + " instances of " + classname); } catch (ClassNotFoundException e) { log.error("Cannot find class " + classname); } } return beans; }
int seedId = 0; serverConfig.configureMe(this); Collection<?> gencoColl = serverConfig.configureInstances(Genco.class); if (null != gencoColl) { for (Object gencoObj: gencoColl) { serverConfig.configureMe(buyer); brokerRepo.add(buyer); gencos.add(buyer); serverConfig.configureMe(cpGenco); cpGenco.init(brokerProxyService, seedId++, randomSeedRepo, timeslotRepo); brokerRepo.add(cpGenco); serverConfig.configureMe(misoBuyer); misoBuyer.init(brokerProxyService, seedId++, this); brokerRepo.add(misoBuyer);
/** * Retrieves the list of configured beans, given a package prefix and a list * of classnames in that package. The final argument should be an instance in * the module where the bean classes are found. This is where the classloader * comes from. */ public Map<String, Collection<?>> getBeans () { if (null != beans) // already configured return beans; configure(); beans = new HashMap<String, Collection<?>>(); for (String classname : beanTypes) { Class<?> clazz; try { clazz = Class.forName("org.powertac.customer.model." + classname); Collection<?> list = serverConfiguration.configureInstances(clazz); beans.put(classname, list); log.info("Loaded " + list.size() + " instances of " + classname); } catch (ClassNotFoundException e) { log.error("Cannot find class " + classname); } } return beans; }
@Override public String initialize (Competition competition, List<String> completedInits) { serverConfig.configureMe(this); if (remoteVisualizer) { // set up the output queue log.info("Remote visualizer on queue " + visualizerQueueName); jmsManagementService.createQueue(visualizerQueueName); } return "VisualizerProxy"; }
@Override public String initialize (Competition competition, List<String> completedInits) { incoming.clear(); serverProps.configureMe(this); brokerProxyService.registerBrokerMessageListener(this, Order.class); super.init(); serverProps.publishConfiguration(this); return "Auctioneer"; }
AbstractCustomer modelEx = modelIterator.next(); Collection<?> instances = serverConfig.configureInstances(modelEx.getClass()); for (Object modelObj: instances) { AbstractCustomer model = (AbstractCustomer) modelObj;
@Override public void saveBootstrapState () { serverConfig.saveBootstrapState(models); for (AbstractCustomer model : models) { // some models have to save local state model.saveBootstrapState(); } }
/** * Configures this singleton when it's needed. Not called during instance * creation to allow testing without a full Spring setup. */ public void configure () { if (null == serverConfiguration) { serverConfiguration = (ServerConfiguration) SpringApplicationContext.getBean("serverPropertiesService"); } if (null == serverConfiguration) { // should not happen outside of testing log.warn("Cannot find serverPropertiesService"); } else { serverConfiguration.configureMe(this); } }
@Override public String initialize (Competition competition, List<String> completedInits) { pendingTransactions.clear(); pendingMarketTransactions.clear(); super.init(); bankInterest = null; serverProps.configureMe(this); RandomSeed random = randomSeedService.getRandomSeed("AccountingService", 0l, "interest"); if (bankInterest == null) { // interest will be non-null in case it was overridden in the config bankInterest = (minInterest + (random.nextDouble() * (maxInterest - minInterest))); log.info("bank interest: " + bankInterest); } serverProps.publishConfiguration(this); return "AccountingService"; }
/** * Saves coefficients for the current timeslot in the form needed for * configuration at the start of the sim session, then adds them to the * bootstrap state. */ public void saveBootstrapState (ServerConfiguration serverConfig) { int horizon = timeslotCoefficients.length; int index = (timeslotRepo.currentSerialNumber() - ringOffset) % horizon; ArrayList<String> newCoeff = new ArrayList<String>(); for (Double coeff : timeslotCoefficients[index]) { newCoeff.add(coeff.toString()); } coefficients = newCoeff; serverConfig.saveBootstrapState(this); }
/** * Configures this singleton when it's needed. Not called during instance * creation to allow testing without a full Spring setup. This version is * Deprecated! Please use configure(ServerConfiguration) instead. */ @Deprecated public void configure () { if (null == serverConfiguration) { serverConfiguration = (ServerConfiguration) SpringApplicationContext.getBean("serverPropertiesService"); } if (null == serverConfiguration) { // should not happen outside of testing log.warn("Cannot find serverPropertiesService"); } else { serverConfiguration.configureMe(this); } }
distributionFee = null; serverProps.configureMe(this); log.info("Configured DU: distro fee = " + distributionFee); serverProps.publishConfiguration(this); return "DistributionUtility";
/** * Creates the instance and sets the reference to the timeService. */ public static void initialize (CompetitionControlService competitionControl, TimeService timeService) { instance = new SimulationClockControl(competitionControl, timeService); ServerConfiguration serverConfig = (ServerConfiguration) SpringApplicationContext.getBean("serverPropertiesService"); serverConfig.configureMe(instance); }
lastRevokeProcess = new Instant(0l); serverProps.configureMe(this); log.info("set revocation fee: " + revocationFee); serverProps.publishConfiguration(this); return "TariffMarket";
/** * This function called once at the beginning of each game by the server * initialization service. Here is where you do pre-game setup. This will read * the server properties file to take the competition input variables needed * (configuration files, days of competition), create a listener for our * service, in order to get the new tariff, as well as create the household * Consumers that will be running in the game. */ @Override public String initialize (Competition competition, List<String> completedInits) { if (!completedInits.contains("DefaultBroker") || !completedInits.contains("TariffMarket")) return null; super.init(); configuration = new Properties(); officeComplexList = new ArrayList<OfficeComplex>(); tariffMarketService.registerNewTariffListener(this); serverPropertiesService.configureMe(this); //tariffMarketService.registerNewTariffListener(this); if (configFile1 == null) { log.info("No Config File for OfficeComplexType1 Taken"); configFile1 = "OfficeComplexDefault.properties"; } addOfficeComplexes(configFile1, "1"); return "OfficeComplexCustomer"; }
/** * This function called once at the beginning of each game by the server * initialization service. Here is where you do pre-game setup. This will read * the server properties file to take the competition input variables needed * (configuration files, days of competition), create a listener for our * service, in order to get the new tariff, as well as create the household * Consumers that will be running in the game. */ @Override public String initialize (Competition competition, List<String> completedInits) { if (!completedInits.contains("DefaultBroker") || !completedInits.contains("TariffMarket")) return null; super.init(); tariffMarketService.registerNewTariffListener(this); configuration = new Properties(); villageList = new ArrayList<Village>(); serverPropertiesService.configureMe(this); if (configFile1 == null) { log.info("No Config File for VillageType1 Taken"); configFile1 = "VillageDefault.properties"; } addVillages(configFile1, "1"); return "HouseholdCustomer"; }