/*
 *  Copyright 2014 Andy Seaborne
 *
 *  Licensed 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
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  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 lz;

import java.util.Collection ;
import java.util.List ;
import java.util.stream.Collectors ;

import lizard.cluster.Platform ;
import lizard.conf.ConfigLib ;
import lizard.conf.Configuration ;
import lizard.conf.LzBuild ;
import lizard.conf.index.ConfigIndex ;
import lizard.conf.index.IndexServer ;
import lizard.conf.node.ConfigNode ;
import lizard.conf.node.NodeServer ;
import lizard.sys.Deploy ;
import lizard.sys.Deployment ;
import lizard.system.LzLib ;
import org.apache.jena.atlas.lib.Lib ;
import org.apache.jena.atlas.logging.LogCtl ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import arq.cmd.CmdException ;
import arq.cmdline.ArgDecl ;
import arq.cmdline.CmdGeneral ;

import com.hp.hpl.jena.rdf.model.Model ;

/** Take a general configuration file and deployment file for this machine
 *  build a dataset and run here.
 *  The lizard version of "arq.sparql". 
 */
public class LZ_Deploy extends CmdGeneral {
    static { LogCtl.setCmdLogging(); }
    
    public static Logger log        = LoggerFactory.getLogger("Lizard") ;  
    public static Logger logConf    = LoggerFactory.getLogger("Conf") ;
    protected ArgDecl argDeploy     = new ArgDecl(ArgDecl.HasValue, "deploy", "server") ;
    private Deployment deployment = null ;
    
    public static void main(String ...args) {
        new LZ_Deploy(args).mainRun() ;
    }
    
    protected LZ_Deploy(String[] argv) {
        super(argv) ;
        super.add(argDeploy, argDeploy.getKeyName(), "Deployment description");
    }
    
    @Override
    protected String getSummary() {
        return "deploy: --deploy=deploymentFile configFiles ..." ;
    }

    @Override
    protected void processModulesAndArgs() {
        if ( ! super.contains(argDeploy) )
            throw new CmdException("Required: --deploy") ;
        
        if ( super.getValues(argDeploy).size() > 1 )
            throw new CmdException("Required: exactly one --deploy") ;

        String deploymentFile = super.getValue(argDeploy) ;
        String [] a = super.getPositional().toArray(new String[0]) ;
        Configuration config = Configuration.fromFile(a) ;
        deployment = Deployment.parse(config, deploymentFile) ; 
    }

    @Override
    protected void exec() {
        try {
            Deploy.deploy(deployment) ;
            while (true) {
                Lib.sleep(10000) ;
            }
        } catch (Throwable th) {
            th.printStackTrace(System.err) ;
        } finally {
            System.exit(0) ;
        }
    }

    @Override
    protected String getCommandName() {
        return "lz-deploy" ;
    }
}

@@ -625,370 +625,33 @@
 ort 
-java.util.Collection ;%0Aimport java.util.List ;%0Aimport java.util.stream.Collectors ;%0A%0Aimport lizard.cluster.Platform ;%0Aimport lizard.conf.ConfigLib ;%0Aimport lizard.conf.Configuration ;%0Aimport lizard.conf.LzBuild ;%0Aimport lizard.conf.index.ConfigIndex ;%0Aimport lizard.conf.index.IndexServer ;%0Aimport lizard.conf.node.ConfigNode ;%0Aimport lizard.conf.node.NodeServer
+lizard.conf.Configuration
  ;%0Ai
@@ -711,37 +711,8 @@
 t ;%0A
-import lizard.system.LzLib ;%0A
 impo
@@ -947,50 +947,8 @@
  ;%0A%0A
-import com.hp.hpl.jena.rdf.model.Model ;%0A%0A
 /** 
@@ -1000,16 +1000,20 @@
 ent file
+%0A * 
  for thi
@@ -1025,28 +1025,23 @@
 hine
-%0A * 
+,
  build 
-a dataset
+servers
  and
@@ -1055,49 +1055,8 @@
 re.%0A
- *  The lizard version of %22arq.sparql%22. %0A
  */%0A

Tidy up