Examples of FabricException


Examples of io.fabric8.api.FabricException

          }
        }
      });
      return (T) answerHolder[0];
    } catch (Exception e) {
      throw new FabricException(e);
    }

  }
View Full Code Here

Examples of io.fabric8.api.FabricException

        if (metadata != null) {
            IOpenShiftConnection connection = getOrCreateConnection(metadata.getCreateOptions());
            app = OpenShiftUtils.getApplication(container, metadata, connection);
        }
        if (app == null && required) {
            throw new FabricException("Unable to find OpenShift application for " + container.getId());
        }
        return app;
    }
View Full Code Here

Examples of io.fabric8.api.FabricException

                if (desc.getReadMethod() != null) {
                    answer.add(desc.getName());
                }
            }
        } catch (Exception e) {
            throw new FabricException("Failed to get property descriptors for " + clazz.toString(), e);
        }

        // few tweaks to maintain compatibility with existing views for now...
        if (clazz.getSimpleName().equals("Container")) {
            answer.add("parentId");
View Full Code Here

Examples of io.fabric8.api.FabricException

    private static void addProperty(Object obj, String field, Map<String, Object> map) {
        try {
            Object prop = PropertyUtils.getProperty(obj, field);
            map.put(field, prop);
        } catch (Exception e) {
            throw new FabricException("Failed to initialize DTO", e);
        }
    }
View Full Code Here

Examples of io.fabric8.api.FabricException

            if (parentId != null && !parentId.isEmpty()) {
                parent = getContainer(parentId);
            }
            return new ContainerImpl(parent, name, this);
        }
        throw new FabricException("Container '" + name + "' does not exist");
    }
View Full Code Here

