Package io.fabric8.api

Examples of io.fabric8.api.LockHandle


        }
        ContainersNode containersNode = fabric.getContainersNode();
        if (containersNode != null) {
          List<Container> selectedContainers = getSelectedContainers();
          if (!selectedContainers.isEmpty()) {
            Container container = selectedContainers.get(0);
            ContainerNode containerNode = containersNode
                .getContainerNode(container.getId());
            if (containerNode != null) {
              Selections.setSingleSelection(
                  fabric.getRefreshableUI(), containerNode);
            }
          }
View Full Code Here


    IStructuredSelection selection = getSelection();
    if (selection != null) {
      boolean changed = false;
      Iterator iterator = selection.iterator();
      while (iterator.hasNext()) {
        Container container = ContainerNode
            .toContainer(iterator.next());
        if (container != null) {
          containers.add(container);
        }
      }
View Full Code Here

          public boolean apply(Container container) {
            return container != null && container.isRoot();
          }
        }));
    if (rootContainers.size() == 1 && fabric != null) {
      Container rootContainer = rootContainers.get(0);
      ContainersNode containersNode = fabric.getContainersNode();
      if (containersNode != null) {
        return containersNode.getContainerNode(rootContainer.getId());
      }
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  public boolean matches(ProfileNode profile) {
    Container ag = getContainer();
    Profile[] profiles = ag.getProfiles();
    for (Profile prof : profiles) {
      if (Objects.equal(prof.getId(), profile.getId())) {
        if (Objects.equal(ag.getVersionId(), profile.getVersion())) {
          return true;
        }
      }
    }
    return false;
View Full Code Here

          CreateJCloudsContainerOptions opts = args.withUser(args.getUser(), args.getPassword(), "admin").build();

          FabricPlugin.getLogger().debug("Compute Service: " + opts.getComputeService());

          // finally create the image
          final CreateJCloudsContainerMetadata metadata = provider.create(opts, new CreationStateListener() {
            @Override
            public void onStateChange(String message) {
              monitor.subTask(message);
            }
          });
View Full Code Here

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

  }
View Full Code Here

    }
   
    class ImportExportHandler {

        void importFromFileSystem(final Path importPath) {
            LockHandle writeLock = aquireWriteLock();
            try {
                assertValid();

                File sourceDir = importPath.toFile();
                IllegalArgumentAssertion.assertTrue(sourceDir.isDirectory(), "Not a valid source dir: " + sourceDir);

                // lets try and detect the old ZooKeeper style file layout and transform it into the git layout
                // so we may /fabric/configs/versions/1.0/profiles => /fabric/profiles in branch 1.0
                File fabricDir = new File(sourceDir, "fabric");
                File configs = new File(fabricDir, "configs");
                String defaultVersion = dataStore.get().getDefaultVersion();
                if (configs.exists()) {
                    LOGGER.info("Importing the old ZooKeeper layout");
                    File versions = new File(configs, "versions");
                    if (versions.exists() && versions.isDirectory()) {
                        File[] files = versions.listFiles();
                        if (files != null) {
                            for (File versionFolder : files) {
                                String version = versionFolder.getName();
                                if (versionFolder.isDirectory()) {
                                    File[] versionFiles = versionFolder.listFiles();
                                    if (versionFiles != null) {
                                        for (File versionFile : versionFiles) {
                                            LOGGER.info("Importing version configuration " + versionFile + " to branch " + version);
                                            importFromFileSystem(versionFile, GitHelpers.CONFIGS, version, true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    File metrics = new File(fabricDir, "metrics");
                    if (metrics.exists()) {
                        LOGGER.info("Importing metrics from " + metrics + " to branch " + defaultVersion);
                        importFromFileSystem(metrics, GitHelpers.CONFIGS, defaultVersion, false);
                    }
                } else {
                    // default to version 1.0
                    String version = "1.0";
                    LOGGER.info("Importing " + fabricDir + " as version " + version);
                    importFromFileSystem(fabricDir, "", version, false);
                }
            } finally {
                writeLock.unlock();
            }
        }
View Full Code Here

                writeLock.unlock();
            }
        }

        void exportProfiles(final String versionId, final String outputFileName, String wildcard) {
            LockHandle readLock = aquireReadLock();
            try {
                assertValid();
               
                final File outputFile = new File(outputFileName);
                outputFile.getParentFile().mkdirs();
               
                // Setup the file filter
                final FileFilter filter;
                if (Strings.isNotBlank(wildcard)) {
                    final WildcardFileFilter matcher = new WildcardFileFilter(wildcard);
                    filter = new FileFilter() {
                        @Override
                        public boolean accept(File file) {
                            // match either the file or parent folder
                            boolean answer = matcher.accept(file);
                            if (!answer) {
                                File parentFile = file.getParentFile();
                                if (parentFile != null) {
                                    answer = accept(parentFile);
                                }
                            }
                            return answer;
                        }
                    };
                } else {
                    filter = null;
                }
               
                GitOperation<String> gitop = new GitOperation<String>() {
                    public String call(Git git, GitContext context) throws Exception {
                        checkoutRequiredProfileBranch(git, context, versionId, null);
                        return exportProfiles(git, context, outputFile, filter);
                    }
                };
                executeRead(gitop);
            } finally {
                readLock.unlock();
            }
        }
View Full Code Here

            versionCache.invalidateAll();
        }
       
        private void runRemoteUrlChanged(final String updateUrl) {
            IllegalArgumentAssertion.assertNotNull(updateUrl, "updateUrl");
            LockHandle writeLock = aquireWriteLock();
            try {
                // TODO(tdi): this is check=then-act, use permit
                if (!isValid()) {
                    LOGGER.warn("Remote url change on invalid component: " + updateUrl);
                    return;
                }
                GitOperation<Void> gitop = new GitOperation<Void>() {
                    @Override
                    public Void call(Git git, GitContext context) throws Exception {
                        Repository repository = git.getRepository();
                        StoredConfig config = repository.getConfig();
                        String currentUrl = config.getString("remote", GitHelpers.REMOTE_ORIGIN, "url");
                        if (!updateUrl.equals(currentUrl)) {
                           
                            LOGGER.info("Remote url change from: {} to: {}", currentUrl, updateUrl);
                           
                            remoteUrl = updateUrl;
                            config.setString("remote", GitHelpers.REMOTE_ORIGIN, "url", updateUrl);
                            config.setString("remote", GitHelpers.REMOTE_ORIGIN, "fetch", "+refs/heads/*:refs/remotes/origin/*");
                            config.save();

                            doPullInternal(context, getCredentialsProvider(), false);
                        }
                        return null;
                    }
                };
                executeInternal(new GitContext(), null, gitop);
            } finally {
                writeLock.unlock();
            }
        }
View Full Code Here

                }
                containerList += container;
                index++;
            }

            LockHandle writeLock = profileRegistry.get().aquireWriteLock();
            try {
                // Create the ensemble profile
                ensembleProfileBuilder.addFileConfiguration(ensemblePropertiesName, DataStoreUtils.toBytes(ensembleProperties));
                Profile ensembleProfile = ensembleProfileBuilder.getProfile();
                LOGGER.info("Creating parent ensemble profile: {}", ensembleProfile);
                profileRegistry.get().createProfile(ensembleProfile);
               
                // Create the member profiles
                for (Profile memberProfile : memberProfiles) {
                    LOGGER.info("Creating member ensemble profile: {}", memberProfile);
                    profileRegistry.get().createProfile(memberProfile);
                }
            } finally {
                writeLock.unlock();
            }
           
            index = 1;
            for (String container : containers) {
                // add this container to the ensemble
View Full Code Here

TOP

Related Classes of io.fabric8.api.LockHandle

Copyright © 2018 www.massapicom. 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.