Search in sources :

Example 1 with ServiceProviderConfigurationKeys

use of com.sun.enterprise.ee.cms.core.ServiceProviderConfigurationKeys in project Payara by payara.

the class GMSAdapterImpl method readGMSConfigProps.

private void readGMSConfigProps(Properties configProps) {
    configProps.put(MEMBERTYPE_STRING, isDas ? SPECTATOR : CORE);
    for (ServiceProviderConfigurationKeys key : ServiceProviderConfigurationKeys.values()) {
        String keyName = key.toString();
        try {
            switch(key) {
                case MULTICASTADDRESS:
                    if (cluster != null) {
                        String value = cluster.getGmsMulticastAddress();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    }
                    break;
                case MULTICASTPORT:
                    if (cluster != null) {
                        String value = cluster.getGmsMulticastPort();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    }
                    break;
                case FAILURE_DETECTION_TIMEOUT:
                    if (clusterConfig != null) {
                        String value = clusterConfig.getGroupManagementService().getFailureDetection().getHeartbeatFrequencyInMillis();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    }
                    break;
                case FAILURE_DETECTION_RETRIES:
                    if (clusterConfig != null) {
                        String value = clusterConfig.getGroupManagementService().getFailureDetection().getMaxMissedHeartbeats();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    }
                    break;
                case FAILURE_VERIFICATION_TIMEOUT:
                    if (clusterConfig != null) {
                        String value = clusterConfig.getGroupManagementService().getFailureDetection().getVerifyFailureWaittimeInMillis();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    }
                    break;
                case DISCOVERY_TIMEOUT:
                    if (clusterConfig != null) {
                        String value = clusterConfig.getGroupManagementService().getGroupDiscoveryTimeoutInMillis();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    }
                    break;
                case IS_BOOTSTRAPPING_NODE:
                    configProps.put(keyName, isDas ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
                    break;
                case BIND_INTERFACE_ADDRESS:
                    if (cluster != null) {
                        String value = cluster.getGmsBindInterfaceAddress();
                        if (value != null) {
                            value = value.trim();
                        }
                        if (value != null && value.length() > 1 && value.charAt(0) != '$') {
                            // Only supported IPv4 address in gf v2.
                            if (NetworkUtility.isBindAddressValid(value)) {
                                configProps.put(keyName, value);
                            } else {
                                GMS_LOGGER.log(LogLevel.SEVERE, GMS_BIND_INT_ADDRESS_INVALID, value);
                            }
                        }
                    }
                    break;
                case FAILURE_DETECTION_TCP_RETRANSMIT_TIMEOUT:
                    if (clusterConfig != null) {
                        String value = clusterConfig.getGroupManagementService().getFailureDetection().getVerifyFailureConnectTimeoutInMillis();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    }
                    break;
                case MULTICAST_POOLSIZE:
                case INCOMING_MESSAGE_QUEUE_SIZE:
                // case MAX_MESSAGE_LENGTH:    todo uncomment with shoal-gms.jar with this defined is promoted.
                case FAILURE_DETECTION_TCP_RETRANSMIT_PORT:
                    if (clusterConfig != null) {
                        Property prop = clusterConfig.getGroupManagementService().getProperty(keyName);
                        if (prop == null) {
                            if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
                                GMS_LOGGER.log(LogLevel.FINE, String.format("No config property found for %s", keyName));
                            }
                            break;
                        }
                        String value = prop.getValue().trim();
                        if (value != null) {
                            configProps.put(keyName, value);
                        }
                    /*
                            int positiveint = 0;
                            try {
                                positiveint = Integer.getInteger(value);
                            } catch (Throwable t) {}

                            // todo
                            if (positiveint > 0) {
                                configProps.put(keyName, positiveint);
                            } // todo else log event that invalid value was provided.
                            */
                    }
                    break;
                // Must place here or they will get flagged as not handled.
                case LOOPBACK:
                case VIRTUAL_MULTICAST_URI_LIST:
                    break;
                default:
                    if (GMS_LOGGER.isLoggable(LogLevel.FINE)) {
                        GMS_LOGGER.log(LogLevel.FINE, String.format("service provider key %s ignored", keyName));
                    }
                    break;
            }
        /* end switch over ServiceProviderConfigurationKeys enum */
        } catch (Throwable t) {
            GMS_LOGGER.log(LogLevel.WARNING, GMS_EXCEPTION_PROCESSING_CONFIG, t.getLocalizedMessage());
        }
    }
    /* end for loop over ServiceProviderConfigurationKeys */
    // check for Grizzly transport specific properties in GroupManagementService property list and then cluster property list.
    // cluster property is more specific than group-mangement-service, so allow cluster property to override group-management-service proeprty
    // if a GrizzlyConfigConstant property is in both list.
    List<Property> props = null;
    if (clusterConfig != null) {
        props = clusterConfig.getGroupManagementService().getProperty();
        for (Property prop : props) {
            String name = prop.getName().trim();
            String value = prop.getValue().trim();
            if (name == null || value == null) {
                continue;
            }
            if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
                GMS_LOGGER.log(LogLevel.CONFIG, "processing group-management-service property name=" + name + " value= " + value);
            }
            if (value.startsWith("${")) {
                if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
                    GMS_LOGGER.log(LogLevel.CONFIG, "skipping group-management-service property name=" + name + " since value is unresolved symbolic token=" + value);
                }
            } else {
                if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
                    GMS_LOGGER.log(LogLevel.CONFIG, "processing group-management-service property name=" + name + " value= " + value);
                }
                if (name.startsWith(GMS_PROPERTY_PREFIX)) {
                    name = name.replaceFirst(GMS_PROPERTY_PREFIX_REGEXP, "");
                }
                configProps.put(name, value);
                if (!validateGMSProperty(name)) {
                    GMS_LOGGER.log(LogLevel.WARNING, GMS_EXCEPTION_IGNORING_PROPERTY, new Object[] { name, value, "" });
                }
            }
        }
    }
    if (cluster != null) {
        props = cluster.getProperty();
        for (Property prop : props) {
            String name = prop.getName().trim();
            String value = prop.getValue().trim();
            if (name == null || value == null) {
                continue;
            }
            if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
                GMS_LOGGER.log(LogLevel.CONFIG, "processing cluster property name=" + name + " value= " + value);
            }
            if (value.startsWith("${")) {
                if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
                    GMS_LOGGER.log(LogLevel.CONFIG, "skipping cluster property name=" + name + " since value is unresolved symbolic token=" + value);
                }
            } else {
                if (name.startsWith(GMS_PROPERTY_PREFIX)) {
                    name = name.replaceFirst(GMS_PROPERTY_PREFIX_REGEXP, "");
                }
                // impossible to register handlers in a regular app before gms starts up.
                if (name.compareTo("ALIVEANDREADY_LOGGING") == 0) {
                    aliveAndReadyLoggingEnabled = Boolean.parseBoolean(value);
                } else if (name.compareTo("LISTENER_PORT") == 0) {
                    // special case mapping.  Glassfish Cluster property GMS_LISTENER_PORT maps to Grizzly Config Constants TCPSTARTPORT and TCPENDPORT.
                    configProps.put(GrizzlyConfigConstants.TCPSTARTPORT.toString(), value);
                    configProps.put(GrizzlyConfigConstants.TCPENDPORT.toString(), value);
                } else if (name.compareTo("TEST_FAILURE_RECOVERY") == 0) {
                    testFailureRecoveryHandler = Boolean.parseBoolean(value);
                } else if (ServiceProviderConfigurationKeys.DISCOVERY_URI_LIST.name().equals(name) && "generate".equals(value)) {
                    value = generateDiscoveryUriList();
                    configProps.put(name, value);
                } else {
                    // handle normal case.  one to one mapping.
                    configProps.put(name, value);
                    GMS_LOGGER.log(LogLevel.CONFIG, "processing cluster property name=" + name + " value= " + value);
                    if (!validateGMSProperty(name)) {
                        GMS_LOGGER.log(LogLevel.WARNING, GMS_EXCEPTION_CLUSTER_PROPERTY_ERROR, new Object[] { name, value, "" });
                    }
                }
            }
        }
    }
}
Also used : ServiceProviderConfigurationKeys(com.sun.enterprise.ee.cms.core.ServiceProviderConfigurationKeys) Property(org.jvnet.hk2.config.types.Property)

Aggregations

ServiceProviderConfigurationKeys (com.sun.enterprise.ee.cms.core.ServiceProviderConfigurationKeys)1 Property (org.jvnet.hk2.config.types.Property)1