Examples of io.fabric8.api.FabricException

                }
                provider.destroy(container);
                destroyed = true;
            } else {
                invalidContainer = true;
                throw new FabricException("Container's lifecycle not managed by Fabric8 (the container was not created by Fabric8).");
            }

        } finally {
            try {
                if (destroyed || force || invalidContainer) {
View Full Code Here

Examples of io.fabric8.api.FabricException

    public CreateContainerMetadata[] createContainers(CreateContainerOptions options, CreationStateListener listener) {
        assertValid();
        try {
            final ContainerProvider provider = getProvider(options.getProviderType());
            if (provider == null) {
                throw new FabricException("Unable to find a container provider supporting '" + options.getProviderType() + "'");
            }
            if (!provider.isValidProvider()) {
                throw new FabricException("The provider '" + options.getProviderType() + "' is not valid in current environment");
            }

            String originalName = options.getName();
            if (originalName == null || originalName.length() == 0) {
                throw new FabricException("A name must be specified when creating containers");
            }

            if (listener == null) {
                listener = new NullCreationStateListener();
            }

            validateProfileDependencies(options);
            ObjectMapper mapper = new ObjectMapper();
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            Map optionsMap = mapper.readValue(mapper.writeValueAsString(options), Map.class);
            String versionId = options.getVersion() != null ? options.getVersion() : dataStore.get().getDefaultVersion();
            Set<String> profileIds = options.getProfiles();
            if (profileIds == null || profileIds.isEmpty()) {
                profileIds = new LinkedHashSet<String>();
                profileIds.add("default");
            }
            optionsMap.put("version", versionId);
            optionsMap.put("profiles", profileIds);
            optionsMap.put("number", 0);

            final List<CreateContainerMetadata> metadatas = new CopyOnWriteArrayList<CreateContainerMetadata>();
            int orgNumber = options.getNumber();
            int number = Math.max(orgNumber, 1);
            final CountDownLatch latch = new CountDownLatch(number);
            Set<String> ignoreContainerNames = new HashSet<>();
            Container[] containers = getContainers();

            // check that there is no container with the given name
            for (Container container : containers) {
                if (container.getId().equals(options.getName())) {
                    throw new IllegalArgumentException("A container with name " + options.getName() + " already exists.");
                }
            }

            for (int i = 1; i <= number; i++) {
                NameValidator validator = Containers.createNameValidator(containers, ignoreContainerNames);
                final String containerName = Containers.createUniqueContainerName(containers, originalName, validator);
                ignoreContainerNames.add(containerName);

                optionsMap.put("name", containerName);

                //Check if datastore configuration has been specified and fallback to current container settings.
                if (!hasValidDataStoreProperties(optionsMap)) {
                    optionsMap.put("dataStoreProperties", profileRegistry.get().getDataStoreProperties());
                }
                Class cl = options.getClass().getClassLoader().loadClass(options.getClass().getName() + "$Builder");
                CreateContainerBasicOptions.Builder builder = (CreateContainerBasicOptions.Builder) mapper.readValue(mapper.writeValueAsString(optionsMap), cl);
                //We always want to pass the obfuscated version of the password to the container provider.
                builder = (CreateContainerBasicOptions.Builder) builder.zookeeperPassword(PasswordEncoder.encode(getZookeeperPassword()));
                final CreateContainerOptions containerOptions = builder.build();
                final CreationStateListener containerListener = listener;
                final FabricService fabricService = this;
                new Thread("Creating container " + containerName) {
                    public void run() {
                        try {
                            if (dataStore.get().hasContainer(containerName)) {
                                CreateContainerBasicMetadata metadata = new CreateContainerBasicMetadata();
                                metadata.setContainerName(containerName);
                                metadata.setCreateOptions(containerOptions);
                                metadata.setFailure(new IllegalArgumentException("A container with name " + containerName + " already exists."));
                                metadatas.add(metadata);
                                return;
                            }
                            dataStore.get().createContainerConfig(containerOptions);
                            CreateContainerMetadata metadata = provider.create(containerOptions, containerListener);
                            if (metadata.isSuccess()) {
                                Container parent = containerOptions.getParent() != null ? getContainer(containerOptions.getParent()) : null;
                                //An ensemble server can be created without an existing ensemble.
                                //In this case container config will be created by the newly created container.
                                //TODO: We need to make sure that this entries are somehow added even to ensemble servers.
                                if (!containerOptions.isEnsembleServer()) {
                                    dataStore.get().createContainerConfig(metadata);
                                }
                                ContainerImpl container = new ContainerImpl(parent, metadata.getContainerName(), FabricServiceImpl.this);
                                metadata.setContainer(container);
                                LOGGER.info("The container " + metadata.getContainerName() + " has been successfully created");
                            } else {
                                LOGGER.warn("The creation of the container " + metadata.getContainerName() + " has failed", metadata.getFailure());
                            }
                            metadatas.add(metadata);
                        } catch (Throwable t) {
                            CreateContainerBasicMetadata metadata = new CreateContainerBasicMetadata();
                            metadata.setContainerName(containerName);
                            metadata.setCreateOptions(containerOptions);
                            metadata.setFailure(t);
                            metadatas.add(metadata);
                            dataStore.get().deleteContainer(fabricService, containerOptions.getName());
                        } finally {
                            latch.countDown();
                        }
                    }
                }.start();
            }
            if (!latch.await(30, TimeUnit.MINUTES)) {
                throw new FabricException("Timeout waiting for container creation");
            }
            return metadatas.toArray(new CreateContainerMetadata[metadatas.size()]);
        } catch (Exception e) {
            LOGGER.error("Failed to create containers " + e, e);
            throw FabricException.launderThrowable(e);
View Full Code Here

Examples of io.fabric8.api.FabricException

            if (exportConfig != null && !exportConfig.isEmpty()) {
                ProfileDependencyConfig config = new ProfileDependencyConfig();
                try {
                    configurer.configure(exportConfig, config);
                } catch (Exception e) {
                    throw new FabricException("Failed to load configuration for " + configName + " of " + config + " due to: " + e, e);
                }

                // Ensure dependent container exists
                if (ProfileDependencyKind.ZOOKEEPER_SERVICE.equals(config.getKind())) {
                    try {
View Full Code Here

Examples of io.fabric8.api.FabricException

                p = DataStoreUtils.toProperties(b);
            } else {
                p = new Properties();
            }
        } catch (Throwable t) {
            throw new FabricException(t);
        }

        return p.getProperty(key);
    }
View Full Code Here

Examples of io.fabric8.api.FabricException

            for (String scheme : requiredSchemes) {
                if (!availableSchemes.contains(scheme)) {
                    sb.append(" ").append(scheme);
                }
            }
            throw new FabricException(sb.toString());
        }

        final Map<String, Map<String, String>> mutableConfigurations = new HashMap<>();
        for (Entry<String, Map<String, String>> entry : configurations.entrySet()) {
            String key = entry.getKey();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.