Package com.sun.enterprise.config.serverbeans

Examples of com.sun.enterprise.config.serverbeans.ServerRef


                String msg = _strMgr.getString("NotStandAloneInstance",
                        serverName);
                throw new MBeanException(new ConfigException(msg));
            }

            ServerRef sRef = new ServerRef();
            sRef.setRef(serverName);
            clbConfig.addServerRef(sRef);
        } catch (ConfigException ce) {
            throw new MBeanException(ce);
        }
    }
View Full Code Here


                    throw new MBeanException(new ConfigException(msg));
                }

                appRefs = s.getApplicationRef();

                ServerRef sRef = clbConfig.getServerRefByRef(target);
                sRef.setLbEnabled(lbEnableInstances);
            }
        } catch (ConfigException ce) {
            throw new MBeanException(ce);
        }
    }
View Full Code Here

    private void deleteServerFromConvergedLbConfig(String configName, Boolean force,
        String serverName) throws MBeanException {
        ConvergedLbConfig clbConfig = getConvergedLbConfig(configName);

        ServerRef sRef = clbConfig.getServerRefByRef(serverName);

        if (sRef == null) {
            // does not exist, just return from here
            _logger.log(Level.FINEST,
                " server " + serverName +
                " does not exist in any cluster in the domain");

            String msg = _strMgr.getString("ServerNotDefined", serverName);
            throw new MBeanException(new RuntimeException(msg));
        }

        if (sRef.isLbEnabled() && (!force)) {
            String msg = _strMgr.getString("ServerNeedsToBeDisabled", serverName);
            throw new MBeanException(new ConfigException(msg));
        }

        // check if its applications are LB disabled.
        Server s = null;

        try {
            ConfigContext ctx = AdminService.getAdminService().getAdminContext()
                                            .getAdminConfigContext();
            s = ServerHelper.getServerByName(ctx, sRef.getRef());
        } catch (ConfigException ce) {
            throw new MBeanException(ce);
        }

        if (s == null) {
View Full Code Here

                // Check if the instance provided is a stand alone instance
                ConvergedLbConfigs lbConfigs = getConvergedLbConfigs();
                ConvergedLbConfig[]  lbConfig = lbConfigs.getConvergedLbConfig();
                for (int i=0; i < lbConfig.length; i++) {
                    ConvergedLbConfig clbConfig = lbConfig[i];
                    ServerRef sRef = clbConfig.getServerRefByRef(target);
                    if (sRef != null) {
                        sRef.setLbEnabled(false);
                        sRef.setDisableTimeoutInMinutes(time);
                        found = true;
                        break;
                    }
                }
                if (!found) {
View Full Code Here

                // Check if the instance provided is a stand alone instance
                ConvergedLbConfigs lbConfigs = getConvergedLbConfigs();
                ConvergedLbConfig[]  lbConfig = lbConfigs.getConvergedLbConfig();
                for (int i=0; i < lbConfig.length; i++) {
                    ConvergedLbConfig clbConfig = lbConfig[i];
                    ServerRef sRef = clbConfig.getServerRefByRef(target);
                    if (sRef != null) {
                        sRef.setLbEnabled(true);
                        found = true;
                        break;
                    }
                }
                if (!found) {
View Full Code Here

    }

    private void deleteServerFromLBConfig(LbConfigs lbconfigs, String configName,String serverName) {
        LbConfig lbConfig = lbconfigs.getLbConfig(configName);

        ServerRef  sRef = lbConfig.getRefByRef(ServerRef.class, serverName);
        if (sRef == null) {
            // does not exist, just return from here
            String msg = localStrings.getLocalString("ServerNotDefined",
                        "Server {0} cannot be used as target", target);
            logger.finest("Server " + serverName +
                    " does not exist in any cluster in the domain");
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }
        if (!Boolean.parseBoolean(force)) {
            if (Boolean.parseBoolean(sRef.getLbEnabled())) {
                String msg = localStrings.getLocalString("ServerNeedsToBeDisabled",
                        "Server [{0}] needs to be disabled before it can be removed from the load balancer.",
                        serverName);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setMessage(msg);
View Full Code Here

    }

    private void addServerToLBConfig(final LbConfigs lbconfigs, final String configName, final String serverName) {
        LbConfig lbConfig = lbconfigs.getLbConfig(configName);

        ServerRef sRef = lbConfig.getRefByRef(ServerRef.class, serverName);
        if (sRef != null) {
            String msg = localStrings.getLocalString("LBServerRefExists",
                   "LB config already contains a server-ref for target {0}", target);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }

        Server server = domain.getServerNamed(serverName);
        boolean isStandAlone = server.getCluster() == null && server.isInstance();
        if (!isStandAlone) {
            String msg = localStrings.getLocalString("NotStandAloneInstance",
                    "[{0}] is not a stand alone instance. Only stand alone instance can be added to a load balancer.",
                    serverName);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }

        try {
            ConfigSupport.apply(new SingleConfigCode<LbConfig>() {
                @Override
                public Object run(LbConfig param) throws PropertyVetoException, TransactionFailure {
                    ServerRef ref = param.createChild(ServerRef.class);
                    ref.setRef(serverName);
                    param.getClusterRefOrServerRef().add(ref);
                    return Boolean.TRUE;
                }
            }, lbConfig);
        } catch (TransactionFailure ex) {
View Full Code Here

                report.setMessage(msg);
                return;
            }
        // target is a server
        } else if (domain.isServer(target)) {
            ServerRef sRef = lbConfig.getRefByRef(ServerRef.class, target);

            // server is not associated to this lb config
            if (sRef == null){
                String msg = localStrings.getLocalString("UnassociatedServer",
                        "Load balancer configuration [{0}] does not have a reference to the given server [{1}].",
                        lbConfigName, target);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setMessage(msg);
                return;
            }

            if (sRef.getHealthChecker() == null) {
                try {
                    addHealthChecker(sRef);
                } catch (TransactionFailure ex) {
                    String msg = localStrings.getLocalString("FailedToAddHC", "Failed to add health checker");
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
View Full Code Here

                        list.add(lbConfigs.get(i));
                    }

                // target is a server
                } else if (domain.isServer(target)) {
                    ServerRef sRef = lbConfigs.get(i).getRefByRef(ServerRef.class, target);

                    // this lb config has a reference to the target server
                    if (sRef != null) {
                        list.add(lbConfigs.get(i));
                    }
View Full Code Here

            updateLBForCluster(report, target, "false", timeout);
        else {
            boolean foundTarget = false;
            List<LbConfig> lbConfigs = lbconfigs.getLbConfig();
            for (LbConfig lc:lbConfigs) {
                ServerRef  sRef = lc.getRefByRef(ServerRef.class, target);
                if (sRef == null) {
                    //log a warning and continue search
                    logger.warning(localStrings.getLocalString("InvalidInstance",
                            "Server {0} does not exist in {1}", target, lc.getName()));
                } else {
                    int curTout = Integer.parseInt(sRef.getDisableTimeoutInMinutes());

                    boolean enabled = sRef.getLbEnabled().equals("true");
                    if ((enabled == false) && (curTout == t)) {
                        String msg = localStrings.getLocalString("ServerDisabled",
                                "Server [{0}] is already disabled.", sRef.getRef());
                        report.setMessage(msg);
                        return;
                    }
                    try {
                        updateLbEnabled(sRef, "false", timeout);
                    } catch (TransactionFailure ex) {
                        String msg = localStrings.getLocalString("FailedToUpdateAttr",
                            "Failed to update lb-enabled attribute for {0}", target);
                        report.setMessage(msg);
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        report.setFailureCause(ex);
                        return;
                    }
                    foundTarget = true;
                }
            }
            // did not find server target
            if (!foundTarget) {
                ServerRef sRef = getServerRefFromCluster(report, target);

                if (sRef == null) {
                    String msg = localStrings.getLocalString("InvalidServer",
                            "Server {0} does not exist", target);
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    report.setMessage(msg);
                    return;
                } else {
                    int curTout = Integer.parseInt(sRef.getDisableTimeoutInMinutes());

                    boolean enabled = sRef.getLbEnabled().equals("true");
                    if ((enabled == false) && (curTout == t)) {
                        String msg = localStrings.getLocalString("ServerDisabled",
                                "Server [{0}] is already disabled.", sRef.getRef());
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        report.setMessage(msg);
                        return;
                    }
                    try {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.config.serverbeans.ServerRef

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.