use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class DiskInitFile method pmidToBytes.
private byte[] pmidToBytes(PersistentMemberID id) {
try {
HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
InternalDataSerializer.invokeToData(id, hdos);
return hdos.toByteArray();
} catch (IOException ex) {
throw new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent);
}
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class DiskInitFile method writeRegionConfig.
private void writeRegionConfig(DiskRegionView drv) {
try {
int len = estimateByteSize(drv.getPartitionName());
int comprLen = estimateByteSize(drv.getCompressorClassName());
HeapDataOutputStream bb = new HeapDataOutputStream(1 + DR_ID_MAX_BYTES + 1 + 1 + 4 + 4 + 4 + 1 + 1 + 4 + len + 4 + 1 + 1 + 1, Version.CURRENT);
bb.write(IFREC_REGION_CONFIG_ID_90);
writeDiskRegionID(bb, drv.getId());
bb.write(drv.getLruAlgorithm());
bb.write(drv.getLruAction());
bb.writeInt(drv.getLruLimit());
bb.writeInt(drv.getConcurrencyLevel());
bb.writeInt(drv.getInitialCapacity());
bb.writeFloat(drv.getLoadFactor());
bb.write((byte) (drv.getStatisticsEnabled() ? 1 : 0));
bb.write((byte) (drv.isBucket() ? 1 : 0));
final EnumSet<DiskRegionFlag> flags = drv.getFlags();
bb.writeUTF(drv.getPartitionName());
bb.writeInt(drv.getStartingBucketId());
bb.writeUTF(drv.getCompressorClassName() == null ? "" : drv.getCompressorClassName());
bb.writeBoolean(flags.contains(DiskRegionFlag.IS_WITH_VERSIONING));
// TODO the offheap flag needs to be in a new version
bb.writeBoolean(drv.getOffHeap());
bb.write(END_OF_RECORD_ID);
// don't do stats for these small records
writeIFRecord(bb, false);
} catch (IOException ex) {
DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent);
if (!this.compactInProgress) {
this.parent.handleDiskAccessException(dae);
}
throw dae;
}
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class EventID method getMembershipId.
/**
* Convert a ClientProxyMembershipID distribted member ID array into one usable by EventIDs
*
* @param client the client's ID
* @return a byte array that may be used in EventID formation
*/
public static byte[] getMembershipId(ClientProxyMembershipID client) {
try {
HeapDataOutputStream hdos = new HeapDataOutputStream(256, Version.CURRENT);
((InternalDistributedMember) client.getDistributedMember()).writeEssentialData(hdos);
return hdos.toByteArray();
} catch (IOException ioe) {
throw new InternalGemFireException(LocalizedStrings.ClientProxyMembershipID_UNABLE_TO_SERIALIZE_IDENTITY.toLocalizedString(), ioe);
}
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class MultiVMRegionTestCase method getCCRegionVersionVector.
/**
* Since version vectors aren't java.io.Serializable we use DataSerializer to return a serialized
* form of the vector
*/
public static byte[] getCCRegionVersionVector() throws Exception {
Object id = getMemberId();
int vm = VM.getCurrentVMNum();
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("vm" + vm + " with id " + id + " copying " + CCRegion.getVersionVector().fullToString());
RegionVersionVector vector = CCRegion.getVersionVector().getCloneForTransmission();
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("clone is " + vector);
HeapDataOutputStream dos = new HeapDataOutputStream(3000, Version.CURRENT);
DataSerializer.writeObject(vector, dos);
byte[] bytes = dos.toByteArray();
org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("serialized size is " + bytes.length);
return bytes;
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class DiskOfflineCompactionJUnitTest method getRVVSize.
static int getRVVSize(int drMapSize, int[] numOfMemberPerDR, boolean gcRVV) {
// if there's one member in rvv, total size is 9 bytes:
// 0: OPLOG_RVV. 1: drMap.size()==1, 2: disRegionId, 3: getRVVTrusted
// 4: memberToVersion.size()==1, 5: memberid, 6-7: versionHolder 8: END_OF_RECORD_ID
// but not every diskRegion has a member in RVV
HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
RegionVersionHolder dummyHolder = new RegionVersionHolder(1);
try {
dummyHolder.toData(out);
} catch (IOException e) {
}
int holderSize = out.size();
out.close();
int size = 1;
size++;
/* drMap.size */
for (int i = 0; i < drMapSize; i++) {
size++;
/* disRegionId */
if (gcRVV) {
size++;
/* numOfMember, i.e. memberToVersion.size */
if (numOfMemberPerDR != null && numOfMemberPerDR[i] > 0) {
for (int j = 0; j < numOfMemberPerDR[i]; j++) {
size++;
/* memberid */
size++;
/* gcversion */
}
}
} else {
size++;
/* getRVVTrusted */
size++;
/* numOfMember, i.e. memberToVersion.size */
if (numOfMemberPerDR != null && numOfMemberPerDR[i] > 0) {
for (int j = 0; j < numOfMemberPerDR[i]; j++) {
size++;
/* memberid */
size += holderSize;
}
}
}
}
size++;
/* END_OF_RECORD_ID */
return size;
}
Aggregations