Search in sources :

Example 1 with RestEndpointGroup

use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.

the class TestFullApplicationContext method testRestApiConfig.

@Test
public void testRestApiConfig() {
    RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
    assertNotNull(restApiConfig);
    assertFalse(restApiConfig.isEnabled());
    for (RestEndpointGroup group : RestEndpointGroup.values()) {
        assertTrue("Unexpected status of REST Endpoint group" + group, restApiConfig.isGroupEnabled(group));
    }
}
Also used : RestApiConfig(com.hazelcast.config.RestApiConfig) RestEndpointGroup(com.hazelcast.config.RestEndpointGroup) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 2 with RestEndpointGroup

use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.

the class RestApiFilter method filterConnection.

@Override
public void filterConnection(String commandLine, ServerConnection connection) {
    RestEndpointGroup restEndpointGroup = getEndpointGroup(commandLine);
    if (restEndpointGroup != null) {
        if (!restApiConfig.isGroupEnabled(restEndpointGroup)) {
            String name = restEndpointGroup.name();
            connection.close("REST endpoint group is not enabled - " + restEndpointGroup + ". To enable it, please do one of the following:\n" + "  - Change member config using JAVA API: " + " config.getNetworkConfig().getRestApiConfig().enableGroups(RestEndpointGroup." + name + ");\n" + "  - Change XML/YAML configuration property: " + "hazelcast.network.rest-api.endpoint-group " + name + " with `enabled` set to true\n" + "  - Add system property: " + "  -Dhz.network.rest-api.endpoint-groups." + name.toLowerCase() + ".enabled=true\n" + "  - Add environment variable property: HZ_NETWORK_RESTAPI_ENDPOINTGROUPS." + name + ".ENABLED=true" + " (recommended when running container/docker image)", null);
        }
    } else if (!commandLine.isEmpty()) {
        connection.close("Unsupported command received on REST API handler.", null);
    }
}
Also used : RestEndpointGroup(com.hazelcast.config.RestEndpointGroup)

Example 3 with RestEndpointGroup

use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.

the class TextProtocolsConfigTest method testRestApiDefaults.

/**
 * <pre>
 * Given: -
 * When: empty RestApiConfig object is created
 * Then: it's disabled and the only enabled REST endpoint group is the CLUSTER_READ
 * </pre>
 */
@Test
public void testRestApiDefaults() throws Exception {
    RestApiConfig restApiConfig = new RestApiConfig();
    assertFalse("REST should be disabled by default", restApiConfig.isEnabled());
    for (RestEndpointGroup endpointGroup : RestEndpointGroup.values()) {
        if (isExpectedDefaultEnabled(endpointGroup)) {
            assertTrue("REST endpoint group should be enabled by default: " + endpointGroup, restApiConfig.isGroupEnabled(endpointGroup));
        } else {
            assertFalse("REST endpoint group should be disabled by default: " + endpointGroup, restApiConfig.isGroupEnabled(endpointGroup));
        }
    }
}
Also used : RestApiConfig(com.hazelcast.config.RestApiConfig) RestEndpointGroup(com.hazelcast.config.RestEndpointGroup) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with RestEndpointGroup

use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.

the class MemberDomConfigProcessor method handleRestEndpointGroup.

private void handleRestEndpointGroup(RestServerEndpointConfig config, Node node) {
    boolean enabled = getBooleanValue(getAttribute(node, "enabled"));
    String name = extractName(node);
    RestEndpointGroup endpointGroup;
    try {
        endpointGroup = RestEndpointGroup.valueOf(name);
    } catch (IllegalArgumentException e) {
        throw new InvalidConfigurationException("Wrong name attribute value was provided in endpoint-group element: " + name + "\nAllowed values: " + Arrays.toString(RestEndpointGroup.values()));
    }
    if (enabled) {
        config.enableGroups(endpointGroup);
    } else {
        config.disableGroups(endpointGroup);
    }
}
Also used : RestEndpointGroup(com.hazelcast.config.RestEndpointGroup) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 5 with RestEndpointGroup

use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.

the class MemberDomConfigProcessor method handleEndpointGroup.

void handleEndpointGroup(Node node, String name) {
    boolean enabled = getBooleanValue(getAttribute(node, "enabled"));
    RestEndpointGroup endpointGroup = lookupEndpointGroup(name);
    RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
    if (enabled) {
        restApiConfig.enableGroups(endpointGroup);
    } else {
        restApiConfig.disableGroups(endpointGroup);
    }
}
Also used : RestApiConfig(com.hazelcast.config.RestApiConfig) RestEndpointGroup(com.hazelcast.config.RestEndpointGroup)

Aggregations

RestEndpointGroup (com.hazelcast.config.RestEndpointGroup)5 RestApiConfig (com.hazelcast.config.RestApiConfig)3 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)1