use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.
the class SetEqualsHashTest method testCollectionItem_equalsAndHash.
@Test
public void testCollectionItem_equalsAndHash() {
SerializationServiceBuilder serializationServiceBuilder = new DefaultSerializationServiceBuilder();
SerializationService build = serializationServiceBuilder.build();
Data value = build.toData(randomString());
CollectionItem firstItem = new CollectionItem(1, value);
CollectionItem secondItem = new CollectionItem(2, value);
assertTrue(firstItem.equals(secondItem));
assertEquals(firstItem.hashCode(), secondItem.hashCode());
}
use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.
the class SetKeyValueSource method open.
@Override
public boolean open(NodeEngine nodeEngine) {
NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
ss = nei.getSerializationService();
Address thisAddress = nei.getThisAddress();
InternalPartitionService ps = nei.getPartitionService();
Data data = ss.toData(setName, StringAndPartitionAwarePartitioningStrategy.INSTANCE);
int partitionId = ps.getPartitionId(data);
Address partitionOwner = ps.getPartitionOwner(partitionId);
if (partitionOwner == null) {
return false;
}
if (thisAddress.equals(partitionOwner)) {
SetService setService = nei.getService(SetService.SERVICE_NAME);
SetContainer setContainer = setService.getOrCreateContainer(setName, false);
List<CollectionItem> items = new ArrayList<CollectionItem>(setContainer.getCollection());
iterator = items.iterator();
}
return true;
}
use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.
the class ListContainer method addTxItemOrdered.
private void addTxItemOrdered(CollectionItem item) {
ListIterator<CollectionItem> iterator = getCollection().listIterator();
while (iterator.hasNext()) {
CollectionItem collectionItem = iterator.next();
if (item.getItemId() < collectionItem.getItemId()) {
iterator.previous();
break;
}
}
iterator.add(item);
}
use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.
the class ListContainer method getMap.
@Override
protected Map<Long, CollectionItem> getMap() {
if (itemMap == null) {
if (itemList != null && !itemList.isEmpty()) {
itemMap = new HashMap<Long, CollectionItem>(itemList.size());
for (CollectionItem item : itemList) {
itemMap.put(item.getItemId(), item);
}
itemList.clear();
} else {
itemMap = new HashMap<Long, CollectionItem>(INITIAL_CAPACITY);
}
itemList = null;
}
return itemMap;
}
use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.
the class ListContainer method setBackup.
public void setBackup(long oldItemId, long itemId, Data value) {
getMap().remove(oldItemId);
getMap().put(itemId, new CollectionItem(itemId, value));
}
Aggregations