@PostConstruct public void init() { predictionRelationships = new PredictionRelationships(); Set<Metric> predictedMetrics = getAllPredictedMetrics(); predictedMetrics.forEach( metric -> { CanonicalPath tenantCp = metric.getPath().getRoot(); CanonicalPath metricTypeCp = metric.getType().getPath(); CanonicalPath metricCp = metric.getPath(); Set<Subscription.SubscriptionOwner> subscriptionOwners = new HashSet<>(); CanonicalPath forecastingHorizonCp = null; if (predictionRelationships.relationships().get(tenantCp) != null) { subscriptionOwners.add(Subscription.SubscriptionOwner.Tenant); forecastingHorizonCp = tenantCp; } if (predictionRelationships.relationships().get(metricTypeCp) != null) { subscriptionOwners.add(Subscription.SubscriptionOwner.MetricType); forecastingHorizonCp = metricTypeCp; } if (predictionRelationships.relationships().get(metricCp) != null) { subscriptionOwners.add(Subscription.SubscriptionOwner.Metric); forecastingHorizonCp = metricCp; } final Long forecastingHorizon = InventoryUtil.parseForecastingHorizon( predictionRelationships.relationships().get(forecastingHorizonCp)); org.hawkular.datamining.api.model.Metric dataMMetric = InventoryUtil.convertMetric(metric, forecastingHorizon); final Subscription subscription = new DataMiningSubscription(new DataMiningForecaster(dataMMetric), subscriptionOwners); subscriptionManager.subscribe(subscription); }); Logger.LOGGER.inventoryInitialized(predictedMetrics.size()); }
@SuppressWarnings("deprecation") public static void setTeamHead(ItemStack item, Player p) { if (p.isOnline() && !p.isDead()) { ItemStack is = p.getInventory().getHelmet(); try { p.getInventory().setHelmet(item); if (is != null && is.getType() != Material.AIR && is.getType() != Material.WOOL) { InventoryUtil.addItemToInventory(p, is.clone(), is.getAmount(), true, true); } p.updateInventory(); } catch (Exception e) { if (!Defaults.DEBUG_VIRTUAL) Log.printStackTrace(e); } } }