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));
}
}
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;
}
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);
}
}
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);
}
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;
}
Aggregations