private TypeRegistry getRegistry() { GemFireCacheImpl gfc = GemFireCacheImpl.getInstance(); if (gfc != null) { return gfc.getPdxRegistry(); } return null; }
private TypeRegistry getRegistry() { GemFireCacheImpl gfc = GemFireCacheImpl.getInstance(); if (gfc != null) { return gfc.getPdxRegistry(); } return null; }
private int getLastPdxTypeId() { return this.c.getPdxRegistry().getLastAllocatedTypeId(); }
public static PdxInstance createPdxEnum(String className, String enumName, int enumOrdinal, GemFireCacheImpl gfc) { if (className == null) { throw new IllegalArgumentException("className must not be null"); } if (enumName == null) { throw new IllegalArgumentException("enumName must not be null"); } TypeRegistry tr = gfc.getPdxRegistry(); EnumInfo ei = new EnumInfo(className, enumName, enumOrdinal); return ei.getPdxInstance(tr.defineEnum(ei)); }
public static PdxInstance createPdxEnum(String className, String enumName, int enumOrdinal, GemFireCacheImpl gfc) { if (className == null) { throw new IllegalArgumentException("className must not be null"); } if (enumName == null) { throw new IllegalArgumentException("enumName must not be null"); } TypeRegistry tr = gfc.getPdxRegistry(); EnumInfo ei = new EnumInfo(className, enumName, enumOrdinal); return ei.getPdxInstance(tr.defineEnum(ei)); }
public static int getPdxRegistrySize() { GemFireCacheImpl cache = GemFireCacheImpl.getExisting(); if(cache == null) { return 0; } TypeRegistry registry = cache.getPdxRegistry(); if(registry == null) { return 0; } return registry.getLocalSize(); }
PdxUnreadData initUnreadData() { if (this.unreadDataInitialized) { return this.unreadData; } this.unreadDataInitialized = true; if (this.tr == null) { // We are being PdxSerializer serialized. // Now is the time to initialize tr. this.tr = GemFireCacheImpl.getForPdx("Could not access Pdx registry").getPdxRegistry(); } PdxUnreadData ud = this.unreadData; if (ud == null && this.pdx != null) { ud = this.tr.getUnreadData(this.pdx); this.unreadData = ud; } return ud; }
PdxUnreadData initUnreadData() { if (this.unreadDataInitialized) { return this.unreadData; } this.unreadDataInitialized = true; if (this.tr == null) { // We are being PdxSerializer serialized. // Now is the time to initialize tr. this.tr = GemFireCacheImpl.getForPdx("Could not access Pdx registry").getPdxRegistry(); } PdxUnreadData ud = this.unreadData; if (ud == null && this.pdx != null) { ud = this.tr.getUnreadData(this.pdx); this.unreadData = ud; } return ud; }
public void xtestPeer() throws Exception { Region r = getCache().getRegion("pdxtest"); r.get(1); TypeRegistry tr = ((GemFireCacheImpl) getCache()).getPdxRegistry(); Collection<PdxType> types = tr.typeMap().values(); assertEquals(MyObjectPdx.class.getName(), types.iterator().next().getClassName()); Collection<EnumInfo> enums = tr.enumMap().values(); assertEquals(MyEnumPdx.const1.name(), enums.iterator().next().getEnum().name()); }
/** * @throws IOException * @since 6.6.2 */ private static void writePdxEnum(Enum<?> e, DataOutput out) throws IOException { TypeRegistry tr = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed.").getPdxRegistry(); int eId = tr.getEnumId(e); if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "write PdxEnum id={} enum={}", eId, e); } writePdxEnumId(eId, out); } public static void writePdxEnumId(int eId, DataOutput out) throws IOException {
private PdxInstanceFactoryImpl(String name, boolean expectDomainClass) { PdxOutputStream os = new PdxOutputStream(); PdxType pt = new PdxType(name, expectDomainClass); GemFireCacheImpl gfc = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed."); TypeRegistry tr = gfc.getPdxRegistry(); this.writer = new PdxWriterImpl(pt, tr, os); }
/** * If o has unread data then add that unread data to copy. */ public static void copy(Object o, Object copy) { // This method is only called by CopyHelper which is public and does not require that a Cache exists. // So we need to call getInstance instead of getExisting. GemFireCacheImpl gfc = GemFireCacheImpl.getInstance(); if (gfc == null) return; TypeRegistry tr = gfc.getPdxRegistry(); PdxUnreadData ud = tr.getUnreadData(o); if (ud != null && !ud.isEmpty()) { tr.putUnreadData(copy, ud); } }
private PdxInstanceFactoryImpl(String name, boolean expectDomainClass) { PdxOutputStream os = new PdxOutputStream(); PdxType pt = new PdxType(name, expectDomainClass); GemFireCacheImpl gfc = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed."); TypeRegistry tr = gfc.getPdxRegistry(); this.writer = new PdxWriterImpl(pt, tr, os); }
/** * If o has unread data then add that unread data to copy. */ public static void copy(Object o, Object copy) { // This method is only called by CopyHelper which is public and does not require that a Cache exists. // So we need to call getInstance instead of getExisting. GemFireCacheImpl gfc = GemFireCacheImpl.getInstance(); if (gfc == null) return; TypeRegistry tr = gfc.getPdxRegistry(); PdxUnreadData ud = tr.getUnreadData(o); if (ud != null && !ud.isEmpty()) { tr.putUnreadData(copy, ud); } }
/** * @throws IOException * since 6.6.2 */ private static Object readPdxEnum(DataInput in) throws IOException { int dsId = in.readByte(); int tmp = readArrayLength(in); int enumId = (dsId << 24) | (tmp & 0xFFFFFF); if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "read PdxEnum id={}", enumId); } GemFireCacheImpl gfc = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed."); TypeRegistry tr = gfc.getPdxRegistry(); Object result = tr.getEnumById(enumId); if (result instanceof PdxInstance) { getDMStats(gfc).incPdxInstanceCreations(); } return result; }
/** * @throws IOException * @since 6.6.2 */ private static void writePdxEnum(Enum<?> e, DataOutput out) throws IOException { TypeRegistry tr = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed.").getPdxRegistry(); int eId = tr.getEnumId(e); if (DEBUG) { logger.info(LocalizedStrings.DEBUG, "write PdxEnum id=" + eId + " enum=" + e); } writePdxEnumId(eId, out); } public static void writePdxEnumId(int eId, DataOutput out) throws IOException {
/** * Create a new Pool for connecting a client to a set of GemFire Cache Servers. * using this factory's settings for attributes. * * @param name the name of the connection pool, used when connecting regions to it * @throws IllegalStateException if the connection pool name already exists * @throws IllegalStateException if this factory does not have any locators or servers * @return the newly created connection pool. * @since 5.7 */ public Pool create(String name) throws CacheException { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); if(cache != null) { TypeRegistry registry = cache.getPdxRegistry(); if(registry != null && !attributes.isGateway()) { registry.creatingPool(); } } return PoolImpl.create(this.pm, name, this.attributes); }
public Object getDefaultValueIfFieldExistsInAnyPdxVersions(String fieldName, String className) throws FieldNotFoundInPdxVersion { PdxType pdxType = GemFireCacheImpl .getForPdx( "PDX registry is unavailable because the Cache has been closed.") .getPdxRegistry().getPdxTypeForField(fieldName, className); if (pdxType == null) { throw new FieldNotFoundInPdxVersion("PdxType with field " + fieldName + " is not found for class " + className); } return pdxType.getPdxField(fieldName).getFieldType().getDefaultValue(); }
public Object getDefaultValueIfFieldExistsInAnyPdxVersions(String fieldName, String className) throws FieldNotFoundInPdxVersion { PdxType pdxType = GemFireCacheImpl .getForPdx( "PDX registry is unavailable because the Cache has been closed.") .getPdxRegistry().getPdxTypeForField(fieldName, className); if (pdxType == null) { throw new FieldNotFoundInPdxVersion("PdxType with field " + fieldName + " is not found for class " + className); } return pdxType.getPdxField(fieldName).getFieldType().getDefaultValue(); }
private PdxWriterImpl convertToTypeWithNoDeletedFields(PdxReaderImpl ur) { PdxOutputStream os = new PdxOutputStream(); PdxType pt = new PdxType(ur.getPdxType().getClassName(), !ur.getPdxType().getNoDomainClass()); GemFireCacheImpl gfc = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed."); TypeRegistry tr = gfc.getPdxRegistry(); PdxWriterImpl writer = new PdxWriterImpl(pt, tr, os); for (PdxField field: pt.getFields()) { if (!field.isDeleted()) { writer.writeRawField(field, ur.getRaw(field)); } } writer.completeByteStreamGeneration(); return writer; }