@Deactivate void deactivate() throws Exception { getDataStore().untrackConfiguration(changeRunnable); executorService.shutdown(); timer.cancel(); if (localIntrospector != null) { localIntrospector.destroy(); } deactivateComponent(); }
private String getNullableSubstitutedAttribute(DataStore.ContainerAttribute attribute) { return dataStore.getContainerAttribute(id, attribute, null, false, true); }
@Override public List<String> getProfileIds() { return dataStore.getContainerProfiles(id); }
/** * Removes all ensemble profiles matching the clusterId from the container. */ private void cleanUpEnsembleProfiles(DataStore dataStore, String container, String clusterId) { List<String> profiles = new LinkedList<String>(dataStore.getContainerProfiles(container)); List<String> toRemove = new LinkedList<String>(); for (String p : profiles) { if (p.startsWith("fabric-ensemble-" + clusterId)) { toRemove.add(p); } } profiles.removeAll(toRemove); dataStore.setContainerProfiles(container, profiles); }
dataStore.trackConfiguration(runnable); onConfigurationChanged(); } else { dataStore.untrackConfiguration(runnable);
@Override public void trackConfiguration(Runnable callback) { assertValid(); dataStore.get().trackConfiguration(callback); }
private void printContainersVerbose(Container[] containers, Version version, PrintStream out) { TablePrinter table = new TablePrinter(); table.columns("id", "version", "type", "connected", "profiles", "blueprint", "spring", "provision status"); for (Container container : containers) { if (CommandUtils.matchVersion(container, version)) { String indent = ""; for (Container c = container; !c.isRoot(); c = c.getParent()) { indent += " "; } //Mark local container with a star symbol String marker = ""; if (container.getId().equals(fabricService.getCurrentContainer().getId())) { marker = "*"; } String blueprintStatus = dataStore.getContainerAttribute(container.getId(), DataStore.ContainerAttribute.BlueprintStatus, "", false, false); String springStatus = dataStore.getContainerAttribute(container.getId(), DataStore.ContainerAttribute.SpringStatus, "", false, false); blueprintStatus = blueprintStatus.toLowerCase(Locale.ENGLISH); springStatus = springStatus.toLowerCase(Locale.ENGLISH); List<String> assignedProfiles = dataStore.getContainerProfiles(container.getId()); table.row(indent + container.getId() + marker, container.getVersion().getId(), container.getType(), aliveText(container), assignedProfiles.get(0), blueprintStatus, springStatus, CommandUtils.status(container)); // we want multiple profiles to be displayed on next lines for (int i = 1; i < assignedProfiles.size(); i++) { table.row("", "", "", "", assignedProfiles.get(i), "", "", ""); } } } table.print(); }
@Override public String getDefaultVersionId() { assertValid(); return dataStore.get().getDefaultVersion(); }
String versionId = dataStore.get().getDefaultVersion(); for (String container : containers) { List<String> profiles = new LinkedList<String>(dataStore.get().getContainerProfiles(container)); profiles.add("fabric-ensemble-" + newClusterId + "-" + Integer.toString(index)); LOGGER.info("Assigning member ensemble profile with id: {} to {}.", ensembleProfileId + "-" + index, container); dataStore.get().setContainerProfiles(container, profiles); index++;
public void setProfiles(Profile[] profiles) { String versionId = dataStore.getContainerVersion(id); List<String> currentProfileIds = dataStore.getContainerProfiles(id); List<String> profileIds = new ArrayList<String>(); if (profiles != null) { for (Profile profile : profiles) { IllegalArgumentAssertion.assertTrue(versionId.equals(profile.getVersion()), "Version mismatch setting profile " + profile + ", expected version " + versionId); IllegalArgumentAssertion.assertFalse(profile.isAbstract(), "The profile " + profile + " is abstract and can not be associated to containers"); IllegalArgumentAssertion.assertFalse(profile.getId().matches(ENSEMBLE_PROFILE_PATTERN) && !currentProfileIds.contains(profile.getId()), "The profile " + profile + " is not assignable."); profileIds.add(profile.getId()); } } if (profileIds.isEmpty()) { profileIds.add(ZkDefs.DEFAULT_PROFILE); } dataStore.setContainerProfiles(id, profileIds); }
public void run() { try { if (dataStore.get().hasContainer(containerName)) { CreateContainerBasicMetadata metadata = new CreateContainerBasicMetadata(); metadata.setContainerName(containerName); return; dataStore.get().createContainerConfig(containerOptions); CreateContainerMetadata metadata = provider.create(containerOptions, containerListener); if (metadata.isSuccess()) { dataStore.get().createContainerConfig(metadata); } else { LOGGER.warn("The creation of the container " + metadata.getContainerName() + " has failed", metadata.getFailure()); dataStore.get().deleteContainer(fabricService, containerOptions.getName()); metadata.setFailure(t); metadatas.add(metadata); dataStore.get().deleteContainer(fabricService, containerOptions.getName()); } finally { latch.countDown();
String fabricVersion = dataStore.get().getFabricReleaseVersion(); importProfiles(dataStore.get().getDefaultVersion(), replaced); for (String url : replaced) { LOGGER.info("Importing additional profile: {}", url);
private void setAttribute(DataStore.ContainerAttribute attribute, String value) { dataStore.setContainerAttribute(id, attribute, value); }
@Override public void setVersion(Version version) { String currentId = getVersionId(); int compareResult = version.getId().compareTo(currentId); if (compareResult != 0) { if (requiresUpgrade(version) && isManaged()) { String status = compareResult > 0 ? "upgrading" : "downgrading"; dataStore.setContainerAttribute(id, DataStore.ContainerAttribute.ProvisionStatus, status); } dataStore.setContainerVersion(id, version.getId()); } }
@Override public Container[] getContainers() { assertValid(); Map<String, Container> containers = new HashMap<String, Container>(); List<String> containerIds = dataStore.get().getContainers(); for (String containerId : containerIds) { String parentId = dataStore.get().getContainerParent(containerId); if (parentId.isEmpty()) { if (!containers.containsKey(containerId)) { Container container = new ContainerImpl(null, containerId, this); containers.put(containerId, container); } } else { Container parent = containers.get(parentId); if (parent == null) { parent = new ContainerImpl(null, parentId, this); containers.put(parentId, parent); } Container container = new ContainerImpl(parent, containerId, this); containers.put(containerId, container); } } return containers.values().toArray(new Container[containers.size()]); }
LOG.debug("Create container metadata: " + metadata); fabricService.adapt(DataStore.class).setContainerMetadata(metadata);
LOGGER.warn("Failed to cleanup container {} entries due to: {}. This will be ignored.", containerId, e.getMessage()); dataStore.get().deleteContainer(this, container.getId());
for (String c : dataStore.getContainers()) { Container container = fabricService.getContainer(c); if (version.getId().equals(container.getVersion().getId())) {
LOGGER.info("AutoScaleController is the master"); group.update(state); dataStore.trackConfiguration(runnable); enableTimer(); onConfigurationChanged(); group.update(state); disableTimer(); dataStore.untrackConfiguration(runnable); disableMasterZkCache(); dataStore.untrackConfiguration(runnable);
@Activate void activate(BundleContext bundleContext, Map<String,String> configuration) { try { this.bundleContext = bundleContext; this.schemaPath = Maps.stringValue(configuration, PROPERTY_SCHEMA_PATH, "schemas"); getDataStore().trackConfiguration(changeRunnable); if (introspector == null) { localIntrospector = new Introspector(); localIntrospector.init(); introspector = localIntrospector; } asyncRecompile(); } catch (Exception e) { throw Throwables.propagate(e); } activateComponent(); }