use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.
the class NearCachedClientMapProxy method getConnectedServerVersion.
private int getConnectedServerVersion() {
ClientContext clientContext = getClientContext();
ClientClusterService clusterService = clientContext.getClusterService();
Address ownerConnectionAddress = clusterService.getOwnerConnectionAddress();
HazelcastClientInstanceImpl client = getClient();
ClientConnectionManager connectionManager = client.getConnectionManager();
Connection connection = connectionManager.getConnection(ownerConnectionAddress);
if (connection == null) {
logger.warning(format("No owner connection is available, " + "near cached cache %s will be started in legacy mode", name));
return UNKNOWN_HAZELCAST_VERSION;
}
return ((ClientConnection) connection).getConnectedServerVersion();
}
use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.
the class ClientCacheHelper method deserializeCacheConfig.
private static <K, V> CacheConfig<K, V> deserializeCacheConfig(HazelcastClientInstanceImpl client, ClientMessage responseMessage, SerializationService serializationService, ClientInvocation clientInvocation) {
Data responseData = CacheGetConfigCodec.decodeResponse(responseMessage).response;
ClientConnection sendConnection = clientInvocation.getSendConnection();
if (null != sendConnection && BuildInfo.UNKNOWN_HAZELCAST_VERSION == sendConnection.getConnectedServerVersion()) {
boolean compatibilityEnabled = client.getProperties().getBoolean(ClientProperty.COMPATIBILITY_3_6_SERVER_ENABLED);
if (compatibilityEnabled) {
LegacyCacheConfig<K, V> legacyConfig = serializationService.toObject(responseData, LegacyCacheConfig.class);
if (null == legacyConfig) {
return null;
}
return legacyConfig.getConfigAndReset();
}
}
return serializationService.toObject(responseData);
}
use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.
the class ClientClusterServiceImpl method getLocalClient.
@Override
public Client getLocalClient() {
Address address = getOwnerConnectionAddress();
final ClientConnectionManager cm = client.getConnectionManager();
final ClientConnection connection = (ClientConnection) cm.getConnection(address);
InetSocketAddress inetSocketAddress = connection != null ? connection.getLocalSocketAddress() : null;
final String uuid = getPrincipal().getUuid();
return new ClientImpl(uuid, inetSocketAddress);
}
use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.
the class ClientServiceTest method testPendingEventPacketsWithEvents.
@Test(timeout = 120000)
public void testPendingEventPacketsWithEvents() throws InterruptedException, UnknownHostException {
HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
IMap map = client.getMap(randomName());
map.addEntryListener(new EntryAdapter(), false);
for (int i = 0; i < 10; i++) {
map.put(randomString(), randomString());
}
HazelcastClientInstanceImpl clientInstanceImpl = ClientTestUtil.getHazelcastClientInstanceImpl(client);
InetSocketAddress socketAddress = hazelcastInstance.getCluster().getLocalMember().getSocketAddress();
Address address = new Address(socketAddress.getAddress().getHostAddress(), socketAddress.getPort());
ClientConnectionManager connectionManager = clientInstanceImpl.getConnectionManager();
final ClientConnection connection = (ClientConnection) connectionManager.getConnection(address);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(0, connection.getPendingPacketCount());
}
});
}
use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.
the class ClientNonSmartInvocationServiceImpl method sendToOwner.
private void sendToOwner(ClientInvocation invocation) throws IOException {
ClientClusterService clusterService = client.getClientClusterService();
Address ownerConnectionAddress = clusterService.getOwnerConnectionAddress();
if (ownerConnectionAddress == null) {
throw new IOException("Packet is not send to owner address");
}
Connection conn = connectionManager.getConnection(ownerConnectionAddress);
if (conn == null) {
throw new IOException("Packet is not sent to owner address: " + ownerConnectionAddress);
}
send(invocation, (ClientConnection) conn);
}
Aggregations