use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class DefaultAddressPickerTest method testBindAddress.
private void testBindAddress(InetAddress address) throws Exception {
addressPicker = new DefaultAddressPicker(config, properties, logger);
addressPicker.pickAddress();
int port = config.getNetworkConfig().getPort();
assertEquals(new Address(address, port), addressPicker.getBindAddress());
assertEquals(addressPicker.getBindAddress(), addressPicker.getPublicAddress());
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class DefaultAddressPickerTest method testPublicAddress_withSpecifiedHostAndPortViaProperty.
@Test
public void testPublicAddress_withSpecifiedHostAndPortViaProperty() throws Exception {
String host = PUBLIC_HOST;
int port = 6789;
config.setProperty("hazelcast.local.publicAddress", host + ":" + port);
addressPicker = new DefaultAddressPicker(config, properties, logger);
addressPicker.pickAddress();
assertEquals(new Address(host, port), addressPicker.getPublicAddress());
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class JoinMessageTrustCheckerTest method createJoinMessage.
private JoinMessage createJoinMessage(String ip) throws UnknownHostException {
InetAddress inetAddress = InetAddress.getByName(ip);
Address address = new Address(inetAddress, 5701);
ConfigCheck configCheck = new ConfigCheck();
return new JoinMessage(Packet.VERSION, 0, MemberVersion.UNKNOWN, address, "uuid", false, configCheck);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class MemberImplTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
hazelcastInstance = new HazelcastInstanceImpl("test", new Config(), new DefaultNodeContext());
address = new Address("127.0.0.1", 5701);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class CacheSplitBrainHandler method prepareMergeRunnable.
Runnable prepareMergeRunnable() {
final Map<String, Map<Data, CacheRecord>> recordMap = new HashMap<String, Map<Data, CacheRecord>>(configs.size());
final IPartitionService partitionService = nodeEngine.getPartitionService();
final int partitionCount = partitionService.getPartitionCount();
final Address thisAddress = nodeEngine.getClusterService().getThisAddress();
for (int i = 0; i < partitionCount; i++) {
// Add your owned entries so they will be merged
if (thisAddress.equals(partitionService.getPartitionOwner(i))) {
CachePartitionSegment segment = segments[i];
Iterator<ICacheRecordStore> iter = segment.recordStoreIterator();
while (iter.hasNext()) {
ICacheRecordStore cacheRecordStore = iter.next();
if (!(cacheRecordStore instanceof SplitBrainAwareCacheRecordStore)) {
continue;
}
String cacheName = cacheRecordStore.getName();
Map<Data, CacheRecord> records = recordMap.get(cacheName);
if (records == null) {
records = new HashMap<Data, CacheRecord>(cacheRecordStore.size());
recordMap.put(cacheName, records);
}
for (Map.Entry<Data, CacheRecord> cacheRecordEntry : cacheRecordStore.getReadOnlyRecords().entrySet()) {
Data key = cacheRecordEntry.getKey();
CacheRecord cacheRecord = cacheRecordEntry.getValue();
records.put(key, cacheRecord);
}
// Clear all records either owned or backup
cacheRecordStore.clear();
// send the cache invalidation event regardless if any actually cleared or not (no need to know how many
// actually cleared)
final CacheService cacheService = nodeEngine.getService(CacheService.SERVICE_NAME);
cacheService.sendInvalidationEvent(cacheName, null, AbstractCacheRecordStore.SOURCE_NOT_AVAILABLE);
}
}
}
return new CacheMerger(nodeEngine, configs, recordMap, mergePolicyProvider);
}
Aggregations