Examples of LoadbalancerReader


Examples of com.sun.enterprise.ee.admin.lbadmin.reader.api.LoadbalancerReader

    /**
     * Visit reader class
     */
    public void visit(BaseReader br) {
        // FIXME, make as assert here about no class cast exception
        LoadbalancerReader lbRdr = (LoadbalancerReader) br;


        PropertyReader[] pRdrs = null;
        try {
            pRdrs = lbRdr.getProperties();
        } catch (LbReaderException le) {
            // should we throw this exception XXX ???
            // or fill in with default values
        }

        if ((pRdrs != null) && (pRdrs.length > 0 ) ){
            Property[] props = new Property[pRdrs.length];
            for(int i =0; i < pRdrs.length; i++) {
                props[i] = new Property();
                pRdrs[i].accept( new PropertyVisitor(props[i]));
            }
            _lb.setProperty2(props);
        }

        ClusterReader[] cRdrs =  null;
        try {
            cRdrs = lbRdr.getClusters();
        } catch (LbReaderException le) {
            // should we throw this exception XXX ???
            // or fill in with default values
        }
       
View Full Code Here

Examples of com.sun.enterprise.ee.admin.lbadmin.reader.api.LoadbalancerReader

     */
    public static String getXML(ConfigContext ctx,String lbConfigName) throws IOException, ConfigException,
                Schema2BeansException{
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        // check if the lb exists
        LoadbalancerReader lbr = LbConfigExporter.getLbReader(ctx,lbConfigName);
        LbConfigExporter.exportXml(lbr, out);
        return out.toString();
    }
View Full Code Here

Examples of com.sun.enterprise.ee.admin.lbadmin.reader.api.LoadbalancerReader

    public void publish() throws IOException, ConfigException,
                Schema2BeansException{


        // check if the lb exists
        LoadbalancerReader lbr = LbConfigExporter.getLbReader(_ctx, _name);

        HttpURLConnection conn =
            _connectionManager.getConnection(LB_UPDATE_CONTEXT_ROOT);
        OutputStream out=null;
        try{
View Full Code Here

Examples of com.sun.enterprise.ee.admin.lbadmin.reader.api.LoadbalancerReader

    public String write() throws IOException, ConfigException,
                Schema2BeansException{

        // check if the lb exists
        LoadbalancerReader lbr = LbConfigExporter.getLbReader(_ctx, _name);           
        File f = new File(_path);

        if (f.isDirectory() ) {
         f = new File(f, _f);
        }
View Full Code Here

Examples of org.glassfish.loadbalancer.admin.cli.reader.api.LoadbalancerReader

        }
    }

    public String process(AdminCommandContext context) throws Exception {

        LoadbalancerReader lbr = null;
        if (lbName != null && lbConfigName == null && target == null) {
            LoadBalancer lb = LbConfigHelper.getLoadBalancer(domain, lbName);
            lbr = LbConfigHelper.getLbReader(domain, appRegistry, lb.getLbConfigName());
        } else if (lbConfigName != null && lbName == null && target == null) {
            lbr = LbConfigHelper.getLbReader(domain, appRegistry, lbConfigName);
        } else if (target != null && lbName == null && lbConfigName == null) {
            Set<String> clusters = new HashSet<String>();
            clusters.addAll(target);
            lbr = new LoadbalancerReaderImpl(domain, appRegistry, clusters, properties);
        } else {
            String msg = LbLogUtil.getStringManager().getString("ExportHttpLbConfigInvalidArgs");
            throw new Exception(msg);
        }

        if (fileName == null) {
            String configName = lbr.getName();
            if (configName != null) {
                fileName = DEFAULT_LB_XML_FILE_NAME + "." + configName;
            } else {
                fileName = DEFAULT_LB_XML_FILE_NAME;
            }
        }

        File lbConfigFile = new File(fileName);
        if (!lbConfigFile.isAbsolute() && !retrieveFile) {
            File loadbalancerDir = new File(env.getInstanceRoot(),
                    "load-balancer");
            if (!loadbalancerDir.exists()) {
                boolean isMkdirSuccess = loadbalancerDir.mkdir();
                if(!isMkdirSuccess){
                  String msg = LbLogUtil.getStringManager().getString(
                            "directoryCreationFailed");
                    throw new Exception(msg);
                }
            }
            lbConfigFile = new File(loadbalancerDir, fileName);
        }

            File tmpLbXmlFile = null;
            if (retrieveFile) {
                tmpLbXmlFile = File.createTempFile("load-balancer", ".xml");
                tmpLbXmlFile.deleteOnExit();
            } else {
                if (lbConfigFile.exists()) {
                    String msg = LbLogUtil.getStringManager().getString(
                            "FileExists", lbConfigFile.getPath());
                    throw new Exception(msg);
                }

                if (!(lbConfigFile.getParentFile().exists())) {
                    String msg = LbLogUtil.getStringManager().getString(
                            "ParentFileMissing", lbConfigFile.getParent());
                    throw new Exception(msg);
                }
                tmpLbXmlFile = lbConfigFile;
            }

            FileOutputStream fo = null;

            try {
                fo = new FileOutputStream(tmpLbXmlFile);
                LbConfigHelper.exportXml(lbr, fo);
                if (retrieveFile) {
                    retrieveLbConfig(context, lbConfigFile, tmpLbXmlFile);
                }
                LbConfig lbConfig = lbr.getLbConfig();
                //Check for the case when lbtargets are provided
                //In such a case, lbconfig will be null
                if(lbConfig != null){
                    lbConfig.setLastExported();
                }
View Full Code Here

Examples of org.glassfish.loadbalancer.admin.cli.reader.api.LoadbalancerReader

    public void publish(ConnectionManager _connectionManager, Domain domain, String lbConfigName) throws IOException,
            Exception {


        // check if the lb exists
        LoadbalancerReader lbr = LbConfigHelper.getLbReader(domain, appRegistry, lbConfigName);

        HttpURLConnection conn =
                _connectionManager.getConnection(LB_UPDATE_CONTEXT_ROOT);
        OutputStream out = null;
        try {
            conn.setDoOutput(true);
            conn.setRequestMethod(POST);
            conn.connect();
            out = conn.getOutputStream();
            LbConfigHelper.exportXml(lbr, out);
            out.flush();
            lbr.getLbConfig().setLastApplied();
        } catch (UnknownHostException uhe) {
            throw new IOException(LbLogUtil.getStringManager().getString("CannotConnectToLBHost", uhe.getMessage()), uhe);
        } catch (Exception e) {
            throw new IOException(e.getMessage(), e);
        } finally {
View Full Code Here

Examples of org.glassfish.loadbalancer.admin.cli.reader.api.LoadbalancerReader

     */
    @Override
    public void visit(BaseReader br) throws Exception {
        // FIXME, make as assert here about no class cast exception
    if (br instanceof LoadbalancerReader) {
      LoadbalancerReader lbRdr = (LoadbalancerReader) br;

      PropertyReader[] pRdrs = lbRdr.getProperties();

      if ((pRdrs != null) && (pRdrs.length > 0)) {
        Property[] props = new Property[pRdrs.length];
        for (int i = 0; i < pRdrs.length; i++) {
          props[i] = new Property();
          pRdrs[i].accept(new PropertyVisitor(props[i]));
        }
        _lb.setProperty2(props);
      }

      ClusterReader[] cRdrs = lbRdr.getClusters();

      if ((cRdrs != null) && (cRdrs.length > 0)) {
        Cluster[] cls = new Cluster[cRdrs.length];
        for (int i = 0; i < cRdrs.length; i++) {
          cls[i] = new Cluster();
View Full Code Here

Examples of org.glassfish.loadbalancer.admin.cli.reader.api.LoadbalancerReader

        }
    }

    public String process(AdminCommandContext context) throws Exception {
       
        LoadbalancerReader lbr = null;
        if (lbName != null && lbConfigName == null && target == null) {
            LoadBalancer lb = LbConfigHelper.getLoadBalancer(domain, lbName);
            lbr = LbConfigHelper.getLbReader(domain, appRegistry, lb.getLbConfigName());
        } else if (lbConfigName != null && lbName == null && target == null) {
            lbr = LbConfigHelper.getLbReader(domain, appRegistry, lbConfigName);
        } else if (target != null && lbName == null && lbConfigName == null){
            Set<String> clusters = new HashSet<String>();
            clusters.addAll(target);
            lbr = new LoadbalancerReaderImpl(domain, appRegistry, clusters, properties);
        } else {
            String msg = LbLogUtil.getStringManager().getString("ExportHttpLbConfigInvalidArgs");
            throw new Exception(msg);
        }

        if(fileName == null){
            String configName = lbr.getName();
            if(configName != null){
                fileName = DEFAULT_LB_XML_FILE_NAME + "." + configName;
            } else {
                fileName = DEFAULT_LB_XML_FILE_NAME;
            }
        }

        File lbXmlFile = new File(fileName);
        if(!lbXmlFile.isAbsolute() && !retrieveFile){
            File loadbalancerDir = new File(env.getInstanceRoot(),
                    "load-balancer");
            if(!loadbalancerDir.exists()){
                loadbalancerDir.mkdir();
            }
            lbXmlFile = new File(loadbalancerDir, fileName);
        }

        File tmpLbXmlFile = null;
        if(retrieveFile){
            tmpLbXmlFile = File.createTempFile("load-balancer", ".xml");
            tmpLbXmlFile.deleteOnExit();
        } else {
            if (lbXmlFile.exists()) {
                String msg = LbLogUtil.getStringManager().getString(
                        "FileExists", lbXmlFile.getPath());
                throw new Exception(msg);
            }

            if (!(lbXmlFile.getParentFile().exists())) {
                String msg = LbLogUtil.getStringManager().getString(
                        "ParentFileMissing", lbXmlFile.getParent());
                throw new Exception(msg);
            }
            tmpLbXmlFile = lbXmlFile;
        }

        FileOutputStream fo = null;

        try {
            fo = new FileOutputStream(tmpLbXmlFile);
            LbConfigHelper.exportXml(lbr, fo);
            if(retrieveFile){
                retrieveLbXml(context, lbXmlFile, tmpLbXmlFile);
            }
            lbr.getLbConfig().setLastExported();
            String msg = LbLogUtil.getStringManager().getString(
                    "GeneratedFileLocation", lbXmlFile.toString());
            return msg;
        } finally {
            if (fo != null) {
View Full Code Here

Examples of org.glassfish.loadbalancer.admin.cli.reader.api.LoadbalancerReader

    public void publish(ConnectionManager _connectionManager, Domain domain, String lbConfigName) throws IOException,
            Exception {


        // check if the lb exists
        LoadbalancerReader lbr = LbConfigHelper.getLbReader(domain, appRegistry, lbConfigName);

        HttpURLConnection conn =
                _connectionManager.getConnection(LB_UPDATE_CONTEXT_ROOT);
        OutputStream out = null;
        try {
            conn.setDoOutput(true);
            conn.setRequestMethod(POST);
            conn.connect();
            out = conn.getOutputStream();
            LbConfigHelper.exportXml(lbr, out);
            out.flush();
            lbr.getLbConfig().setLastApplied();
        } catch (UnknownHostException uhe) {
            throw new IOException(LbLogUtil.getStringManager().getString("CannotConnectToLBHost", uhe.getMessage()), uhe);
        } catch (Exception e) {
            throw new IOException(e.getMessage(), e);
        } finally {
View Full Code Here

Examples of org.glassfish.loadbalancer.admin.cli.reader.api.LoadbalancerReader

        }
    }

    public String process(AdminCommandContext context) throws Exception {
       
        LoadbalancerReader lbr = null;
        if (lbName != null && lbConfigName == null && target == null) {
            LoadBalancer lb = LbConfigHelper.getLoadBalancer(domain, lbName);
            lbr = LbConfigHelper.getLbReader(domain, appRegistry, lb.getLbConfigName());
        } else if (lbConfigName != null && lbName == null && target == null) {
            lbr = LbConfigHelper.getLbReader(domain, appRegistry, lbConfigName);
        } else if (target != null && lbName == null && lbConfigName == null){
            Set<String> clusters = new HashSet<String>();
            clusters.addAll(target);
            lbr = new LoadbalancerReaderImpl(domain, appRegistry, clusters, properties);
        } else {
            String msg = LbLogUtil.getStringManager().getString("ExportHttpLbConfigInvalidArgs");
            throw new Exception(msg);
        }

        if(fileName == null){
            String configName = lbr.getName();
            if(configName != null){
                fileName = DEFAULT_LB_XML_FILE_NAME + "." + configName;
            } else {
                fileName = DEFAULT_LB_XML_FILE_NAME;
            }
        }

        File lbXmlFile = new File(fileName);
        if(!lbXmlFile.isAbsolute() && !retrieveFile){
            File loadbalancerDir = new File(env.getInstanceRoot(),
                    "load-balancer");
            if(!loadbalancerDir.exists()){
                loadbalancerDir.mkdir();
            }
            lbXmlFile = new File(loadbalancerDir, fileName);
        }

        File tmpLbXmlFile = null;
        if(retrieveFile){
            tmpLbXmlFile = File.createTempFile("load-balancer", ".xml");
            tmpLbXmlFile.deleteOnExit();
        } else {
            if (lbXmlFile.exists()) {
                String msg = LbLogUtil.getStringManager().getString(
                        "FileExists", lbXmlFile.getPath());
                throw new Exception(msg);
            }

            if (!(lbXmlFile.getParentFile().exists())) {
                String msg = LbLogUtil.getStringManager().getString(
                        "ParentFileMissing", lbXmlFile.getParent());
                throw new Exception(msg);
            }
            tmpLbXmlFile = lbXmlFile;
        }

        FileOutputStream fo = null;

        try {
            fo = new FileOutputStream(tmpLbXmlFile);
            LbConfigHelper.exportXml(lbr, fo);
            if(retrieveFile){
                retrieveLbXml(context, lbXmlFile, tmpLbXmlFile);
            }
            LbConfig lbConfig = lbr.getLbConfig();
            //Check for the case when lbtargets are provided
            //In such a case, lbconfig will be null
            if(lbConfig != null){
                lbConfig.setLastExported();
            }
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.