use of com.hazelcast.client.Client in project hazelcast by hazelcast.
the class GetConnectedClientsOperation method run.
@Override
public void run() throws Exception {
ClientEngine service = getService();
final Collection<Client> serviceClients = service.getClients();
this.clients = createHashMap(serviceClients.size());
for (Client clientEndpoint : serviceClients) {
ClientEndpointImpl clientEndpointImpl = (ClientEndpointImpl) clientEndpoint;
this.clients.put(clientEndpointImpl.getUuid(), clientEndpointImpl.getClientType());
}
}
use of com.hazelcast.client.Client in project hazelcast by hazelcast.
the class ClientBwListConfigHandlerTest method testApplyConfig_emptyWhitelist.
@Test
public void testApplyConfig_emptyWhitelist() {
ClientBwListDTO config = createConfig(Mode.WHITELIST);
handler.applyConfig(config);
Client client = createClient("127.0.0.1", "a_name");
assertFalse(clientEngine.isClientAllowed(client));
}
use of com.hazelcast.client.Client in project hazelcast by hazelcast.
the class ClientBwListConfigHandlerTest method testApplyConfig_disabledMode.
@Test
public void testApplyConfig_disabledMode() {
clientEngine.applySelector(ClientSelectors.none());
ClientBwListDTO config = createConfig(Mode.DISABLED);
handler.applyConfig(config);
Client client = createClient("127.0.0.1", randomString());
assertTrue(clientEngine.isClientAllowed(client));
}
use of com.hazelcast.client.Client in project hazelcast by hazelcast.
the class ClientBwListConfigHandlerTest method testApplyConfig_whitelist.
@Test
public void testApplyConfig_whitelist() {
ClientBwListDTO config = createConfig(Mode.WHITELIST, new ClientBwListEntryDTO(Type.IP_ADDRESS, "127.0.0.*"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "192.168.0.1"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "192.168.0.42-43"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "fe80:0:0:0:45c5:47ee:fe15:493a"), new ClientBwListEntryDTO(Type.INSTANCE_NAME, "client*"), new ClientBwListEntryDTO(Type.LABEL, "label*"));
handler.applyConfig(config);
Client[] allowed = { createClient("127.0.0.3", "a_name"), createClient("192.168.0.1", "a_name"), createClient("192.168.0.42", "a_name"), createClient("fe80:0:0:0:45c5:47ee:fe15:493a", "a_name"), createClient("192.168.0.101", "client4"), createClient("192.168.0.101", "a_name", "label") };
for (Client client : allowed) {
assertTrue(clientEngine.isClientAllowed(client));
}
Client[] denied = { createClient("192.168.0.101", "a_name", "random"), createClient("fe70:0:0:0:35c5:16ee:fe15:491a", "a_name", "random") };
for (Client client : denied) {
assertFalse(clientEngine.isClientAllowed(client));
}
}
use of com.hazelcast.client.Client in project hazelcast by hazelcast.
the class ClientMetricsTest method assertClientMetricsObservedEventually.
private void assertClientMetricsObservedEventually(HazelcastInstance memberInstance, MetricsRegistry metricsRegistry, String prefix, String metric, ProbeUnit unit) {
assertTrueEventually(() -> {
CapturingCollector collector = new CapturingCollector();
metricsRegistry.collect(collector);
ClientEngine clientEngine = getNode(memberInstance).getClientEngine();
Collection<Client> clients = clientEngine.getClients();
assertEquals(2, clients.size());
for (Client client : clients) {
UUID clientUuid = client.getUuid();
ClientStatistics clientStatistics = clientEngine.getClientStatistics().get(clientUuid);
assertNotNull(clientStatistics);
long timestamp = clientStatistics.timestamp();
MetricDescriptor expectedDescriptor = DEFAULT_DESCRIPTOR_SUPPLIER.get().withPrefix(prefix).withMetric(metric).withUnit(unit).withTag("client", clientUuid.toString()).withTag("clientname", client.getName()).withTag("timestamp", Long.toString(timestamp)).withExcludedTargets(asList(MetricTarget.values())).withIncludedTarget(MANAGEMENT_CENTER);
assertContains(collector.captures().keySet(), expectedDescriptor);
}
});
}
Aggregations