Refine search
@Override protected Object doExecute() throws Exception { System.out.println(String.format(FORMAT, "Fabric Release:", emptyIfNull(FabricVersionUtils.getReleaseVersion()))); System.out.println(String.format(FORMAT, "Web Console:", emptyIfNull(fabricService.getWebConsoleUrl()))); System.out.println(String.format(FORMAT, "Rest API:", emptyIfNull(fabricService.getRestAPI()))); System.out.println(String.format(FORMAT, "Git URL:", emptyIfNull(fabricService.getGitUrl()))); if (fabricService.getCurrentContainer() != null) { System.out.println(String.format(FORMAT, "Jolokia URL:", emptyIfNull(fabricService.getCurrentContainer().getJolokiaUrl()))); } System.out.println(String.format(FORMAT, "ZooKeeper URI:", emptyIfNull(fabricService.getZookeeperUrl()))); System.out.println(String.format(FORMAT, "Maven Download URI:", fabricService.getMavenRepoURI())); System.out.println(String.format(FORMAT, "Maven Upload URI:", fabricService.getMavenRepoUploadURI())); return null; }
private String getContainerAttribute(FabricService fabricService, String name, String attribute) { Container container = fabricService.getContainer(name); if (NAME_ATTRIBUTE.equals(attribute)) { return container.getId(); } else { DataStore dataStore = fabricService.adapt(DataStore.class); return dataStore.getContainerAttribute(container.getId(), attributes.get(attribute.toLowerCase()), "", false, true); } } }
private boolean containerExists(String containerName) { Container[] containers = fabricService.getContainers(); for (Container c : containers) { if (containerName.equals(c.getId())) { return true; } } return false; } }
public FabricDTO(FabricService fabricService) { this.zookeeperUrl = fabricService.getZookeeperUrl(); this.currentContainerName = fabricService.getCurrentContainerName(); this.defaultVersion = fabricService.getDefaultVersionId(); this.environment = fabricService.getEnvironment(); this.mavenRepoURI = asString(fabricService.getMavenRepoURI()); this.mavenRepoUploadURI = asString(fabricService.getMavenRepoUploadURI()); this.defaultJvmOptions = fabricService.getDefaultJvmOptions(); }
protected Profile getProcessProfile(ProcessRequirements requirements, boolean includeController) { Container container = fabricService.getCurrentContainer(); ProcessProfile profile = new ProcessProfile(container, requirements, fabricService, includeController); return new ProfileOverlayImpl(profile, fabricService.getEnvironment(), true, fabricService); }
.ensembleServer(isEnsembleServer) .number(number) .zookeeperUrl(fabricService.getZookeeperUrl()) .zookeeperPassword(fabricService.getZookeeperPassword()) .jvmOpts(jvmOpts != null ? jvmOpts : fabricService.getDefaultJvmOptions()) .jmxUser(jmxUser) .jmxPassword(jmxPassword) metadata = fabricService.createContainers(builder.build()); rethrowAuthenticationErrors(metadata); ShellUtils.storeFabricCredentials(session, jmxUser, jmxPassword); password = null; promptForJmxCredentialsIfNeeded(); metadata = fabricService.createContainers(builder.jmxUser(username).jmxPassword(password).build()); ShellUtils.storeFabricCredentials(session, username, password);
/** * Creates an aggregation of all available {@link Profile}s. */ private Profile getAllProfilesOverlay() { Container container = fabricService.get().getCurrentContainer(); ProfileService profileService = fabricService.get().adapt(ProfileService.class); Version version = container.getVersion(); Profile versionProfile = getVersionProfile(version); return Profiles.getEffectiveProfile(fabricService.get(), profileService.getOverlayProfile(versionProfile)); }
public static Map<String, String> getEnvironmentVariables(FabricService service, CreateContainerOptions options, String environment) { Set<String> profileIds = options.getProfiles(); String versionId = options.getVersion(); String zookeeperUrl = service.getZookeeperUrl(); String zookeeperUser = service.getZooKeeperUser(); String zookeeperPasswordRaw = service.getZookeeperPassword(); String zookeeperPassword = zookeeperPasswordRaw; if (zookeeperPassword != null) { zookeeperPassword = PasswordEncoder.encode(zookeeperPassword); String localIp = service.getCurrentContainer().getLocalIp(); if (!Strings.isNullOrBlank(localIp)) { int idx = zookeeperUrl.lastIndexOf(':');
protected AbstractContainerCreateAction(FabricService fabricService, ZooKeeperClusterService clusterService) { this.fabricService = fabricService; this.profileService = fabricService.adapt(ProfileService.class); this.clusterService = clusterService; }
public Container[] getChildren() { List<Container> children = new ArrayList<Container>(); for (Container container : fabricService.getContainers()) { if (container.getParent() != null && getId().equals(container.getParent().getId())) { children.add(container); } } return children.toArray(new Container[children.size()]); }
protected Container getCurrentContainer() { try { return fabricService.get().getCurrentContainer(); } catch (Exception e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Ignoring exception due to current container not being available " + e, e); } return null; } }
public void init() { requirements = service.getRequirements(); List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements(); for (ProfileRequirements profileRequirement : profileRequirements) { String key = profileRequirement.getProfile(); ProfileStatus status = profileStatusMap.get(key); if (status == null) { status = createStatus(key, profileRequirement); profileStatusMap.put(key, status); } } Container[] containers = service.getContainers(); for (Container container : containers) { if (container.isAliveAndOK()) { Profile[] profiles = container.getProfiles(); for (Profile profile : profiles) { String key = profile.getId(); ProfileStatus status = profileStatusMap.get(key); if (status == null) { ProfileRequirements profileRequirement = new ProfileRequirements(key); requirements.addOrUpdateProfileRequirements(profileRequirement); status = createStatus(key, profileRequirement); profileStatusMap.put(key, status); } status.incrementCount(); } } } }
private static String substituteFromProfile(FabricService fabricService, Map<String, Map<String, String>> configs, String pid, String key) { Map<String, String> configuration = configs.get(pid); if (configuration != null && configuration.containsKey(key)) { return configuration.get(key); } else { // lets default to the current container if a version doesn't exist in a different profile Profile overlayProfile = fabricService.getCurrentContainer().getOverlayProfile(); Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile); configuration = effectiveProfile.getConfiguration(pid); if (configuration != null && configuration.containsKey(key)) { return configuration.get(key); } else { return EMPTY; } } }
@Override public void createContainers(String version, String profile, int count) throws Exception { FabricService fabricService = containerProvider.getFabricService(); CreateDockerContainerOptions.Builder builder = null; if (fabricService != null) { builder = createAuthoScaleOptions(fabricService); } if (builder != null) { // TODO this is actually generic to all providers! :) for (int i = 0; i < count; i++) { Container[] containers = fabricService.getContainers(); final CreateDockerContainerOptions.Builder configuredBuilder = builder.number(1).version(version).profiles(profile); NameValidator nameValidator = Containers.createNameValidator(fabricService.getContainers()); String name = Containers.createContainerName(containers, profile, containerProvider.getScheme(), nameValidator); CreateDockerContainerOptions options = configuredBuilder.name(name).build(); LOG.info("Creating container name " + name + " version " + version + " profile " + profile + " " + count + " container(s)"); fabricService.createContainers(options); } } else { LOG.warn("Could not create version " + version + " profile " + profile + " due to missing autoscale configuration"); } }
/** * Destroy the given containers */ public static void destroy(Set<Container> containers) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class); try { FabricService fabricService = fabricProxy.getService(); for (Container aux : containers) { try { //We want to use the latest metadata Container container = fabricService.getContainer(aux.getId()); container.destroy(true); } catch (Exception ex) { ex.printStackTrace(System.err); //noop } } } finally { fabricProxy.close(); } }
protected CreateChildContainerOptions.Builder createAutoScaleOptions(AutoScaleRequest request, FabricService fabricService) { CreateChildContainerOptions.Builder builder = CreateChildContainerOptions.builder(); Container[] containers = fabricService.getContainers(); if (containers != null) { List<String> containerIds = Containers.rootContainerIds(containers); // allow the requirements to customise which root to use... if (containerIds.isEmpty()) { throw new IllegalStateException("No root containers are available!"); } String rootContainer = null; if (containerIds.size() == 1) { rootContainer = containerIds.get(0); } else { rootContainer = chooseRootContainer(request, containerIds); } if (Strings.isNullOrBlank(rootContainer)) { throw new IllegalStateException("Could not choose a root container from the possible IDs: " + containerIds + " with requirements: " + getChildScalingRequirements(request)); } else { builder = builder.parent(rootContainer); } } String zookeeperUrl = fabricService.getZookeeperUrl(); String zookeeperPassword = fabricService.getZookeeperPassword(); return builder.jmxUser("admin").jmxPassword(zookeeperPassword). zookeeperUrl(zookeeperUrl).zookeeperPassword(zookeeperPassword); }
String[] createContainers) throws IOException { ContainerProvider containerProvider = fabricService.getProvider(containerProviderScheme); Objects.notNull(containerProvider, "No ContainerProvider available for scheme: " + containerProviderScheme); if (!containerProvider.isValidProvider()) { String parent = fabricService.getCurrentContainerName(); String jvmOpts = dto.getJvmOpts(); .number(dto.requiredInstances()) .ensembleServer(false) .proxyUri(fabricService.getMavenRepoURI()) .jvmOpts(jvmOpts) .zookeeperUrl(fabricService.getZookeeperUrl()) .zookeeperPassword(fabricService.getZookeeperPassword()) .profiles(profileId) .version(version);
@Override public void stop(TaskContext context) { Container current = fabricService.get().getCurrentContainer(); Version version = current.getVersion(); String profileId = context.getConfiguration().get(TEMPLATE_PROFILE_PROPERTY_NAME) + "-" + name; if (version.hasProfile(profileId)) { //Just delete the profile version.getProfile(profileId).delete(true); } }
protected CreateDockerContainerOptions.Builder createAuthoScaleOptions(FabricService fabricService) { CreateDockerContainerOptions.Builder builder = CreateDockerContainerOptions.builder(); String zookeeperUrl = fabricService.getZookeeperUrl(); String zookeeperPassword = fabricService.getZookeeperPassword(); return builder.zookeeperUrl(zookeeperUrl).zookeeperPassword(zookeeperPassword); }
protected CreateSshContainerOptions.Builder createAutoScaleOptions(AutoScaleRequest request, FabricService fabricService, HostProfileCounter hostProfileCounter) { CreateSshContainerOptions.Builder builder = chooseHostContainerOptions(request, hostProfileCounter); if (builder == null) return null; String zookeeperUrl = fabricService.getZookeeperUrl(); String zookeeperPassword = fabricService.getZookeeperPassword(); if (builder.getProxyUri() == null) { builder.proxyUri(fabricService.getMavenRepoURI()); } return builder.zookeeperUrl(zookeeperUrl).zookeeperPassword(zookeeperPassword); }