use of org.apache.geode.internal.cache.DiskEntry.Helper.ValueWrapper in project geode by apache.
the class Oplog method copyForwardModifyForCompact.
private void copyForwardModifyForCompact(DiskRegionView dr, DiskEntry entry, BytesAndBitsForCompactor wrapper) {
if (getOplogSet().getChild() != this) {
getOplogSet().getChild().copyForwardModifyForCompact(dr, entry, wrapper);
} else {
DiskId did = entry.getDiskId();
boolean exceptionOccurred = false;
int len = did.getValueLength();
try {
// TODO: compaction needs to get version?
byte userBits = wrapper.getBits();
ValueWrapper vw;
if (wrapper.getOffHeapData() != null) {
vw = new DiskEntry.Helper.OffHeapValueWrapper(wrapper.getOffHeapData());
} else {
vw = new DiskEntry.Helper.CompactorValueWrapper(wrapper.getBytes(), wrapper.getValidLength());
}
// Compactor always says to do an async basicModify so that its writes
// will be grouped. This is not a true async write; just a grouped one.
basicModify(dr, entry, vw, userBits, true, true);
} catch (IOException ex) {
exceptionOccurred = true;
getParent().getCancelCriterion().checkCancelInProgress(ex);
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, getParent());
} catch (InterruptedException ie) {
exceptionOccurred = true;
Thread.currentThread().interrupt();
getParent().getCancelCriterion().checkCancelInProgress(ie);
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, getParent());
} finally {
if (wrapper.getOffHeapData() != null) {
wrapper.setOffHeapData(null, (byte) 0);
}
if (exceptionOccurred) {
did.setValueLength(len);
}
}
}
}
use of org.apache.geode.internal.cache.DiskEntry.Helper.ValueWrapper in project geode by apache.
the class Oplog method offlineModify.
public void offlineModify(DiskRegionView drv, DiskEntry entry, byte[] value, boolean isSerializedObject) {
try {
ValueWrapper vw = new DiskEntry.Helper.ByteArrayValueWrapper(isSerializedObject, value);
byte userBits = calcUserBits(vw);
// save versions for creates and updates even if value is bytearrary in 7.0
VersionStamp vs = entry.getVersionStamp();
if (vs != null) {
if (vs.getMemberID() == null) {
throw new AssertionError("Version stamp should have a member at this point for entry " + entry);
}
// Since we are modifying this entry's value while offline make sure its version stamp
// has this disk store as its member id and bump the version
vs.setMemberID(getParent().getDiskStoreID());
VersionTag vt = vs.asVersionTag();
vt.setRegionVersion(drv.getRegionVersionVector().getNextVersion());
vt.setEntryVersion(vt.getEntryVersion() + 1);
vt.setVersionTimeStamp(System.currentTimeMillis());
vs.setVersions(vt);
userBits = EntryBits.setWithVersions(userBits, true);
}
basicModify(drv, entry, vw, userBits, false, false);
} catch (IOException ex) {
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, drv.getName());
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, drv.getName());
}
}
Aggregations