@Override protected Feed getInstanceFromId(Optional<Entity> entity, String id) { if (id == null || !entity.isPresent()) return null; for (Feed feed : ((EntityInternal)entity).feeds().getFeeds()) { if (id.equals(feed.getId())) { return feed; } } return null; } }
@Override public void apply(EntityLocal entity) { SshFeed machineMetricsFeed = createMachineMetricsFeed(entity); ((EntityInternal) entity).feeds().add(machineMetricsFeed); addMachineMetricsEnrichers(entity); LOG.info("Configured machine metrics feed and enrichers on {}", entity); }
@Override public void setEntity(EntityLocal entity) { super.setEntity(entity); if (BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_FEED_REGISTRATION_PROPERTY)) { ((EntityInternal)entity).feeds().addFeed(this); } }
public void run() { Collection<Feed> feeds = ((EntityInternal)entity).feeds().getFeeds(); for (Feed feed : feeds) { if (uniqueTag.equals(feed.getUniqueTag())) { return; } } fail("No feed found with uniqueTag "+uniqueTag+" in entity "+entity+"; feeds="+feeds); }}); }
@Override public synchronized void onUnmanaged(BrooklynObject instance) { if (LOG.isTraceEnabled()) LOG.trace("onUnmanaged: {}", instance); if (!isStopped()) { removeFromCollector(instance); if (instance instanceof Entity) { Entity entity = (Entity) instance; for (BrooklynObject adjunct : entity.policies()) removeFromCollector(adjunct); for (BrooklynObject adjunct : entity.enrichers()) removeFromCollector(adjunct); for (BrooklynObject adjunct : ((EntityInternal)entity).feeds().getFeeds()) removeFromCollector(adjunct); } } }
@Test(groups="Integration") public void testFeedDeDupe() throws Exception { testReturnsSshStdoutAndInfersMachine(); entity.addFeed(feed); log.info("Feed 0 is: "+feed); testReturnsSshStdoutAndInfersMachine(); log.info("Feed 1 is: "+feed); entity.addFeed(feed); FeedSupport feeds = ((EntityInternal)entity).feeds(); Assert.assertEquals(feeds.getFeeds().size(), 1, "Wrong feed count: "+feeds.getFeeds()); }
@Test public void testFeedDeDupe() throws Exception { testPollsAndParsesHttpGetResponse(); entity.addFeed(feed); log.info("Feed 0 is: "+feed); testPollsAndParsesHttpGetResponse(); log.info("Feed 1 is: "+feed); entity.addFeed(feed); FeedSupport feeds = ((EntityInternal)entity).feeds(); Assert.assertEquals(feeds.getFeeds().size(), 1, "Wrong feed count: "+feeds.getFeeds()); }
@Test(groups="Integration") public void testFeedDeDupe() throws Exception { testReturnsShellExitStatus(); entity.addFeed(feed); log.info("Feed 0 is: "+feed); testReturnsShellExitStatus(); log.info("Feed 1 is: "+feed); entity.addFeed(feed); FeedSupport feeds = ((EntityInternal)entity).feeds(); Assert.assertEquals(feeds.getFeeds().size(), 1, "Wrong feed count: "+feeds.getFeeds()); }
@Test(groups="Live") public void testFeedDeDupe() throws Exception { testReturnsStdoutAndInfersMachine(); entity.addFeed(feed); log.info("Feed 0 is: "+feed); testReturnsStdoutAndInfersMachine(); log.info("Feed 1 is: "+feed); entity.addFeed(feed); FeedSupport feeds = ((EntityInternal)entity).feeds(); Assert.assertEquals(feeds.getFeeds().size(), 1, "Wrong feed count: "+feeds.getFeeds()); }
@Override public String call() { DynamicTasks.markInessential(); for (Feed feed : entity().feeds().getFeeds()) { if (feed.isActivated()) feed.stop(); } DynamicTasks.waitForLast(); return "Stop feeds completed with no errors."; } }
@Test public void testFeedDeDupe() throws Exception { testPollsFunctionRepeatedlyToSetAttribute(); entity.addFeed(feed); log.info("Feed 0 is: "+feed); Feed feed0 = feed; testPollsFunctionRepeatedlyToSetAttribute(); entity.addFeed(feed); log.info("Feed 1 is: "+feed); Feed feed1 = feed; Assert.assertFalse(feed1==feed0); FeedSupport feeds = ((EntityInternal)entity).feeds(); Assert.assertEquals(feeds.getFeeds().size(), 1, "Wrong feed count: "+feeds.getFeeds()); // a couple extra checks, compared to the de-dupe test in other *FeedTest classes Feed feedAdded = Iterables.getOnlyElement(feeds.getFeeds()); Assert.assertTrue(feedAdded==feed1); Assert.assertFalse(feedAdded==feed0); }
for (Feed feed : entity.feeds().getFeeds()) { builder.feeds.add(feed.getId());
objectsToRebindFinal.addAll( ((EntityInternal)bo).feeds().getFeeds() );
@Override public void addFeeds(RebindContext rebindContext, EntityMemento memento) { for (String feedId : memento.getFeeds()) { AbstractFeed feed = (AbstractFeed) rebindContext.lookup().lookupFeed(feedId); if (feed != null) { try { entity.feeds().add(feed); } catch (Exception e) { rebindContext.getExceptionHandler().onAddFeedFailed(entity, feed, e); } try { if (!rebindContext.isReadOnly(feed)) { feed.start(); } } catch (Exception e) { rebindContext.getExceptionHandler().onRebindFailed(BrooklynObjectType.ENTITY, entity, e); } } else { LOG.warn("Feed not found; discarding feed {} of entity {}({})", new Object[] {feedId, memento.getType(), memento.getId()}); } } }
private void addReferencedObjects(DeltaCollector deltaCollector) { MutableSet<BrooklynObject> referencedObjects = MutableSet.of(); // collect references for (Entity entity : deltaCollector.entities) { // FIXME How to let the policy/location tell us about changes? Don't do this every time! for (Location location : entity.getLocations()) { Collection<Location> findLocationsInHierarchy = TreeUtils.findLocationsInHierarchy(location); referencedObjects.addAll(findLocationsInHierarchy); } if (persistPoliciesEnabled) { referencedObjects.addAll(entity.policies()); } if (persistEnrichersEnabled) { referencedObjects.addAll(entity.enrichers()); } if (persistFeedsEnabled) { referencedObjects.addAll(((EntityInternal)entity).feeds().getFeeds()); } } for (BrooklynObject instance : referencedObjects) { deltaCollector.addIfNotRemoved(instance); } }
Assert.assertTrue(RecordingSshjTool.connectionCount.get()>0); Collection<Feed> origFeeds = ((EntityInternal)origNginx).feeds().getFeeds(); LOG.info("feeds before rebind are: "+origFeeds); Assert.assertTrue(origFeeds.size() >= 1); Collection<Feed> newFeeds = ((EntityInternal)newNginx).feeds().getFeeds(); LOG.info("feeds after rebind are: "+newFeeds); Assert.assertTrue(newFeeds.size() >= 1);
@Test public void testDeletesOrphanedFeeds() throws Exception { EntityInternal entity = origApp.addChild(EntitySpec.create(TestEntity.class).impl(MyEntity.class)); Feed feed = entity.feeds().add(new MyFeed()); MementoTweaker tweaker = new MementoTweaker(new Deletions().entities(entity.getId())); assertTransformDeletes(new Deletions().feeds(feed.getId()), tweaker); }
instance = Entities.deproxy(instance); result.entity(instance.getId(), serializer.toString(newObjectMemento(instance))); for (Feed instanceAdjunct: ((EntityInternal)instance).feeds().getFeeds()) { result.feed(instanceAdjunct.getId(), serializer.toString(newObjectMemento(instanceAdjunct)));