org.apache.brooklyn.api.mgmt.LocationManager.isManaged()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.apache.brooklyn.api.mgmt.LocationManager.isManaged()方法的一些代码示例,展示了LocationManager.isManaged()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocationManager.isManaged()方法的具体详情如下:
包路径:org.apache.brooklyn.api.mgmt.LocationManager
类名称:LocationManager
方法名:isManaged

LocationManager.isManaged介绍

[英]whether the location is under management by this management context
[中]该位置是否受此管理上下文的管理

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/**
 * Registers the given location (and all its children) with the management context. 
 * @throws IllegalStateException if the parent location is not already managed
 * 
 * @since 0.6.0 (added only for backwards compatibility, where locations are being created directly; previously in {@link Entities}).
 * @deprecated in 0.6.0; use {@link LocationManager#createLocation(LocationSpec)} instead.
 */
@Deprecated
public static void manage(Location loc, ManagementContext managementContext) {
  if (!managementContext.getLocationManager().isManaged(loc)) {
    log.warn("Deprecated use of unmanaged location ("+loc+"); will be managed automatically now but not supported in future versions");
    // FIXME this occurs MOST OF THE TIME e.g. including BrooklynLauncher.location(locationString)
    // not sure what is the recommend way to convert from locationString to locationSpec, or the API we want to expose;
    // deprecating some of the LocationRegistry methods seems sensible?
    log.debug("Stack trace for location of: Deprecated use of unmanaged location; will be managed automatically now but not supported in future versions", new Exception("TRACE for: Deprecated use of unmanaged location"));
    managementContext.getLocationManager().manage(loc);
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

public static boolean isManaged(Location loc) {
  ManagementContext mgmt = ((LocationInternal)loc).getManagementContext();
  return (mgmt != null) && mgmt.isRunning() && mgmt.getLocationManager().isManaged(loc);
}

代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-docker

@Override
public void deleteLocation() {
  DockerContainerLocation location = getDynamicLocation();
  if (location != null) {
    try {
      location.close();
    } catch (IOException ioe) {
      LOG.debug("Error closing container location", ioe);
    }
    LocationManager mgr = getManagementContext().getLocationManager();
    if (mgr.isManaged(location)) {
      mgr.unmanage(location);
    }
  }
  sensors().set(DYNAMIC_LOCATION, null);
  sensors().set(LOCATION_NAME, null);
}

代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-mesos

@Override
public void deleteLocation() {
  MarathonTaskLocation location = getDynamicLocation();
  if (location != null) {
    LocationManager mgr = getManagementContext().getLocationManager();
    if (mgr.isManaged(location)) {
      mgr.unmanage(location);
    }
  }
  sensors().set(DYNAMIC_LOCATION, null);
  sensors().set(LOCATION_NAME, null);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base

@Override
public void deleteLocation() {
  LocationManager mgr = getManagementContext().getLocationManager();
  ServerPoolLocation location = getDynamicLocation();
  if (location != null && mgr.isManaged(location)) {
    LOG.debug("{} deleting and unmanaging location {}", this, location);
    location.deregister();
    mgr.unmanage(location);
  }
  
  sensors().set(LOCATION_SPEC, null);
  sensors().set(DYNAMIC_LOCATION, null);
  sensors().set(LOCATION_NAME, null);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp

assertExpectedTargetsEventually(members);
Assert.assertTrue(mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations())));
rebind();
Assert.assertTrue(mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations())),
    "location not managed after rebind");
Assert.assertTrue(mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations())));
log.info("resized "+cluster+" ("+result+") - "+cluster.getChildren());
HashSet<StubAppServer> newEntities = Sets.newHashSet(Iterables.filter(cluster.getChildren(), StubAppServer.class));

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

if (!getManagementContext().getLocationManager().isManaged(child)) {
  Locations.manage(child, getManagementContext());

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp

@BeforeMethod(alwaysRun=true)
@Override
public void setUp() throws Exception {
  super.setUp();
  
  EntitySpec<StubAppServer> serverSpec = EntitySpec.create(StubAppServer.class);
  cluster = app().createAndManageChild(EntitySpec.create(DynamicCluster.class)
      .configure(DynamicCluster.INITIAL_SIZE, initialClusterSize)
      .configure(DynamicCluster.MEMBER_SPEC, serverSpec));
  urlMapping = app().createAndManageChild(EntitySpec.create(UrlMapping.class)
      .configure("domain", "localhost")
      .configure("target", cluster));
  app().start( ImmutableList.of(
      mgmt().getLocationManager().createLocation(
          LocationSpec.create(LocalhostMachineProvisioningLocation.class))
      ));
  log.info("app's location managed: "+mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(app().getLocations())));
  log.info("clusters's location managed: "+mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations())));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base

@Override
  public void deleteLocation() {
    StubContainerLocation location = getDynamicLocation();

    if (location != null) {
      try {
        location.close();
      } catch (IOException ioe) {
        LOG.debug("Error closing container location", ioe);
      }
      LocationManager mgr = getManagementContext().getLocationManager();
      if (mgr.isManaged(location)) {
        mgr.unmanage(location);
      }
    }

    sensors().set(DYNAMIC_LOCATION, null);
    sensors().set(LOCATION_NAME, null);
  }
}

相关文章