Search in sources :

Example 1 with RestApiConfig

use of com.hazelcast.config.RestApiConfig 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 RestApiConfig

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

the class TcpServerContext method initRestApiConfig.

private static RestApiConfig initRestApiConfig(Config config) {
    AdvancedNetworkConfig advancedNetworkConfig = config.getAdvancedNetworkConfig();
    boolean isAdvancedNetwork = advancedNetworkConfig.isEnabled();
    RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
    if (isAdvancedNetwork && advancedNetworkConfig.getEndpointConfigs().get(REST) != null) {
        RestServerEndpointConfig restServerEndpointConfig = advancedNetworkConfig.getRestEndpointConfig();
        restApiConfig.setEnabled(true).setEnabledGroups(restServerEndpointConfig.getEnabledGroups());
    }
    return restApiConfig;
}
Also used : RestApiConfig(com.hazelcast.config.RestApiConfig) AdvancedNetworkConfig(com.hazelcast.config.AdvancedNetworkConfig) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig)

Example 3 with RestApiConfig

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

the class UnifiedProtocolDecoder method onRead.

@Override
public HandlerStatus onRead() throws Exception {
    upcast(src).flip();
    try {
        if (src.remaining() < PROTOCOL_LENGTH) {
            // The protocol has not yet been fully received.
            return CLEAN;
        }
        String protocol = loadProtocol();
        serverContext.getAuditLogService().eventBuilder(AuditlogTypeIds.NETWORK_SELECT_PROTOCOL).message("Protocol bytes received for a connection").level(Level.DEBUG).addParameter("protocol", protocol).log();
        if (CLUSTER.equals(protocol)) {
            initChannelForCluster();
        } else if (CLIENT_BINARY.equals(protocol)) {
            initChannelForClient();
        } else if (RestApiTextDecoder.TEXT_PARSERS.isCommandPrefix(protocol)) {
            RestApiConfig restApiConfig = serverContext.getRestApiConfig();
            if (!restApiConfig.isEnabledAndNotEmpty()) {
                throw new IllegalStateException("REST API is not enabled. " + "To enable REST API, please do one of the following:\n" + "- Change member config using JAVA API: " + "config.getNetworkConfig().getRestApiConfig().setEnabled(true);\n" + "- Change XML/YAML configuration property: hazelcast.network.rest-api.enabled to true\n" + "- Add system property: -Dhz.network.rest-api.enabled=true\n" + "- Add environment variable property: HZ_NETWORK_RESTAPI_ENABLED=true" + " (recommended when running container/docker image)");
            }
            initChannelForText(protocol, true);
        } else if (MemcacheTextDecoder.TEXT_PARSERS.isCommandPrefix(protocol)) {
            MemcacheProtocolConfig memcacheProtocolConfig = serverContext.getMemcacheProtocolConfig();
            if (!memcacheProtocolConfig.isEnabled()) {
                throw new IllegalStateException("Memcache text protocol is not enabled. " + "To enable Memcache, please do one of the following:\n" + "- Change member config using JAVA API: " + "config.getNetworkConfig().getMemcacheProtocolConfig().setEnabled(true);\n" + "- Change XML/YAML configuration property: " + "hazelcast.network.memcache-protocol.enabled to true\n" + "- Add system property: -Dhz.network.memcache-protocol.enabled=true\n" + "- Add environment variable property: HZ_NETWORK_MEMCACHEPROTOCOL_ENABLED=true" + " (recommended when running container/docker image)");
            }
            // text doesn't have a protocol; anything that isn't cluster/client protocol will be interpreted as txt.
            initChannelForText(protocol, false);
        } else {
            throw new IllegalStateException("Unknown protocol: " + protocol);
        }
        if (!channel.isClientMode()) {
            protocolEncoder.signalProtocolEstablished(protocol);
        }
        return CLEAN;
    } finally {
        compactOrClear(src);
    }
}
Also used : RestApiConfig(com.hazelcast.config.RestApiConfig) MemcacheProtocolConfig(com.hazelcast.config.MemcacheProtocolConfig) StringUtil.bytesToString(com.hazelcast.internal.util.StringUtil.bytesToString)

Example 4 with RestApiConfig

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

the class MemberDomConfigProcessor method handleRestApi.

private void handleRestApi(Node node) {
    RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
    boolean enabled = getBooleanValue(getAttribute(node, "enabled"));
    restApiConfig.setEnabled(enabled);
    handleRestApiEndpointGroups(node);
}
Also used : RestApiConfig(com.hazelcast.config.RestApiConfig)

Example 5 with RestApiConfig

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

the class WanRESTTest method getConfig.

@Override
protected Config getConfig() {
    Config config = smallInstanceConfig();
    RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
    restApiConfig.setEnabled(true);
    restApiConfig.enableGroups(RestEndpointGroup.WAN);
    JoinConfig joinConfig = config.getNetworkConfig().getJoin();
    joinConfig.getMulticastConfig().setEnabled(false);
    joinConfig.getTcpIpConfig().setEnabled(true).addMember("127.0.0.1");
    return config;
}
Also used : RestApiConfig(com.hazelcast.config.RestApiConfig) RestApiConfig(com.hazelcast.config.RestApiConfig) JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) JoinConfig(com.hazelcast.config.JoinConfig)

Aggregations

RestApiConfig (com.hazelcast.config.RestApiConfig)29 Config (com.hazelcast.config.Config)22 QuickTest (com.hazelcast.test.annotation.QuickTest)11 Test (org.junit.Test)11 HazelcastInstance (com.hazelcast.core.HazelcastInstance)8 MemcacheProtocolConfig (com.hazelcast.config.MemcacheProtocolConfig)6 JoinConfig (com.hazelcast.config.JoinConfig)4 RestEndpointGroup (com.hazelcast.config.RestEndpointGroup)3 HazelcastTestSupport.smallInstanceConfig (com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig)3 RestServerEndpointConfig (com.hazelcast.config.RestServerEndpointConfig)2 AdvancedNetworkConfig (com.hazelcast.config.AdvancedNetworkConfig)1 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)1 NetworkConfig (com.hazelcast.config.NetworkConfig)1 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)1 StringUtil.bytesToString (com.hazelcast.internal.util.StringUtil.bytesToString)1 DiscoveryStrategyFactory (com.hazelcast.spi.discovery.DiscoveryStrategyFactory)1 Before (org.junit.Before)1