Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2014 Red Hat, Inc. Red Hat licenses this file to you under the Apache License, version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package io.fabric8.commands;
 import java.util.List;
 import java.util.Map;
 import  org.apache.felix.gogo.commands.Argument;
 import  org.apache.felix.gogo.commands.Command;
 import  org.apache.felix.gogo.commands.Option;
 @Command(name = ., scope = ., description = ., detailedDescription = "classpath:ensemble.txt")
 public class EnsembleRemoveAction extends AbstractAction {
     @Option(name = "--generate-zookeeper-password", multiValued = false, description = "Flag to enable automatic generation of password")
     private boolean generateZookeeperPassword = false;
     @Option(name = "--new-zookeeper-password", multiValued = false, description = "The ensemble new password to use (defaults to the old one)")
     private String zookeeperPassword;
     @Option(name = "--zookeeper-ticktime", multiValued = false, description = "The length of a single tick, which is the basic time unit used by ZooKeeper, as measured in milliseconds. It is used to regulate heartbeats, and timeouts. For example, the minimum session timeout will be two ticks")
     private int zooKeeperTickTime;
     @Option(name = "--zookeeper-init-limit", multiValued = false, description = "The amount of time, in ticks (see tickTime), to allow followers to connect and sync to a leader")
     private int zooKeeperInitLimit;
     @Option(name = "--zookeeper-sync-limit", multiValued = false, description = "The amount of time, in ticks (see tickTime), to allow followers to sync with ZooKeeper")
     private int zooKeeperSyncLimit;
     @Option(name = "--zookeeper-data-dir", multiValued = false, description = "The location where ZooKeeper will store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.")
     private String zooKeeperDataDir;
     @Option(name = "-f", aliases = "--force", multiValued = false, description = "Flag to force the addition without prompt")
     private boolean force = false;
     @Option(name = "--migration-timeout", multiValued = false, description = "Timeout to wait for containers to migrate to the new ensemble")
     @Argument(required = true, multiValued = true, description = "List of containers to be removed. Must be an even number of containers.")
     private List<Stringcontainers;
     private final BundleContext bundleContext;
     private final ZooKeeperClusterService clusterService;
     EnsembleRemoveAction(BundleContext bundleContextZooKeeperClusterService clusterService) {
         this. = bundleContext;
         this. = clusterService;
     protected Object doExecute() throws Exception {
         if (EnsembleCommandSupport.checkIfShouldModify(session, )) {
             if ( != null && !.isEmpty()) {
                 StringBuilder sb = new StringBuilder();
                 sb.append("Removing containers:");
                 for (String container : ) {
                     sb.append(" ").append(container);
                 sb.append(" to the ensemble. This may take a while.");
                 CreateEnsembleOptions.Builder builder = CreateEnsembleOptions.builder();
                 builder = builder.zooKeeperServerTickTime()
                 if () {
                     //Don't add password
                 } else if ( == null || .isEmpty()) {
                     builder = builder.zookeeperPassword(.getZookeeperPassword());
                 } else {
                     builder = builder.zookeeperPassword();
                ServiceProxy<ZooKeeperClusterServiceserviceProxy = ServiceProxy.createServiceProxy(ZooKeeperClusterService.class);
                try {
                    ..println("Updated Zookeeper connection string: " + serviceProxy.getService().getZooKeeperUrl());
                } finally {
        return null;
    private void applyEnsembleConfiguration() throws Exception {
        Map<StringStringcurrentConfig = .getEnsembleConfiguration();
        int currentTickTime = Integer.parseInt(currentConfig.get("tickTime"));
        int currentInitLimit = Integer.parseInt(currentConfig.get("initLimit"));
        int currentSyncLimit = Integer.parseInt(currentConfig.get("syncLimit"));
        String currentDataDir = currentConfig.get("dataDir");
        currentDataDir = currentDataDir.substring(0, currentDataDir.lastIndexOf("/"));
         =  != 0 ?  : currentTickTime;
         =  != 0 ?  : currentInitLimit;
         =  != 0 ?  : currentSyncLimit;
         = !Strings.isNullOrBlank() ?  : currentDataDir;
New to GrepCode? Check out our FAQ X