@Override public Set<Partition> getPartitions() { final int partitionCount = partitionService.getPartitionCount(); Set<Partition> partitions = new LinkedHashSet<Partition>(partitionCount); for (int i = 0; i < partitionCount; i++) { final Partition partition = partitionService.getPartition(i); partitions.add(partition); } return partitions; }
@Override public int getPartitionId(Data key) { return partitionService.getPartitionId(key); }
@Override public Partition getPartition(Object key) { final int partitionId = partitionService.getPartitionId(key); return partitionService.getPartition(partitionId); }
@Override public int getPartitionCount() { return partitionService.getPartitionCount(); } }
@Override public void putAll(Map<? extends K, ? extends V> map) { ClientPartitionService partitionService = getContext().getPartitionService(); int partitionCount = partitionService.getPartitionCount(); Map<Integer, List<Map.Entry<Data, Data>>> entryMap = new HashMap<Integer, List<Map.Entry<Data, Data>>>(partitionCount); for (Entry<? extends K, ? extends V> entry : map.entrySet()) { checkNotNull(entry.getKey(), NULL_KEY_IS_NOT_ALLOWED); checkNotNull(entry.getValue(), NULL_VALUE_IS_NOT_ALLOWED); Data keyData = toData(entry.getKey()); int partitionId = partitionService.getPartitionId(keyData); List<Map.Entry<Data, Data>> partition = entryMap.get(partitionId); if (partition == null) { partition = new ArrayList<Map.Entry<Data, Data>>(); entryMap.put(partitionId, partition); } partition.add(new AbstractMap.SimpleEntry<Data, Data>(keyData, toData(entry.getValue()))); } putAllInternal(map, entryMap); }
private static Address getSendAddress(HazelcastClientInstanceImpl client, int partitionId) throws IOException { Address address; if (client.getClientConfig().getNetworkConfig().isSmartRouting()) { address = client.getClientPartitionService().getPartitionOwner(partitionId); if (address == null) { throw new IOException("Partition does not have an owner. partitionId: " + partitionId); } } else { address = client.getConnectionManager().getOwnerConnectionAddress(); if (address == null) { throw new IOException("NonSmartClientInvocationService: Owner connection is not available."); } } return address; }
@Override public int getPartitionCount() { return partitionService.getPartitionCount(); } }
@Override public Partition getPartition(Object key) { final int partitionId = partitionService.getPartitionId(key); return partitionService.getPartition(partitionId); }
@Override public void putAll(Map<? extends K, ? extends V> map) { ClientPartitionService partitionService = getContext().getPartitionService(); int partitionCount = partitionService.getPartitionCount(); Map<Integer, List<Map.Entry<Data, Data>>> entryMap = new HashMap<Integer, List<Map.Entry<Data, Data>>>(partitionCount); for (Entry<? extends K, ? extends V> entry : map.entrySet()) { checkNotNull(entry.getKey(), NULL_KEY_IS_NOT_ALLOWED); checkNotNull(entry.getValue(), NULL_VALUE_IS_NOT_ALLOWED); Data keyData = toData(entry.getKey()); int partitionId = partitionService.getPartitionId(keyData); List<Map.Entry<Data, Data>> partition = entryMap.get(partitionId); if (partition == null) { partition = new ArrayList<Map.Entry<Data, Data>>(); entryMap.put(partitionId, partition); } partition.add(new AbstractMap.SimpleEntry<Data, Data>(keyData, toData(entry.getValue()))); } putAllInternal(map, entryMap); }
private static Address getSendAddress(HazelcastClientInstanceImpl client, int partitionId) throws IOException { Address address; if (client.getClientConfig().getNetworkConfig().isSmartRouting()) { address = client.getClientPartitionService().getPartitionOwner(partitionId); if (address == null) { throw new IOException("Partition does not have an owner. partitionId: " + partitionId); } } else { address = client.getConnectionManager().getOwnerConnectionAddress(); if (address == null) { throw new IOException("NonSmartClientInvocationService: Owner connection is not available."); } } return address; }
@Override public int getPartitionId(Object key) { return partitionService.getPartitionId(key); }
@Override public String randomPartitionKey() { return Integer.toString(random.nextInt(partitionService.getPartitionCount())); }
@Override public Set<Partition> getPartitions() { final int partitionCount = partitionService.getPartitionCount(); Set<Partition> partitions = new LinkedHashSet<Partition>(partitionCount); for (int i = 0; i < partitionCount; i++) { final Partition partition = partitionService.getPartition(i); partitions.add(partition); } return partitions; }
@Override public void invokeOnPartitionOwner(ClientInvocation invocation, int partitionId) throws IOException { final Address owner = partitionService.getPartitionOwner(partitionId); if (owner == null) { throw new IOException("Partition does not have an owner. partitionId: " + partitionId); } if (!isMember(owner)) { throw new TargetNotMemberException("Partition owner '" + owner + "' is not a member."); } invocation.getClientMessage().setPartitionId(partitionId); Connection connection = getOrTriggerConnect(owner, invocation.getClientMessage().acquiresResource()); send(invocation, (ClientConnection) connection); }
@Override public int getPartitionId(Object key) { return partitionService.getPartitionId(key); }
@Override public String randomPartitionKey() { return Integer.toString(random.nextInt(partitionService.getPartitionCount())); }
@Override public void invokeOnPartitionOwner(ClientInvocation invocation, int partitionId) throws IOException { final Address owner = partitionService.getPartitionOwner(partitionId); if (owner == null) { throw new IOException("Partition does not have an owner. partitionId: " + partitionId); } if (!isMember(owner)) { throw new TargetNotMemberException("Partition owner '" + owner + "' is not a member."); } invocation.getClientMessage().setPartitionId(partitionId); Connection connection = getOrTriggerConnect(owner, invocation.getClientMessage().acquiresResource()); send(invocation, (ClientConnection) connection); }
@Override public int getPartitionId(Data key) { return partitionService.getPartitionId(key); }
@Override public int getPartitionCount() { return clientContext.getPartitionService().getPartitionCount(); }
@Override public int getPartitionId(Object object) { return clientContext.getPartitionService().getPartitionId(object); }