use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class PutBackupOperation method run.
@Override
public void run() throws Exception {
MultiMapRecord record = new MultiMapRecord(recordId, isBinary() ? value : toObject(value));
Collection<MultiMapRecord> coll = getOrCreateMultiMapValue().getCollection(false);
if (index == -1) {
response = coll.add(record);
} else {
try {
((List<MultiMapRecord>) coll).add(index, record);
response = true;
} catch (IndexOutOfBoundsException e) {
response = e;
}
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class PutOperation method run.
@Override
public void run() throws Exception {
MultiMapContainer container = getOrCreateContainer();
recordId = container.nextId();
MultiMapRecord record = new MultiMapRecord(recordId, isBinary() ? value : toObject(value));
Collection<MultiMapRecord> coll = container.getOrCreateMultiMapValue(dataKey).getCollection(false);
if (index == -1) {
response = coll.add(record);
} else {
try {
((List<MultiMapRecord>) coll).add(index, record);
response = true;
} catch (IndexOutOfBoundsException e) {
response = e;
}
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class TxnRemoveAllBackupOperation method run.
@Override
public void run() throws Exception {
MultiMapContainer container = getOrCreateContainer();
MultiMapValue multiMapValue = container.getOrCreateMultiMapValue(dataKey);
response = true;
for (Long recordId : recordIds) {
if (!multiMapValue.containsRecordId(recordId)) {
response = false;
return;
}
}
Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
for (Long recordId : recordIds) {
Iterator<MultiMapRecord> iter = coll.iterator();
while (iter.hasNext()) {
MultiMapRecord record = iter.next();
if (record.getRecordId() == recordId) {
iter.remove();
break;
}
}
}
if (coll.isEmpty()) {
delete();
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class TxnRemoveAllOperation method run.
@Override
public void run() throws Exception {
begin = Clock.currentTimeMillis();
MultiMapContainer container = getOrCreateContainer();
MultiMapValue multiMapValue = container.getOrCreateMultiMapValue(dataKey);
response = true;
for (Long recordId : recordIds) {
if (!multiMapValue.containsRecordId(recordId)) {
response = false;
return;
}
}
Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
removed = new LinkedList<MultiMapRecord>();
for (Long recordId : recordIds) {
Iterator<MultiMapRecord> iter = coll.iterator();
while (iter.hasNext()) {
MultiMapRecord record = iter.next();
if (record.getRecordId() == recordId) {
iter.remove();
removed.add(record);
break;
}
}
}
if (coll.isEmpty()) {
delete();
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class TxnRemoveAllOperation method afterRun.
@Override
public void afterRun() throws Exception {
long elapsed = Math.max(0, Clock.currentTimeMillis() - begin);
final MultiMapService service = getService();
service.getLocalMultiMapStatsImpl(name).incrementRemoves(elapsed);
if (removed != null) {
getOrCreateContainer().update();
for (MultiMapRecord record : removed) {
publishEvent(EntryEventType.REMOVED, dataKey, null, record.getObject());
}
}
}
Aggregations